コード例 #1
0
 void OnTriggerExit2D(Collider2D col)
 {
     if (col.gameObject.GetComponent <AttackableTarget>())
     {
         state = State.Moving;
     }
 }
コード例 #2
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.GetComponent <AttackableTarget>() != null && state != State.Attacking)
     {
         attackTarget = col.gameObject.GetComponent <AttackableTarget>();
         state        = State.Attacking;
     }
 }
コード例 #3
0
 private void hitTarget()
 {
     if (attackTarget != null)
     {
         if (timeLeftBeforeHit <= 0)
         {
             attackTarget.hitTarget(attackPower);
             timeLeftBeforeHit = timeBetweenHits;
             if (!attackTarget.alive)
             {
                 state        = State.Idle;
                 attackTarget = null;
             }
         }
         else
         {
             timeLeftBeforeHit -= Time.deltaTime;
         }
     }
 }
コード例 #4
0
    //public bool reachedDestination;

    // Start is called before the first frame update
    void Start()
    {
        timeLeftBeforeHit = timeBetweenHits;
        state             = Creature.State.Idle;
    }