예제 #1
0
    private void GetInputFromEachPlayer(PhotonPlayer photonPlayer, ref PlayerSelected[] player, object move)
    {
        PlayerSelected playerSelected = new PlayerSelected();

        if (photonPlayer.isLocal)
        {
            playerSelected.Hand = (RockPaperScissors)(byte)move;
            playerSelected.ID   = photonPlayer.ID;
            player[0]           = playerSelected;
            Debug.Log(" ID : " + player[0].ID + " , Selected : " + player[0].Hand + " ");
        }
        else if (photonPlayer.GetNext().isLocal)
        {
            playerSelected.Hand = (RockPaperScissors)(byte)move;
            playerSelected.ID   = photonPlayer.ID;
            player[1]           = playerSelected;
            Debug.Log(" ID : " + player[1].ID + " , Selected : " + player[1].Hand + " ");
        }
        else if (photonPlayer.GetNext().GetNext().isLocal)
        {
            playerSelected.Hand = (RockPaperScissors)(byte)move;
            playerSelected.ID   = photonPlayer.ID;
            player[2]           = playerSelected;
            Debug.Log(" ID : " + player[2].ID + " , Selected : " + player[2].Hand + " ");
        }
        else
        {
            playerSelected.Hand = (RockPaperScissors)(byte)move;
            playerSelected.ID   = photonPlayer.ID;
            player[3]           = playerSelected;
            Debug.Log(" ID : " + player[3].ID + " , Selected : " + player[3].Hand + " ");
        }
    }
예제 #2
0
 public void SetPlayers(IList <string> playerNames)
 {
     foreach (var label in labels)
     {
         layout.Controls.Remove(label);
     }
     labels.Clear();
     for (var index = 0; index < playerNames.Count; index++)
     {
         string player = playerNames[index];
         var    label  = new Label
         {
             Text      = FormatScore(player, 0, 0),
             AutoSize  = true,
             Font      = new Font(new FontFamily("Arial"), 12),
             ForeColor = Color.White,
             BackColor = ColorsPalette.Colors[index],
             Padding   = new Padding(0),
             Margin    = new Padding(0),
             Tag       = player
         };
         var indexCopy = index;
         label.MouseEnter += (sender, args) => PlayerSelected?.Invoke(indexCopy, player);
         label.MouseLeave += (sender, args) => PlayerSelected?.Invoke(-1, "");
         labels.Add(label);
         layout.Controls.Add(label);
     }
     Resized();
 }
예제 #3
0
    public PlayerSelected TwoPlayers(PlayerSelected p1, PlayerSelected p2)
    {
        if (p1.Hand == p2.Hand)
        {
            return(Draw);
        }

        else if (p1.Hand == RockPaperScissors.None && p2.Hand != RockPaperScissors.None)
        {
            return(p2);
        }

        else if (p1.Hand != RockPaperScissors.None && p2.Hand == RockPaperScissors.None)
        {
            return(p1);
        }

        else if (p1.Hand == RockPaperScissors.Paper)
        {
            if (p2.Hand == RockPaperScissors.Rock)
            {
                return(p1);
            }
            else
            {
                return(p2);
            }
        }

        else if (p1.Hand == RockPaperScissors.Rock)
        {
            if (p2.Hand == RockPaperScissors.Paper)
            {
                return(p2);
            }
            else
            {
                return(p1);
            }
        }

        else if (p1.Hand == RockPaperScissors.Scissors)
        {
            if (p2.Hand == RockPaperScissors.Paper)
            {
                return(p1);
            }
            else
            {
                return(p2);
            }
        }

        return(Draw);
    }
        public void SelectPlayer(PlayerColour colour)
        {
            var newPlayerTool = playerTools.Where(x => x.Player == colour).First();

            if (selectedPlayerTool != null)
            {
                selectedPlayerTool.Select(false);
            }
            newPlayerTool.Select(true);
            selectedPlayerTool = newPlayerTool;
            PlayerSelected?.Invoke(this, new PlayerSelectedEventArgs(colour));
        }
    public void Select(int selection)
    {
        PlayerSelection = (Selections)selection;

        EnableDisableButtons(false);
        //Notify All listeners
        PlayerSelected?.Invoke((Selections)PlayerSelection);

        if (gameMode == Gamemodes.Single)
        {
            StartGame?.Invoke();
        }

        if (EnemySelection != null)
        {
            StartGame?.Invoke();
        }
    }
