Example #1
0
 public void Kill(TownScript ennemy)
 {
     foreach (PlayerScript player in players)
     {
         player.Kill();
     }
     ennemy.Kill();
 }
Example #2
0
 public void Attack(TownScript ennemy)
 {
     isAttack = true;
     foreach (PlayerScript player in players)
     {
         player.updatePlayer(Input.mousePosition, true, ennemy);
     }
 }
Example #3
0
 void Start()
 {
     manager = Camera.main.GetComponent <PlayersManager> ();
     HP      = hp;
     if (tag == "orcTown" && isSpawn)
     {
         Orcspawner = this;
     }
 }
Example #4
0
 public void updatePlayer(Vector3 mouse, bool attack, TownScript other = null)
 {
     dest = Camera.main.ScreenToWorldPoint(mouse);
     findDirection(mouse, Camera.main.WorldToScreenPoint(transform.position));
     if (action == PlayerScript.PlayerAction.STAY)
     {
         action = PlayerScript.PlayerAction.MOVE;
     }
     isAttack = attack;
     ennemy   = other;
     if (isAttack == false)
     {
         anim.SetBool("humanFight", false);
     }
     if (action != PlayerScript.PlayerAction.FIGHT)
     {
         anim.SetBool("humanMove", true);
     }
 }
Example #5
0
 // Update is called once per frame
 void Update()
 {
     if (ennemy != null && !ennemy.gameObject.activeSelf)
     {
         ennemy = null;
         anim.SetBool("humanFight", false);
         action = PlayerAction.STAY;
     }
     nbFrames++;
     if (action == PlayerAction.MOVE)
     {
         Vector3 oldpos = transform.position;
         transform.position = Vector3.MoveTowards(transform.position, dest, speed * Time.deltaTime);
         if (oldpos == transform.position)
         {
             anim.SetBool("humanMove", false);
             action = PlayerAction.STAY;
         }
     }
     if (action == PlayerAction.FIGHT)
     {
         if (ennemy == null)
         {
             action = PlayerAction.STAY;
         }
         else if (nbFrames >= nbFramesBeforeAttack)
         {
             nbFrames   = 0;
             ennemy.hp -= attack;
             Debug.Log("Orc Unit [" + ennemy.hp + "/" + ennemy.HP + "] has been attacked.");
             if (ennemy.hp <= 0)
             {
                 ennemy.hp = 0;
                 ennemy.Kill();
             }
         }
     }
 }
Example #6
0
 public void Kill()
 {
     ennemy   = null;
     isAttack = false;
     anim.SetBool("humanFight", false);
 }