Exemple #1
0
        public void OnNetworkInputMessage(GameInputMessage m)
        {
            if (this.gameRunning)
            {
                // received input from other player, store it
                this.inputsReceived.Add(m.GameRound, new UserInput()
                {
                    UnitTypePlaced = m.UnitTypePlaced,
                    x = m.X,
                    y = m.Y,
                });

                this.otherPlayerNumber = m.playerNumber;
                this.otherEnergy       = m.energy;
                this.otherHealth       = m.health;
            }
        }
Exemple #2
0
        public void SubmitTurn(string gameId, int turn, string playerName, int playerId, int[] cardIds, Action onSuccess)
        {
            var req  = new RESTEasyRequest();
            var body = new TurnSubmissionMessage();

            body.gameID   = gameId;
            body.playerID = playerName;
            for (int i = 0; i < cardIds.Length; i++)
            {
                var input = new GameInputMessage();
                input.order  = i;
                input.owner  = playerId;
                input.swap   = 0; // TODO: swap cards
                input.cardID = cardIds[i];
                body.inputs.Add(input);
            }
            Debug.Log(string.Format("Card submissions: {0}", body));
            req.Body(JsonUtility.ToJson(body)).Url(State.HTTP_HOST + "/api/v1/game/" + gameId + "/turn/" + playerName).OnSuccess(onSuccess).OnFailure((s, i) => handleFailure(req, s, i));
            StartCoroutine(req.Put());
        }