Esempio n. 1
0
        public static GamepadState GetState(Index controlIndex, bool raw = false)
        {
            GamepadState state = new GamepadState();

            state.A = GetButton(Button.A, controlIndex);
            state.B = GetButton(Button.B, controlIndex);
            state.Y = GetButton(Button.Y, controlIndex);
            state.X = GetButton(Button.X, controlIndex);

            state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
            state.LeftShoulder  = GetButton(Button.LeftShoulder, controlIndex);
            state.RightStick    = GetButton(Button.RightStick, controlIndex);
            state.LeftStick     = GetButton(Button.LeftStick, controlIndex);

            state.Start = GetButton(Button.Start, controlIndex);
            state.Back  = GetButton(Button.Back, controlIndex);

            state.LeftStickAxis  = GetAxis(Axis.LeftStick, controlIndex, raw);
            state.rightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
            state.dPadAxis       = GetAxis(Axis.Dpad, controlIndex, raw);

            state.Left  = (state.dPadAxis.x < 0);
            state.Right = (state.dPadAxis.x > 0);
            state.Up    = (state.dPadAxis.y > 0);
            state.Down  = (state.dPadAxis.y < 0);

            state.LeftTrigger  = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
            state.RightTrigger = GetTrigger(Trigger.RightTrigger, controlIndex, raw);

            return(state);
        }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //キー情報取得
        keyState = GamepadInput.GamePad.GetState(playerNo, false);

        //アニメーション
        if (foodhave)
        {
            if (!foodTrigger)
            {
                // 食べ物の複製
                foods = GameObject.Instantiate(food) as GameObject;

                //いろいろあたり判定を無視する
                Physics.IgnoreCollision(foods.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
                Physics.IgnoreCollision(foods.GetComponent <Collider>(), gameObject.GetComponent <CharacterController>());
                Physics.IgnoreCollision(foods.GetComponent <Collider>(), GameObject.FindWithTag("Player").GetComponent <Collider>());
                Physics.IgnoreCollision(foods.GetComponent <Collider>(), GameObject.FindWithTag("Player").GetComponent <CharacterController>());
                foodTrigger = true;
            }
            animator.SetBool("Hold", true);

            //持ち上げるやーつ
            // 位置を調整
            foods.transform.position = muzzle.position;
            // 向きを調整
            foods.transform.rotation = muzzle.rotation;
            foods.GetComponent <Food>().deletetime++;

            //スンッってならないやつ
            foods.gameObject.GetComponent <Rigidbody>().useGravity = false;

            //キーが押された時
            //if (Input.GetKeyDown(KeyCode.Z))
            if ((keyState.A || keyState.LeftTrigger > 0.7f) && trigger == false)
            {
                //アニメーション
                animator.SetBool("Hold", false);

                trigger  = true;
                foodhave = false;

                // Rigidbodyに力を加えて発射
                //スンッってならないやつ
                foods.gameObject.GetComponent <Rigidbody>().useGravity = true;
                Vector3 force;
                force = this.gameObject.transform.forward * speed;
                foods.GetComponent <Rigidbody>().AddForce(force);

                //エサに自分のタグをつける
                foods.GetComponent <Food>().PlayerID = this.PlayerID;
                foodTrigger = false;
            }
        }
        if (!keyState.A && keyState.LeftTrigger < 0.7f && trigger == true)
        {
            trigger = false;
        }
    }
Esempio n. 3
0
 public static GamepadState ApplyMoveDisable(GamepadState state)
 {
     state.LeftStickAxis = Vector2.zero;
     state.dPadAxis      = Vector2.zero;
     state.Left          = false;
     state.Right         = false;
     state.Up            = false;
     state.Down          = false;
     return(state);
 }
Esempio n. 4
0
 public static GamepadState ApplyConfused(GamepadState state)
 {
     state.LeftStickAxis *= -1;
     state.dPadAxis      *= -1;
     state.Left           = (state.dPadAxis.x < 0);
     state.Right          = (state.dPadAxis.x > 0);
     state.Up             = (state.dPadAxis.y > 0);
     state.Down           = (state.dPadAxis.y < 0);
     return(state);
 }
Esempio n. 5
0
    private void Start()
    {
        stock_set = transform.Find("Stock").GetComponent <StockSetting>();

        Initialized();
        ModeSetting.initialized();
        ModeSetting.ConnectedUpdate();
        for (int i = 0; i < ModeSetting.k_player_num_max; i++)
        {
            gamepad_state = gamepad_state_old = GamePad.GetState((GamePad.Index) 0);
        }
    }
