Esempio n. 1
0
    void IdleState()
    {
        //Idle Behaviour
        if ( Vector3.Distance(this.transform.position, origin) > 10) navAgent.SetDestination (origin);
        else anim.Play("Wait");

        //Transistion to ChaseState
        if (player != null) {
            if (Vector3.Distance (this.transform.position, player.transform.position) < 30)
                currentState = blobState.Chase;
        } else {
            if (player == null) {
                player = GameObject.FindGameObjectWithTag ("Player");
            } else
                Debug.LogError ("NO player");
            if (player != null) {
                playerScript = player.GetComponent("PlayerScript") as PlayerScript;
            }
        }
    }
Esempio n. 2
0
    void ChaseState()
    {
        //Chase Behaviour
        if (player != null)	navAgent.SetDestination (player.transform.position);
        if (!anim.IsPlaying ("Walk") && !anim.IsPlaying ("Damage")) anim.Play ("Walk");

        //Transition to Idle
        if (player != null) {
            if (Vector3.Distance (this.transform.position, player.transform.position) > 60)
                currentState = blobState.Idle;
        } else {
            if (player == null) {
                player = GameObject.FindGameObjectWithTag ("Player");
            } else
                Debug.LogError ("NO player");
            if (player != null) {
                playerScript = player.GetComponent("PlayerScript") as PlayerScript;
            }
        }
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     currentHitPoints = baseHitPoints;
     anim = GetComponent<Animation>();
     navAgent = GetComponent<NavMeshAgent>();
     currentState = blobState.Idle;
     origin = this.transform.position;
     if (player == null) {
         player = GameObject.FindGameObjectWithTag ("Player");
     } else
         Debug.LogError ("NO player");
     if (player != null) {
         playerScript = player.GetComponent("PlayerScript") as PlayerScript;
     }
 }
Esempio n. 4
0
    void OnTriggerEnter(Collider other)
    {
        if (currentState != blobState.Dead) {
            if (other.gameObject.tag == "Sword") {
                if (playerScript.attacking){
                    anim.Play ("Damage");
                    baseHitPoints--;

                    if (baseHitPoints <= 0) {
                        currentState = blobState.Dead;
                    }
                }
            }
        }
    }