Beispiel #1
0
    public void UserJoined(string username, int seat, bool local)
    {
        if (local)
        {
            networkPlayers[seat] = localPlayer.GetInternalPlayer();
        }
        else
        {
            GameObject newPlayer = new GameObject();
            newPlayer.transform.parent = transform;
            newPlayer.name             = username;
            MonoNetworkPlayerBase player = null;
            player = newPlayer.AddComponent <MonoRemoteNetworkPlayer>();
            player.TurnTimeoutHandler       = TurnTimeoutHandler;
            player.gameTable                = GameTable;
            networkPlayers[seat]            = player.InitializeNetworkPlayer();
            networkPlayers[seat].PlayerName = username;
        }

        if (networkPlayers[seat] != null)
        {
            SeatPlayer(networkPlayers[seat], seat);
        }

        if (IsRoomFilled())
        {
            GameTable.InitializeMultiPlayerGame(MultiplayerManager.CurrentEndCondition, MultiplayerManager.CurrentEndConditionGoal);
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        GUI.depth = 19;
        GUI.skin  = EndGamePopupSkin;

        GUI.Box(groupPosition1, LanguageManager.getString("GMENDN"));
        GUI.BeginGroup(groupPosition1);

        GUI.EndGroup();

        GUI.Box(groupPosition2, "");
        GUI.BeginGroup(groupPosition2);

        if (LobbyPlayerStats.RoomData != null && (Properties.ActiveGameType != GameType.MultiPlayer || LobbyPlayerStats.RoomData.getRoomOwner() == Player.GetInternalPlayer().PlayerName) && GUI.Button(new Rect(groupPosition2.width / 20, groupPosition2.height / 10, groupPosition2.width / 100 * 40, groupPosition2.height - groupPosition2.height / 5), LanguageManager.getString("RPLY")))
        {
            Replay();
        }

        if (GUI.Button(new Rect(groupPosition2.width / 2, groupPosition2.height / 10, groupPosition2.width / 100 * 43, groupPosition2.height - groupPosition2.height / 5), LanguageManager.getString("LEAVEGM")))
        {
            DialogBox.DialogBoxButtons = DialogBoxButtons.YES_NO;
            DialogBox.DialogText       = LanguageManager.getString("PROMPT_LEAVEGM");
            DialogBox.CallbackObject   = gameObject;
            DialogBox.Show();
        }

        GUI.EndGroup();
    }
Beispiel #3
0
    private IEnumerator createRoom(Dictionary <string, object> tableProperties)
    {
        LoadingScreen.Show();
        yield return(null);

        WarpClient.GetInstance().CreateRoom(roomName, Player.GetInternalPlayer().PlayerName, 4, tableProperties);
    }
Beispiel #4
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            InGameMenu.Show();
        }

        if (dataNewlyBound)
        {
            dataNewlyBound = false;

            MultiplayerGamers.ResetPlayers();
            UIGameTable.CleanTable();

            //  GET CURRENT PLAYER SEATS
            object seat0, seat1, seat2, seat3;
            if (RoomProperties.TryGetValue("SEAT0", out seat0))
            {
                MultiplayerGamers.UserJoined(seat0.ToString(), 0, seat0.ToString().Equals(player.GetInternalPlayer().PlayerName));
            }

            if (RoomProperties.TryGetValue("SEAT1", out seat1))
            {
                MultiplayerGamers.UserJoined(seat1.ToString(), 1, seat1.ToString().Equals(player.GetInternalPlayer().PlayerName));
            }

            if (RoomProperties.TryGetValue("SEAT2", out seat2))
            {
                MultiplayerGamers.UserJoined(seat2.ToString(), 2, seat2.ToString().Equals(player.GetInternalPlayer().PlayerName));
            }

            if (RoomProperties.TryGetValue("SEAT3", out seat3))
            {
                MultiplayerGamers.UserJoined(seat3.ToString(), 3, seat3.ToString().Equals(player.GetInternalPlayer().PlayerName));
            }

            object gameType, gameGoal;

            if (RoomProperties.TryGetValue("TYPE", out gameType))
            {
                if (gameType.ToString() == "0")
                {
                    MultiplayerManager.CurrentEndCondition = Common.Enums.GameMode.RoundCount;
                }
                else
                {
                    MultiplayerManager.CurrentEndCondition = Common.Enums.GameMode.TargetScore;
                }
            }
            if (RoomProperties.TryGetValue("GOAL", out gameGoal))
            {
                MultiplayerManager.CurrentEndConditionGoal = gameGoal;
            }
        }
    }
    public static int GetRelativePlayerSeat(int player)
    {
        var seat = player - unityPlayer.GetInternalPlayer().GetPlayersSeat();

        if (seat < 0)
        {
            seat += 4;
        }

        return(seat);
    }