Esempio n. 6
0
    //コントローラーの入力が行われたタイミングをとるために
    //比べるデータの作成
    void GamepadStateUpdate()
    {
        //使われているコントローラーの情報のみ更新
        for (int i = 0; i < ModeSetting.player_data.Count; i++)
        {
            gamepad_state_old = gamepad_state;
            //リストに格納されているもの順に調べる

            ///ここでコントローラーの番号を+1すること
            gamepad_state = GamePad.GetState((GamePad.Index)ModeSetting.player_data[i].player_number + 1);
            break;
        }
    }
Esempio n. 7
0
 public void Initialized()
 {
     spriteRenderer = this.gameObject.GetComponent <SpriteRenderer>();
     rigid          = this.GetComponent <Rigidbody2D>();
     //slasherCollider = this.GetComponentInChildren<CapsuleCollider2D>();
     slasherCollider.enabled = false;
     isCollided      = false;
     moveVelocity    = Vector2.zero;
     angulerVelocity = 0.0f;
     stateUpdater    = Wait;
     inputUpdater    = GamePadStateUpdate;
     gamepadStateOld = gamepadState = GamepadInput.GamePad.GetState(playerNo);
     angulerVelocity = 0.0f;
 }
Esempio n. 8
0
        private static void Marge(ref GamepadState gamepad, GamepadState state)
        {
            gamepad.A |= state.A;
            gamepad.B |= state.B;
            gamepad.Y |= state.Y;
            gamepad.X |= state.X;

            gamepad.AUp |= state.AUp;
            gamepad.BUp |= state.BUp;
            gamepad.YUp |= state.YUp;
            gamepad.XUp |= state.XUp;

            gamepad.ADown |= state.ADown;
            gamepad.BDown |= state.BDown;
            gamepad.YDown |= state.YDown;
            gamepad.XDown |= state.XDown;

            gamepad.RightShoulder |= state.RightShoulder;
            gamepad.LeftShoulder  |= state.LeftShoulder;
            gamepad.RightStick    |= state.RightStick;
            gamepad.LeftStick     |= state.LeftStick;

            gamepad.RightShoulderUp |= state.RightShoulderUp;
            gamepad.LeftShoulderUp  |= state.LeftShoulderUp;

            gamepad.RightShoulderDown |= state.RightShoulderDown;
            gamepad.LeftShoulderDwon  |= state.LeftShoulderDwon;

            gamepad.RightShoulder |= state.RightShoulder;
            gamepad.LeftShoulder  |= state.LeftShoulder;

            gamepad.Start |= state.Start;
            gamepad.Back  |= state.Back;

            gamepad.rightStickAxis = (state.rightStickAxis + gamepad.rightStickAxis) / 2;

            gamepad.Left  |= state.Left;
            gamepad.Right |= state.Right;
            gamepad.Up    |= state.Up;
            gamepad.Down  |= state.Down;

            gamepad.LeftStickAxis = (state.LeftStickAxis + gamepad.LeftStickAxis) / 2;

            gamepad.dPadAxis = (state.dPadAxis + gamepad.dPadAxis) / 2;

            gamepad.LeftTrigger            = Mathf.Max(state.LeftTrigger, gamepad.LeftTrigger);
            gamepad.RightTrigger           = Mathf.Max(state.RightTrigger, gamepad.RightTrigger);;
            gamepad.AnyKeyPressedDownAXYB |= state.AnyKeyPressedDownAXYB;
        }
