Beispiel #1
0
        public int Check(char code)
        {
            int check = 0;

            input_stream.Add(code);
            if (input_stream.Count > codeArr.Length)
            {
                input_stream.RemoveAt(0);
            }
            if (input_stream.Count == codeArr.Length)
            {
                for (int i = input_stream.Count - 1; i > 0; i--)
                {
                    if (input_stream[i] != codeArr[i])
                    {
                        check = -1;
                        break;
                    }
                }
                if (check == 0)
                {
                    Unlock?.Invoke();
                }
            }
            return(check);
        }
        /// <summary>
        /// Updates the cylinder data and state.
        /// </summary>
        public void Update()
        {
            float driveDelta = GetDriveDelta();

            switch (State)
            {
            case StateType.Idle:                     // Idle state
                if (driveDelta != 0f)
                {
                    State = StateType.Moving;
                    goto case StateType.Moving;
                }
                break;

            case StateType.Moving:                     // Moving state
                if (driveDelta == 0f)
                {
                    State = StateType.Idle;
                    break;
                }
                float prevRotation = Rotation;
                Rotation += driveDelta;

                if (Rotation >= MaxTensionRotation && driveDelta > 0f && MaxTensionRotation != 1f)
                {
                    Rotation = prevRotation;
                    State    = StateType.Stuck;
                    goto case StateType.Stuck;
                }

                if (Rotation >= 1f)
                {
                    State = StateType.Unlocked;
                    Unlock?.Invoke(this, EventArgs.Empty);
                }
                break;

            case StateType.Stuck:                     // Stuck state
                if (driveDelta <= 0f)
                {
                    State = StateType.Moving;
                    goto case StateType.Moving;
                }
                break;

            case StateType.Unlocked:                     // Unlocked state
                if (Rotation < 1f)
                {
                    State = StateType.Idle;
                    goto case StateType.Idle;
                }
                break;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Проверка правельности введенного символа
 /// </summary>
 /// <param name="code"></param>
 public void Check(char code)
 {
     inCode.Add(code);
     for (int i = 0; i < inCode.Count; i++)
     {
         if (codeArr[i] != inCode[i])
         {
             inCode.Clear();
             counter--;
             if (counter == 0)
             {
                 LockAll?.Invoke();
             }
             return;
         }
     }
     if (inCode.Count == codeArr.Length)
     {
         Unlock?.Invoke();
     }
 }
    /// <summary>
    /// Performs time sensitive functionality after the unlock event.
    /// </summary>
    private IEnumerator ProcessUnlock()
    {
        yield return(new WaitForSeconds(.5f));

        Unlock?.Invoke(this, EventArgs.Empty);
    }
Beispiel #5
0
 private LineRenderer _handDrawingLine; // lastNodeと指の間のLineRenderer private void OnUnlock() => Unlock?.Invoke();
 private void OnUnlock() => Unlock?.Invoke();