// Update is called once per frame
 void Update()
 {
     attack_timer += Time.deltaTime;
     if (is_human_castle && !game_over && hit_points < 1)
     {
         game_over = true;
         Debug.Log("The Orc Team wins.");
         GetComponent <unit_sounds>().Play("Acknowledge");
         CircleCollider2D.Destroy(GetComponent <CircleCollider2D>());
         SpriteRenderer.Destroy(GetComponent <SpriteRenderer>());
         Invoke("Restart", 5);
     }
     if (is_orc_castle && !game_over && hit_points < 1)
     {
         game_over = true;
         Debug.Log("The Human Team wins.");
         GetComponent <unit_sounds>().Play("Acknowledge");
         CircleCollider2D.Destroy(GetComponent <CircleCollider2D>());
         SpriteRenderer.Destroy(GetComponent <SpriteRenderer>());
         Invoke("Restart", 5);
     }
     if ((is_human_castle || is_orc_castle) && game_over)
     {
         return;
     }
     if (hit_points < 1 && dead == false)
     {
         dead   = true;
         attack = 0;
         footman_ex01 footman = GetComponent <footman_ex01>();
         if (footman)
         {
             footman.dead = true;
         }
         Rigidbody2D body = GetComponent <Rigidbody2D>();
         if (body)
         {
             Rigidbody2D.Destroy(body);
         }
         unit_sounds sounds = GetComponent <unit_sounds>();
         if (sounds)
         {
             sounds.Play("Dead");
         }
         Animator animator = GetComponent <Animator>();
         if (animator)
         {
             animator.SetTrigger("Dead");
         }
         if (sounds || animator)
         {
             Invoke("Kill", 2.5f);
         }
         else
         {
             Kill();
         }
     }
 }
Example #2
0
 void HumanWins()
 {
     gameOver = true;
     Debug.Log("The Human Team wins.");
     CircleCollider2D.Destroy(GetComponent <CircleCollider2D> ());
     SpriteRenderer.Destroy(GetComponent <SpriteRenderer> ());
     Invoke("Restart", 5);
 }