public void SetSelectedObject(GameObject go)
 {
     if (IsSelected(go) || go == null)
     {
         return;
     }
     if (selectedObject != go)
     {
         Node node = graph.GetNodeAt(Mathf.RoundToInt(go.transform.position.x), Mathf.RoundToInt(go.transform.position.z));
         if (unitDatabase.NodeContainsEnemies(node))
         {
             Unit unit = unitDatabase.GetUnitFromNode(node);
             Debug.Log(unit.health);
             selectedObject = go;
         }
         else if (towerDatabase.ContainsTowers(node))
         {
             Tower       tower       = towerDatabase.GetTowerFromNode(node);
             TowerHealth towerHealth = towerDatabase.GetTowerHealth(tower);
             Debug.Log(tower.Health);
             selectedObject = towerHealth.gameObject;
             Debug.Log("Selected GameObject " + selectedObject.name);
         }
         else
         {
             Debug.Log("No tower or units on node");
             DeselectObject();
         }
     }
 }
Exemple #2
0
 public void AddTowerHealth(TowerHealth towerHealth)
 {
     if (towerHealth != null)
     {
         towerHealthList.Add(towerHealth);
     }
 }
Exemple #3
0
 public void UpgradeTower()
 {
     if (true)
     {
         TowerHealth.GetInstance().IncreaseTowerHp(10);
         Debug.Log("Max: " + TowerHealth.GetInstance().Slider.maxValue + " Value: " + TowerHealth.GetInstance().Slider.value);
     }
 }
 void Start()
 {
     Speed             = Speed + (Random.value) + (Random.value);
     Tower             = GameObject.FindObjectOfType <TowerHealth>();
     targetWaypoint    = this.FindClosestWaypoint();
     this.movementLine = makeLine(Vector2.zero, Color.green);
     delay             = delayTime;
 }
	void Start()
	{
		animAttack = GetComponent<Animator>();
		Speed = Speed + (Random.value) + (Random.value);
		Tower = GameObject.FindObjectOfType<TowerHealth>();
		targetWaypoint = this.FindClosestWaypoint();
		this.movementLine = makeLine(Vector2.zero, Color.green);
		delay = delayTime;
	}
Exemple #6
0
 void Awake()
 {
     animator  = gameObject.GetComponent <Animator> ();
     health    = GetComponent <TowerHealth> ();
     ownerName = transform.Find("TowerCanvas").Find("OwnerName").GetComponent <Text> ();
     PhotonView.Instantiate(ownerName);
     bulletSpeed    = 3.0f;
     bulletLifetime = 3.0f;
     bulletCastTime = 4.0f;
 }
Exemple #7
0
 IEnumerator DamageOverTime(float attackSpeed, Collider2D tower)
 {
     while (gameObject.GetComponent <AttackerColliderHealth>().currentHealth > 0)
     {
         TowerHealth towerHealthScript = tower.GetComponent <TowerHealth>();
         towerHealthScript.currentHealth -= atkDmg;
         Debug.Log("An enemy did damage");
         yield return(new WaitForSeconds(attackSpeed));
     }
 }
    void Awake()
    {
        // Setting up the references.
        tower = GameObject.FindGameObjectWithTag ("Tower");
        towerHealth = tower.GetComponent <TowerHealth> ();

        //enemyHealth = GetComponent<EnemyHealth>();
        anim = GetComponent <Animator> ();
        zombieParts.Add (blood);
        zombieParts.Add (armAndLeg);
        zombieParts.Add (arms);
        zombieParts.Add (arm);
        zombieParts.Add (moreBlood);
    }
    private void Start()
    {
        animator    = GetComponent <Animator>();
        boxCollider = GetComponent <BoxCollider2D>();
        rb2D        = GetComponent <Rigidbody2D>();

        DamageDisabled = false;

        currentState = State.Moving;
        newState     = currentState;

        board = BoardManager.GetInstance();
        enemy = EnemyHealth.GetInstance();
        tower = TowerHealth.GetInstance();
        spawn = SpawnEnemies.GetInstance();
    }
Exemple #10
0
 // Order of execution is Awake > OnEnable > Start. We probably could use Start here and keep it consistent, but this doesn't hurt anything and is sure to make events happen in order
 private void Awake()
 {
     Instance = this;
 }
Exemple #11
0
    private void Start()
    {
        GameObject towerObj = GameObject.Find("Tower");

        towerhp = towerObj.GetComponent <TowerHealth>();
    }
        void Start()
        {
            tower = GameObject.FindObjectOfType <TowerHealth>();

            liveImages = GetComponentsInChildren <Image>();
        }
 void Start()
 {
     towerHealth           = GetComponent <TowerHealth>();
     towerHealth.OnZeroHp += Dead;
 }
Exemple #14
0
 // Use this for initialization
 void Awake()
 {
     health = GetComponent <TowerHealth>();
     team   = GetComponent <Team>();
 }
Exemple #15
0
        void RemoveTowerHealth(Tower tower)
        {
            TowerHealth towerHealth = GetTowerHealth(tower);

            towerHealthList.Remove(towerHealth);
        }