Exemplo n.º 1
0
 private void Awake()
 {
     m_emergeState  = new EmergeState(this);
     m_chasingState = new ChasingState(this);
     m_attackState  = new AttackState(this);
     m_jumpToState  = new JumpToState(this);
     m_exhaustState = new ExhaustState(this);
 }
Exemplo n.º 2
0
    private void UpdateEngineSound()
    {
        if (!_isFAKilled)
        {
            PrimaryEngine.pitch = 0.7f + 0.3f * _throttle;
        }
        else
        {
            PrimaryEngine.pitch = 0.6f;
        }

        ExhaustState state = PlayerShip.MyReference.ExhaustController.GetExhaustState();

        if (state == ExhaustState.Thruster)
        {
            SecondaryEngine.volume = Mathf.Lerp(SecondaryEngine.volume, 1, 30 * Time.fixedDeltaTime);
            SecondaryEngine.pitch  = 1;
            if (SecondaryEngine.clip == null || SecondaryEngine.clip.name != "Afterburner")
            {
                SecondaryEngine.clip = GameManager.Inst.SoundManager.GetClip("Afterburner");
            }
            else if (!SecondaryEngine.isPlaying)
            {
                SecondaryEngine.Play();
            }
        }
        else if (state == ExhaustState.Normal || state == ExhaustState.Idle)
        {
            if (PlayerShip.Engine.IsPrepCruise)
            {
                /*
                 * if(PlayerShip.Engine.PrepPercent > 0.99f)
                 * {
                 *      SecondaryEngine.volume = Mathf.Lerp(SecondaryEngine.volume, 0, 60 * Time.fixedDeltaTime);;
                 * }
                 * else
                 * {
                 *      SecondaryEngine.volume = Mathf.Lerp(SecondaryEngine.volume, 1, 30 * Time.fixedDeltaTime);
                 * }
                 *
                 * if(SecondaryEngine.clip == null || SecondaryEngine.clip.name != "CruiseChargeUp")
                 * {
                 *
                 *      SecondaryEngine.clip = GameManager.Inst.SoundManager.GetClip("CruiseChargeUp");
                 * }
                 * else if(!SecondaryEngine.isPlaying)
                 * {
                 *      SecondaryEngine.Play();
                 * }
                 */

                SecondaryEngine.volume = Mathf.Lerp(SecondaryEngine.volume, 1f, 30 * Time.fixedDeltaTime);
                if (SecondaryEngine.clip == null || SecondaryEngine.clip.name != "Cruise")
                {
                    SecondaryEngine.clip   = GameManager.Inst.SoundManager.GetClip("Cruise");
                    SecondaryEngine.volume = 0;
                }
                else if (!SecondaryEngine.isPlaying)
                {
                    SecondaryEngine.Play();
                }
                SecondaryEngine.pitch = 0.4f + Mathf.Pow(PlayerShip.Engine.PrepPercent, 2) * 0.6f;
            }
            else
            {
                SecondaryEngine.pitch  = 1;
                SecondaryEngine.volume = Mathf.Lerp(SecondaryEngine.volume, 0, 30 * Time.fixedDeltaTime);
            }
        }
        else if (state == ExhaustState.Cruise)
        {
            SecondaryEngine.volume = Mathf.Lerp(SecondaryEngine.volume, 1, 30 * Time.fixedDeltaTime);
            SecondaryEngine.pitch  = 1.2f;
            if (SecondaryEngine.clip == null || SecondaryEngine.clip.name != "Cruise")
            {
                SecondaryEngine.clip   = GameManager.Inst.SoundManager.GetClip("Cruise");
                SecondaryEngine.volume = 0;
            }
            else if (!SecondaryEngine.isPlaying)
            {
                SecondaryEngine.Play();
            }
        }
    }
Exemplo n.º 3
0
    public void setExhaustState(ExhaustState state)
    {
        if (state == _state)
        {
            return;
        }

        if (_exhausts == null)
        {
            _exhausts      = new List <GameObject>();
            _exhaustTrails = new List <TrailRenderer>();
        }

        foreach (GameObject go in _exhausts)
        {
            GameObject.Destroy(go);
        }

        _exhausts.Clear();
        _exhaustTrails.Clear();
        _state = state;

        foreach (Transform t in ExhaustHolders)
        {
            GameObject exhaust = null;
            if (state == ExhaustState.Idle)
            {
                exhaust = GameObject.Instantiate(Resources.Load("EngineFlameIdle")) as GameObject;
            }
            else if (state == ExhaustState.Normal)
            {
                exhaust = GameObject.Instantiate(Resources.Load("EngineFlameNormal")) as GameObject;
                setExhaustLength(_normalExhaustScaleZ);

                if (_flare == null)
                {
                    _flare = GameObject.Instantiate(Resources.Load("EngineFlare")) as GameObject;
                    _flare.transform.parent           = t;
                    _flare.transform.localScale       = new Vector3(1, 1, 1);
                    _flare.transform.localPosition    = Vector3.zero;
                    _flare.transform.localEulerAngles = Vector3.zero;
                }
            }
            else if (state == ExhaustState.Thruster)
            {
                exhaust = GameObject.Instantiate(Resources.Load("EngineFlameThruster")) as GameObject;
            }
            else if (state == ExhaustState.Cruise)
            {
                exhaust = GameObject.Instantiate(Resources.Load("EngineFlameCruise")) as GameObject;
            }

            exhaust.transform.parent           = t;
            exhaust.transform.localScale       = FlameScale;
            exhaust.transform.localPosition    = Vector3.zero;
            exhaust.transform.localEulerAngles = Vector3.zero;
            ParticleSystem         particle = exhaust.GetComponent <ParticleSystem>();
            ParticleSystemRenderer renderer = particle.GetComponent <ParticleSystemRenderer>();
            renderer.maxParticleSize *= FlameScale.x;
            _exhausts.Add(exhaust);

            TrailRenderer trail = exhaust.transform.GetComponentInChildren <TrailRenderer>();
            if (trail != null)
            {
                _exhaustTrails.Add(trail);
            }
        }
    }