void Start() { Zombie = transform.parent; _state = Zombie.GetComponent <ZombieSM>(); curAnim = Zombie.GetComponent <tk2dSpriteAnimator>(); zombieHealth = Zombie.GetComponent <ZombieHealth>(); }
IEnumerator MoveZombie(Transform zombie, float moveTime) { ZombieSM zsm = zombie.GetComponent <ZombieSM>(); CharacterController CC = zombie.GetComponent <CharacterController>(); while (Time.time < moveTime) { // zombie.GetComponent<tk2dSpriteAnimator>().Play(); if (zsm.curState != ZombieSM.ZombieState.ControlledMovement) { yield break; } CC.Move(Move * Time.deltaTime); yield return(null); } // check if in movezone, then enumerate until out. // make the move zone into collider for just zombies if (MoveZone.collider.bounds.Contains(zombie.position) && zsm.curState == ZombieSM.ZombieState.ControlledMovement) { StartCoroutine(MoveZombie(zombie, Time.time + 1)); } else { zsm.curState = ZombieSM.ZombieState.Wander; zombie.GetComponent <tk2dSpriteAnimator>().Stop(); } }
void OnTriggerStay(Collider other) { if (!_foundPlayer) { // Keeps checking for player every 0.5 seconds if in detection range // but behind a wall. This is so it doesn't raycast every update if (other.tag == "Player" && !_foundPlayer && _lookForPlayerTimer < Time.time && _state.curState != ZombieSM.ZombieState.TakingDamage && _state.curState != ZombieSM.ZombieState.Die) { // Temp change from .Stunned int layerMask = ~(1 << 0); RaycastHit hit; if (Physics.Raycast(Zombie.position, other.transform.position - Zombie.position, out hit, 70, layerMask)) { if (hit.transform.tag == "Wall") { _lookForPlayerTimer = Time.time + _lookForPause; } else if (hit.transform.tag == "Player") { _foundPlayer = true; _outsideDetectionRange = false; Player = other.transform; _state.curState = ZombieSM.ZombieState.Chase; PlayRandomSound(); StartCoroutine(AccelerateSpeed()); StartCoroutine(AlertNearbyZombiesTimer()); CalculateChase(); } /* * if(hit.transform.gameObject.layer == LayerMask.NameToLayer( "Wall" )){ * print("hit wall layer"); * } * if(hit.transform.gameObject.layer == LayerMask.NameToLayer( "Player" )){ * print("hit player layer"); * } */ } } } else if (_alertNearbyZombies) // Alerts other zombies to player { if (other.tag == "Zombie") { // print("found nearby zombie"); ZombieSM zsm = other.GetComponent <ZombieSM>(); if (zsm.curState == ZombieSM.ZombieState.Wander || zsm.curState == ZombieSM.ZombieState.ControlledMovement || zsm.curState == ZombieSM.ZombieState.EnumeratedMovement) { zsm.SetStateToChase(); other.transform.FindChild("ZombieDetectionRange").GetComponent <ZombieChase>().PlayRandomSound(); //.GetComponents<ZombieChase>().PlayRandomSound(); // print("set nearby zombie to chase"); } } } }
void OnTriggerEnter(Collider other) { if (other.tag == "Zombie") { ZombieSM zsm = other.GetComponent <ZombieSM>(); if (zsm.Stoppable && zsm.curState == ZombieSM.ZombieState.Stop && !zsm.Cutscene) { zsm.curState = ZombieSM.ZombieState.Wander; } } }
// Use this for initialization void Start() { LastHitTime = 0; curAnim = GetComponent <tk2dSpriteAnimator>(); sprite = GetComponent <tk2dSprite>(); _state = GetComponent <ZombieSM>(); CC = GetComponent <CharacterController>(); int healthIndex = Random.Range(0, Healths.Length); health = Healths[healthIndex]; }
void OnTriggerExit(Collider other) { if (other.tag == "Zombie") { ZombieSM zsm = other.GetComponent <ZombieSM>(); if (zsm.curState == ZombieSM.ZombieState.ControlledMovement) { zsm.curState = ZombieSM.ZombieState.EnumeratedMovement; StartCoroutine(EnumeratedMove(other.transform, Time.time + enumMoveTime)); } } }
void OnTriggerEnter(Collider other) { if (other.tag == "Zombie") { // print ("IN MOVE 2 found zombie"); ZombieSM zsm = other.GetComponent <ZombieSM>(); if (zsm.curState == ZombieSM.ZombieState.Stop || zsm.curState == ZombieSM.ZombieState.Wander) { zsm.SetStateToControlledMovement(contMove); } } }
void Start() { curAnim = GetComponent <tk2dSpriteAnimator>(); _state = GetComponent <ZombieSM>(); CC = GetComponent <CharacterController>(); Sprite = GetComponent <tk2dSprite>(); timeMod = time; trueTime = 1f / timeMod; //Color orange = new Color(255, 80, 0, 255); Colors = new Color[] { Color.cyan, Color.green, Color.magenta, Color.yellow, Color.blue, Color.white, Color.grey, Color.red, Color.black }; StartCoroutine(ChangeColor(trueTime)); }
IEnumerator EnumeratedMove(Transform zombie, float moveTime) { CharacterController CC = zombie.GetComponent <CharacterController>(); ZombieSM zsm = zombie.GetComponent <ZombieSM>(); while (Time.time < moveTime) { if (zsm.curState != ZombieSM.ZombieState.EnumeratedMovement) { yield break; } CC.Move(enumMove * Time.deltaTime); yield return(null); } if (zsm.curState == ZombieSM.ZombieState.EnumeratedMovement) { //zsm.SetStateToChase(); zsm.curState = ZombieSM.ZombieState.Wander; } }
// Use this for initialization void Start() { //int[] chaseSpeeds = {_speed1, _speed2, _speed3}; int speedIndex = Random.Range(0, _chaseSpeeds.Length); _speed = _chaseSpeeds[speedIndex]; _startSpeed = _speed; //_speed = 72; //_speed = Random.Range(35, 52); // print ("SPEED: " + _speed); Zombie = transform.parent; _state = Zombie.GetComponent <ZombieSM>(); curAnim = Zombie.GetComponent <tk2dSpriteAnimator>(); CC = Zombie.GetComponent <CharacterController>(); if (AlwaysChase) { _state.SetStateToChase(); } }
// Use this for initialization void Start() { //int[] chaseSpeeds = {_speed1, _speed2, _speed3}; int speedIndex = Random.Range(0, _chaseSpeeds.Length); _speed = _chaseSpeeds[speedIndex]; _startSpeed = _speed; //_speed = 72; //_speed = Random.Range(35, 52); // print ("SPEED: " + _speed); Zombie = transform.parent; _state = Zombie.GetComponent<ZombieSM>(); curAnim = Zombie.GetComponent<tk2dSpriteAnimator>(); CC = Zombie.GetComponent<CharacterController>(); if(AlwaysChase){ _state.SetStateToChase(); } }
// Use this for initialization void Start() { _state = GetComponent<ZombieSM>(); //curAnim = transform.FindChild("ZombieSprite").GetComponent<tk2dSpriteAnimator>(); curAnim = GetComponent<tk2dSpriteAnimator>(); }
void Start() { curAnim = GetComponent<tk2dSpriteAnimator>(); _state = GetComponent<ZombieSM>(); CC = GetComponent<CharacterController>(); Sprite = GetComponent<tk2dSprite>(); timeMod = time; trueTime = 1f/timeMod; //Color orange = new Color(255, 80, 0, 255); Colors = new Color[] {Color.cyan, Color.green, Color.magenta, Color.yellow, Color.blue, Color.white, Color.grey, Color.red, Color.black}; StartCoroutine(ChangeColor(trueTime)); }
private tk2dSpriteAnimator curAnim; // current animation for zombie // Use this for initialization void Start() { _state = GetComponent <ZombieSM>(); //curAnim = transform.FindChild("ZombieSprite").GetComponent<tk2dSpriteAnimator>(); curAnim = GetComponent <tk2dSpriteAnimator>(); }
void Start() { Zombie = transform.parent; _state = Zombie.GetComponent<ZombieSM>(); curAnim = Zombie.GetComponent<tk2dSpriteAnimator>(); zombieHealth = Zombie.GetComponent<ZombieHealth>(); }
// Use this for initialization void Start() { LastHitTime = 0; curAnim = GetComponent<tk2dSpriteAnimator>(); sprite = GetComponent<tk2dSprite>(); _state = GetComponent<ZombieSM>(); CC = GetComponent<CharacterController>(); int healthIndex = Random.Range(0, Healths.Length); health = Healths[healthIndex]; }