예제 #1
0
 /// <summary>
 /// Creates a new soldier bee instance.
 /// </summary>
 /// <param name="game">Associated game object.</param>
 /// <param name="gamePlayScreen">Gameplay screen where the bee will appear.</param>
 /// <param name="beehive">The bee's associated beehive.</param>
 public SoldierBee(Game game, GameplayScreen gamePlayScreen, Beehive beehive)
     : base(game, gamePlayScreen, beehive)
 {
     AnimationKey = "SoldierBee";
 }
        /// <summary>
        /// Creates all the beehives and bees.
        /// </summary>
        private void CreateBeehives(Rectangle safeArea, HoneyJar jar)
        {
            Vector2 scaleVector = ScreenManager.SpriteBatch.ScaleVector;

            // Init position parameters
            Vector2 scorebarPosition = 
                new Vector2(beehiveTexture.Width * scaleVector.X / 4, beehiveTexture.Height * scaleVector.Y * 9 / 10);

            Vector2[] beehivePositions = new Vector2[5] 
            {           
                // top left
                new Vector2(safeArea.Left + UIConstants.BeehiveLeftMargin, 
                    safeArea.Top + UIConstants.BeehiveTopMargin),
                // top middle
                new Vector2(safeArea.Center.X - beehiveTexture.Width * scaleVector.X / 2, 
                    safeArea.Top + UIConstants.BeehiveTopMargin),
                // top right
                new Vector2(safeArea.Right - beehiveTexture.Width * scaleVector.X - UIConstants.BeehiveRightMargin, 
                    safeArea.Top + UIConstants.BeehiveTopMargin),
                // left
                new Vector2(safeArea.Left + UIConstants.BeehiveLeftMargin, 
                    safeArea.Center.Y - beehiveTexture.Height * scaleVector.Y / 2 + UIConstants.BeehiveMiddleOffset),
                // right
                new Vector2(safeArea.Right - beehiveTexture.Width * scaleVector.X - UIConstants.BeehiveRightMargin, 
                    safeArea.Center.Y - beehiveTexture.Height * scaleVector.Y / 2  + UIConstants.BeehiveMiddleOffset) 
                };

            // Create the beehives
            for (int beehiveCounter = 0; beehiveCounter < beehivePositions.Length; beehiveCounter++)
            {
                ScoreBar scoreBar = new ScoreBar(ScreenManager.Game, 0, 100, beehivePositions[beehiveCounter] +
                                        scorebarPosition, (int)(beehiveTexture.Height * scaleVector.Y / 10),
                                        (int)(beehiveTexture.Width * scaleVector.X / 2), Color.Green, 
                                        ScoreBar.ScoreBarOrientation.Horizontal, 100, this, false);
                ScreenManager.Game.Components.Add(scoreBar);

                Beehive beehive =
                    new Beehive(ScreenManager.Game, this, beehiveTexture, scoreBar, beehivePositions[beehiveCounter]);

                beehive.AnimationDefinitions = animations;

                ScreenManager.Game.Components.Add(beehive);
                beehives.Add(beehive);
                scoreBar.DrawOrder = beehive.DrawOrder;
            }

            for (int beehiveIndex = 0; beehiveIndex < beehivePositions.Length; beehiveIndex++)
            {
                // Create the Soldier bees
                for (int SoldierBeeCounter = 0; SoldierBeeCounter < amountOfSoldierBee; SoldierBeeCounter++)
                {
                    SoldierBee bee = new SoldierBee(ScreenManager.Game, this, beehives[beehiveIndex]);
                    bee.AnimationDefinitions = animations;
                    ScreenManager.Game.Components.Add(bee);
                    bees.Add(bee);
                }

                // Creates the worker bees
                for (int workerBeeCounter = 0; workerBeeCounter < amountOfWorkerBee; workerBeeCounter++)
                {
                    WorkerBee bee = new WorkerBee(ScreenManager.Game, this, beehives[beehiveIndex]);
                    bee.AnimationDefinitions = animations;
                    ScreenManager.Game.Components.Add(bee);
                    bees.Add(bee);
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Creates a new bee instance.
 /// </summary>
 /// <param name="game">The game object.</param>
 /// <param name="gamePlayScreen">The gameplay screen.</param>
 /// <param name="beehive">The related beehive.</param>
 public Bee(Game game, GameplayScreen gamePlayScreen, Beehive beehive)
     : base(game, gamePlayScreen)
 {
     this.relatedBeehive = beehive;
     DrawOrder = Int32.MaxValue - 20;
 }