Exemplo n.º 1
0
        /// <summary>
        /// Get the strength coming in to one tile for one player!
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="requestingPlayer"></param>
        /// <returns></returns>
        public int GetStrengthForPlayerAtPosition(Vector2Int pos, PlayerKey requestingPlayer)
        {
            int val = GetStrengthForPlayerAtPositionRecursive(pos, new Vector2Int(-1, 0), requestingPlayer)
                      + GetStrengthForPlayerAtPositionRecursive(pos, new Vector2Int(1, 0), requestingPlayer)
                      + GetStrengthForPlayerAtPositionRecursive(pos, new Vector2Int(0, 1), requestingPlayer)
                      + GetStrengthForPlayerAtPositionRecursive(pos, new Vector2Int(0, -1), requestingPlayer);

            return(val);
        }
Exemplo n.º 2
0
 public MatchState(
     MatchStateType name,
     PlayerKey controllingPlayer,
     PlayerKey otherPlayer)
 {
     this.controllingPlayer = controllingPlayer;
     this.otherPlayer       = otherPlayer;
     this.name = name;
 }
Exemplo n.º 3
0
 public PlayerData(
     DrawOrder drawOrder,
     PlayerKey key,
     int currentMana,
     int maxMana)
 {
     this.drawOrder     = drawOrder;
     this.fieldEntities = new List <IFieldEntity>();
     this.hand          = new List <ICardInstance>();
     this.key           = key;
     this.currentMana   = currentMana;
     this.maxMana       = maxMana;
 }
Exemplo n.º 4
0
        public FieldEntity <CardInstance <Monster> > SpawnMonster(
            CardInstance <Monster> monster,
            Vector2Int position,
            PlayerKey spawningPlayer = null)
        {
            FieldEntity <CardInstance <Monster> > entity = new FieldEntity <CardInstance <Monster> >(this, monster, position);

            if (spawningPlayer != null)
            {
                playerDatas[spawningPlayer].fieldEntities.Add(entity);
            }
            MonsterCreated?.Invoke(entity);
            return(entity);
        }
Exemplo n.º 5
0
        public MatchData(
            Decklist deckPlayer1,
            Decklist deckPlayer2,
            Vector2Int gridSizeX,
            Vector2Int crystalPosition,
            int crystalStrength)
        {
            playerDatas   = new Dictionary <PlayerKey, PlayerData>();
            cardInstances = new Dictionary <ICardInstance, PlayerKey>();
            fieldEntities = new Dictionary <Vector2Int, IFieldEntity>();

            player1Key = new PlayerKey();
            player2Key = new PlayerKey();

            List <ICardInstance> player1Instances = new List <ICardInstance>();
            List <ICardInstance> player2Instances = new List <ICardInstance>();

            foreach (DecklistEntry entry in deckPlayer1.cards)
            {
                ICardData     cardData     = Cards.DB[entry.cardName];
                ICardInstance cardInstance = Cards.CreateCardInstance(cardData, player1Key);

                cardInstances.Add(cardInstance, player1Key);
                player1Instances.Add(cardInstance);
            }
            foreach (DecklistEntry entry in deckPlayer2.cards)
            {
                ICardData     cardData     = Cards.DB[entry.cardName];
                ICardInstance cardInstance = Cards.CreateCardInstance(cardData, player2Key);

                cardInstances.Add(cardInstance, player1Key);
                player2Instances.Add(cardInstance);
            }
            DrawOrder drawOrderP1 = new DrawOrder(player1Instances);
            DrawOrder drawOrderP2 = new DrawOrder(player2Instances);

            playerDatas.Add(player1Key, new PlayerData(drawOrderP1, player1Key, 5, 5));
            playerDatas.Add(player2Key, new PlayerData(drawOrderP2, player2Key, 5, 5));

            _crystal = new Crystal(crystalStrength);

            new FieldEntity <Crystal>(this, _crystal, crystalPosition);
            this.crystalPosition = crystalPosition;
            currentState         = new MatchState(MatchStateType.Idle, player1Key, player2Key);
        }
Exemplo n.º 6
0
        internal static ICardInstance CreateCardInstance(ICardData cardData, PlayerKey player1Key)
        {
            Type          cardType     = cardData.type;
            ICardInstance cardInstance = null;

            if (cardType == typeof(Monster))
            {
                cardInstance = new CardInstance <Monster>(cardData);
            }
            else if (cardType == typeof(Spell))
            {
                cardInstance = new CardInstance <Spell>(cardData);
            }

            if (cardInstance == null)
            {
                throw new System.Exception("Invalid Card Type");
            }

            return(cardInstance);
        }
Exemplo n.º 7
0
 public bool Equals(PlayerKey other)
 {
     return(_uid == other._uid);
 }
Exemplo n.º 8
0
 public HandRequest(PlayerKey sender)
 {
     this.sender = sender;
 }
Exemplo n.º 9
0
        private int GetStrengthForPlayerAtPositionRecursive(Vector2Int pos, Vector2Int dir, PlayerKey requestingPlayer)
        {
            pos += dir;
            if (!fieldEntities.ContainsKey(pos))
            {
                return(0);
            }
            IFieldEntity fieldEntity = fieldEntities[pos];

            if (fieldEntity.TryGetEntity <CardInstance <Monster> >(out CardInstance <Monster> monster))
            {
                if (cardInstances[monster] == requestingPlayer)
                {
                    return(GetStrengthForPlayerAtPositionRecursive(pos, dir, requestingPlayer) + monster.data.combatValue);
                }
                else
                {
                    return(0);
                }
            }
            return(0);
        }