Esempio n. 1
0
    public void handleWalk()
    {
        if (GetComponent<EnemyScript>()) {
            mode = SoldierMode.AGGRESSIVE;
        }
        if (targetEnemy && mode == SoldierMode.AGGRESSIVE && Vector3.Distance(transform.position, targetEnemy.transform.position) < 0.2F) {
            anim.SetBool("attacking", true);
            if (Time.time > t0 + 1f) {
                if (targetEnemy.name == "HDV_Ork") {
                    if (name == "OrcSoldier(Clone)") {
                        targetEnemy = null;
                        return;
                    }
                    targetEnemy.GetComponent<TownHallScript>().handleDefense();
                }
                targetEnemy.GetComponent<MapObject>().hp -= 1;
                t0 = Time.time;
            }
        } else {
            Vector3 currentTarget = (targetEnemy && mode == SoldierMode.AGGRESSIVE) ? targetEnemy.transform.position : targetPosition;

            if (transform.position != currentTarget) {
                anim.SetBool("attacking",false);
                anim.SetBool("walking", true);
                transform.position = Vector3.MoveTowards(transform.position, currentTarget, Time.deltaTime);
        transform.rotation = Quaternion.LookRotation(Vector3.forward, transform.position - currentTarget);
            }
            else {
        anim.SetBool("walking",false);
            }
        }
    }
Esempio n. 2
0
 public void handleTag(GameObject target)
 {
     if (target.tag != this.tag) {
         if (gameObject != target) {
                 mode = SoldierMode.AGGRESSIVE;
                 targetEnemy = target;
         }
     }
     else {
         setPassive();
     }
 }
Esempio n. 3
0
 public void handleTag(GameObject target)
 {
     if (target.tag != this.tag)
     {
         if (gameObject != target)
         {
             mode        = SoldierMode.AGGRESSIVE;
             targetEnemy = target;
         }
     }
     else
     {
         setPassive();
     }
 }
Esempio n. 4
0
    public void handleWalk()
    {
        if (GetComponent <EnemyScript>())
        {
            mode = SoldierMode.AGGRESSIVE;
        }
        if (targetEnemy && mode == SoldierMode.AGGRESSIVE && Vector3.Distance(transform.position, targetEnemy.transform.position) < 0.2F)
        {
            anim.SetBool("attacking", true);
            if (Time.time > t0 + 1f)
            {
                if (targetEnemy.name == "HDV_Ork")
                {
                    if (name == "OrcSoldier(Clone)")
                    {
                        targetEnemy = null;
                        return;
                    }
                    targetEnemy.GetComponent <TownHallScript>().handleDefense();
                }
                targetEnemy.GetComponent <MapObject>().hp -= 1;
                t0 = Time.time;
            }
        }
        else
        {
            Vector3 currentTarget = (targetEnemy && mode == SoldierMode.AGGRESSIVE) ? targetEnemy.transform.position : targetPosition;

            if (transform.position != currentTarget)
            {
                anim.SetBool("attacking", false);
                anim.SetBool("walking", true);
                transform.position = Vector3.MoveTowards(transform.position, currentTarget, Time.deltaTime);
                transform.rotation = Quaternion.LookRotation(Vector3.forward, transform.position - currentTarget);
            }
            else
            {
                anim.SetBool("walking", false);
            }
        }
    }
Esempio n. 5
0
 public void setPassive()
 {
     mode = SoldierMode.PASSIVE;
     targetEnemy = null;
 }
Esempio n. 6
0
 public void setPassive()
 {
     mode        = SoldierMode.PASSIVE;
     targetEnemy = null;
 }