// Update is called once per frame
    void Update()
    {
        if (true)
        {
            playerType = this.gameObject.transform.parent.transform.parent.GetComponent <PlayerController>().GetPlayerNum();

            switch (playerType)
            {
            case PlayerController.PlayerNum.PlayerOne:
                m_image.sprite = m_frame[0];
                break;

            case PlayerController.PlayerNum.PlayerTwo:
                m_image.sprite = m_frame[1];
                break;

            case PlayerController.PlayerNum.PlayerThree:
                m_image.sprite = m_frame[2];
                break;

            case PlayerController.PlayerNum.PlayerFour:
                m_image.sprite = m_frame[3];
                break;

            default:
                break;
            }
        }
    }
    // ゲームパッドのインデックスを取得する
    public GamePad.Index GetBindPadIndex(PlayerController.PlayerNum player)
    {
        if (data.ContainsKey(player))
        {
            return(data[player]);
        }

        return(GamePad.Index.Any);
    }
예제 #3
0
    // 入力のステートを取得する
    public GamepadState GetInputState(PlayerController.PlayerNum player = PlayerController.PlayerNum.PlayerOne)
    {
        if (data.ContainsKey(player))
        {
            return(data[player]);
        }

        return(null);
    }
 // 指定したプレイヤーにパッド情報をバインドする
 public void SetBindPadIndex(PlayerController.PlayerNum player, GamePad.Index padIndex)
 {
     if (!data.ContainsKey(player))
     {
         data.Add(player, padIndex);
     }
     else
     {
         data[player] = padIndex;
     }
 }
예제 #5
0
 public void SetShotPlayerNum(PlayerController.PlayerNum player)
 {
     m_playerNum = player;
 }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        //キーボードから強制的にゲーム開始
        if (Input.GetKeyDown(KeyCode.Space))
        {
            GameManager.PlayerNum = 3;
            GameManager g = GameObject.FindObjectOfType <GameManager>().GetComponent <GameManager>();
            g.LoadStageScene();
        }

        // ゲームを開始するかどうかを判定するフラグ
        isStart = false;

        // ゲームパッドループ
        for (GamePad.Index padIndex = GamePad.Index.One; (int)padIndex <= Input.GetJoystickNames().Length; padIndex++)
        {
            oldInput[padIndex] = input[padIndex];
            input[padIndex]    = GamePad.GetState((GamePad.Index)padIndex);

            // 参加処理
            if (input[padIndex].Start == true && oldInput[padIndex].Start == false)
            {
                // 未登録状態ならゲームパッドを現在のプレイヤーにバインドして登録状態に移行
                if (registFlg[padIndex] == false)
                {
                    for (PlayerController.PlayerNum playerNum = 0; (int)playerNum < Input.GetJoystickNames().Length; playerNum++)
                    {
                        if (enterFlg.ContainsKey(playerNum) == false)
                        {
                            BindGamepad.Instance.SetBindPadIndex(playerNum, padIndex);
                            registFlg[padIndex] = true;
                            if (playerBindPad.ContainsKey(padIndex) == false)
                            {
                                playerBindPad.Add(padIndex, playerNum);
                            }
                            else
                            {
                                playerBindPad[padIndex] = playerNum;
                            }
                            enterFlg.Add(playerNum, false);
                            //Debug
                            Debug.Log("Regist:" + (int)playerNum);
                            m_playerIcon[(int)playerNum].GetComponent <PlayerIcon>().SetActive();
                            break;
                        }
                    }
                }
            }

            // 準備完了処理
            if (input[padIndex].B == true && oldInput[padIndex].B == false)
            {
                // 登録状態か?
                if (registFlg[padIndex] == true)
                {
                    // 準備完了状態でなければ準備完了処理
                    if (enterFlg[playerBindPad[padIndex]] == false)
                    {
                        enterFlg[playerBindPad[padIndex]] = true;
                        m_playerNum++;
                        Debug.Log("Enter:" + (int)playerBindPad[padIndex]);
                        m_playerIcon[(int)playerBindPad[padIndex]].transform.GetChild(0).gameObject.SetActive(true);
                        m_playerIcon[(int)playerBindPad[padIndex]].transform.GetChild(1).gameObject.SetActive(false);
                    }
                }
            }

            // 準備完了キャンセル処理
            if (input[padIndex].A == true && oldInput[padIndex].A == false)
            {
                // 準備完了状態か?
                if (playerBindPad.ContainsKey(padIndex) && enterFlg.ContainsKey(playerBindPad[padIndex]))
                {
                    //準備完了状態である
                    if (enterFlg[playerBindPad[padIndex]] == true)
                    {
                        // 準備完了状態から参加状態に戻す
                        enterFlg[playerBindPad[padIndex]] = false;
                        m_playerNum--;
                        Debug.Log("Enter Cancel:" + (int)playerBindPad[padIndex]);
                        m_playerIcon[(int)playerBindPad[padIndex]].transform.GetChild(0).gameObject.SetActive(false);
                        m_playerIcon[(int)playerBindPad[padIndex]].transform.GetChild(1).gameObject.SetActive(true);
                    }
                }
            }
        }


        bool tmpFlg = true;

        foreach (var data in enterFlg)
        {
            if (data.Value == false)
            {
                tmpFlg = false;
            }
        }


        // 開始可能な状態かつXボタンが押されたらシーン遷移
        if (tmpFlg == true && m_playerNum >= MIN_PLAYER_NUM)
        {
            m_ReadyToFight.gameObject.SetActive(true);
            // ゲームパッドループ
            for (GamePad.Index padIndex = GamePad.Index.One; (int)padIndex <= Input.GetJoystickNames().Length; padIndex++)
            {
                if (input.ContainsKey(padIndex) && input[padIndex].Start)
                {
                    isStart = true;
                    SoundManager.Instance.PlaySE(SoundManager.SElist.SE_Choice);
                }
            }
        }
        else
        {
            m_ReadyToFight.gameObject.SetActive(false);
        }
    }
 // 指定したプレイヤーのバインド情報を削除する
 public void DeleteBindPadIndex(PlayerController.PlayerNum player)
 {
     data.Remove(player);
 }
예제 #8
0
 public void SetInput(PlayerController.PlayerNum player)
 {
     data.Add(player, GamePad.GetState(BindGamepad.Instance.GetBindPadIndex(player)));
 }