Пример #1
0
 public void Pulse()
 {
     if (state != PulsarState.Inactive)
     {
         return;
     }
     pulseStartTime = waveEngine.t + activationLag;
     state          = PulsarState.PrePulse;
 }
Пример #2
0
    protected void Update()
    {
        // Activation conditions
        if (manualActivate)
        {
            Pulse();
            manualActivate = false;
        }

        if (!waveEngine)
        {
            return;
        }

        // Normalized time past activation
        float t = pulseLength == 0 ? 0 : (waveEngine.t - pulseStartTime) / pulseLength;

        if (autoActivate && state == PulsarState.Inactive)
        {
            Pulse();
        }

        // Behavior
        if (state == PulsarState.PrePulse && t >= 0)
        {
            OnPulseStart(t);
            state = PulsarState.MidPulse;
        }
        if (state == PulsarState.MidPulse && t <= 1)
        {
            OnPulsing(t);
        }
        if (state == PulsarState.MidPulse && t >= 1)
        {
            OnPulseEnd(t);
            state = PulsarState.Inactive;
        }
    }