コード例 #1
0
    IEnumerator StunTime(float stunDuration)
    {
        float stunTime = Time.time + stunDuration;

        _state.curState = ZombieSM.ZombieState.TakingDamage;

        isStunned = true;
        curAnim.Stop();
        Color origColor = sprite.color;
        float colorMod  = 10f;
        Color stunColor = new Color(origColor.r / colorMod, origColor.g / colorMod, origColor.b / colorMod, origColor.a);

        sprite.color = stunColor;
        while (Time.time < stunTime)
        {
            if (_state.curState == ZombieSM.ZombieState.Die)
            {
                sprite.color = origColor;
                isStunned    = false;
                curAnim.Play();
                yield break;
            }
            yield return(null);
        }
        isStunned    = false;
        sprite.color = origColor;
        curAnim.Play();
        _state.SetStateToChase();
    }
コード例 #2
0
    IEnumerator MovementPause(float standTime)
    {
        float totalTime = Time.time + standTime;

        while (Time.time < totalTime)
        {
            if (_state.curState == ZombieSM.ZombieState.Die)
            {
                yield break;
            }
            yield return(null);
        }
        if (!zombieHealth.isStunned)
        {
            _state.SetStateToChase();
        }

        /*
         * //print ("in movement pause");
         * yield return new WaitForSeconds(standTime);
         *
         *
         *
         *
         * if(_state.curState == ZombieSM.ZombieState.Die){
         *      yield break;
         * }
         *
         * // curAnim.StopAndResetFrame();
         * if(!zombieHealth.isStunned)
         *      _state.SetStateToChase();
         * //_state.curState = ZombieSM.ZombieState.Chase;
         */
    }
コード例 #3
0
ファイル: ZombieChase.cs プロジェクト: newmanwillis/Dead_Week
    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");
                }
            }
        }
    }
コード例 #4
0
ファイル: ZombieChase.cs プロジェクト: newmanwillis/Dead_Week
    // 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();
        }
    }
コード例 #5
0
ファイル: ZombieChase.cs プロジェクト: newmanwillis/Dead_Week
    // 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();
        }
    }