Exemple #1
0
        public void NextRound()
        {
            if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token))
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString()
                };

                Token ct = new Token()
                {
                    Name  = "clientToken",
                    Value = base.GameProperties.Token.ToString()
                };

                nextRoundWebLoad            = new JSONFromWeb("CheckWinner", base.GameProperties.GameServer + @"/game/check-winner", new Token[] { gid, ct }, typeof(Response.NextRound));
                nextRoundWebLoad.OnSuccess += new UnityAction(onNextRoundWebLoadSucceded);
                nextRoundWebLoad.OnFail    += new UnityAction(onNextRoundWebLoadWebLoadFailed);

                GameProperties.WebLoader.AddDownload(nextRoundWebLoad);
            }
            else
            {
                base.Error = "No GameID or clientToken set";
            }
        }
Exemple #2
0
        public void GetCurrentChosenCards()
        {
            if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token))
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString()
                };

                Token ct = new Token()
                {
                    Name  = "clientToken",
                    Value = base.GameProperties.Token.ToString()
                };

                getCurrentChosenCardsWebLoad            = new JSONFromWeb(" GetCurrentChosenCards", base.GameProperties.GameServer + @"/game/get-current-chosen-cards", new Token[] { gid, ct }, typeof(Response.ChosenCards));
                getCurrentChosenCardsWebLoad.OnSuccess += new UnityAction(onGetCurrentChosenCardsSucceded);
                getCurrentChosenCardsWebLoad.OnFail    += new UnityAction(onGetCurrentChosenCardsFailed);

                GameProperties.WebLoader.AddDownload(getCurrentChosenCardsWebLoad);
            }
            else
            {
                base.Error = "No GameID or clientToken set";
            }
        }
Exemple #3
0
        public void ChooseWinner(int cardid)
        {
            if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token))
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString()
                };

                Token ct = new Token()
                {
                    Name  = "clientToken",
                    Value = base.GameProperties.Token.ToString()
                };

                Token cid = new Token()
                {
                    Name  = "cardid",
                    Value = cardid.ToString()
                };

                chooseWinnerWebLoad            = new JSONFromWeb("ChooseWinner", base.GameProperties.GameServer + @"/game/choose-winner", new Token[] { gid, ct, cid }, typeof(Response.ChooseWinner));
                chooseWinnerWebLoad.OnSuccess += new UnityAction(onChooseWinnerWebLoadSucceded);
                chooseWinnerWebLoad.OnFail    += new UnityAction(onChooseWinnerWebLoadFailed);

                GameProperties.WebLoader.AddDownload(chooseWinnerWebLoad);
            }
            else
            {
                base.Error = "No GameID or clientToken set";
            }
        }
