Ejemplo n.º 1
0
        IEnumerator Movement()
        {
            var keys = _keys[(int)Side];

            while (true)
            {
                Action action = Idle;
                if (Input.GetKey(keys[0]))
                {
                    action = MoveUp;
                }
                if (Input.GetKey(keys[1]))
                {
                    action = MoveDown;
                }
                if (Side == Player.Player1)
                {
                    QAIManager.Imitate(this, GetState(), action);
                }
                if (Side == Player.Player2)
                {
                    action();
                }
                yield return(new WaitForFixedUpdate());
            }
        }
Ejemplo n.º 2
0
    IEnumerator Spas()
    {
        while (true)
        {
            Action a = Brake;
            if (Input.GetKey(SpeederKey))
            {
                a = FullSpeed;
            }
            QAIManager.Imitate(this, GetState(), a);

            yield return(new WaitForFixedUpdate());
        }
    }
Ejemplo n.º 3
0
 public void FixedUpdate()
 {
     if (_testModel)
     {
         Instantiate(Resources.Load <ModelTest>("ModelTest"));
         _testModel = false;
     }
     _grid.DebugDraw(value => value == 0 ? Color.red : value == 1 ? Color.gray : Color.yellow);
     if (QAIManager.CurrentMode != QAIMode.Imitating)
     {
         var state = GetState();
         QAIManager.GetAction(state)();
         ArchiveState(state);
     }
     else
     {
         Action currentAction = null;
         if (Key(KeyCode.UpArrow, KeyCode.W))
         {
             currentAction = MoveUp;
         }
         if (Key(KeyCode.DownArrow, KeyCode.S))
         {
             currentAction = MoveDown;
         }
         if (Key(KeyCode.RightArrow, KeyCode.D))
         {
             currentAction = MoveRight;
         }
         if (Key(KeyCode.LeftArrow, KeyCode.A))
         {
             currentAction = MoveLeft;
         }
         if (currentAction != null)
         {
             QAIManager.Imitate(this, GetState(), currentAction);
         }
     }
 }