Exemplo n.º 1
0
        /// <summary>
        /// Enables the appropriate frame depending on the given position on board.
        /// </summary>
        public void EnableFrame(IntVector2 position)
        {
            if (!isEnabled)
            {
                return;
            }

            var item = boardStorage.GetItem(position);

            if (!(item is ArmyStorageItem armyItem))
            {
                //We light on only armies.
                return;
            }

            if (!GetArmyColor(armyItem, out var color))
            {
                return;
            }

            board.GetBoardButton(position).EnableFrame(color);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates player position profit as summary of all his armies profits.
        /// </summary>
        private double CalcPlayerPositionProfit(List <Cell> currentPlayerArmyCells)
        {
            double result = 0;

            if (currentPlayerArmyCells.Count == 0)
            {
                return(0);
            }

            var playerType = GetPlayerTypeByCell(currentPlayerArmyCells[0]);

            foreach (var cell in currentPlayerArmyCells)
            {
                var boardItem = boardStorage.GetItem(cell);
                if (boardItem is ArmyStorageItem item)
                {
                    result += CalcArmyPositionProfit(item.Army.ArmyPower(),
                                                     boardStorage.GetDistanceToEnemyCastle(cell, playerType));
                }
            }

            return(result);
        }
        /// <summary>
        /// Returns a copy of boardIcon on the given position of the storage.
        /// Icon is placed on the same position.
        /// </summary>
        public GameObject CloneBoardIcon(IBoardStorage boardStorage, int fromX, int fromY)
        {
            var item = boardStorage.GetItem(fromX, fromY);

            return(InstantiateIcon(item.StoredObject.GetComponent <Image>().sprite));
        }