예제 #1
0
    void Update()
    {
        //	we OR the inputs, as they're only used on a tick, we store it until frame is done
        var  NewAxisReading = (int)Input.GetAxisRaw(JoystickAxisName);
        bool LeftDown       = (NewAxisReading < 0) && (LastAxisReading >= 0);
        bool RightDown      = (NewAxisReading > 0) && (LastAxisReading <= 0);

        LastAxisReading = NewAxisReading;

        if (LeftDown || Input.GetKeyDown(LeftKey))
        {
            if (TickStart_Direction == PopperMan.Direction.Up)
            {
                Direction = PopperMan.Direction.Left;
            }
            else if (TickStart_Direction == PopperMan.Direction.Left)
            {
                Direction = PopperMan.Direction.Down;
            }
            else if (TickStart_Direction == PopperMan.Direction.Down)
            {
                Direction = PopperMan.Direction.Right;
            }
            else if (TickStart_Direction == PopperMan.Direction.Right)
            {
                Direction = PopperMan.Direction.Up;
            }
        }
        else if (RightDown || Input.GetKeyDown(RightKey))
        {
            if (TickStart_Direction == PopperMan.Direction.Up)
            {
                Direction = PopperMan.Direction.Right;
            }
            else if (TickStart_Direction == PopperMan.Direction.Left)
            {
                Direction = PopperMan.Direction.Up;
            }
            else if (TickStart_Direction == PopperMan.Direction.Down)
            {
                Direction = PopperMan.Direction.Left;
            }
            else if (TickStart_Direction == PopperMan.Direction.Right)
            {
                Direction = PopperMan.Direction.Down;
            }
        }
    }
예제 #2
0
    public void ClearInput()
    {
        if (Alive)
        {
            if (Direction != TickStart_Direction)
            {
                OnPlayerChangedDir.Invoke();
            }
        }

        TickStart_Direction = Direction;

        /*
         * //	work out if we let-go in a frame
         * Input_Direction = PopperMan.Direction.None;
         * SetDirectionIfKey( PopperMan.Direction.Up, PopperMan.NesPadJoystickButton.Up );
         * SetDirectionIfKey( PopperMan.Direction.Down, PopperMan.NesPadJoystickButton.Down );
         * SetDirectionIfKey( PopperMan.Direction.Left, PopperMan.NesPadJoystickButton.Left );
         * SetDirectionIfKey( PopperMan.Direction.Right, PopperMan.NesPadJoystickButton.Right );
         * TickStart_Direction = Input_Direction;
         * Input_Direction = PopperMan.Direction.None;
         */
    }
예제 #3
0
 void Start()
 {
     //	avoid first erroneous change-dir detection
     TickStart_Direction = Direction;
 }