Beispiel #1
0
        ///<summary>
        ///	Called once per frame
        ///</summary>
        void Update()
        {
            if (_bowlingBallPrefabStateComponent.inputMode == InputMode.KEYBOARD_ONLY)
            {
                if (_bowlingBallPrefabStateComponent.bowlingBallState == BowlingBallState.PRE_GAME_AIM_MODE)
                {
                    //	HANDLE MOVE
                    if (Input.GetKeyDown(KeyCode.LeftArrow))
                    {
                        _bowlingBallPrefabStateComponent.moveBallBy(new Vector2(-_MOVE_BY_AMOUNT_FLOAT, 0));
                    }
                    else if (Input.GetKeyDown(KeyCode.RightArrow))
                    {
                        _bowlingBallPrefabStateComponent.moveBallBy(new Vector2(_MOVE_BY_AMOUNT_FLOAT, 0));
                    }

                    //	HANDLE MOVE
                    if (Input.GetKeyDown(KeyCode.UpArrow))
                    {
                        _bowlingBallPrefabStateComponent.moveBallBy(new Vector2(0, _MOVE_BY_AMOUNT_FLOAT));
                    }
                    else if (Input.GetKeyDown(KeyCode.DownArrow))
                    {
                        _bowlingBallPrefabStateComponent.moveBallBy(new Vector2(0, -_MOVE_BY_AMOUNT_FLOAT));
                    }


                    //  HANDLE THROW
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        _bowlingBallPrefabStateComponent.throwBall();
                    }
                }
                else
                {
                    //	HANDLE RESET
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        _bowlingBallPrefabStateComponent.resetGame();
                    }
                }
            }             //END IF KEYBOARD MODE
        }
Beispiel #2
0
        ///<summary>
        ///	Called once per frame
        ///</summary>
        void Update()
        {
            if (_bowlingBallPrefabStateComponent.inputMode == InputMode.MOUSE_ONLY)
            {
                if (_bowlingBallPrefabStateComponent.bowlingBallState == BowlingBallState.PRE_GAME_AIM_MODE)
                {
                    //	HANDLE MOVE
                    //	NOTE: IF YOUR MOUSE 'HITS' THE InvisibleMouseDetectionCubeLayer GAMEOBJECT THEN ITS A LEGAL POSITION
                    //	NOTE: THE "BowlingBallPrefab" HAS A LAYER OF "Ignore Raycast", WHICH WE REQUIRE
                    //
                    RaycastHit raycastHit;
                    if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out raycastHit, Mathf.Infinity))
                    {
                        if (raycastHit.collider.gameObject.layer == LayerMask.NameToLayer("InvisibleMouseDetectionCubeLayer"))
                        {
                            _bowlingBallPrefabStateComponent.moveBallTo(new Vector2(raycastHit.point.x, raycastHit.point.y));
                        }
                    }


                    //	HANDLE THROW
                    if (Input.GetMouseButton(0))
                    {
                        _bowlingBallPrefabStateComponent.throwBall();
                    }
                }
                else
                {
                    //	HANDLE RESET
                    if (Input.GetMouseButtonDown(0))
                    {
                        _bowlingBallPrefabStateComponent.resetGame();
                    }
                }
            }             //END IF MOUSEMODE
        }