Пример #1
0
        /// <summary>
        /// Creates all the beehives and bees.
        /// </summary>
        private void CreateBeehives()
        {
            // Init position parameters
            Vector2 scorebarPosition = new Vector2(18, beehiveTexture.Height - 15);

            Vector2[] beehivePositions =
                new Vector2[5]
            {
                new Vector2(83, 8),
                new Vector2(347, 8),
                new Vector2(661, 8),
                new Vector2(83, 201),
                new Vector2(661, 201)
            };

            // Create the beehives
            for (int beehiveCounter = 0; beehiveCounter < beehivePositions.Length; beehiveCounter++)
            {
                ScoreBar scoreBar = new ScoreBar(ScreenManager.Game, 0, 100, beehivePositions[beehiveCounter] +
                                                 scorebarPosition, 10, 68, 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);
                }
            }
        }
        /// <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 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);
                }
            }
        }