Beispiel #6
0
 private void SetTrump(Common.Enums.CardType cardType)
 {
     Hide();
     if (Properties.ActiveGameType == GameType.SinglePlayer)
     {
         player.getInternalPlayer().SetTrumpType(cardType);
     }
     else
     {
         networkPlayer.GetInternalPlayer().SetTrumpType(cardType);
     }
 }
Beispiel #7
0
 public void DialogBoxCallback(bool answer)
 {
     if (Properties.ActiveGameType == GameType.SinglePlayer)
     {
         if (answer)
         {
             Hide();
             PlayerStats.Hide();
             LobbyPlayerStats.Hide();
             MainMenu.Show();
         }
         else
         {
             Hide();
         }
     }
     else
     {
         if (answer)
         {
             WarpClient.GetInstance().LeaveRoom(LobbyPlayerStats.RoomData.getId());
             if (LobbyPlayerStats.RoomData.getRoomOwner() == Player.GetInternalPlayer().PlayerName)
             {
                 string roomDeleteCommand = "ROOMDLT";
                 MultiplayerManager.SendBytes(ByteHelper.GetBytes(roomDeleteCommand));
                 WarpClient.GetInstance().DeleteRoom(LobbyPlayerStats.RoomData.getId());
                 RoomSelectionMenu.Show(roomDeleteCommand);
             }
             else
             {
                 RoomSelectionMenu.Renew();
             }
             LobbyPlayerStats.RoomData = null;
             PlayerStats.Hide();
             LobbyPlayerStats.Hide();
             Hide();
         }
     }
 }
Beispiel #8
0
    public void Release()
    {
        GameObject scriptWrapper = GameObject.FindGameObjectWithTag("SCRIPTWRAPPER");

        if (scriptWrapper != null && !released)
        {
            released = true;
            MonoPlayer        player        = scriptWrapper.GetComponent <MonoPlayer>();
            MonoNetworkPlayer networkPlayer = scriptWrapper.GetComponent <MonoNetworkPlayer>();
            if (transform.position.y > player.splitter.transform.position.y)
            {
                //  CARD PLAYED
                this.transform.position      = new Vector3(transform.position.x, transform.position.y, 1f);
                player.playerDeck.playedCard = this;

                PlayedCardsController.PlaceCard(transform);
                UserInteraction.InputActive = false;

                // FINALLY ACTUALLY PLAY THE CARD
                if (Properties.ActiveGameType == GameType.SinglePlayer)
                {
                    player.getInternalPlayer().PlayCard(this.card);
                }
                else
                {
                    networkPlayer.GetInternalPlayer().PlayCard(this.card);
                }

                released = false;
            }
            else
            {
                ResetPosition(false);
            }
        }
    }
