Ejemplo n.º 1
0
 public Player()
 {
     playerIndex     = playingPlayerList.Count;
     playerName      = DefaultPlayerName(playerIndex);
     playerInputInfo = LoadPlayerInputConfig(playerIndex);
     playingPlayerList.Add(this);
 }
Ejemplo n.º 2
0
 public Player(string playerName)
 {
     playerIndex     = playingPlayerList.Count;
     this.playerName = playerName;
     playerInputInfo = LoadPlayerInputConfig(playerIndex);
     playingPlayerList.Add(this);
 }
Ejemplo n.º 3
0
    protected override void BindPlayerInputs(PlayerInputInfo inputInfo)
    {
        if (didBindInputs)
        {
            return;
        }

        int index = playerNumber - 1;

        if (index > inputInfo.players.Count - 1)
        {
            return;
        }

        if (inputInfo.players.ElementAt(index))
        {
            inputInfo.players[index].onPlayerMoved        += Move;
            inputInfo.players[index].onDownButtonPressed  += Select;
            inputInfo.players[index].onRightButtonPressed += Deselect;

            currentCursor.ChangeColor(playerColor.playerColor);

            SetupCurrentCursor();

            didBindInputs = true;
        }

        pInputInfo = inputInfo;
    }
    public void OnPlayerJoined(PlayerInputInfo inputInfo)
    {
        if (playerNumber <= 2)
        {
            inputInfo.players[playerNumber - 1].onDownButtonPressed += OnPlayerSelect;

            playerNumber++;
        }
    }
Ejemplo n.º 5
0
    protected virtual void BindPlayerInputs(PlayerInputInfo inputInfo)
    {
        int index = inputInfo.players.Count - 1;

        //add the latest player
        inputInfo.players[index].onPlayerMoved        += Move;
        inputInfo.players[index].onDownButtonPressed  += Select;
        inputInfo.players[index].onRightButtonPressed += Deselect;

        SetupCurrentCursor();
    }
Ejemplo n.º 6
0
    public static void SavePlayerInputConfig(Player savePlayer)
    {
        string directory         = Application.streamingAssetsPath + WithoutStreamingAssetsPath;
        string defaultPlayerName = DefaultPlayerName(savePlayer.playerIndex);
        string fileName          = defaultPlayerName + ConfigFileNameSuffix;
        string fullPath          = directory + fileName;

        string saveData = PlayerInputInfo.ToSaveData(savePlayer.playerInputInfo);

        System.IO.File.WriteAllText(fullPath, saveData);
    }
Ejemplo n.º 7
0
    void InitControllers()
    {
        _inputControllerList = new List <PlayerInputInfo>();

        PlayerInputInfo p1 = new PlayerInputInfo(
            KeyCode.Joystick1Button0,
            KeyCode.Joystick1Button5,
            P1_MAIN_HOR_AXIS, P1_MAIN_VER_AXIS,
            P1_SEC_HOR_AXIS, P1_SEC_VER_AXIS);

        _inputControllerList.Add(p1);
    }
Ejemplo n.º 8
0
        public void Update(PlayerInputInfo inputInfo)
        {
            rigidBody.velocity = new Vector2(inputInfo.horizontal * speed, inputInfo.vertical * speed);
            playerTransform.Find("PlayerGfx").GetComponent <Animator>().SetTrigger("Run");

            if (inputInfo.horizontal < 0)
            {
                player.GetComponent <PlayerBehavior>().FlipSprite(true);
            }
            else
            {
                player.GetComponent <PlayerBehavior>().FlipSprite(false);
            }
        }
Ejemplo n.º 9
0
    public void OnPlayerJoined(PlayerInputInfo inputInfo)
    {
        int index = playerNumber - 1;

        if (index > inputInfo.players.Count - 1)
        {
            return;
        }


        if (inputInfo.players.ElementAt(index))
        {
            activePortrait = portraits[0];
            activePortrait.SetSwordVisiblity(false);
            TogglePortraitsVisibility(true);
        }
    }
Ejemplo n.º 10
0
        void Update()
        {
            if (photonView.IsMine)
            {
                inputInfo.Update();

                if (!inputInfo.IsPlayerInputEmpty())
                {
                    PlayerInputInfo input = inputInfo.GetPlayerInput();
                    moveInfo.Update(input);
                }
                else
                {
                    rigidBody.velocity = Vector2.zero;
                }
            }
        }
Ejemplo n.º 11
0
    public void UnBindPlayerInputs(ref PlayerInputInfo inputInfo, int index)
    {
        playerInputInfo.players[playerIndex].onPlayerMoved -= Move;

        playerInputInfo.players[playerIndex].onUpButtonPressed  -= OnUpButton;
        playerInputInfo.players[playerIndex].onUpButtonReleased -= OnUpButtonReleased;

        playerInputInfo.players[playerIndex].onDownButtonPressed  -= OnDownButton;
        playerInputInfo.players[playerIndex].onDownButtonReleased -= OnDownButtonReleased;

        playerInputInfo.players[playerIndex].onLeftButtonPressed  -= OnLeftButton;
        playerInputInfo.players[playerIndex].onLeftButtonReleased -= OnLeftButtonReleased;

        playerInputInfo.players[playerIndex].onRightButtonPressed  -= OnRightButton;
        playerInputInfo.players[playerIndex].onRightButtonReleased -= OnRightButtonReleased;

        ResetStates();
    }
