예제 #1
0
        void OnTriggerStay(Collider collision)
        {
            IA_Hob_Code script = holder.GetComponent <IA_Hob_Code>();

            if (IsHiting && collision.gameObject == script.GetTarget())
            {
                Debug.Log("hit");
                script.ApplyDamage(collision.gameObject);
                IsHiting = false;
            }
        }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     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);
         }
     }
 }
예제 #3
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);
         }
     }
 }
예제 #4
0
        void OnTriggerStay(Collider collision)
        {
            IA_Hob_Code script = holder.GetComponent <IA_Hob_Code>();

            if (IsHiting && collision.gameObject == script.GetTarget())
            {
                Debug.Log("hit");
                if (Random.Range(0, 10) == 1)
                {
                    collision.gameObject.GetComponent <UnarmedCharacter>().status = Status.Stunned;
                    if (collision.gameObject.GetComponent <PlayerStat>().coroutine != null)
                    {
                        StopCoroutine(collision.gameObject.GetComponent <PlayerStat>().coroutine);
                    }
                    collision.gameObject.GetComponent <PlayerStat>().SetDOT_Time(2);
                    collision.gameObject.GetComponent <PlayerStat>().coroutine = StartCoroutine(collision.gameObject.GetComponent <PlayerStat>().GetOverTime());
                }
                script.ApplyDamage(collision.gameObject);
                IsHiting = false;
            }
        }