Esempio n. 9
0
        public static GamepadState GetState(Index controlIndex, GamepadState oldState = null, bool raw = false)
        {
            GamepadState state = oldState;

            if (oldState == null)
            {
                state = new GamepadState();
            }

            state.A_down = (!state.A && GetButton(Button.A, controlIndex));
            state.B_down = (!state.B && GetButton(Button.B, controlIndex));
            state.X_down = (!state.X && GetButton(Button.X, controlIndex));
            state.Y_down = (!state.Y && GetButton(Button.Y, controlIndex));

            state.Start_down = (!state.Start && GetButton(Button.Start, controlIndex));
            state.Back_down  = (!state.Back && GetButton(Button.Back, controlIndex));

            state.A = GetButton(Button.A, controlIndex);
            state.B = GetButton(Button.B, controlIndex);
            state.Y = GetButton(Button.Y, controlIndex);
            state.X = GetButton(Button.X, controlIndex);

            state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
            state.LeftShoulder  = GetButton(Button.LeftShoulder, controlIndex);
            state.RightStick    = GetButton(Button.RightStick, controlIndex);
            state.LeftStick     = GetButton(Button.LeftStick, controlIndex);

            state.Start = GetButton(Button.Start, controlIndex);
            state.Back  = GetButton(Button.Back, controlIndex);

            state.LeftStickAxis  = GetAxis(Axis.LeftStick, controlIndex, raw);
            state.rightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
            state.dPadAxis       = GetAxis(Axis.Dpad, controlIndex, raw);

            state.Left  = (state.dPadAxis.x < 0);
            state.Right = (state.dPadAxis.x > 0);
            state.Up    = (state.dPadAxis.y > 0);
            state.Down  = (state.dPadAxis.y < 0);

            state.LeftTrigger  = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
            state.RightTrigger = GetTrigger(Trigger.RightTrigger, controlIndex, raw);

            return(state);
        }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        //Get controller input
        keyState = GamepadInput.GamePad.GetState(playerNo, false);
        axis     = GamepadInput.GamePad.GetAxis(GamepadInput.GamePad.Axis.LeftStick, playerNo, false);

        if (Input.GetKey(KeyCode.RightArrow) || axis.x > 0.2f)
        {
            if (_playflag)
            {
                sm.PlaySFX(_audioSFX[0]);
                _playflag = false;
                _playButton.GetComponent <Image>().sprite = _playSprites[0];
                _quitButton.GetComponent <Image>().sprite = _quitSprites[1];
            }
        }

        if (Input.GetKey(KeyCode.LeftArrow) || axis.x < -0.2f)
        {
            if (!_playflag)
            {
                sm.PlaySFX(_audioSFX[0]);
                _playflag = true;
                _playButton.GetComponent <Image>().sprite = _playSprites[1];
                _quitButton.GetComponent <Image>().sprite = _quitSprites[0];
            }
        }
        if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.KeypadEnter) || keyState.A)
        {
            sm.PlaySFX(_audioSFX[1]);
            if (_playflag)
            {
                SceneManager.LoadScene(1);
            }
            else
            {
                Application.Quit();
            }
        }
    }
Esempio n. 11
0
    void GamePadStateUpdate()
    {
        gamepadStateOld = gamepadState;

        gamepadState = GamepadInput.GamePad.GetState(playerNo, true);
    }
        public static GamepadState GetState(Index controlIndex, bool raw = false)
        {
            GamepadState state = new GamepadState();

            state.A = GetButton(Button.A, controlIndex);
            state.B = GetButton(Button.B, controlIndex);
            state.Y = GetButton(Button.Y, controlIndex);
            state.X = GetButton(Button.X, controlIndex);

            state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
            state.LeftShoulder = GetButton(Button.LeftShoulder, controlIndex);
            state.RightStick = GetButton(Button.RightStick, controlIndex);
            state.LeftStick = GetButton(Button.LeftStick, controlIndex);

            state.Start = GetButton(Button.Start, controlIndex);
            state.Back = GetButton(Button.Back, controlIndex);

            state.LeftStickAxis = GetAxis(Axis.LeftStick, controlIndex, raw);
            state.rightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
            state.dPadAxis = GetAxis(Axis.Dpad, controlIndex, raw);

            state.Left = (state.dPadAxis.x < 0);
            state.Right = (state.dPadAxis.x > 0);
            state.Up = (state.dPadAxis.y > 0);
            state.Down = (state.dPadAxis.y < 0);

            state.LeftTrigger = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
            state.RightTrigger = GetTrigger(Trigger.RightTrigger, controlIndex, raw);

            return state;
        }
