Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (Hob.GetHealth() <= 0 && !drop)
     {
         animator.SetBool("Dead", true);
         Hob.GetTarget().gameObject.GetComponent <UnarmedCharacter>().Coins += 200;
         drop = true;
         return;
     }
     if (Hob.GetHealth() <= 0)
     {
         return;
     }
     if (Time.time > Hob.GetAllow_action())
     {
         if (Hob.GetTarget() != null)
         {
             float Distance = Vector3.Distance(Hob.transform.position, Hob.GetTarget().transform.position);
             if (Distance > Hob.GetFightingRange())
             {
                 Hob.chase();
             }
             else
             {
                 if (Distance <= Hob.GetAttackRange())
                 {
                     Hob.attack();
                 }
                 else
                 {
                     if (Hob.GetFight() && Distance <= Hob.GetFightingRange())
                     {
                         Hob.StartCoroutine("fighting");
                     }
                 }
             }
         }
     }
     else
     {
         if (Hob.GetTarget() != null)
         {
             Vector3 Targetposition = new Vector3(Hob.GetTarget().transform.position.x, transform.position.y, Hob.GetTarget().transform.position.z);
             transform.LookAt(Targetposition);
             transform.position = Vector3.MoveTowards(transform.position, Hob.GetTarget().transform.position, 6 * Time.deltaTime);
         }
     }
 }