Page 4 of 5

Re: Golem Clash - Black Hole Studios

Posted: Wed May 01, 2019 10:47 am
by StevanAlzate
Sprint #12:

Fecha de inicio: 30/4/2019
Fecha de finalización: 2/5/2019

Clase #1 (Martes):
Diseño pantalla de inicio (2)
Programación e implementación de pantalla de inicio (2)

¿Qué hemos hecho?
Hicimos el diseño de la pantalla de inicio básicca, con un botón para comenzar y otro para salir del juego y cerrar la ventana, también se hicieron cambios al logo del juego para que se ajuste más a la estética general y se hicieron algunos balanceos a los enemigos.

Pantalla de Inicio
Image

Script Botón de Start y Quit

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class StartButton : MonoBehaviour
{
    [SerializeField] private int action;

    void OnMouseEnter()
    {
        transform.localScale = new Vector2(1.1f, 1.1f);
    }

    void OnMouseExit()
    {
        transform.localScale = new Vector2(1, 1);
    }

    void OnMouseDown()
    {
        Action(action);
    }

    void Action (int a)
    {
        if (a == 1)
        {
            SceneManager.LoadScene("GameScene");
        }

        if (a == 2)
        {
            Application.Quit();
        }
    }
}
¿Que vamos a hacer?
Vamos a meter los nuevos enemigos al juego con sus animaciones y stats.

Re: Golem Clash - Black Hole Studios

Posted: Thu May 02, 2019 12:26 pm
by xacarana
Image

Muy bien el avance, recuerden publicar el día de la clase.

Re: Golem Clash - Black Hole Studios

Posted: Thu May 02, 2019 11:21 pm
by StevanAlzate
Sprint #12:

Fecha de inicio: 30/4/2019
Fecha de finalización: 2/5/2019

Clase #2 (Jueves):
Digitalización nuevos enemigos (2)
Creación de animaciones para nuevos enemigos (1)
Balanceo de nuevos enemigos /precios de torres y poderes (2)

¿Qué hemos hecho?
Se metieron los enemigos nuevos completos al juego, ya hay 3 tipos que van apareciendo a medida que pasa el tiempo, para que se sienta el cambio de un enemigo al otro, se balancearon los drops, precios, daño, vida y velocidad generales del juego.

Enemigo Madera
Image
Enemigo Híbrido
Image

Gameplay con todos los cambios hasta ahora


¿Que vamos a hacer?
Vamos a pulir errores y balanceo de enemigos para ajustar la dificultad del juego.

Re: Golem Clash - Black Hole Studios

Posted: Fri May 03, 2019 3:30 pm
by xacarana
Image

Bien, ¿como van con la programación? necesitamos ver como estan asignando las actividades de codificación.

Re: Golem Clash - Black Hole Studios

Posted: Tue May 07, 2019 4:32 pm
by StevanAlzate
Sprint #13:

Fecha de inicio: 7/4/2019
Fecha de finalización: 9/5/2019

Clase #1 (Martes):
Ideación y diseño de pantalla de pausa (2)
Programación de botón y panel da pausa. (2)

¿Qué hemos hecho?
Diseñamos y digitalizamos la pantalla y botones de pause y se programaron estos, ahora se puede pausar el juego, lo que saca un panel con botones para reiniciar o continuar el juego, o volver a la pantalla de inicio en caso de que se quiera parar de jugar.

Script Botones de pausa

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class pauseButtons : MonoBehaviour
{
    [SerializeField] private int action;
    [SerializeField] private GameObject pausePanel;

    private Color startColor;
    [SerializeField]private Color mouseColor;

    void Start()
    {
            startColor = GetComponent<Renderer>().material.color;
    }
    void OnMouseEnter()
    {
        GetComponent<Renderer>().material.color = mouseColor;
    }

    void OnMouseExit()
    {
        GetComponent<Renderer>().material.color = startColor;
    }

    void OnMouseDown()
    {
        Action(action);
    }

    void Action(int a)
    {
        if (a == 0)
        {
            Time.timeScale = 0;
            pausePanel.SetActive(true);
        }
        else if (a == 1)
        {
            Time.timeScale = 1;
            pausePanel.SetActive(false);
            GetComponent<Renderer>().material.color = startColor;
        }
        else if (a == 2)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        else if (a == 3)
        {
            SceneManager.LoadScene("TitleScreen");
        }
    }
}
Video Pausa


¿Que vamos a hacer?
Vamos a empezar a ponerle sonido al juego

Re: Golem Clash - Black Hole Studios

Posted: Thu May 09, 2019 12:31 pm
by xacarana
Image

Muy bien, debemos incluir también el código y el responsable de cada funcionalidad.

Re: Golem Clash - Black Hole Studios

Posted: Thu May 09, 2019 9:59 pm
by StevanAlzate
Fecha de inicio: 7/4/2019
Fecha de finalización: 9/5/2019

Clase #2 (Jueves):
Implementación de sonidos

¿Que hemos hecho?
Se le pusieron sonidos a elementos como los disparos de flechas y construcción para mejor inmersión, también sonidos que ayudan como feedback al jugador como un sonido en el momento en el que se mejora una torre.