Beispiel #9
0
    void OnGUI()
    {
        GUI.depth = 20;
        GUI.skin  = popupSkin;
        GUI.BeginGroup(menuPosition);
        //  MAIN BOX
        GUI.Box(mainGroupPosition, "");
        //  INNER GROUP
        GUI.DrawTexture(dealTitlePosition, LanguageManager.playerLanguage == "en" ? DealTitle_EN : DealTitle);
        GUI.BeginGroup(innerGroupPosition);

        GUI.DrawTexture(new Rect(0, 0, innerGroupPosition.width / 10, innerGroupPosition.width / 10), Border1);
        GUI.DrawTexture(new Rect(innerGroupPosition.width / 10 * 9, 0, innerGroupPosition.width / 10, innerGroupPosition.width / 10), Border2);


        //GUI.Label(new Rect(0, 0, innerGroupPosition.width, marginHeight), LanguageManager.getString("MKBDNG"));

        float offsetX = 0;
        float offsetY = 0;


        offsetY += innerGroupPosition.height / 4;
        //  FIRST ROW
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "0"))
        {
            //  BID 0
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(0);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(0);
            }
        }
        offsetX += buttonWidth + marginWidth;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "5"))
        {
            //  BID 5
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(5);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(5);
            }
        }
        offsetX += buttonWidth + marginWidth;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "6"))
        {
            //  BID 6
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(6);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(6);
            }
        }
        offsetX += buttonWidth + marginWidth;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "7"))
        {
            //  BID 7
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(7);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(7);
            }
        }
        offsetX += buttonWidth + marginWidth;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "8"))
        {
            //  BID 8
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(8);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(8);
            }
        }
        offsetX += buttonWidth + marginWidth;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "9"))
        {
            //  BID 9
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(9);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(9);
            }
        }


        //  SECOND ROW
        offsetY += marginHeight;
        offsetX  = 0;


        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "10"))
        {
            //  BID 10
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(10);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(10);
            }
        }
        offsetX += buttonWidth + marginWidth2;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "11"))
        {
            //  BID 11
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(11);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(11);
            }
        }
        offsetX += buttonWidth + marginWidth2;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "12"))
        {
            //  BID 12
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(12);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(12);
            }
        }
        offsetX += buttonWidth + marginWidth2;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth, buttonWidth), "13"))
        {
            //  BID 13
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(13);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(13);
            }
        }
        offsetX += buttonWidth + marginWidth2;
        if (GUI.Button(new Rect(offsetX, offsetY, buttonWidth * 2, buttonWidth), LanguageManager.getString("PASS")))
        {
            //  PASS
            SetActive(false);
            if (Properties.ActiveGameType == GameType.SinglePlayer)
            {
                player.getInternalPlayer().Bid(-1);
            }
            else
            {
                NetworkPlayer.GetInternalPlayer().Bid(-1);
            }
        }

        if (currentRound != null)
        {
            var biddings = currentRound.GetInitialPhase().GetRoundScores();

            for (int i = 0; i < 4; i++)
            {
                var said = biddings[i].GetSaid();
                var bid  = "";
                if (said == -2)
                {
                    bid = "-";
                }
                else if (said == -1)
                {
                    bid = LanguageManager.getString("PASS");
                }
                else
                {
                    bid = said.ToString();
                }


                GUI.Label(new Rect(biddingsPos.x, offsetY, biddingsPos.width, biddingsPos.height), gameTable.gameTable.GetPlayerSeatedAt(i).PlayerName);
                GUI.Label(new Rect(biddingsPos2.x, offsetY, biddingsPos2.width, biddingsPos2.height), bid);
                offsetY += marginHeight / 2;
            }
        }

        GUI.EndGroup();
        GUI.EndGroup();
    }
Beispiel #10
0
 public static void connectToWarp(string username)
 {
     StaticPlayer.GetInternalPlayer().PlayerName = username;
     WarpClient.GetInstance().Connect(username);
 }