Ejemplo n.º 12
0
        public void Update()
        {
            if (inputTerm)
            {
                PlayerInputInfo input = default;

                input.horizontal  = joystickInfo.Horizontal;
                input.horizontal += Input.GetAxisRaw("Horizontal");

                input.vertical  = joystickInfo.Vertical;
                input.vertical += Input.GetAxisRaw("Vertical");

                if (Mathf.Abs(input.horizontal) > 0f || Mathf.Abs(input.vertical) > 0f)
                {
                    inputQueue.Enqueue(input);
                }
            }
        }
Ejemplo n.º 13
0
    public void BindPlayerInputs(ref PlayerInputInfo inputInfo, int index)
    {
        inputInfo.players[index].onPlayerMoved += Move;

        inputInfo.players[index].onUpButtonPressed  += OnUpButton;
        inputInfo.players[index].onUpButtonReleased += OnUpButtonReleased;

        inputInfo.players[index].onDownButtonPressed  += OnDownButton;
        inputInfo.players[index].onDownButtonReleased += OnDownButtonReleased;

        inputInfo.players[index].onLeftButtonPressed  += OnLeftButton;
        inputInfo.players[index].onLeftButtonReleased += OnLeftButtonReleased;

        inputInfo.players[index].onRightButtonPressed  += OnRightButton;
        inputInfo.players[index].onRightButtonReleased += OnRightButtonReleased;

        playerIndex     = index;
        playerInputInfo = inputInfo;
    }
Ejemplo n.º 14
0
 public PlayerInputInfo[] GetInputResult(List <PlayerInputInfo> playerInput) //判斷是否在輸入成功區間
 {
     PlayerInputInfo [] result = new PlayerInputInfo[2] {
         new PlayerInputInfo(EColor.NONE, .0f), new PlayerInputInfo(EColor.NONE, .0f)
     };
     bool [] bsuccess = new bool[4];
     //List<PlayerInputInfo> result = new List<PlayerInputInfo>();
     for (int i = 0; i < playerInput.Count; i++)
     {
         float playerInputTime = playerInput[i].time % SecRound;
         for (int j = 0; j < 4; j++)
         {
             Debug.Log("j=" + j);
             Debug.Log("bsuccess[0]=" + bsuccess[0]);
             if (!bsuccess[j] && playerInputTime >= (InputTime[j] - Deviation) && playerInputTime <= (InputTime[j] + Deviation))
             {
                 bsuccess[j] = true;
                 if (j == 0)
                 {
                     result[0] = playerInput[i];
                     Debug.Log(result[0]);
                     Debug.Log(playerInput[i]);
                 }
                 else if (j == 1 && bsuccess[0])
                 {
                     result[0].color = MixColor(playerInput[i].color, playerInput[i - 1].color);
                     Debug.Log("a");
                 }
                 else if (j == 2)
                 {
                     result[1] = playerInput[i];
                 }
                 else if (j == 3 && bsuccess[2])
                 {
                     result[1].color = MixColor(playerInput[i].color, playerInput[i - 1].color);
                     Debug.Log("b");
                 }
             }
         }
     }
     return(result);
 }
Ejemplo n.º 15
0
    public static PlayerInputInfo LoadPlayerInputConfig(int loadPlayerIndex)
    {
        PlayerInputInfo resultInfo = null;

        string directory         = Application.streamingAssetsPath + WithoutStreamingAssetsPath;
        string defaultPlayerName = DefaultPlayerName(loadPlayerIndex);
        string fileName          = defaultPlayerName + ConfigFileNameSuffix;
        string fullPath          = directory + fileName;

        if (System.IO.File.Exists(fullPath))
        {
            string saveData = System.IO.File.ReadAllText(fullPath);
            resultInfo = PlayerInputInfo.FromSaveData <PlayerInputInfo>(saveData);
        }
        else
        {
            resultInfo = Resources.Load <PlayerInputInfo>(PlayerInputInfoPath + defaultPlayerName + DefaultFileName);
        }

        return(resultInfo);
    }
    public void OnPlayerJoined(PlayerInputInfo inputInfo)
    {
        //loop through our keys
        foreach (int playerNumber in characters.Keys)
        {
            int index = playerNumber - 1;

            if (index > inputInfo.players.Count - 1)
            {
                return;
            }

            if (inputInfo.players.ElementAt(index))
            {
                playersJoined++;

                if (!didStart)
                {
                    if (characters.TryGetValue(playerNumber, out Character c))
                    {
                        if (c != null)
                        {
                            c.disableInput = true;
                        }
                    }
                }

                if (playersJoined == 2)
                {
                    OnAllPlayersJoined();
                }
            }
        }

        pInputInfo = inputInfo;
    }
Ejemplo n.º 17
0
 public void onPlayerJoined(PlayerInputInfo inputInfo)
 {
     BindPlayerInputs(inputInfo);
 }
 public void SetPlayerInputInfo(PlayerInputInfo inputInfo)
 {
     InputInfo = inputInfo;
 }