예제 #1
0
    void Update()
    {
        if (keyboardInput == null)
        {
            keyboardInput = input.KeyboardInput;
        }
        if (steerwheelInput == null)
        {
            steerwheelInput = input.SteerWheelInput;
        }

        //Update states
        {
            selfDriving               = Time.time - lastAutoUpdate < 0.5f;
            underKeyboardControl      = (keyboardInput != null && (keyboardInput.SteerInput != 0.0f || keyboardInput.AccelBrakeInput != 0.0f));
            underSteeringWheelControl = input.HasValidSteeringWheelInput();
        }

        Vector3 simLinVel = controller.RB.velocity;
        Vector3 simAngVel = controller.RB.angularVelocity;

        var projectedLinVec = Vector3.Project(simLinVel, transform.forward);

        actualLinVel = projectedLinVec.magnitude * (Vector3.Dot(simLinVel, transform.forward) > 0 ? 1.0f : -1.0f);

        var projectedAngVec = Vector3.Project(simAngVel, transform.up);

        actualAngVel = projectedAngVec.magnitude * (projectedAngVec.y > 0 ? -1.0f : 1.0f);
    }
예제 #2
0
    static public KeyboardInputController CreateKeyboardInputController(bool _singlePress, KeyCode _moveUp, KeyCode _moveDown, KeyCode _moveLeft = KeyCode.None, KeyCode _moveRight = KeyCode.None,
                                                                        KeyCode _drop = KeyCode.None, KeyCode _shiftLeft = KeyCode.None, KeyCode _shiftRight = KeyCode.None)
    {
        KeyboardInputController controller = new KeyboardInputController(_moveUp, _moveDown, _moveLeft, _moveRight, _drop, _shiftLeft, _shiftRight);

        controller.SinglePress = _singlePress;
        return(controller);
    }
예제 #3
0
 void Awake()
 {
     if (input == null) {
         input = this;
     }
     else if (input != this) {
         Destroy(gameObject);
     }
 }
예제 #4
0
 void Awake()
 {
     if (input == null)
     {
         input = this;
     }
     else if (input != this)
     {
         Destroy(gameObject);
     }
 }
예제 #5
0
 // Start is called before the first frame update
 void Start()
 {
     sprite = GetComponent <SpriteRenderer>();
     if (hinput.gamepad.Count > playerNumber)
     {
         inputController = GamePadInputController.CreateGamepadInputController(true, playerNumber, false);
     }
     else
     {
         inputController = KeyboardInputController.CreateKeyboardInputController(true, this.moveUp, this.moveDown, this.moveLeft, this.moveRight, this.action, this.shiftLeft, this.shiftRight);
     }
 }
예제 #6
0
 // Start is called before the first frame update
 void Start()
 {
     rb2d = GetComponent <Rigidbody2D>();
     if (hinput.gamepad.Count > playerNumber)
     {
         inputController = GamePadInputController.CreateGamepadInputController(false, playerNumber);
     }
     else
     {
         inputController = KeyboardInputController.CreateKeyboardInputController(false, this.moveUp, this.moveDown);
     }
     //inputController = GamePadInputController.CreateGamepadInputController(false, playerNumber);
 }
예제 #7
0
 protected void GameInitialize()
 {
     this.gameStatus   = GAME_STATUS_TITLE;
     this.scrollSpeed  = 1.0f;
     this.earned_score = 0;
     this.remain_life  = 10;
     this.titleContainer.SetActive(true);
     this.playContainer.SetActive(false);
     this.endContainer.SetActive(false);
     Time.timeScale = this.gameSpeed;
     this.myKeyboardInputController = new KeyboardInputController(this);
     this.GetCharacter().Dash();
 }
예제 #8
0
    void Start()
    {
        Keyboard = GetComponent <KeyboardInputController>();
        Wheel    = GetComponent <SteeringWheelInputController>();

        Wheel.TriggerPress += ev =>
        {
            if (ev == InputEvent.AUTONOMOUS_MODE_OFF)
            {
                StopControl();
            }
        };
    }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     _joystickInstance = JoystickInputController.Instance;
     _keyboardInstance = KeyboardInputController.Instance;
 }
예제 #10
0
    void BindInput(GameLogic gameLogic)
    {
        KeyboardInputController keyboardInput = gameObject.AddComponent <KeyboardInputController>();

        keyboardInput.inputReceiver = gameLogic;
    }