Example #1
0
 private void OnInput(CodeInput newInput)
 {
     int[] numArray = CodeMachineHost.BitPatterns[newInput];
     if (this.inputEmitter != null && !this.inputEmitter.Dead)
     {
         this.inputEmitter.Cue.Stop(false);
     }
     this.inputEmitter = SoundEffectExtensions.EmitAt(this.inputSound, this.CodeMachineAO.Position, RandomHelper.Between(-0.05, 0.05));
     for (int index1 = 0; index1 < 36; ++index1)
     {
         for (int index2 = 0; index2 < 4; ++index2)
         {
             CodeMachineHost.BitState bitState = this.BitStates[index1 * 4 + index2];
             bitState.On = numArray[index1] == 1;
             if (bitState.On)
             {
                 bitState.SinceIdle = TimeSpan.Zero;
             }
         }
     }
     this.SinceInput = TimeSpan.Zero;
 }
Example #2
0
 private void UpdateBits(TimeSpan elapsed)
 {
     for (int index1 = 0; index1 < 36; ++index1)
     {
         int num1 = index1 % 6;
         int num2 = index1 / 6;
         for (int index2 = 0; index2 < 4; ++index2)
         {
             BackgroundPlane          backgroundPlane = this.BitPlanes[index1 * 4 + index2];
             CodeMachineHost.BitState bitState        = this.BitStates[index1 * 4 + index2];
             TimeSpan timeSpan = TimeSpan.FromTicks(CodeMachineHost.Delay.Ticks * (long)(num1 + num2));
             if (bitState.On)
             {
                 if (bitState.SinceOn < CodeMachineHost.FadeInDuration)
                 {
                     bitState.SinceOn       += elapsed;
                     backgroundPlane.Opacity = FezMath.Saturate((float)bitState.SinceOn.Ticks / (float)CodeMachineHost.FadeInDuration.Ticks);
                     bitState.SinceOff       = TimeSpan.FromSeconds((1.0 - (double)backgroundPlane.Opacity) * CodeMachineHost.FadeOutDuration.TotalSeconds) - timeSpan;
                 }
                 else if (bitState.SinceIdle < CodeMachineHost.TimeOut)
                 {
                     bitState.SinceIdle += elapsed;
                 }
                 else
                 {
                     bitState.On = false;
                 }
             }
             else if (bitState.SinceOff < CodeMachineHost.FadeOutDuration)
             {
                 bitState.SinceOff      += elapsed;
                 backgroundPlane.Opacity = FezMath.Saturate((float)(1.0 - (double)bitState.SinceOff.Ticks / (double)CodeMachineHost.FadeOutDuration.Ticks));
                 bitState.SinceOn        = TimeSpan.FromSeconds((double)backgroundPlane.Opacity * CodeMachineHost.FadeInDuration.TotalSeconds) - timeSpan;
             }
         }
     }
 }