Script Spot

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Spot : MonoBehaviour
{
    [Header("No Cambiables")]
    [SerializeField] private Color mousecolor;
    [SerializeField] private Color nopecolor;
    [SerializeField] private Color upColor;

    [SerializeField] private GameObject player;

    private Color turretColor;
    private Color startColor;
    private Renderer rend;
    private GameObject cursor;
    private GameObject cursor2;
    private string mouseState;

    public Text cursorText;

    [Header("Cambiables")]
    [SerializeField] private GameObject PTower;
    [SerializeField] private GameObject MTower;
    [SerializeField] private GameObject samplePT;
    [SerializeField] private GameObject sampleMT;
    [SerializeField] private GameObject sample;

    private bool turretPlaced;
    private GameObject placedTurret;

    private int cost;

    private int currency;
    private GameObject child;

    void Update()
    {
        mouseState = MouseState.mouseState; ;
    }

    void Start()
    {
        turretPlaced = false;

        rend = GetComponent<Renderer>();
        startColor = rend.material.color;

        cursor = GameObject.FindGameObjectWithTag("Cursor");
        cursor2 = GameObject.FindGameObjectWithTag("Cursor2");

        cursorText.text = null;
    } 

    void OnMouseEnter()
    {
        if (!turretPlaced)
        {
            if (mouseState == "PTower")
            {
                cost = PTower.GetComponent<TurretAI>().cost;
                rend.material.color = mousecolor;
                cursorText.text = "Build (-$" + cost + ")";
                sample = Instantiate(samplePT, transform.position, transform.rotation);
            }
            else if (mouseState == "MTower")
            {
                cost = MTower.GetComponent<TurretAI>().cost;
                rend.material.color = mousecolor;
                cursorText.text = "Build (-$" + cost + ")";
                sample = Instantiate(sampleMT, transform.position, transform.rotation);
            }            
        }

        if (turretPlaced)
        {
            if (mouseState == "Upgrade")
            {
                cost = placedTurret.GetComponent<TurretAI>().cost;
                placedTurret.GetComponent<Renderer>().material.color = upColor;
                rend.material.color = upColor;
                cursorText.text = "Upgrade (-$" + (cost/2) + ")";
            }

            else if (mouseState == "Destroy")
            {
                cost = placedTurret.GetComponent<TurretAI>().cost;
                placedTurret.GetComponent<Renderer>().material.color = nopecolor;
                rend.material.color = nopecolor;
                cursorText.text = "Demolish (+$" + (cost / 2) + ")";
            }
        }

        ChangeCursor();
    }

    void OnMouseExit()
    {
        rend.material.color = startColor;
        ChangeCursor();
        if (mouseState != "Ice" && mouseState != "Mud" && mouseState != "Cannon")
        {
            cursorText.text = null;
        }

        if (mouseState == "PTower" || mouseState == "MTower") Destroy(sample);

        if (turretPlaced) placedTurret.GetComponent<Renderer>().material.color = turretColor;
    }

    void OnMouseDown()
    {
        currency = GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency;

        if (mouseState == "PTower")
        {
            cost = PTower.GetComponent<TurretAI>().cost;
        }
        else if (mouseState == "MTower")
        {
            cost = MTower.GetComponent<TurretAI>().cost;
        }

        if (cost <= currency && (mouseState == "PTower" || mouseState == "MTower") && !turretPlaced)
        {
            if (mouseState == "PTower")
            {
                player.GetComponent<FortHealth>().currency -= cost;
                placedTurret = Instantiate(PTower, transform.position, transform.rotation);
                turretColor = placedTurret.GetComponent<Renderer>().material.color;
            }
            if (mouseState == "MTower")
            {
                player.GetComponent<FortHealth>().currency -= cost;
                placedTurret = Instantiate(MTower, transform.position, transform.rotation);
                turretColor = placedTurret.GetComponent<Renderer>().material.color;
            }

            Destroy(sample);
            turretPlaced = true;
        }

        if (mouseState == "Destroy" && turretPlaced)
        {
            player.GetComponent<FortHealth>().currency += (cost / 2);
            Destroy(placedTurret);
            turretPlaced = false;
        }

        if (mouseState == "Upgrade" && turretPlaced && currency >= (cost/2))
        {
            placedTurret.GetComponent<AudioSource>().Play(0);
            placedTurret.GetComponent<TurretAI>().fireRate += 0.5f;
            player.GetComponent<FortHealth>().currency -= (cost / 2);
        }

        else return;
    }



    public void ChangeCursor()
    {
        if (cursor.GetComponent<Renderer>().enabled)
        {
            cursor.GetComponent<Renderer>().enabled = false;
            cursor2.GetComponent<Renderer>().enabled = true;
        }

        else if (cursor2.GetComponent<Renderer>().enabled)
        {
            cursor2.GetComponent<Renderer>().enabled = false;
            cursor.GetComponent<Renderer>().enabled = true;
        }

        else return;
    }

}
¿Que vamos a hacer?
Vamos a arreglar detalles estéticos y algunos errores que ocurren con los poderes.

Re: Golem Clash - Black Hole Studios

Posted: Thu May 16, 2019 11:49 am
by Sofial1224
Entrega

Presentación

https://drive.google.com/file/d/1u2FIk- ... sp=sharing

Gameplay



Scripts