Exemple #4
0
        public void PlayCard(int cardId)
        {
            if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token))
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString()
                };

                Token ct = new Token()
                {
                    Name  = "clientToken",
                    Value = base.GameProperties.Token.ToString()
                };

                Token cid = new Token()
                {
                    Name  = "cardid",
                    Value = cardId.ToString()
                };


                playCardWebLoad            = new JSONFromWeb("PlayCard", base.GameProperties.GameServer + @"/game/play-card", new Token[] { gid, ct, cid }, typeof(Response.PlayCard));
                playCardWebLoad.OnSuccess += new UnityAction(onPlayCardWebloadSucceded);
                playCardWebLoad.OnFail    += new UnityAction(onPlayCardWebloadFailed);

                GameProperties.WebLoader.AddDownload(playCardWebLoad);
            }
            else
            {
                base.Error = "No GameID or clientToken set";
            }
        }
        public void DrawCard()
        {
            if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token))
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString()
                };

                Token ct = new Token()
                {
                    Name  = "clientToken",
                    Value = base.GameProperties.Token.ToString()
                };

                drawCardWebLoad            = new JSONFromWeb("DrawCard", base.GameProperties.GameServer + @"/card/draw-card", new Token[] { gid, ct }, typeof(Response.Cards));
                drawCardWebLoad.OnSuccess += new UnityAction(onDrawCardWebloadSucceded);
                drawCardWebLoad.OnFail    += new UnityAction(onDrawCardWebloadFailed);

                GameProperties.WebLoader.AddDownload(drawCardWebLoad);
            }
            else
            {
                base.Error = "No GameID or clientToken set";
            }
        }
        public void CreateLobby()
        {
            if (!string.IsNullOrEmpty(GameName) && !isCreating)
            {
                Token dat = new Token()
                {
                    Name  = "clientToken",
                    Value = GameProperties.Token,
                };

                Token nam = new Token()
                {
                    Name  = "gameName",
                    Value = GameName,
                };

                createLobbyWebload            = new JSONFromWeb("CreateLobby", GameProperties.GameServer + @"/lobby/create-lobby", new Token[] { dat, nam }, typeof(Response.LobbyCreate));
                createLobbyWebload.OnFail    += (new UnityAction(this.onCreationFailed));
                createLobbyWebload.OnSuccess += (new UnityAction(this.onCreationSucceded));
                GameProperties.WebLoader.AddDownload(createLobbyWebload);

                isCreating = true;
            }
            else
            {
                base.Error = "No Game name assigned";
            }
        }
        public void StartGame()
        {
            if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token) && !tryToStart)
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString()
                };

                Token ct = new Token()
                {
                    Name  = "clientToken",
                    Value = base.GameProperties.Token.ToString()
                };

                startGameWebload            = new JSONFromWeb("GetLobbyState", base.GameProperties.GameServer + @"/lobby/start-game", new Token[] { gid, ct }, typeof(Response.StartGame));
                startGameWebload.OnSuccess += new UnityAction(onGameStartedWebloadSucceded);
                startGameWebload.OnFail    += new UnityAction(onGameStartedWebloadFailed);

                GameProperties.WebLoader.AddDownload(startGameWebload);
            }
            else
            {
                base.Error = "No GameID or clientToken set";
                this.Leave();
            }
        }
        private void getLobbies()
        {
            if (!isUpdating)
            {
                isUpdating                   = true;
                currentLobbieLoad            = new JSONFromWeb("GetLobbies", base.GameProperties.GameServer + @"/lobby/get-lobbies", typeof(Response.Lobbies));
                currentLobbieLoad.OnSuccess += new UnityAction(currentLobbieLoadSucceded);
                currentLobbieLoad.OnFail    += new UnityAction(currentLobbieLoadFailed);

                base.GameProperties.WebLoader.AddDownload(currentLobbieLoad);
            }
        }
        public void UpdateLobbyData()
        {
            if (base.GameProperties.GameId != 0)
            {
                Token gid = new Token()
                {
                    Name  = "gameId",
                    Value = base.GameProperties.GameId.ToString(),
                };

                lobbyWebload            = new JSONFromWeb("GetLobbyState", base.GameProperties.GameServer + @"/lobby/get-lobby-state", gid, typeof(Response.Lobby));
                lobbyWebload.OnSuccess += new UnityAction(onLobbyUpdateWebloadSucceded);
                lobbyWebload.OnFail    += new UnityAction(onLobbyUpdateWebloadFail);

                GameProperties.WebLoader.AddDownload(lobbyWebload);
            }
            else
            {
                base.Error = "No GameID set";
            }
        }
        public void DoIt()
        {
            if (!string.IsNullOrEmpty(UserName))
            {
                Token dat = new Token()
                {
                    Name  = "name",
                    Value = UserName,
                };

                data            = new JSONFromWeb("Authenticate", base.GameProperties.GameServer + @"/lobby/authenticate", dat, typeof(Response.Authenticate));
                data.OnSuccess += new UnityAction(connectionSucceeded);
                data.OnFail    += new UnityAction(connectionFailed);

                GameProperties.WebLoader.AddDownload(data);
            }
            else
            {
                Error = "No User Name entered";
            }
        }
Exemple #11
0
        public void JoinInLobby()
        {
            if (!tryToJoin)
            {
                if (base.GameProperties.GameId != 0 && !string.IsNullOrEmpty(base.GameProperties.Token))
                {
                    tryToJoin = true;
                    Token ct = new Token()
                    {
                        Name  = "clientToken",
                        Value = base.GameProperties.Token,
                    };

                    Token gi = new Token()
                    {
                        Name  = "gameId",
                        Value = base.GameProperties.GameId.ToString(),
                    };

                    Token[] dat = new Token[2] {
                        ct, gi
                    };

                    lobbyjoin            = new JSONFromWeb("JoinLobby", base.GameProperties.GameServer + @"/lobby/join-lobby", dat, typeof(Response.LobbyJoin));
                    lobbyjoin.OnSuccess += new UnityAction(onJoinLobbySucceeded);
                    lobbyjoin.OnFail    += new UnityAction(onJoinLobbyFailed);

                    GameProperties.WebLoader.AddDownload(lobbyjoin);
                }
                else
                {
                    base.Error = "No GameID or Token set";
                    base.Leave();
                }
            }
            else
            {
                Debug.Log("trying to join Lobby, a new try is not needed");
            }
        }