Esempio n. 13
0
        public static GamepadState GetState(Index controlIndex, bool raw = false)
        {
            state = gamepads[((int)controlIndex) + 1];
            if (controlIndex == Index.Disable)
            {
                return(state);
            }
            else if (controlIndex == Index.Keyboard1 || controlIndex == Index.Keyboard2)
            {
                FillKeyboard(ref state, controlIndex);
                return(state);
            }
            state.A = GetButton(Button.A, controlIndex);
            state.B = GetButton(Button.B, controlIndex);
            state.Y = GetButton(Button.Y, controlIndex);
            state.X = GetButton(Button.X, controlIndex);

            state.AUp = GetButtonUp(Button.A, controlIndex);
            state.BUp = GetButtonUp(Button.B, controlIndex);
            state.YUp = GetButtonUp(Button.Y, controlIndex);
            state.XUp = GetButtonUp(Button.X, controlIndex);

            state.ADown = GetButtonDown(Button.A, controlIndex);
            state.BDown = GetButtonDown(Button.B, controlIndex);
            state.YDown = GetButtonDown(Button.Y, controlIndex);
            state.XDown = GetButtonDown(Button.X, controlIndex);

            state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
            state.LeftShoulder  = GetButton(Button.LeftShoulder, controlIndex);
            state.RightStick    = GetButton(Button.RightStick, controlIndex);
            state.LeftStick     = GetButton(Button.LeftStick, controlIndex);

            state.RightShoulderUp = GetButtonUp(Button.RightShoulder, controlIndex);
            state.LeftShoulderUp  = GetButtonUp(Button.LeftShoulder, controlIndex);

            state.RightShoulderDown = GetButtonDown(Button.RightShoulder, controlIndex);
            state.LeftShoulderDwon  = GetButtonDown(Button.LeftShoulder, controlIndex);

            state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
            state.LeftShoulder  = GetButton(Button.LeftShoulder, controlIndex);

            state.Start = GetButton(Button.Start, controlIndex);
            state.Back  = GetButton(Button.Back, controlIndex);

            state.LeftStickAxis  = GetAxis(Axis.LeftStick, controlIndex, raw);
            state.rightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
            state.dPadAxis       = GetAxis(Axis.Dpad, controlIndex, raw);

            state.Left  = (state.dPadAxis.x < 0);
            state.Right = (state.dPadAxis.x > 0);
            state.Up    = (state.dPadAxis.y > 0);
            state.Down  = (state.dPadAxis.y < 0);

            state.LeftTrigger           = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
            state.RightTrigger          = GetTrigger(Trigger.RightTrigger, controlIndex, raw);
            state.AnyKeyPressedDownAXYB = state.XDown || state.ADown || state.YDown || state.BDown;
            if (controlIndex == Index.Any)
            {
                GamepadState k1 = new GamepadState();
                FillKeyboard(ref k1, Index.Keyboard1);
                GamepadState k2 = new GamepadState();
                FillKeyboard(ref k2, Index.Keyboard2);
                Marge(ref state, k1);
                Marge(ref state, k2);
            }
            return(state);
        }
