// Use this for initialization void Start() { currentState = States.Navigating; _navMeshInterface = gameObject.GetComponent <AlienNavMeshInterface>(); _health = gameObject.GetComponent <SmallAlienHealth>(); anims = gameObject.GetComponent <Animator>(); }
// Use this for initialization void Start() { currentState = States.Navigating; _navMeshInterface = gameObject.GetComponent <AlienNavMeshInterface>(); _health = gameObject.GetComponent <SmallAlienHealth>(); anims = gameObject.GetComponent <Animator>(); SplashDamage = GameObject.Find("SplashDamage").GetComponent <SplashDamageScript>(); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { startAttackTime = Time.time; HitTime = Time.time + (stateInfo.length / 3f); SplashDamage = GameObject.Find("SplashDamage").GetComponent <SplashDamageScript>(); _nav = animator.gameObject.GetComponent <AlienNavMeshInterface>(); playerHealth = GameObject.Find("PlayerSpawnLocation").GetComponent <PlayerHealthScript>(); }
// Use this for initialization void Start() { rb = gameObject.GetComponent <Rigidbody>(); anims = gameObject.GetComponent <Animator>(); ai = gameObject.GetComponent <SmallAlienAI>(); health = gameObject.GetComponent <SmallAlienHealth>(); nav = gameObject.GetComponent <AlienNavMeshInterface>(); mesh = gameObject.transform.FindChild("SmallAlienMesh").gameObject; startEmission = mesh.GetComponent <SkinnedMeshRenderer>().material.GetColor("_Emission"); startDrag = gameObject.GetComponent <Rigidbody>().drag; startY = transform.position.y; }
// When the alien get's close to the dummy, it'll attack it. void OnTriggerEnter(Collider other) { if (other.tag == "Alien") { distractedAliens[distratedAliensIndex] = other.transform.parent; distratedAliensIndex++; AlienNavMeshInterface thisAlien = other.GetComponentInParent <AlienNavMeshInterface>(); SmallAlienAI thisAlienAI = other.GetComponentInParent <SmallAlienAI>(); thisAlien.target = gameObject; thisAlienAI.SetState(SmallAlienAI.States.Navigating); thisAlien.attackingPlayer = false; health.healthRateMultiplier += drainHealthMultiplier; } }
// When the dummy get's destroyed, all of the aliens on it will move back to the player. void OnDestroy() { for (int i = 0; i < distractedAliens.Length; i++) { if (distractedAliens[i] != null) { AlienNavMeshInterface thisAlien = distractedAliens[i].GetComponent <AlienNavMeshInterface>(); SmallAlienAI thisAlienAI = distractedAliens[i].GetComponent <SmallAlienAI>(); thisAlien.target = playerLoc; thisAlienAI.SetState(SmallAlienAI.States.Navigating); thisAlien.FindAttackPosition(); thisAlien.attackingPlayer = true; } } }
// When the dummy get's destroyed, all of the aliens on it will move back to the player. void OnDestroy() { for (int i = 0; i < distractedAliens.Length; i++) { if (distractedAliens[i] != null) { AlienNavMeshInterface thisAlien = distractedAliens[i].GetComponent <AlienNavMeshInterface>(); SmallAlienAI thisAlienAI = distractedAliens[i].GetComponent <SmallAlienAI>(); thisAlien.target = playerLoc; thisAlien.SetNavMeshAgentDestination(playerLoc.transform.position); thisAlienAI.SetState(SmallAlienAI.States.Navigating); thisAlien.nmo.enabled = false; thisAlien.attackingPlayer = true; } } }
// Use this for initialization void Start() { Nav = transform.parent.GetComponent <AlienNavMeshInterface>(); }