void OnTriggerEnter(Collider other){ Debug.Log ("Being called?"); if (other.gameObject.tag != "Player"){ // because we don't want the grenade to disappear as soon as you throw it mAI = other.GetComponent<MercuryAI>(); if (mAI != null){ Debug.Log("Hit Enemy"); enemyHit = true; //mAI.state = MercuryAI.State.Stunned; Utilities.Stun(mAI.gameObject); //hit.GetComponent<MercuryAI>().state = MercuryAI.State.Idle; if (enemyHit == true){ if (Input.GetKeyDown(KeyCode.F) && harvest.isHarvesting && harvest.harvestTime < 1f){ mAI.currentHealth -= damage; } } } } }
// Use this for initialization void Start () { // Getting the Monster Data here from the Mob Database // md = Utilities.GetMobData("Malice"); ///////////////////////////////////////////////////// currentHealth = maxHealth; mercury = GameObject.FindGameObjectWithTag ("Mercury").GetComponent<MercuryAI> (); Controller = GetComponent<Animator>(); /* Nav Mesh Properties */ agent = GetComponent<NavMeshAgent> (); agent.speed = walkSpeed; // Default is walk. agent.angularSpeed = rotationSpeed; //////////////////////////////////// state = defaultState; StartCoroutine ("FSM"); }
/* --------- UTILITY FUNCTION SCRIPTS ---------*/ private void Initialize(){ if (instance == null) instance = this; currentHunger = maxHunger; currentHealth = maxHealth; myTransform = transform; player = GameObject.FindGameObjectWithTag("Player"); fleePoints = GameObject.FindGameObjectsWithTag("Flee"); Controller = GetComponent<Animator>(); /* Nav Mesh Properties */ agent = GetComponent<NavMeshAgent> (); agent.speed = walkSpeed; // Default is walk. agent.angularSpeed = rotationSpeed; /* State Machine Properties*/ state = defaultState; }