예제 #1
0
        private void SetState(OrbiterState state)
        {
            var oldState = State;

            State    = state;
            WaitTime = state == OrbiterState.Idle
                ? 0 : GetTime(state);
            OnState(state);
            OnStateChange(oldState);
        }
예제 #2
0
        protected override void OnStateChange(OrbiterState _)
        {
            bool firing = State == OrbiterState.Firing;

            if (fireBeam.enabled != firing)
            {
                fireBeam.enabled = firing;
            }

            ParticleState(chargeParticles, OrbiterState.Charging);
            ParticleState(fireParticles, OrbiterState.Firing);
        }
예제 #3
0
        private void OnState(OrbiterState state)
        {
            switch (state)
            {
            case OrbiterState.Cooldown: OnCooldown(); return;

            case OrbiterState.Charging: OnCharge(ChargeTime); return;

            case OrbiterState.Firing: OnFire(FireDuration); return;

            case OrbiterState.Idle: OnIdle(); return;
            }
        }
예제 #4
0
        private void ParticleState(ParticleSystem ps, OrbiterState playState)
        {
            bool plays = State == playState;

            if (plays && !ps.isPlaying)
            {
                ps.Play();
            }
            else if (!plays && ps.isPlaying)
            {
                ps.Stop();
            }
        }
예제 #5
0
        private float GetTime(OrbiterState state)
        {
#pragma warning disable // Convert switch statement to expression
            switch (state)
            {
            case OrbiterState.Cooldown: return(CooldownTime);

            case OrbiterState.Charging: return(ChargeTime);

            case OrbiterState.Firing: return(FireDuration);

            default: return(1);
            }
            ;
#pragma warning restore
        }
예제 #6
0
 protected virtual void OnStateChange(OrbiterState oldState)
 {
 }