예제 #6
0
        public override void OnPlayerSelected(Player player)
        {
            if (player.Health <= 0)
            {
                return;
            }

            if (PossibleTargets.Contains(Enumerators.AbilityTargetType.PLAYER) &&
                player.AvatarObject.CompareTag(SRTags.PlayerOwned) ||
                PossibleTargets.Contains(Enumerators.AbilityTargetType.OPPONENT) &&
                player.AvatarObject.CompareTag(SRTags.OpponentOwned) ||
                PossibleTargets.Contains(Enumerators.AbilityTargetType.ALL))
            {
                SelectedPlayer = player;
                SelectedCard?.SetSelectedUnit(false);

                SelectedCard = null;
                SelectedPlayer.SetGlowStatus(true);
                PlayerSelected?.Invoke(player);
            }
        }
예제 #7
0
 public void OnPlayerSelected(DestinyPlayer player)
 {
     PlayerSelected?.Invoke(this, player);
 }
예제 #8
0
 private void OnButtonPressed(Button button)
 {
     PlayerSelected?.Invoke(ButtonLookup[button]);
 }
예제 #9
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var player = players.Players.FirstOrDefault(pl => pl.Name.Equals((string)SearchBox.SelectedItem));

            PlayerSelected?.Invoke(this, player);
        }
