Пример #1
0
        /// <summary>
        /// Alters the Player's resource count and changes the position of the resource card to fit with the current placed ones.
        /// </summary>
        /// <param name="gameBoard"></param>
        /// <param name="player"></param>
        public override void WhenAddedToGameBoard(GameBoardSection gameBoard)
        {
            base.WhenAddedToGameBoard(gameBoard);

            Debug.Assert(Card.Player.ResourceCardsPlacedThisTurn < Player.ResourceCardsCanLay);

            float padding = 10;

            int typeIndex = (int)ResourceCard.ResourceType;
            int cardCount = Card.Player.Resources[typeIndex].Count;

            if (cardCount == 0)
            {
                // We are adding the first resource card of this type
                LocalPosition = new Vector2((-gameBoard.Size.X + ResourceCard.Size.X) * 0.5f + padding, -gameBoard.Size.Y * 0.5f + ResourceCard.Size.Y * 0.5f + padding + typeIndex * (ResourceCard.Size.Y + padding));
            }
            else
            {
                // We are adding another resource card, so overlay it on top and slightly to the side of the previous one
                LocalPosition = Card.Player.Resources[typeIndex][cardCount - 1].Parent.LocalPosition + new Vector2(ResourceCard.Size.X * 0.15f, 0);
            }

            Card.Player.Resources[typeIndex].Add(ResourceCard);
            Card.Player.ResourceCardsPlacedThisTurn++;
        }
        /// <summary>
        /// To decide if this ability is worth playing, we look at the number of ships it will actually affect.
        /// </summary>
        /// <param name="aiGameBoardSection"></param>
        /// <param name="otherGameBoardSection"></param>
        /// <returns></returns>
        public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
        {
            int count = 0;

            foreach (CardShipPair ship in otherGameBoardSection.ShipCardControl)
            {
                if (ship.Ship.ShipData.Defence + ship.Ship.ShipData.Speed <= 5)
                {
                    count++;
                }
            }

            if (count >= 3)
            {
                return(AICardWorthMetric.kGoodCardToPlay);
            }
            else if (count >= 2)
            {
                return(AICardWorthMetric.kAverageCardToPlay);
            }
            else if (count >= 1)
            {
                return(AICardWorthMetric.kBadCardToPlay);
            }
            else
            {
                return(AICardWorthMetric.kShouldNotPlayAtAll);
            }
        }
Пример #3
0
        /// <summary>
        /// If our opponent has a ship as well as it's station, or it's station has a turret then this is a good card to play.
        /// Otherwise this is an average card to play.
        /// </summary>
        /// <param name="aiGameBoardSection"></param>
        /// <param name="otherGameBoardSection"></param>
        /// <returns></returns>
        public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
        {
            if (otherGameBoardSection.ShipCardControl.ChildrenCount > 1 || !(otherGameBoardSection.ShipCardControl.FirstChild() as CardShipPair).Ship.Turret.IsDefaultTurret)
            {
                return(AICardWorthMetric.kGoodCardToPlay);
            }

            return(AICardWorthMetric.kAverageCardToPlay);
        }
        /// <summary>
        /// If the opponent has few ships deployed this is a good card to play.
        /// If they have an average number, this is an average card to play.
        /// If they have a lot deployed, it is a bad card to play.
        /// </summary>
        /// <param name="aiGameBoardSection"></param>
        /// <param name="otherGameBoardSection"></param>
        /// <returns></returns>
        public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
        {
            int numberOfShipsDeployed = otherGameBoardSection.ShipCardControl.ChildrenCount;

            if (numberOfShipsDeployed <= 2)
            {
                return(AICardWorthMetric.kGoodCardToPlay);
            }
            else if (numberOfShipsDeployed <= 3)
            {
                return(AICardWorthMetric.kAverageCardToPlay);
            }
            else
            {
                return(AICardWorthMetric.kBadCardToPlay);
            }
        }
        /// <summary>
        /// Fixes up our UI for the battle screen
        /// </summary>
        public override void Begin()
        {
            // This is used in base.Begin() so must be fixed up before we call that function
            GameBoardSection.ShipCardControl.StationPosition *= new Vector2(1, -1);

            base.Begin();

            LocalRotation = MathHelper.Pi;
            GameBoardSection.LocalRotation = MathHelper.Pi;
            GameBoardSection.ShipCardControl.LocalPosition *= new Vector2(1, -1);

            bool includeChildrenToAdd = true;

            foreach (CardOutline cardOutline in GameBoardSection.GetChildrenOfType <CardOutline>(includeChildrenToAdd))
            {
                cardOutline.LocalPosition *= new Vector2(1, -1);
            }

            UIBoardSection.LocalRotation         = MathHelper.Pi;
            UIBoardSection.HandUI.LocalRotation  = MathHelper.Pi;
            UIBoardSection.DeckUI.LocalPosition *= new Vector2(1, -1);
            UIBoardSection.DeckUI.DeckCountLabel.LocalPosition *= new Vector2(1, -1);
        }
 public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
 {
     return(AICardWorthMetric.kShouldNotPlayAtAll);
 }
Пример #7
0
 public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
 {
     return(AICardWorthMetric.kAverageCardToPlay);
 }
Пример #8
0
 /// <summary>
 /// We should always play resource cards.
 /// They have no cost and there is no reason not to play them.
 /// </summary>
 /// <returns></returns>
 public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
 {
     return(AICardWorthMetric.kShouldDefinitelyPlay);
 }
Пример #9
0
 /// <summary>
 /// The default turret card is never played conventionally like a normal card - it is to fit in with our system only.
 /// Therefore it doesn't matter what we return here - it is never going to be called.
 /// </summary>
 /// <returns></returns>
 public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
 {
     Debug.Fail("This should never be called");
     return(AICardWorthMetric.kShouldNotPlayAtAll);
 }
Пример #10
0
        /// <summary>
        /// When we add a ship to the game board.
        /// Want to update the player's ships placed and set up event callbacks for when this ship dies
        /// </summary>
        /// <param name="gameBoard"></param>
        /// <param name="player"></param>
        public override void WhenAddedToGameBoard(GameBoardSection gameBoard)
        {
            base.WhenAddedToGameBoard(gameBoard);

            ReparentTo(gameBoard.ShipCardControl);   // Reparent this under the card ship control rather than the game board which it was initially added to
        }
Пример #11
0
 /// <summary>
 /// When our AI is analysing the cards it has in it's hands, it needs to work out the best cards to lay.
 /// By analysing the current board set up, other cards the AI has, cards the opponent has down etc. we
 /// can create a value for how good a choice for the AI laying this card will be.
 /// This will also only be called if our card can actually be laid so we do not need to perform that validation here.
 /// </summary>
 public abstract AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection);
Пример #12
0
 /// <summary>
 /// In general this is a good card to play
 /// </summary>
 /// <param name="aiGameBoardSection"></param>
 /// <param name="otherGameBoardSection"></param>
 /// <returns></returns>
 public override AICardWorthMetric CalculateAIMetric(GameBoardSection aiGameBoardSection, GameBoardSection otherGameBoardSection)
 {
     return AICardWorthMetric.kGoodCardToPlay;
 }
Пример #13
0
 /// <summary>
 /// An abstract function used to perform custom fixup when adding to the game board.
 /// Does not trigger any card behaviours, but is more used for shuffling objects around the scene and fixing up sizes.
 /// </summary>
 /// <param name="gameBoard"></param>
 /// <param name="player"></param>
 public virtual void WhenAddedToGameBoard(GameBoardSection gameBoard)
 {
     Card.OnLay();
 }