Esempio n. 14
0
        public static void GetState(ref GamepadState oldState, Index controlIndex, bool raw = false)
        {
            if (oldState == null)
            {
                return;
            }

            GamepadState state = new GamepadState();

            // Controller
            state.A = GetButton(Button.A, controlIndex);
            state.B = GetButton(Button.B, controlIndex);
            state.Y = GetButton(Button.Y, controlIndex);
            state.X = GetButton(Button.X, controlIndex);

            state.RB = GetButton(Button.RightShoulder, controlIndex);
            state.LB = GetButton(Button.LeftShoulder, controlIndex);
            state.RightStickClick = GetButton(Button.RightStick, controlIndex);
            state.LeftStickClick  = GetButton(Button.LeftStick, controlIndex);

            state.Start = GetButton(Button.Start, controlIndex);
            state.Back  = GetButton(Button.Back, controlIndex);

            state.LeftStickAxis  = GetAxis(Axis.LeftStick, controlIndex, raw);
            state.RightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
            state.dPadAxis       = GetAxis(Axis.Dpad, controlIndex, raw);

            state.Left  = (state.dPadAxis.x < -0.1f);
            state.Right = (state.dPadAxis.x > 0.1f);
            state.Up    = (state.dPadAxis.y > 0.1f);
            state.Down  = (state.dPadAxis.y < -0.1f);

            state.LT = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
            state.RT = GetTrigger(Trigger.RightTrigger, controlIndex, raw);

            // Keyboard
            state.A = state.A == false?GetButton(KeyCode.L, controlIndex) : true;

            state.B = state.B == false?GetButton(KeyCode.M, controlIndex) : true;

            state.X = state.X == false?GetButton(KeyCode.O, controlIndex) : true;

            state.Y = state.Y == false?GetButton(KeyCode.P, controlIndex) : true;

            state.LB = state.LB == false?GetButton(KeyCode.A, controlIndex) : true;

            state.RB = state.RB == false?GetButton(KeyCode.E, controlIndex) : true;

            state.Start = state.Start == false?GetButton(KeyCode.Return, controlIndex) : true;

            state.Back = state.Back == false?GetButton(KeyCode.Backspace, controlIndex) : true;

            if (state.LeftStickAxis.x == 0)
            {
                if (GetButton(KeyCode.D, controlIndex))
                {
                    state.LeftStickAxis.x = 1;
                }
                else if (GetButton(KeyCode.Q, controlIndex))
                {
                    state.LeftStickAxis.x = -1;
                }
            }

            if (state.LeftStickAxis.y == 0)
            {
                if (GetButton(KeyCode.Z, controlIndex))
                {
                    state.LeftStickAxis.y = 1;
                }
                else if (GetButton(KeyCode.S, controlIndex))
                {
                    state.LeftStickAxis.y = -1;
                }
            }

            if (state.RightStickAxis.x == 0)
            {
                if (GetButton(KeyCode.H, controlIndex))
                {
                    state.RightStickAxis.x = 1;
                }
                else if (GetButton(KeyCode.F, controlIndex))
                {
                    state.RightStickAxis.x = -1;
                }
            }

            if (state.RightStickAxis.y == 0)
            {
                if (GetButton(KeyCode.T, controlIndex))
                {
                    state.RightStickAxis.y = 1;
                }
                else if (GetButton(KeyCode.G, controlIndex))
                {
                    state.RightStickAxis.y = -1;
                }
            }

            state.Down = state.Down == false?GetButton(KeyCode.DownArrow, controlIndex) : true;

            state.Left = state.Left == false?GetButton(KeyCode.LeftArrow, controlIndex) : true;

            state.Right = state.Right == false?GetButton(KeyCode.RightArrow, controlIndex) : true;

            state.Up = state.Up == false?GetButton(KeyCode.UpArrow, controlIndex) : true;

            state.LT = state.LT == 0 ? GetButton(KeyCode.W, controlIndex) ? 1 : 0 : 1;
            state.RT = state.RT == 0 ? GetButton(KeyCode.X, controlIndex) ? 1 : 0 : 1;

            // Old pad pressed
            state.APressed = state.A;
            state.BPressed = state.B;
            state.XPressed = state.X;
            state.YPressed = state.Y;

            state.RBPressed = state.RB;
            state.LBPressed = state.LB;

            state.RTPressed = state.RT == 1;
            state.LTPressed = state.RT == 1;

            state.UpPressed    = state.Up;
            state.RightPressed = state.Right;
            state.LeftPressed  = state.Left;
            state.DownPressed  = state.Down;

            state.LStickUpPressed    = state.LeftStickAxis.y > 0.8f;
            state.LStickDownPressed  = state.LeftStickAxis.y < -0.8f;
            state.LStickRightPressed = state.LeftStickAxis.x > 0.8f;
            state.LStickLeftPressed  = state.LeftStickAxis.x < -0.8f;

            if (oldState.Up == true)
            {
                state.UpPressed = false;
            }
            if (oldState.Left == true)
            {
                state.LeftPressed = false;
            }
            if (oldState.Right == true)
            {
                state.RightPressed = false;
            }
            if (oldState.Down == true)
            {
                state.DownPressed = false;
            }

            if (oldState.A == true)
            {
                state.APressed = false;
            }
            if (oldState.B == true)
            {
                state.BPressed = false;
            }
            if (oldState.X == true)
            {
                state.XPressed = false;
            }
            if (oldState.Y == true)
            {
                state.YPressed = false;
            }

            if (oldState.RB == true)
            {
                state.RBPressed = false;
            }
            if (oldState.LB == true)
            {
                state.LBPressed = false;
            }
            if (oldState.RT == 1)
            {
                state.RTPressed = false;
            }
            if (oldState.RB == true)
            {
                state.RBPressed = false;
            }

            if (oldState.LeftStickAxis.y > 0.8f)
            {
                state.LStickUpPressed = false;
            }
            if (oldState.LeftStickAxis.y < -0.8f)
            {
                state.LStickDownPressed = false;
            }
            if (oldState.LeftStickAxis.x > 0.8f)
            {
                state.LStickRightPressed = false;
            }
            if (oldState.LeftStickAxis.x < -0.8f)
            {
                state.LStickLeftPressed = false;
            }

            oldState = state;
        }
