コード例 #1
0
        private void MoveKnob(double x, double y, int milli)
        {
            double additionX = x - Base.Width / 2;
            double additionY = y - Base.Height / 2;
            double dist      = Dist(additionX, additionY, 0, 0);

            if (dist >= 42)
            {
                additionX *= 40 / dist;
                additionY *= 40 / dist;
            }
            DoubleAnimation animationX = new DoubleAnimation();

            _stoppedMoving        = false;
            animationX.From       = KnobPosition.X;
            animationX.To         = additionX;
            animationX.Completed += (sender, args) =>
            {
                _stoppedMoving = true;
                KnobPosition.X = KnobPosition.X;
                KnobPosition.Y = KnobPosition.Y;
            };
            animationX.Duration = new Duration(new TimeSpan(0, 0, 0, 0, milli));
            DoubleAnimation animationY = new DoubleAnimation();

            animationY.From     = KnobPosition.Y;
            animationY.To       = additionY;
            animationY.Duration = new Duration(new TimeSpan(0, 0, 0, 0, milli));

            KnobPosition.BeginAnimation(TranslateTransform.XProperty, animationX);
            KnobPosition.BeginAnimation(TranslateTransform.YProperty, animationY);
        }
コード例 #2
0
     private bool KMSelectable_OnInteract()
     {
         this.Position = this.Position switch { KnobPosition.Up => KnobPosition.Right, KnobPosition.Right => KnobPosition.Down, KnobPosition.Down => KnobPosition.Left, _ => KnobPosition.Up };
         this.transform.localEulerAngles = new Vector3(0, TranslatedKnobConnector.KnobPositionToRotation(this.Position), 0);
         this.Turned?.Invoke(this, EventArgs.Empty);
         return(false);
     }
 }
コード例 #3
0
 private void KMNeedyModule_OnNeedyActivation()
 {
     this.needyActive = true;
     if (this.serialNumberLetters.Count > 0)
     {
         // For each incorrect position, with 50% chance, two letters that both don't match the condition are chosen. This makes it quicker on average to identify it as incorrect.
         this.correctPosition = (KnobPosition)Random.Range(0, 4);
         if (this.correctPosition == KnobPosition.Up)
         {
             // Both letters present in the serial number
             this.letters[0, 0] = this.GetLetter(true);
             this.letters[0, 1] = this.GetLetter(true);
         }
         else
         {
             var roll = Random.Range(0, 4);
             this.letters[0, 0] = this.GetLetter(roll == 0);
             this.letters[0, 1] = this.GetLetter(roll == 1);
         }
         if (this.correctPosition == KnobPosition.Down)
         {
             // Neither letter present in the serial number
             this.letters[1, 0] = this.GetLetter(false);
             this.letters[1, 1] = this.GetLetter(false);
         }
         else
         {
             var roll = Random.Range(0, 4);
             this.letters[1, 0] = this.GetLetter(roll != 0);
             this.letters[1, 1] = this.GetLetter(roll != 1);
         }
         if (this.correctPosition == KnobPosition.Left)
         {
             // Left letter present in the serial number
             this.letters[2, 0] = this.GetLetter(true);
             this.letters[2, 1] = this.GetLetter(false);
         }
         else
         {
             var roll = Random.Range(0, 4);
             this.letters[2, 0] = this.GetLetter(roll == 0);
             this.letters[2, 1] = this.GetLetter(roll != 1);
         }
         if (this.correctPosition == KnobPosition.Right)
         {
             // Right letter present in the serial number
             this.letters[3, 0] = this.GetLetter(false);
             this.letters[3, 1] = this.GetLetter(true);
         }
         else
         {
             var roll = Random.Range(0, 4);
             this.letters[3, 0] = this.GetLetter(roll != 0);
             this.letters[3, 1] = this.GetLetter(roll == 1);
         }
     }
     else
     {
         this.correctPosition = KnobPosition.Down;
         for (int i = 3; i >= 0; --i)
         {
             this.letters[i, 0] = (char)('A' + Random.Range(0, 26));
             this.letters[i, 1] = (char)('A' + Random.Range(0, 26));
         }
     }
     this.Log("Module active. The letters are as follows: Up: {0} {1}; Down: {2} {3}; Left: {4} {5}; Right: {6} {7}. The correct position is {8}.",
              this.letters[0, 0], this.letters[0, 1], this.letters[1, 0], this.letters[1, 1], this.letters[2, 0], this.letters[2, 1], this.letters[3, 0], this.letters[3, 1], this.correctPosition);
     this.UpdateLEDs();
     this.Connector.SetRotation((KnobPosition)Random.Range(0, 4));
 }
コード例 #4
0
 internal static float KnobPositionToRotation(KnobPosition position) => position switch
 {