ForHealth

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FortHealth : MonoBehaviour
{
    [SerializeField] private Text currencyText;
    [SerializeField] private int mps;
    [SerializeField] private int startCurrency;

    [SerializeField] public Image healthBar;

    public float health;
    public int currency;

    public int dropCount;

    [SerializeField] private GameObject gameOver;

    private GameObject cursor2;

    void Start()
    {
        InvokeRepeating("UpdateCurrency", 0f, 1f);

        health = 100;
        currency = startCurrency;

        currencyText.text = "        $" + currency.ToString();

        cursor2 = GameObject.FindGameObjectWithTag("Cursor2");
        cursor2.GetComponent<Renderer>().enabled = false;

        gameOver.SetActive(false);
    }

    void UpdateCurrency ()
    {
        currency += mps;
    }

    void Update()
    {
        currencyText.text = "       $" + currency.ToString();

        if (healthBar.fillAmount != health / 100)
        {
            healthBar.fillAmount = health / 100;
        }

       
        if (health <= 0) gameOver.SetActive(true); ;
    }
}
Build

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Build : MonoBehaviour
{
    private Vector2 startScale;

    [SerializeField] public string state;
    [SerializeField] private Text cursorText;

    private AudioSource click;

    void Start()
    {        
        startScale = transform.localScale;
        cursorText = GameObject.FindGameObjectWithTag("CursorText").GetComponent<Text>();

        click = GetComponent<AudioSource>();
    }

    void OnMouseEnter()
    {
        transform.localScale = startScale + new Vector2(0.03f, 0.03f);
    }

    void OnMouseExit()
    {
        transform.localScale = startScale;
    }

    void OnMouseDown()
    {
        MouseState.mouseState = state;
        cursorText.text = null;

        click.Play(0);
    }

}
Upgrade

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Upgrade : MonoBehaviour
{
    [SerializeField] private Color startColor;
    [SerializeField] private Color selectedColor;
    [SerializeField] private Text cursorText;
    private Renderer rend;

    private AudioSource click;

    void Start()
    {
        rend = GetComponent<Renderer>();
        startColor = rend.material.color;
        cursorText = GameObject.FindGameObjectWithTag("CursorText").GetComponent<Text>();

        click = GetComponent<AudioSource>();
    }


    void OnMouseEnter()
    {
        transform.localScale = new Vector2(0.19f, 0.19f);
    }

    void OnMouseExit()
    {
        transform.localScale = new Vector2(0.155f, 0.155f);
    }

    void OnMouseDown()
    {
        MouseState.mouseState = "Upgrade";
        cursorText.text = null;

        click.Play(0);
    }

    void Update()
    {
        if (MouseState.mouseState == "Upgrade")
        {
            rend.material.color = selectedColor;
        }

        else rend.material.color = startColor;
    }

}
Destroy

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Destroy : MonoBehaviour
{
    [SerializeField] private Color startColor;
    [SerializeField] private Color selectedColor;
    [SerializeField] private Text cursorText;

    private Renderer rend;

    private AudioSource click;

    void Start()
    {
        rend = GetComponent<Renderer>();
        startColor = rend.material.color;
        cursorText = GameObject.FindGameObjectWithTag("CursorText").GetComponent<Text>();

        click = GetComponent<AudioSource>();
    }

    void OnMouseEnter()
    {
        transform.localScale = new Vector2(0.18f, 0.18f);
    }

    void OnMouseExit()
    {
        transform.localScale = new Vector2(0.147f, 0.147f);
    }

    void OnMouseDown()
    {
        MouseState.mouseState = "Destroy";
        cursorText.text = null;

        click.Play(0);
    }

    void Update()
    {
        if (MouseState.mouseState == "Destroy")
        {
            rend.material.color = selectedColor;
        }

        else rend.material.color = startColor;
    }
}
TurretAI

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TurretAI : MonoBehaviour
{
    [Header("Publics")]
    public Transform target;
    public GameObject bullet;
    public int cost;

    [Header("Characteristics")]
    public float fireRate;
    [SerializeField] private float range;

    private bool shooting;


    void Start()
    {
        InvokeRepeating("UpdateTarget", 0f, 0.5f);
        shooting = false;
    }

    void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(transform.position, range);
    }

    void UpdateTarget()
    {
        GameObject[] enemyArray = GameObject.FindGameObjectsWithTag("Enemy");
        GameObject nearestEnemy = null;
        float shortestDistance = Mathf.Infinity;

        foreach (GameObject enemy in enemyArray)
        {
            bool enemyDead = enemy.GetComponent<EnemyAI>().dead;
            float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);
            if (distanceToEnemy < shortestDistance && !enemyDead)
            {
                shortestDistance = distanceToEnemy;
                nearestEnemy = enemy;
            }
        }

        if (nearestEnemy != null && shortestDistance <= range && !shooting)
        {
            target = nearestEnemy.transform;
            StartCoroutine(Shoot());
        }
        else target = null;

    }  

    IEnumerator Shoot()
    {
        if (target != null)
        {
            shooting = true;
            GameObject b = (GameObject)Instantiate(bullet, transform.position, transform.rotation);
            b.GetComponent<bullet>().enemyTarget = target;
            yield return new WaitForSeconds(fireRate);
            StartCoroutine(Shoot());
            shooting = false;
        }
    }
}
Bullet

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bullet : MonoBehaviour
{
    [SerializeField]
    private float speed;
    [SerializeField]
    private float damage;
    public Transform enemyTarget;

    void Update()
    {
        if (enemyTarget == null)
        {
            Destroy(gameObject);
        }

        transform.rotation = Quaternion.LookRotation(Vector3.forward, enemyTarget.transform.position - transform.position);
        transform.position = Vector2.MoveTowards(transform.position, enemyTarget.position, speed * Time.deltaTime);

        if (Vector3.Distance(transform.position, enemyTarget.transform.position) <= 0.2 && enemyTarget != null)
        {
            enemyTarget.GetComponent<EnemyAI>().health -= damage;
            Destroy(gameObject);
        }
     
    }

}
Spot

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Spot : MonoBehaviour
{
    [Header("No Cambiables")]
    [SerializeField] private Color mousecolor;
    [SerializeField] private Color nopecolor;
    [SerializeField] private Color upColor;

    [SerializeField] private GameObject player;

    private Color turretColor;
    private Color startColor;
    private Renderer rend;
    private GameObject cursor;
    private GameObject cursor2;
    private string mouseState;

    public Text cursorText;

    [Header("Cambiables")]
    [SerializeField] private GameObject PTower;
    [SerializeField] private GameObject MTower;
    [SerializeField] private GameObject samplePT;
    [SerializeField] private GameObject sampleMT;
    [SerializeField] private GameObject sample;

    [SerializeField] private int upgradeCount;

    private bool turretPlaced;
    private GameObject placedTurret;
    private string turretType;

    private int cost;

    private int currency;
    private GameObject child;

    void Update()
    {
        mouseState = MouseState.mouseState; ;
    }

    void Start()
    {
        turretPlaced = false;

        rend = GetComponent<Renderer>();
        startColor = rend.material.color;

        cursor = GameObject.FindGameObjectWithTag("Cursor");
        cursor2 = GameObject.FindGameObjectWithTag("Cursor2");

        cursorText.text = null;

        upgradeCount = 0;
    } 

    void OnMouseEnter()
    {
        if (!turretPlaced)
        {
            if (mouseState == "PTower")
            {
                cost = PTower.GetComponent<TurretAI>().cost;
                rend.material.color = mousecolor;
                cursorText.text = "Build (-$" + cost + ")";
                sample = Instantiate(samplePT, transform.position, transform.rotation);
                ChangeCursor();
            }
            else if (mouseState == "MTower")
            {
                cost = MTower.GetComponent<TurretAI>().cost;
                rend.material.color = mousecolor;
                cursorText.text = "Build (-$" + cost + ")";
                sample = Instantiate(sampleMT, transform.position, transform.rotation);
                ChangeCursor();
            }            
        }

        if (turretPlaced)
        {
            if (mouseState == "Upgrade")
            {
                cost = placedTurret.GetComponent<TurretAI>().cost;
                placedTurret.GetComponent<Renderer>().material.color = upColor;
                rend.material.color = upColor;
                cursorText.text = "Upgrade (-$" + (cost/2) + ")";
                ChangeCursor();
            }

            else if (mouseState == "Destroy")
            {
                cost = placedTurret.GetComponent<TurretAI>().cost;
                placedTurret.GetComponent<Renderer>().material.color = nopecolor;
                rend.material.color = nopecolor;
                cursorText.text = "Demolish (+$" + (cost / 2) + ")";
                ChangeCursor();
            }
        }
    }

    void OnMouseExit()
    {
        rend.material.color = startColor;
        if (mouseState != "Ice" && mouseState != "Mud" && mouseState != "Cannon")
        {
            cursorText.text = null;
        }

        if (mouseState == "PTower" || mouseState == "MTower")
        {
            Destroy(sample);
            if (!turretPlaced)
            {
                ChangeCursor();
            }
        }

        if (turretPlaced)
        {
            placedTurret.GetComponent<Renderer>().material.color = turretColor;
            if (mouseState == "Destroy" || mouseState == "Upgrade")
            {
                ChangeCursor();
            }
        }
    }

    void OnMouseDown()
    {
        currency = GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency;

        if (mouseState == "PTower")
        {
            cost = PTower.GetComponent<TurretAI>().cost;
        }
        else if (mouseState == "MTower")
        {
            cost = MTower.GetComponent<TurretAI>().cost;
        }

        if (cost <= currency && (mouseState == "PTower" || mouseState == "MTower") && !turretPlaced)
        {
            if (mouseState == "PTower")
            {
                player.GetComponent<FortHealth>().currency -= cost;
                placedTurret = Instantiate(PTower, transform.position, transform.rotation);
                turretType = "Stone";
                turretColor = placedTurret.GetComponent<Renderer>().material.color;
            }
            if (mouseState == "MTower")
            {
                player.GetComponent<FortHealth>().currency -= cost;
                placedTurret = Instantiate(MTower, transform.position, transform.rotation);
                turretType = "Wood";
                turretColor = placedTurret.GetComponent<Renderer>().material.color;
            }

            Destroy(sample);
            turretPlaced = true;
            cursorText.text = null;
            ChangeCursor();
            rend.material.color = startColor;
        }

        if (mouseState == "Destroy" && turretPlaced)
        {
            player.GetComponent<FortHealth>().currency += (cost / 2);
            Destroy(placedTurret);
            turretPlaced = false;

            ChangeCursor();
            rend.material.color = startColor;
            cursorText.text = null;

            upgradeCount = 0;
        }

        if (mouseState == "Upgrade" && turretPlaced && currency >= (cost/2))
        {
            placedTurret.GetComponent<AudioSource>().Play(0);
            placedTurret.GetComponent<TurretAI>().fireRate = (placedTurret.GetComponent<TurretAI>().fireRate / 1.2f);
            player.GetComponent<FortHealth>().currency -= (cost / 2);

            upgradeCount++;
            if (upgradeCount > 2)
            {
                if (turretType == "Wood")
                {
                    Destroy(placedTurret);
                    placedTurret = Instantiate(PTower, transform.position, transform.rotation);
                    turretType = "Stone";
                    turretColor = placedTurret.GetComponent<Renderer>().material.color;
                    cost = PTower.GetComponent<TurretAI>().cost;
                    upgradeCount = 0;

                }
            }
        }

        else return;
    }



    public void ChangeCursor()
    {
        if (cursor.GetComponent<Renderer>().enabled)
        {
            cursor.GetComponent<Renderer>().enabled = false;
            cursor2.GetComponent<Renderer>().enabled = true;
        }

        else if (cursor2.GetComponent<Renderer>().enabled)
        {
            cursor2.GetComponent<Renderer>().enabled = false;
            cursor.GetComponent<Renderer>().enabled = true;
        }

        else return;
    }

}
TowerColor

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TowerColor : MonoBehaviour
{
    [SerializeField] private Color startColor;
    [SerializeField] private Color selectedColor;
    private Renderer rend;

    private string state;
    
    void Start()
    {
        state = GetComponentInParent<Build>().state;
        rend = GetComponent<Renderer>();
        startColor = rend.material.color;
    }


    void Update()
    {
        if (MouseState.mouseState == state)
        {
            rend.material.color = selectedColor;
        }

        else rend.material.color = startColor;
    }
}
EnemyAI

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class EnemyAI : MonoBehaviour
{
    public float speed;
    [SerializeField] public int damage;
    [SerializeField] private GameObject drop;

    private GameObject player;
    private WaypointArray wp;
    private byte wpcounter;

    private Animator animator;

    public float health;
    public bool dead;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        wp = GameObject.FindGameObjectWithTag("Waypoints").GetComponent<WaypointArray>();

        animator = GetComponent<Animator>();
        dead = false;
    }

    void Update()
    {
        if (health >= 0)
        {
            transform.position = Vector2.MoveTowards(transform.position, wp.waypoints[wpcounter].position, speed * Time.deltaTime);
            animator.speed = speed;

            if (Vector2.Distance(transform.position, wp.waypoints[wpcounter].position) < 0.02)
            {
                if (wpcounter < wp.waypoints.Length - 1)
                {
                    wpcounter++;
                }
                else
                {
                    player.GetComponent<FortHealth>().health -= damage;
                    Destroy(gameObject);
                }
            }
        }

        else if (health < 1)
        {
            IEnumerator Muerte()
            {
                dead = true;
                animator.SetTrigger("estaMuerto");
                yield return new WaitForSeconds(1);
                if (player.GetComponent<FortHealth>().dropCount == 3)
                {
                    Instantiate(drop, transform.position, transform.rotation);
                    player.GetComponent<FortHealth>().dropCount = 0;
                }
                else player.GetComponent<FortHealth>().dropCount += 1;
                Destroy(gameObject);
            }
            StartCoroutine(Muerte());
        }
    }


}
WaveSpawn

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class WaveSpawn : MonoBehaviour
{
    [Header("Checkers")]
    public byte wave;
    [SerializeField] private int difficulty;

    [SerializeField] private Text waveText;
    [SerializeField] private GameObject[] enemies;
    
    [SerializeField] private byte enemyAdd;
    [SerializeField] private byte timeBetweenWaves;

    private float countdown;
    private GameObject randomEnemy;

    void Start()
    {
        enemies[0].GetComponent<EnemyAI>().damage = 10;
        enemies[1].GetComponent<EnemyAI>().damage = 7;
        enemies[2].GetComponent<EnemyAI>().damage = 4;


        waveText.text = "Wave " + wave.ToString();

        countdown = 3f;
        difficulty = 1;
    }

    void Update()
    {
        waveText.text = "Wave " + wave.ToString();

        if (countdown <= 0f)
        {
            StartCoroutine(SpawnWave());
            countdown = timeBetweenWaves;
        }

        countdown -= Time.deltaTime;
    }

    private GameObject GetEnemy (int difficulty)
    {
        return enemies[Random.Range(0, difficulty)];
    }

    IEnumerator SpawnWave()
    {
        wave++;

        for (int i = 0; i < wave; i++)
        {
            randomEnemy = GetEnemy(difficulty);
            Instantiate(randomEnemy, transform.position, transform.rotation);
            yield return new WaitForSeconds(1);
            i++;
        }

        if ((wave%enemyAdd) == 0)
        {
            difficulty++;
        }

        if (difficulty > enemies.Length)
        {
            difficulty = enemies.Length;
        }
    }
}
WayPointArray

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WaypointArray : MonoBehaviour
{
    public Transform[] waypoints;
}
Drop

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Drop : MonoBehaviour
{
    [SerializeField] private byte drop;
    [SerializeField] private Color mousecolor;
    [SerializeField] private Color startColor;

    private GameObject player;
    private Renderer rend;

    void Start()
    {
        rend = GetComponent<Renderer>();
        startColor = rend.material.color;
        player = player = GameObject.FindGameObjectWithTag("Player");
    }

    void OnMouseEnter()
    {
        rend.material.color = mousecolor;
        transform.localScale = new Vector2(0.08f, 0.08f);
    }

    void OnMouseExit()
    {
        rend.material.color = startColor;
        transform.localScale = new Vector2(0.0685f, 0.0685f);
    }

    void OnMouseDown()
    {
        player.GetComponent<FortHealth>().currency += drop;
        Destroy(gameObject);
    }
}
Power

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Power : MonoBehaviour
{
    [SerializeField] private GameObject mudPower;
    [SerializeField] private GameObject icePower;
    [SerializeField] private GameObject cannonPower;
    public static bool inUse;
    private bool first;
    private string pState;

    [SerializeField] private float range;
    [SerializeField] private int cost;

    [SerializeField] private int currency;

    void Start()
    {
        if (MouseState.mouseState == "Mud")
        {
            range = 2.5f;
            transform.localScale = new Vector2(0.3307724f, 0.3307724f);
            cost = 15;
        }
        else if (MouseState.mouseState == "Ice")
        {
            range = 1.7f;
            transform.localScale = new Vector2(0.2275714f, 0.2275714f);
            cost = 20;
        }
        else if (MouseState.mouseState == "Cannon")
        {
            range = 1.2f;
            transform.localScale = new Vector2(0.1631687f, 0.1631687f);
            cost = 30;
        }

        first = true;
        GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency += cost;
    }

    void Update()
    {
        if (pState != MouseState.mouseState)
        {
            first = true;
        }
        pState = MouseState.mouseState;

        if (Input.GetMouseButtonDown(0))
        {
                currency = GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency;

                if (MouseState.mouseState == "Mud" && cost <= currency && !inUse)
                {
                    StartCoroutine(EffectSeconds(3.5f, 1));
                }

                else if (MouseState.mouseState == "Ice" && cost <= currency && !inUse)
                {
                    StartCoroutine(EffectSeconds(2f, 2));
                }

                else if (MouseState.mouseState == "Cannon" && cost <= currency && !inUse)
                {
                    StartCoroutine(EffectSeconds(2f, 3));
                }
        }
    }

    IEnumerator EffectSeconds(float t, int a)
    {
        inUse = true;

        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency -= cost;

        int i = 1;

        if (a == 1 && !first)
        {
            GameObject mud = Instantiate(mudPower, transform.position, transform.rotation);

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    i++;
                }
            }

            GameObject[] enemiesInRange = new GameObject[i];
            int j = 0;

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    enemiesInRange[j] = enemy;
                    j++;
                }
            }

            for (int k = 0; k<enemiesInRange.Length; k++)
            {
                if (enemiesInRange[k] != null)
                {
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = (enemiesInRange[k].GetComponent<EnemyAI>().speed / 2);
                }
            }

            yield return new WaitForSeconds(t);

            for (int k = 0; k < enemiesInRange.Length; k++)
            {
                if (enemiesInRange[k] != null)
                {
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = (enemiesInRange[k].GetComponent<EnemyAI>().speed * 2);
                }
            }

            Destroy(mud);
        }

        else if (a == 2 && !first)
        {
            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    i++;
                }
            }

            GameObject[] enemiesInRange = new GameObject[i];
            float[] speeds = new float[i];
            GameObject[] ice = new GameObject[i];
            int j = 0;

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    enemiesInRange[j] = enemy;
                    j++;
                }
            }

            for (int k = 0; k < enemiesInRange.Length; k++)
            {
                if (enemiesInRange[k] != null)
                {
                    speeds[k] = enemiesInRange[k].GetComponent<EnemyAI>().speed;
                    ice[k] = Instantiate(icePower, enemiesInRange[k].transform.position, enemiesInRange[k].transform.rotation);
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = 0;
                }
            }

            yield return new WaitForSeconds(t);

            for (int k = 0; k < enemiesInRange.Length; k++)
            {
                Destroy(ice[k]);
                if (enemiesInRange[k] != null)
                {
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = speeds[k];                  
                }
            }
        }

        else if (a == 3 && !first)
        {
            GameObject cannon = Instantiate(cannonPower, transform.position, transform.rotation);

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    enemy.GetComponent<EnemyAI>().health -= 100;
                }
            }

            yield return new WaitForSeconds(0.4f);
            Destroy(cannon);
        }

        first = false;
        inUse = false;
    }
}
PowerButton

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PowerButton : MonoBehaviour
{
    [SerializeField] private string state;

    [SerializeField] private string action;
    [SerializeField] private int cost;
    [SerializeField] private Text cursorText;

    [SerializeField] private Color startColor;
    [SerializeField] private Color selectedColor;
    private Renderer rend;

    private GameObject powerIns;
    private bool selected;

    [SerializeField] private GameObject power;

    private AudioSource click;

    void Start()
    {
        rend = GetComponent<Renderer>();
        startColor = rend.material.color;
        cursorText = GameObject.FindGameObjectWithTag("CursorText").GetComponent<Text>();

        click = GetComponent<AudioSource>();
    }


    void OnMouseEnter()
    {
        if (!Power.inUse)
        {
            transform.localScale = new Vector2(0.3f, 0.3f);
        }
    }

    void OnMouseExit()
    {
        if (!Power.inUse)
        {
            transform.localScale = new Vector2(0.24f, 0.24f);
        }
    }

    void OnMouseDown()
    {
        if (!selected && !Power.inUse)
        {
            MouseState.mouseState = state;
            powerIns = Instantiate(power, transform.position, transform.rotation);
            cursorText.text = action + " (-$" + cost + ")";
            selected = true;

            click.Play(0);
        }
    }

    void Update()
    {
        if (MouseState.mouseState == state)
        {
            rend.material.color = selectedColor;
        }

        else
        {
            rend.material.color = startColor;
            Destroy(powerIns);
            selected = false;
        }
    }
}
GameOver

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class GameOver : MonoBehaviour
{
    [SerializeField] private Text goWaveText;
    [SerializeField] private GameObject spawner;
    private bool active;

    void Start()
    {
        byte wave = spawner.GetComponent<WaveSpawn>().wave;
        goWaveText.text = "You Survived " + wave + " Waves";
        active = false;

        StartCoroutine(Activate());
    }

    void Update()
    {

        if (Input.GetMouseButtonDown(0) && active)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }

    IEnumerator Activate()
    {
        yield return new WaitForSeconds(2.5f);
        active = true;
        Time.timeScale = 0;
    }
}