Esempio n. 15
0
    void Update()
    {
        //キー情報取得
        keyState = GamepadInput.GamePad.GetState(playerNo, false);
        axis     = GamepadInput.GamePad.GetAxis(GamepadInput.GamePad.Axis.LeftStick, playerNo, false);

        //移動

        //計算
        moveX = axis.x * speed;
        moveZ = axis.y * speed;
        if (!controller.isGrounded)
        {
            moveY -= 9.8f * Time.deltaTime;                         //重力
        }
        if (controller.isGrounded)
        {
            moveY = 0.0f;
        }

        Vector3 direction = new Vector3(moveX, moveY, moveZ);

        controller.Move(direction * Time.deltaTime);

        //回転
        float step = rotatespeed + Time.deltaTime;

        if (axis.x * axis.x > 0.0f || axis.y * axis.y > 0.0f)
        {
            animator.SetBool("Running", true);
        }
        else
        {
            animator.SetBool("Running", false);
        }

        if (axis.x * axis.x > 0.2f || axis.y * axis.y > 0.2f)
        {
            gameObject.transform.rotation = Quaternion.RotateTowards(gameObject.transform.rotation, Quaternion.LookRotation(new Vector3(direction.x, 0f, direction.z)), step);
        }

        //死亡処理
        if (HP < 1 && respawnCount < 1)
        {
            respawnCount = respawnTime;
            loveRate     = Mathf.CeilToInt(loveRate / 2f);
            GameObject go = Instantiate(deathPrefab, gameObject.transform.position, Quaternion.Euler(-90f, 0f, 0f));
            gameObject.GetComponent <CapsuleCollider>().enabled = false;
            gameObject.transform.GetChild(0).gameObject.SetActive(false);
        }
        //リスポーン処理
        if (respawnCount > 0)
        {
            respawnCount -= 1;
            Debug.Log(respawnCount);
        }
        if (respawnCount == 1)
        {
            HP           = 3;
            respawnCount = 0;
            gameObject.transform.position = respawnPoint.transform.position;
            GameObject go = Instantiate(deathPrefab, gameObject.transform.position, Quaternion.Euler(-90f, 0f, 0f));
            gameObject.GetComponent <CapsuleCollider>().enabled = true;
            gameObject.transform.GetChild(0).gameObject.SetActive(true);
        }

        Debug.Log(HP);
        //UIの色を変える
        playerUI.GetComponent <Image>().color = colorHP[HP];

        GameManager.Instance.ModifyHeartImageNum(PlayerID);
    }
Esempio n. 16
0
        public static GamepadState GetState(Index controlIndex, bool raw = false)
        {
            GamepadState state = new GamepadState();

            if (Index.Five != controlIndex)
            {
                state.A = GetButton(Button.A, controlIndex);
                state.B = GetButton(Button.B, controlIndex);
                state.Y = GetButton(Button.Y, controlIndex);
                state.X = GetButton(Button.X, controlIndex);

                state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
                state.LeftShoulder  = GetButton(Button.LeftShoulder, controlIndex);
                state.RightStick    = GetButton(Button.RightStick, controlIndex);
                state.LeftStick     = GetButton(Button.LeftStick, controlIndex);

                state.Start = GetButton(Button.Start, controlIndex);
                state.Back  = GetButton(Button.Back, controlIndex);

                state.LeftStickAxis  = GetAxis(Axis.LeftStick, controlIndex, raw);
                state.rightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
                state.dPadAxis       = GetAxis(Axis.Dpad, controlIndex, raw);

                state.Left  = (state.dPadAxis.x < 0);
                state.Right = (state.dPadAxis.x > 0);
                state.Up    = (state.dPadAxis.y > 0);
                state.Down  = (state.dPadAxis.y < 0);

                state.LeftTrigger  = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
                state.RightTrigger = GetTrigger(Trigger.RightTrigger, controlIndex, raw);
            }
            else
            {
                Debug.Log("frjeahg");
                state.A = Input.GetButtonDown("Abotan555");
                state.B = false;
                state.Y = false;
                state.X = false;

                state.RightShoulder = false;
                state.LeftShoulder  = false;
                state.RightStick    = false;
                state.LeftStick     = false;

                state.Start = false;
                state.Back  = false;

                state.LeftStickAxis  = new Vector2(Input.GetAxis("XboxAxisXJoy5"), Input.GetAxis("XboxAxisYJoy5") * -1.0f);
                state.rightStickAxis = new Vector2(Input.GetAxis("XboxAxis4Joy5"), Input.GetAxis("XboxAxis5Joy5"));
                state.dPadAxis       = new Vector2(0.0f, 0.0f);

                state.Left = false;

                state.Right = false;

                state.Up = false;

                state.Down = false;


                state.LeftTrigger  = 0.0f;
                state.RightTrigger = 0.0f;
            }
            return(state);
        }