Beispiel #11
0
    public void onBytes(byte[] msg)
    {
        string networkMessage = ByteHelper.GetString(msg);

        LogManager.Log("Received Update: " + networkMessage);

        string[] messageArgs = networkMessage.Split('-');

        string messageCommand;

        if (messageArgs.Length == 0)
        {
            messageCommand = networkMessage;
        }
        else
        {
            messageCommand = messageArgs[0];
        }

        switch (messageCommand)
        {
        case "SIT":
            if (LobbyPlayerStats.RoomData.getRoomOwner() == NonStaticPlayer.GetInternalPlayer().PlayerName)
            {
                int seat = -1;
                if (int.TryParse(messageArgs[1], out seat))
                {
                    string playerName = messageArgs[2];

                    //  SET ROOM PROPERTY
                    Dictionary <string, object> tableProperties = new Dictionary <string, object>();
                    tableProperties.Add("SEAT" + seat.ToString(), playerName);
                    List <string> removeProperties = new List <string>();

                    object seat0, seat1, seat2, seat3;
                    if (LobbyPlayerStats.RoomProperties.TryGetValue("SEAT0", out seat0) && seat0.ToString() == playerName)
                    {
                        removeProperties.Add("SEAT0");
                        NonStaticPlayer.gameTable.gameTable.LeaveTable(0);
                    }

                    if (LobbyPlayerStats.RoomProperties.TryGetValue("SEAT1", out seat1) && seat1.ToString() == playerName)
                    {
                        removeProperties.Add("SEAT1");
                        NonStaticPlayer.gameTable.gameTable.LeaveTable(1);
                    }

                    if (LobbyPlayerStats.RoomProperties.TryGetValue("SEAT2", out seat2) && seat2.ToString() == playerName)
                    {
                        removeProperties.Add("SEAT2");
                        NonStaticPlayer.gameTable.gameTable.LeaveTable(2);
                    }

                    if (LobbyPlayerStats.RoomProperties.TryGetValue("SEAT3", out seat3) && seat3.ToString() == playerName)
                    {
                        removeProperties.Add("SEAT3");
                        NonStaticPlayer.gameTable.gameTable.LeaveTable(3);
                    }

                    if (removeProperties.Count == 0)
                    {
                        removeProperties = null;
                    }

                    WarpClient.GetInstance().UpdateRoomProperties(LobbyPlayerStats.RoomData.getId(), tableProperties, removeProperties);
                }
            }

            break;

        case "ROOMDLT":

            WarpClient.GetInstance().LeaveRoom(LobbyPlayerStats.RoomData.getId());
            LobbyPlayerStats.Hide();
            RoomSelectionMenu.Show("ROOMDLT");
            break;

        case "PLAY":
            int playerSeat, cardType, cardValue;
            if (int.TryParse(messageArgs[1], out playerSeat))
            {
                if (playerSeat != NonStaticPlayer.GetInternalPlayer().GetPlayersSeat())
                {
                    if (int.TryParse(messageArgs[2], out cardType))
                    {
                        if (int.TryParse(messageArgs[3], out cardValue))
                        {
                            RemoteNetworkPlayer networkPlayer = MultiplayerGamers.GetPlayerBySeat(playerSeat) as RemoteNetworkPlayer;
                            Card cardToPlay = new Card(cardValue, cardType);
                            networkPlayer.PlayCard(cardToPlay);
                        }
                    }
                }
            }

            break;

        case "BID":
            int bidPlayerSeat, bid;
            if (int.TryParse(messageArgs[1], out bidPlayerSeat))
            {
                if (bidPlayerSeat != NonStaticPlayer.GetInternalPlayer().GetPlayersSeat())
                {
                    if (int.TryParse(messageArgs[2], out bid))
                    {
                        NetworkPlayerBase networkPlayer = MultiplayerGamers.GetPlayerBySeat(bidPlayerSeat);
                        if (bid == 999)
                        {
                            networkPlayer.Bid(-1);
                        }
                        else
                        {
                            networkPlayer.Bid(bid);
                        }
                    }
                }
            }
            break;

        case "SETTRMP":
            int trumpPlayerSeat, trumpType;
            if (int.TryParse(messageArgs[1], out trumpPlayerSeat))
            {
                if (trumpPlayerSeat != NonStaticPlayer.GetInternalPlayer().GetPlayersSeat())
                {
                    if (int.TryParse(messageArgs[2], out trumpType))
                    {
                        NetworkPlayerBase networkPlayer = MultiplayerGamers.GetPlayerBySeat(trumpPlayerSeat);
                        networkPlayer.SetTrumpType(CardHelper.GetCardTypeFromValue(trumpType));
                    }
                }
            }
            break;

        case "DEALCALLBACK":
            IncreaseDealCallback();
            break;

        case "START":
            if (LobbyPlayerStats.RoomData.getRoomOwner() != NonStaticPlayer.GetInternalPlayer().PlayerName)
            {
                MultiplayerGamers.GameTable.gameTable.PlayersReadyCallback();
            }
            break;
        }

        LogManager.Log(networkMessage);
    }