Beispiel #1
0
        public void ReceiveOpponentsMovement()
        {
            if (playerMovePayload != null)
            {
                Player opponentMoving = GameManager.Instance.GetOpponentByClientId(playerMovePayload.clientId);

                Hexagon sourceHexagon = MapManager.Instance.GetHexagonByMapSizeAndIndex(GameSetup.mapSize, playerMovePayload.source);
                Hexagon targetHexagon = MapManager.Instance.GetHexagonByMapSizeAndIndex(GameSetup.mapSize, playerMovePayload.target);

                targetHexagon.gameObject.name = GameConfig.ENEMY_HEXAGON_NAME;
                targetHexagon.SetLandSprite(MapManager.Instance.PlainSprite);

                if (targetHexagon.isPlayer)
                {
                    //This will be an attack
                }
                else
                {
                    sourceHexagon.DeductUnits(playerMovePayload.movingUnits);
                    targetHexagon.SetAsEnemy(opponentMoving, playerMovePayload.movingUnits);

                    if (GameSetup.Instance.showEnemies)
                    {
                        MapManager.Instance.RevealNeighbors(targetHexagon);
                    }
                }

                playerMovePayload = null;
            }
        }
Beispiel #2
0
 public void SetOpponentsMovementPayload(PlayerMovePayload payload)
 {
     if (playerMovePayload == null && payload != null)
     {
         playerMovePayload = payload;
     }
 }
Beispiel #3
0
 private void ReceiveOpponentsMovement()
 {
     if (this.movementMessage != null)
     {
         PlayerMovePayload p = JsonUtility.FromJson <PlayerMovePayload>(this.movementMessage);
         GameManager.Instance.SetOpponentsMovementPayload(p);
         GameManager.Instance.ReceiveOpponentsMovement();
     }
 }
Beispiel #4
0
        public void PassMoveToOpponentPlayer(int source, int baseUnits, int target, int movingUnits)
        {
            PlayerMovePayload payload = new PlayerMovePayload();

            payload.clientId    = localPlayer.clientId;
            payload.source      = source;
            payload.baseUnits   = baseUnits;
            payload.target      = target;
            payload.movingUnits = movingUnits;

            string data = JsonUtility.ToJson(payload);

            SendPayload(GameConfig.NetworkCode.RECEIVE_OPPONENT_MOVE_ACTION, data, localPlayer.clientId);
        }