Esempio n. 17
0
        public static GamepadState GetState(Index controlIndex, bool raw = false)
        {
            GamepadState state = new GamepadState();

            state.A = GetButton(Button.A, controlIndex);
            state.B = GetButton(Button.B, controlIndex);
            state.Y = GetButton(Button.Y, controlIndex);
            state.X = GetButton(Button.X, controlIndex);

            state.RightShoulder = GetButton(Button.RightShoulder, controlIndex);
            state.LeftShoulder  = GetButton(Button.LeftShoulder, controlIndex);
            state.RightStick    = GetButton(Button.RightStick, controlIndex);
            state.LeftStick     = GetButton(Button.LeftStick, controlIndex);

            state.Start = GetButton(Button.Start, controlIndex);
            state.Back  = GetButton(Button.Back, controlIndex);

            state.LeftStickAxis  = GetAxis(Axis.LeftStick, controlIndex, raw);
            state.rightStickAxis = GetAxis(Axis.RightStick, controlIndex, raw);
            state.dPadAxis       = GetAxis(Axis.Dpad, controlIndex, raw);

            state.Left  = (state.dPadAxis.x < 0);
            state.Right = (state.dPadAxis.x > 0);
            state.Up    = (state.dPadAxis.y > 0);
            state.Down  = (state.dPadAxis.y < 0);

            state.LeftTrigger  = GetTrigger(Trigger.LeftTrigger, controlIndex, raw);
            state.RightTrigger = GetTrigger(Trigger.RightTrigger, controlIndex, raw);

            /*
             * if (state.A)
             * {
             *  Debug.Log("A");
             * }
             * if (state.B)
             * {
             *  Debug.Log("B");
             * }
             * if (state.X)
             * {
             *  Debug.Log("X");
             * }
             * if (state.Y)
             * {
             *  Debug.Log("Y");
             * }
             * if (state.RightShoulder)
             * {
             *  Debug.Log("RightShoulder");
             * }
             * if (state.LeftShoulder)
             * {
             *  Debug.Log("LeftShoulder");
             * }
             * if (state.Back)
             * {
             *  Debug.Log("Back");
             * }
             * if (state.Start)
             * {
             *  Debug.Log("Start");
             * }
             * if (state.RightStick)
             * {
             *  Debug.Log("RightStick");
             * }
             * if (state.LeftStick)
             * {
             *  Debug.Log("LeftStick");
             * }
             */

            return(state);
        }