예제 #10
0
    public List <PlayerSelected> ThreePlayers(PlayerSelected p1, PlayerSelected p2, PlayerSelected p3)
    {
        List <PlayerSelected> winners = new List <PlayerSelected>();

        //Draw Condition
        if (p1.Hand == p2.Hand && p2.Hand == p3.Hand)
        {
            winners.Add(Draw);
        }

        //Three players have chosen their choices
        else if (p1.Hand != RockPaperScissors.None && p2.Hand != RockPaperScissors.None && p3.Hand != RockPaperScissors.None)
        {
            //Draw Condition
            if (p1.Hand != p2.Hand && p2.Hand != p3.Hand && p3.Hand != p1.Hand)
            {
                winners.Add(Draw);
            }

            //Win Condition
            //Player 1 choose "Paper"
            else if (p1.Hand == RockPaperScissors.Paper)
            {
                //Player 1 choose "Paper" & Player 2 choose "Paper"
                if (p2.Hand == RockPaperScissors.Paper)
                {
                    if (p3.Hand == RockPaperScissors.Rock)
                    {
                        winners.Add(p1);
                        winners.Add(p2);
                    }
                    else if (p3.Hand == RockPaperScissors.Scissors)
                    {
                        winners.Add(p3);
                    }
                }

                //Player 1 choose "Paper" & Player 2 choose "Rock"
                else if (p2.Hand == RockPaperScissors.Rock)
                {
                    if (p3.Hand == RockPaperScissors.Paper)
                    {
                        winners.Add(p1);
                        winners.Add(p3);
                    }
                    else if (p3.Hand == RockPaperScissors.Rock)
                    {
                        winners.Add(p1);
                    }
                }

                //Player 1 choose "Paper" & Player 2 choose "Scissors"
                else if (p2.Hand == RockPaperScissors.Scissors)
                {
                    if (p3.Hand == RockPaperScissors.Paper)
                    {
                        winners.Add(p2);
                    }
                    else if (p3.Hand == RockPaperScissors.Scissors)
                    {
                        winners.Add(p2);
                        winners.Add(p3);
                    }
                }
            }

            //Player 1 choose "Rock"
            else if (p1.Hand == RockPaperScissors.Rock)
            {
                //Player 1 choose "Rock" & Player 2 choose "Paper"
                if (p2.Hand == RockPaperScissors.Paper)
                {
                    if (p3.Hand == RockPaperScissors.Paper)
                    {
                        winners.Add(p2);
                        winners.Add(p3);
                    }
                    else if (p3.Hand == RockPaperScissors.Rock)
                    {
                        winners.Add(p2);
                    }
                }

                //Player 1 choose "Rock" & Player 2 choose "Rock"
                else if (p2.Hand == RockPaperScissors.Rock)
                {
                    if (p3.Hand == RockPaperScissors.Paper)
                    {
                        winners.Add(p3);
                    }
                    else if (p3.Hand == RockPaperScissors.Scissors)
                    {
                        winners.Add(p1);
                        winners.Add(p2);
                    }
                }

                //Player 1 choose "Rock" & Player 2 choose "Scissors"
                else if (p2.Hand == RockPaperScissors.Scissors)
                {
                    if (p3.Hand == RockPaperScissors.Rock)
                    {
                        winners.Add(p1);
                        winners.Add(p3);
                    }
                    else if (p3.Hand == RockPaperScissors.Scissors)
                    {
                        winners.Add(p1);
                    }
                }
            }

            //Player 1 choose "Scissors"
            else if (p1.Hand == RockPaperScissors.Scissors)
            {
                //Player 1 choose "Scissors" and Player 2 choose "Paper"
                if (p2.Hand == RockPaperScissors.Paper)
                {
                    if (p3.Hand == RockPaperScissors.Paper)
                    {
                        winners.Add(p1);
                    }
                    else if (p3.Hand == RockPaperScissors.Scissors)
                    {
                        winners.Add(p1);
                        winners.Add(p3);
                    }
                }

                //Player 1 choose "Scissors" and Player 2 choose "Rock"
                else if (p2.Hand == RockPaperScissors.Rock)
                {
                    if (p3.Hand == RockPaperScissors.Rock)
                    {
                        winners.Add(p2);
                        winners.Add(p3);
                    }
                    else if (p3.Hand == RockPaperScissors.Scissors)
                    {
                        winners.Add(p2);
                    }
                }

                //Player 1 choose "Scissors" and Player 2 choose "Scissors"
                else if (p2.Hand == RockPaperScissors.Scissors)
                {
                    if (p3.Hand == RockPaperScissors.Paper)
                    {
                        winners.Add(p1);
                        winners.Add(p2);
                    }
                    else if (p3.Hand == RockPaperScissors.Rock)
                    {
                        winners.Add(p3);
                    }
                }
            }
        }

        //Two players didn't choose any choices
        else if (p1.Hand != RockPaperScissors.None && p2.Hand == RockPaperScissors.None && p3.Hand == RockPaperScissors.None)
        {
            winners.Add(p1);
        }
        else if (p1.Hand == RockPaperScissors.None && p2.Hand == RockPaperScissors.None && p3.Hand != RockPaperScissors.None)
        {
            winners.Add(p3);
        }
        else if (p1.Hand == RockPaperScissors.None && p2.Hand != RockPaperScissors.None && p3.Hand == RockPaperScissors.None)
        {
            winners.Add(p2);
        }

        //One player didn't choose a choice
        else if (p1.Hand != RockPaperScissors.None && p2.Hand != RockPaperScissors.None && p3.Hand == RockPaperScissors.None)
        {
            win2 = TwoPlayers(p1, p2);
            winners.Add(win2);
        }
        else if (p1.Hand != RockPaperScissors.None && p2.Hand == RockPaperScissors.None && p3.Hand != RockPaperScissors.None)
        {
            win2 = TwoPlayers(p1, p3);
            winners.Add(win2);
        }
        else if (p1.Hand == RockPaperScissors.None && p2.Hand != RockPaperScissors.None && p3.Hand != RockPaperScissors.None)
        {
            win2 = TwoPlayers(p2, p3);
            winners.Add(win2);
        }
        return(winners);
    }