示例#1
0
    public void LoadNetZone(RuntimeZone _localZone, NetZone _netZone, PlayerData _ownerPlayer)
    {
        //remove any illegal cards
        for (int i = 0; i < _localZone.cards.Count; i++)
        {
            RuntimeCard _card = _localZone.cards[i];
            if (Array.Exists(_netZone.cards, x => x.unique_cardId == _card.guid) == false)
            {
                //remove the card
                StartCoroutine(GameScene.Active.ShowPlayerMessage("Developer Warning:: The Server Reverted A Move"));
                _localZone.RemoveCard(_card.guid);
            }
        }

        //add any new cards
        for (int i = 0; i < _netZone.cards.Length; i++)
        {
            NetCard     _card      = _netZone.cards[i];
            RuntimeCard _localCard = _localZone.cards.Find(x => x.guid == _card.unique_cardId);
            if (_localCard == null)
            {
                //add the card
                _localZone.AddCard(NetworkUtilities.GetRuntimeCard(_card, _ownerPlayer));
            }
        }
    }
    public static void MoveCard(RuntimeZone _fromZone, RuntimeZone _toZone, int _unique_CardId)
    {
        RuntimeCard _card = _fromZone.cards.Find(x => x.guid == _unique_CardId);

        _fromZone.RemoveCard(_unique_CardId);
        _toZone.AddCard(_card);
    }
    private GameState CreateTestGameState()
    {
        var gameState = new GameState();

        gameState.players.Add(new PlayerInfo());
        gameState.players.Add(new PlayerInfo());
        gameState.currentPlayer   = gameState.players[0];
        gameState.currentOpponent = gameState.players[1];

        foreach (var player in gameState.players)
        {
            var life = new Stat();
            life.statId                  = 0;
            life.name                    = "Life";
            life.baseValue               = 20;
            life.originalValue           = 20;
            life.minValue                = 0;
            life.maxValue                = 99;
            player.stats[life.statId]    = life;
            player.namedStats[life.name] = life;
        }

        foreach (var player in gameState.players)
        {
            var zone = new RuntimeZone();
            zone.zoneId     = 0;
            zone.instanceId = 0;
            zone.name       = "Test zone";
            zone.maxCards   = 100;

            var life = new Stat();
            life.statId        = 0;
            life.name          = "Life";
            life.baseValue     = 2;
            life.originalValue = 2;
            life.minValue      = 0;
            life.maxValue      = 99;

            var card = new RuntimeCard();
            card.cardId                = 0;
            card.instanceId            = 0;
            card.stats[life.statId]    = life;
            card.namedStats[life.name] = life;

            zone.AddCard(card);

            player.zones[zone.zoneId]    = zone;
            player.namedZones[zone.name] = zone;
        }

        return(gameState);
    }