Esempio n. 18
0
    // Update is called once per frame
    void Update()
    {
        if (CT > 0)
        {
            CT--;
        }
        //キー情報取得
        keyState = GamepadInput.GamePad.GetState(playerNo, false);

        //キーが押された時
        //if (Input.GetKeyDown(KeyCode.Z))
        if ((keyState.X || keyState.RightTrigger > 0.7f) && trigger == false && CT < 1 &&
            this.gameObject.GetComponent <FoodThrow>().foodhave == false)
        {
            animator.SetTrigger("AttackTrigger");

            trigger = true;
            CT      = cooltime;

            delayTrigger = true;
        }
        else if (!keyState.X && keyState.RightTrigger < 0.7f && trigger == true)
        {
            trigger = false;
        }

        if (delay > delayCount)
        {
            delay        = 0;
            delayTrigger = false;

            // 弾の複製

            //パワーアップ
            if (powerUp)
            {
                attacks = GameObject.Instantiate(PowerBullet) as GameObject;
                attacks.GetComponent <Bullet>().powerUp = true;
                powerUp = false;
            }
            else
            {
                attacks = GameObject.Instantiate(Bullet) as GameObject;
            }

            //色々あたり判定を無視する
            Physics.IgnoreCollision(attacks.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            Physics.IgnoreCollision(attacks.GetComponent <Collider>(), gameObject.GetComponent <CharacterController>());

            //弾に自分のタグをつける
            attacks.GetComponent <Bullet>().PlayerID = this.PlayerID;

            Vector3 force;
            force = this.gameObject.transform.forward * speed;
            // Rigidbodyに力を加えて発射
            attacks.GetComponent <Rigidbody>().AddForce(force);
            //位置を調整
            attacks.transform.position = muzzle.position;
            // 向きを調整
            attacks.transform.rotation = muzzle.rotation;
        }

        if (powerUp)
        {
            gameObject.transform.GetChild(3).gameObject.SetActive(true);
        }
        else
        {
            gameObject.transform.GetChild(3).gameObject.SetActive(false);
        }

        if (delayTrigger)
        {
            delay++;
        }
    }
Esempio n. 19
0
 public static void GamePadInitialize()
 {
     state = new GamepadState();
 }
Esempio n. 20
0
    void Update()
    {
        if (players[maxPlayers - 1] != null)
        {
            if (Input.GetButton("Jump"))
            {
                players[maxPlayers - 1].Jump();
            }
            PopUpMenu("Cancel");
            if (Input.GetButtonDown("Fire1"))
            {
                Attack(maxPlayers - 1, 0);
            }
            if (Input.GetButtonDown("Fire2"))
            {
                Attack(maxPlayers - 1, 1);
            }
            if (Input.GetButtonDown("Fire3"))
            {
                Attack(maxPlayers - 1, 2);
            }
            if (Input.GetButtonDown("Fire4"))
            {
                Attack(maxPlayers - 1, 3);
            }
            players[maxPlayers - 1].RotateTowardsCursor();
            players[maxPlayers - 1].Direction(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")));
        }
        else
        {
            if (Input.GetButtonUp("Cancel"))
            {
                CharacterCreatorMenu(maxPlayers - 1);
            }
        }

        for (int i = 0; i < (maxPlayers - 1); i++)
        {
            GamepadInput.GamepadState gamePad = GamepadInput.GamePad.GetState((GamepadInput.GamePad.Index)(i + 1));
            if (players[i] != null)
            {
                players[i].Direction(gamePad.LeftStickAxis);

                if (gamePad.A)
                {
                    players[i].Jump();
                }
                players[i].Rotate(gamePad.rightStickAxis);
                if (gamePad.RightTrigger > 0)
                {
                    Attack(i, 0);
                }
                if (gamePad.LeftTrigger > 0)
                {
                    Attack(i, 1);
                }
                if (gamePad.RightShoulder)
                {
                    Attack(i, 2);
                }
                if (gamePad.LeftShoulder)
                {
                    Attack(i, 3);
                }
            }
            else
            {
                if (gamePad.Start)
                {
                    CharacterCreatorMenu(i);
                }
            }
        }
    }
Esempio n. 21
0
        private static void FillKeyboard(ref GamepadState state, Index controlIndex)
        {
            KeyboardSetting setting = KeyboardSetting.GetKetboard(controlIndex.ToString());

            state.A = Input.GetKey(setting.A);
            state.B = Input.GetKey(setting.B);
            state.Y = Input.GetKey(setting.Y);
            state.X = Input.GetKey(setting.X);

            state.AUp = Input.GetKeyUp(setting.A);
            state.BUp = Input.GetKeyUp(setting.B);
            state.YUp = Input.GetKeyUp(setting.Y);
            state.XUp = Input.GetKeyUp(setting.X);

            state.ADown = Input.GetKeyDown(setting.A);
            state.BDown = Input.GetKeyDown(setting.B);
            state.YDown = Input.GetKeyDown(setting.Y);
            state.XDown = Input.GetKeyDown(setting.X);

            state.RightShoulder = Input.GetKey(setting.RightShoulder);
            state.LeftShoulder  = Input.GetKey(setting.LeftShoulder);
            state.RightStick    = Input.GetKey(setting.RightStick);
            state.LeftStick     = Input.GetKey(setting.LeftStick);

            state.RightShoulderUp = Input.GetKeyUp(setting.RightShoulder);
            state.LeftShoulderUp  = Input.GetKeyUp(setting.LeftShoulder);

            state.RightShoulderDown = Input.GetKeyDown(setting.RightShoulder);
            state.LeftShoulderDwon  = Input.GetKeyDown(setting.LeftShoulder);

            state.RightShoulder = Input.GetKey(setting.RightShoulder);
            state.LeftShoulder  = Input.GetKey(setting.LeftShoulder);

            state.Start = Input.GetKey(setting.Start);
            state.Back  = Input.GetKey(setting.Back);

            state.rightStickAxis = Vector2.zero;

            state.Left  = Input.GetKey(setting.Left);
            state.Right = Input.GetKey(setting.Right);
            state.Up    = Input.GetKey(setting.Up);
            state.Down  = Input.GetKey(setting.Down);
            move        = Vector2.zero;
            if (state.Left)
            {
                move.x += -1.0f;
            }
            if (state.Right)
            {
                move.x += 1.0f;
            }
            if (state.Down)
            {
                move.y += -1.0f;
            }
            if (state.Up)
            {
                move.y += 1.0f;
            }
            state.LeftStickAxis = move;
            dPad = Vector2.zero;
            if (Input.GetKey(setting.DpadUp))
            {
                dPad.y += 1.0f;
            }
            if (Input.GetKey(setting.DpadDown))
            {
                dPad.y += -1.0f;
            }
            if (Input.GetKey(setting.DpadRight))
            {
                dPad.x += 1.0f;
            }
            if (Input.GetKey(setting.DpadLeft))
            {
                dPad.x += -1.0f;
            }
            state.dPadAxis = dPad;

            state.LeftTrigger           = Input.GetKey(setting.LeftTrigger) ? 1.0f : 0.0f;
            state.RightTrigger          = Input.GetKey(setting.RightTrigger) ? 1.0f : 0.0f;
            state.AnyKeyPressedDownAXYB = state.XDown || state.ADown || state.YDown || state.BDown;
        }