Re: Golem Clash - Black Hole Studios

Posted: Wed May 22, 2019 12:14 am
by Sofial1224
Sprint

Fecha de inicio: 20/5/2019
Fecha de finalización: 24/5/2019


Clase #1 (Martes):
Cambio de sprite (1)
Arreglo del gameover (2)

¿Que hemos hecho?

Cambiamos el sprite del poder del cañon para que se viera mas como una explosión y le agregamos su respectiva animación.

Image

Descubrimos que la pantalla de GameOver tenia problemas con el fondo, el juego seguia corriendo y algunos textos del juego se veian cuando salia la imagen. Arreglamos todos los problemas mencionados y este es el resultado final.

Image

Re: Golem Clash - Black Hole Studios

Posted: Thu May 23, 2019 12:13 pm
by StevanAlzate
Sprint #14

Fecha de inicio: 20/5/2019
Fecha de finalización: 24/5/2019

Clase #2 (Jueves):
  • [Arreglo de bugs (3)
  • Otros ajustes (2)

¿Que hemos hecho?
  • Se arregló el error que hacía que los poderes se quedaran por un tiempo indefinido al seleccionar otro botón mientras el poder estaba funcionando.
  • Los poderes ahora se usan con el click derecho y no con el izquierdo, esto significa que el jugador puede tener seleccionado un poder y ejecutar otras acciones simultaneamente.
  • Se ajustaron los scripts del texto del cursor para que se acomoden a los cambios a los poderes.
  • Se cambiaron los colores de los botones de los poderes cuando están seleccionados junto con el color del rango que sigue al cursor para que estos fueran más fáciles de identificar.
  • Ahora los botones se ponen oscuros y no cambian cuando el mouse les pasa por encima si están en un estado en el que no se pueden usar.
En este video se muestra los cambios mencionados


Powers Script

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Power : MonoBehaviour
{
    [SerializeField] private GameObject mudPower;
    [SerializeField] private GameObject icePower;
    [SerializeField] private GameObject cannonPower;
    public static bool inUse;
    private string pState;

    [SerializeField] private float range;
    [SerializeField] private int cost;

    [SerializeField] private int currency;

    void Start()
    {
        if (MouseState.powerState == "Mud")
        {
            range = 2.5f;
            transform.localScale = new Vector2(0.3307724f, 0.3307724f);
            cost = 15;
        }
        else if (MouseState.powerState == "Ice")
        {
            range = 1.7f;
            transform.localScale = new Vector2(0.2275714f, 0.2275714f);
            cost = 20;
        }
        else if (MouseState.powerState == "Cannon")
        {
            range = 1.2f;
            transform.localScale = new Vector2(0.1631687f, 0.1631687f);
            cost = 30;
        }
    }

    void Update()
    {
        pState = MouseState.powerState;

        if (Input.GetMouseButtonDown(1))
        {
                currency = GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency;

                if (MouseState.powerState == "Mud" && cost <= currency && !inUse)
                {
                    StartCoroutine(EffectSeconds(3.5f, 1));
                }

                else if (MouseState.powerState == "Ice" && cost <= currency && !inUse)
                {
                    StartCoroutine(EffectSeconds(2f, 2));
                }

                else if (MouseState.powerState == "Cannon" && cost <= currency && !inUse)
                {
                    StartCoroutine(EffectSeconds(2f, 3));
                }
        }
    }

    IEnumerator EffectSeconds(float t, int a)
    {
        inUse = true;

        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");

        int i = 1;

        if (a == 1)
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency -= cost;
            GameObject mud = Instantiate(mudPower, transform.position, transform.rotation);

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    i++;
                }
            }

            GameObject[] enemiesInRange = new GameObject[i];
            int j = 0;

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    enemiesInRange[j] = enemy;
                    j++;
                }
            }

            for (int k = 0; k<enemiesInRange.Length; k++)
            {
                if (enemiesInRange[k] != null)
                {
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = (enemiesInRange[k].GetComponent<EnemyAI>().speed / 2);
                }
            }

            yield return new WaitForSeconds(t);

            for (int k = 0; k < enemiesInRange.Length; k++)
            {
                if (enemiesInRange[k] != null)
                {
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = (enemiesInRange[k].GetComponent<EnemyAI>().speed * 2);
                }
            }

            Destroy(mud);
        }

        else if (a == 2)
        {
            bool enemyDetected = false;

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    i++;
                }
            }

            GameObject[] enemiesInRange = new GameObject[i];
            float[] speeds = new float[i];
            GameObject[] ice = new GameObject[i];
            int j = 0;

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    enemiesInRange[j] = enemy;
                    j++;
                }
            }

            for (int k = 0; k < enemiesInRange.Length; k++)
            {
                if (enemiesInRange[k] != null)
                {
                    enemyDetected = true;
                    speeds[k] = enemiesInRange[k].GetComponent<EnemyAI>().speed;
                    ice[k] = Instantiate(icePower, enemiesInRange[k].transform.position, enemiesInRange[k].transform.rotation);
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = 0;
                }
            }

            if (enemyDetected)
            {
                GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency -= cost;
                yield return new WaitForSeconds(t);
            }

            for (int k = 0; k < enemiesInRange.Length; k++)
            {
                Destroy(ice[k]);
                if (enemiesInRange[k] != null)
                {
                    enemiesInRange[k].GetComponent<EnemyAI>().speed = speeds[k];                  
                }
            }
        }

        else if (a == 3)
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency -= cost;
            GameObject cannon = Instantiate(cannonPower, transform.position, transform.rotation);

            foreach (GameObject enemy in enemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy <= range)
                {
                    enemy.GetComponent<EnemyAI>().health -= 100;
                }
            }

            yield return new WaitForSeconds(0.4f);
            Destroy(cannon);
        }

        inUse = false;
    }
}
PowerButton Script

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PowerButton : MonoBehaviour
{
    [SerializeField] private string state;

    [SerializeField] private string action;
    [SerializeField] private int cost;
    [SerializeField] private Text cursorText;

    [SerializeField] private Color startColor;
    [SerializeField] private Color selectedColor;
    [SerializeField] private Color nopeColor;
    private Renderer rend;

    private GameObject powerIns;
    private bool selected;

    [SerializeField] private GameObject power;

    private AudioSource click;

    void Start()
    {
        rend = GetComponent<Renderer>();
        startColor = rend.material.color;
        cursorText = GameObject.FindGameObjectWithTag("CursorText").GetComponent<Text>();

        click = GetComponent<AudioSource>();
    }


    void OnMouseEnter()
    {
        if (!Power.inUse)
        {
            transform.localScale = new Vector2(0.3f, 0.3f);
        }
    }

    void OnMouseExit()
    {
        if (!Power.inUse)
        {
            transform.localScale = new Vector2(0.24f, 0.24f);
        }
    }

    void OnMouseDown()
    {
        if (!selected && !Power.inUse)
        {
            MouseState.powerState = state;
            powerIns = Instantiate(power, transform.position, transform.rotation);
            cursorText.text = action + " (-$" + cost + ")";
            selected = true;

            click.Play(0);
        }
    }

    void Update()
    {     
        if (MouseState.powerState == state)
        {
            rend.material.color = selectedColor;
        }

        else if (Power.inUse)
        {
            rend.material.color = nopeColor;
        }

        else
        {
            rend.material.color = startColor;
            Destroy(powerIns);
            selected = false;
        }
    }
}
Spot Script

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Spot : MonoBehaviour
{
    [Header("No Cambiables")]
    [SerializeField] private Color mousecolor;
    [SerializeField] private Color nopecolor;
    [SerializeField] private Color upColor;

    [SerializeField] private GameObject player;

    private Color turretColor;
    private Color startColor;
    private Renderer rend;
    private GameObject cursor;
    private GameObject cursor2;
    private string mouseState;

    private string befCursorText;

    public Text cursorText;

    [Header("Cambiables")]
    [SerializeField] private GameObject PTower;
    [SerializeField] private GameObject MTower;
    [SerializeField] private GameObject samplePT;
    [SerializeField] private GameObject sampleMT;
    [SerializeField] private GameObject sample;

    [SerializeField] private int upgradeCount;

    private bool turretPlaced;
    private GameObject placedTurret;
    private string turretType;

    private int cost;

    private int currency;
    private GameObject child;

    void Update()
    {
        mouseState = MouseState.mouseState; ;
    }

    void Start()
    {
        turretPlaced = false;

        rend = GetComponent<Renderer>();
        startColor = rend.material.color;

        cursor = GameObject.FindGameObjectWithTag("Cursor");
        cursor2 = GameObject.FindGameObjectWithTag("Cursor2");

        upgradeCount = 0;

        cursorText.text = null;
    } 

    void OnMouseEnter()
    {
        befCursorText = cursorText.text;

        if (!turretPlaced)
        {
            if (mouseState == "PTower")
            {
                cost = PTower.GetComponent<TurretAI>().cost;
                rend.material.color = mousecolor;
                cursorText.text = "Build (-$" + cost + ")";
                sample = Instantiate(samplePT, transform.position, transform.rotation);
                ChangeCursor();
            }
            else if (mouseState == "MTower")
            {
                cost = MTower.GetComponent<TurretAI>().cost;
                rend.material.color = mousecolor;
                cursorText.text = "Build (-$" + cost + ")";
                sample = Instantiate(sampleMT, transform.position, transform.rotation);
                ChangeCursor();
            }            
        }

        if (turretPlaced)
        {
            if (mouseState == "Upgrade")
            {
                cost = placedTurret.GetComponent<TurretAI>().cost;
                placedTurret.GetComponent<Renderer>().material.color = upColor;
                rend.material.color = upColor;
                cursorText.text = "Upgrade (-$" + (cost/2) + ")";
                ChangeCursor();
            }

            else if (mouseState == "Destroy")
            {
                cost = placedTurret.GetComponent<TurretAI>().cost;
                placedTurret.GetComponent<Renderer>().material.color = nopecolor;
                rend.material.color = nopecolor;
                cursorText.text = "Demolish (+$" + (cost / 2) + ")";
                ChangeCursor();
            }
        }
    }

    void OnMouseExit()
    {
        rend.material.color = startColor;
        cursorText.text = befCursorText;

        if (mouseState == "PTower" || mouseState == "MTower")
        {
            Destroy(sample);
            if (!turretPlaced)
            {
                ChangeCursor();
            }
        }

        if (turretPlaced)
        {
            placedTurret.GetComponent<Renderer>().material.color = turretColor;
            if (mouseState == "Destroy" || mouseState == "Upgrade")
            {
                ChangeCursor();
            }
        }
    }

    void OnMouseDown()
    {

        currency = GameObject.FindGameObjectWithTag("Player").GetComponent<FortHealth>().currency;

        if (mouseState == "PTower")
        {
            cost = PTower.GetComponent<TurretAI>().cost;
        }
        else if (mouseState == "MTower")
        {
            cost = MTower.GetComponent<TurretAI>().cost;
        }

        if (cost <= currency && (mouseState == "PTower" || mouseState == "MTower") && !turretPlaced)
        {
            if (mouseState == "PTower")
            {
                player.GetComponent<FortHealth>().currency -= cost;
                placedTurret = Instantiate(PTower, transform.position, transform.rotation);
                turretType = "Stone";
                turretColor = placedTurret.GetComponent<Renderer>().material.color;
            }
            if (mouseState == "MTower")
            {
                player.GetComponent<FortHealth>().currency -= cost;
                placedTurret = Instantiate(MTower, transform.position, transform.rotation);
                turretType = "Wood";
                turretColor = placedTurret.GetComponent<Renderer>().material.color;
            }

            Destroy(sample);
            turretPlaced = true;
            cursorText.text = befCursorText;
            ChangeCursor();
            rend.material.color = startColor;
        }

        if (mouseState == "Destroy" && turretPlaced)
        {
            player.GetComponent<FortHealth>().currency += (cost / 2);
            Destroy(placedTurret);
            turretPlaced = false;

            ChangeCursor();
            rend.material.color = startColor;
            cursorText.text = befCursorText;

            upgradeCount = 0;
        }

        if (mouseState == "Upgrade" && turretPlaced && currency >= (cost/2))
        {
            placedTurret.GetComponent<AudioSource>().Play(0);
            placedTurret.GetComponent<TurretAI>().fireRate -= placedTurret.GetComponent<TurretAI>().fireRate * 0.2f;
            player.GetComponent<FortHealth>().currency -= (cost / 2);

            if (turretType == "Stone") return;

            upgradeCount++;
            if (upgradeCount > 2)
            {
                if (turretType == "Wood")
                {
                    Destroy(placedTurret);
                    placedTurret = Instantiate(PTower, transform.position, transform.rotation);
                    turretType = "Stone";
                    turretColor = placedTurret.GetComponent<Renderer>().material.color;
                    cost = PTower.GetComponent<TurretAI>().cost;
                    upgradeCount = 0;

                }
            }
        }
    }
MouseState Script

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseState : MonoBehaviour
{
    [SerializeField] public static string mouseState;
    [SerializeField] public static string powerState;
}
¿Que vamos a hacer?
Vamos a arreglar algunos otros bugs encontrados.