/// <summary> /// Creates a new vat instance. /// </summary> /// <param name="game">The associated game object.</param> /// <param name="gamePlayScreen">Gameplay screen where the vat will be displayed.</param> /// <param name="texture">The vat's texture.</param> /// <param name="position">The position of the vat.</param> /// <param name="score">An associated score bar.</param> public Vat(Game game, GameplayScreen gamePlayScreen, Texture2D texture, Vector2 position, ScoreBar score) : base(game, gamePlayScreen) { this.texture = texture; this.position = position; this.score = score; DrawOrder = (int)(position.Y + Bounds.Height); }
/// <summary> /// Creates a new beehive instance. /// </summary> /// <param name="game">The game object.</param> /// <param name="gamePlayScreen">The gameplay screen.</param> /// <param name="texture">The texture representing the beehive.</param> /// <param name="score">Score object representing the amount of honey in the /// hive.</param> /// <param name="position">The beehive's position.</param> public Beehive(Game game, GameplayScreen gamePlayScreen, Texture2D texture, ScoreBar score, Vector2 position) : base(game, gamePlayScreen) { this.texture = texture; this.score = score; this.position = position; AllowBeesToGenerate = true; DrawOrder = (int)position.Y; }
/// <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> /// Create all the game components. /// </summary> private void CreateGameComponents() { ScoreBar scoreBar = new ScoreBar(ScreenManager.Game, 0, 100, new Vector2(8, 65), 10, 70, Color.Blue, ScoreBar.ScoreBarOrientation.Horizontal, 0, this, true); ScreenManager.Game.Components.Add(scoreBar); // Create the honey jar jar = new HoneyJar(ScreenManager.Game, this, new Vector2(20, 8), scoreBar); ScreenManager.Game.Components.Add(jar); // Create all the beehives and the bees CreateBeehives(); // Create the smoke gun's score bar int totalSmokeAmount = ConfigurationManager.ModesConfiguration[gameDifficultyLevel].TotalSmokeAmount; Vector2 smokeButtonPosition = new Vector2(664, 346) + new Vector2(22, smokeButton.Height - 8); smokeButtonScorebar = new ScoreBar(ScreenManager.Game, 0, totalSmokeAmount, smokeButtonPosition, 12, 70, Color.White, ScoreBar.ScoreBarOrientation.Horizontal, totalSmokeAmount, this, false); ScreenManager.Game.Components.Add(smokeButtonScorebar); // Creates the BeeKeeper beeKeeper = new BeeKeeper(ScreenManager.Game, this); beeKeeper.AnimationDefinitions = animations; beeKeeper.ThumbStickArea = new Rectangle((int)controlstickBoundaryPosition.X, (int)controlstickBoundaryPosition.Y, controlstickBoundary.Width, controlstickBoundary.Height); ScreenManager.Game.Components.Add(beeKeeper); // Create the vat's score bar scoreBar = new ScoreBar(ScreenManager.Game, 0, 300, new Vector2(306, 440), 10, 190, Color.White, ScoreBar.ScoreBarOrientation.Horizontal, 0, this, true); ScreenManager.Game.Components.Add(scoreBar); // Create the vat vat = new Vat(ScreenManager.Game, this, ScreenManager.Game.Content.Load <Texture2D>("Textures/vat"), new Vector2(294, 355), scoreBar); ScreenManager.Game.Components.Add(vat); scoreBar.DrawOrder = vat.DrawOrder + 1; }
/// <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); } } }
/// <summary> /// Create all the game components. /// </summary> private void CreateGameComponents() { Vector2 scaleVector = ScreenManager.SpriteBatch.ScaleVector; Rectangle safeArea = SafeArea; Texture2D jarTexture = ScreenManager.Game.Content.Load<Texture2D>("Textures/honeyJar"); Vector2 honeyJarLocation = safeArea.GetVector() + new Vector2(UIConstants.HoneyJarLeftMargin, UIConstants.HoneyJarTopMargin); Vector2 jarBarLocation = honeyJarLocation + new Vector2(0, jarTexture.Height * scaleVector.Y + 7); ScoreBar scoreBar = new ScoreBar(ScreenManager.Game, 0, 100, jarBarLocation, (int)(jarTexture.Height / 6 * scaleVector.Y), (int)(jarTexture.Width * scaleVector.X), Color.Blue, ScoreBar.ScoreBarOrientation.Horizontal, 0, this, true); ScreenManager.Game.Components.Add(scoreBar); // Create the honey jar jar = new HoneyJar(ScreenManager.Game, this, honeyJarLocation, scoreBar); ScreenManager.Game.Components.Add(jar); // Create all the beehives and the bees CreateBeehives(safeArea, jar); // We only initialize the smoke button position here since we need access // to the screen manager in order to do so (and it is null in the // constructor) smokeButtonPosition = new Vector2(safeArea.Right - UIConstants.SmokeButtonRightAbsoluteMargin, safeArea.Bottom - UIConstants.SmokeButtonBottomAbsoluteMargin); // Create the smoke gun's score bar int totalSmokeAmount = ConfigurationManager.ModesConfiguration[gameDifficultyLevel].TotalSmokeAmount; Vector2 smokeBarLocation = smokeButtonPosition + new Vector2(UIConstants.SmokeButtonSize * scaleVector.X / 8, UIConstants.SmokeButtonSize * scaleVector.Y); smokeButtonScorebar = new ScoreBar(ScreenManager.Game, 0, totalSmokeAmount, smokeBarLocation, (int)(UIConstants.SmokeButtonSize * scaleVector.X / 10), (int)(UIConstants.SmokeButtonSize * scaleVector.Y * 3 / 4), Color.White, ScoreBar.ScoreBarOrientation.Horizontal, totalSmokeAmount, this, false); smokeTextLocation = smokeButtonPosition + new Vector2( UIConstants.SmokeButtonSize * scaleVector.X / 2 - font16px.MeasureString(SmokeText).X * scaleVector.X / 2, UIConstants.SmokeButtonSize * scaleVector.Y * 11 / 10); ScreenManager.Game.Components.Add(smokeButtonScorebar); // Creates the BeeKeeper beeKeeper = new BeeKeeper(ScreenManager.Game, this); beeKeeper.AnimationDefinitions = animations; beeKeeper.ThumbStickArea = new Rectangle((int)controlstickBoundaryPosition.X, (int)controlstickBoundaryPosition.Y, controlstickBoundary.Width, controlstickBoundary.Height); ScreenManager.Game.Components.Add(beeKeeper); // Creates the vat Texture2D vatTexture = ScreenManager.Game.Content.Load<Texture2D>("Textures/vat"); Vector2 vatLocation = new Vector2(safeArea.Center.X - vatTexture.Width * scaleVector.X / 2, safeArea.Bottom - vatTexture.Height * scaleVector.Y - UIConstants.VatBottomMargin); Vector2 vatScorebarLocation = vatLocation + new Vector2((vatTexture.Width * scaleVector.X - UIConstants.VatScorebarWidth) / 2, vatTexture.Height * scaleVector.Y * 7 / 10); scoreBar = new ScoreBar(ScreenManager.Game, 0, 300, vatScorebarLocation, UIConstants.VatScorebarHeight, UIConstants.VatScorebarWidth, Color.White, ScoreBar.ScoreBarOrientation.Horizontal, 0, this, true); vat = new Vat(ScreenManager.Game, this, vatTexture, vatLocation, scoreBar); ScreenManager.Game.Components.Add(vat); vatArrowPosition = vatLocation + new Vector2(vatTexture.Width * scaleVector.X / 2 - arrowTexture.Width * scaleVector.X / 2, UIConstants.VatArrowOffset); ScreenManager.Game.Components.Add(scoreBar); scoreBar.DrawOrder = vat.DrawOrder + 1; }
/// <summary> /// Create all the game components. /// </summary> private void CreateGameComponents() { Vector2 scaleVector = ScreenManager.SpriteBatch.ScaleVector; Rectangle safeArea = SafeArea; Texture2D jarTexture = ScreenManager.Game.Content.Load <Texture2D>("Textures/honeyJar"); Vector2 honeyJarLocation = safeArea.GetVector() + new Vector2(UIConstants.HoneyJarLeftMargin, UIConstants.HoneyJarTopMargin); Vector2 jarBarLocation = honeyJarLocation + new Vector2(0, jarTexture.Height * scaleVector.Y + 7); ScoreBar scoreBar = new ScoreBar(ScreenManager.Game, 0, 100, jarBarLocation, (int)(jarTexture.Height / 6 * scaleVector.Y), (int)(jarTexture.Width * scaleVector.X), Color.Blue, ScoreBar.ScoreBarOrientation.Horizontal, 0, this, true); ScreenManager.Game.Components.Add(scoreBar); // Create the honey jar jar = new HoneyJar(ScreenManager.Game, this, honeyJarLocation, scoreBar); ScreenManager.Game.Components.Add(jar); // Create all the beehives and the bees CreateBeehives(safeArea, jar); // We only initialize the smoke button position here since we need access // to the screen manager in order to do so (and it is null in the // constructor) smokeButtonPosition = new Vector2(safeArea.Right - UIConstants.SmokeButtonRightAbsoluteMargin, safeArea.Bottom - UIConstants.SmokeButtonBottomAbsoluteMargin); // Create the smoke gun's score bar int totalSmokeAmount = ConfigurationManager.ModesConfiguration[gameDifficultyLevel].TotalSmokeAmount; Vector2 smokeBarLocation = smokeButtonPosition + new Vector2(UIConstants.SmokeButtonSize * scaleVector.X / 8, UIConstants.SmokeButtonSize * scaleVector.Y); smokeButtonScorebar = new ScoreBar(ScreenManager.Game, 0, totalSmokeAmount, smokeBarLocation, (int)(UIConstants.SmokeButtonSize * scaleVector.X / 10), (int)(UIConstants.SmokeButtonSize * scaleVector.Y * 3 / 4), Color.White, ScoreBar.ScoreBarOrientation.Horizontal, totalSmokeAmount, this, false); smokeTextLocation = smokeButtonPosition + new Vector2( UIConstants.SmokeButtonSize * scaleVector.X / 2 - font16px.MeasureString(SmokeText).X *scaleVector.X / 2, UIConstants.SmokeButtonSize * scaleVector.Y * 11 / 10); ScreenManager.Game.Components.Add(smokeButtonScorebar); // Creates the BeeKeeper beeKeeper = new BeeKeeper(ScreenManager.Game, this); beeKeeper.AnimationDefinitions = animations; beeKeeper.ThumbStickArea = new Rectangle((int)controlstickBoundaryPosition.X, (int)controlstickBoundaryPosition.Y, controlstickBoundary.Width, controlstickBoundary.Height); ScreenManager.Game.Components.Add(beeKeeper); // Creates the vat Texture2D vatTexture = ScreenManager.Game.Content.Load <Texture2D>("Textures/vat"); Vector2 vatLocation = new Vector2(safeArea.Center.X - vatTexture.Width * scaleVector.X / 2, safeArea.Bottom - vatTexture.Height * scaleVector.Y - UIConstants.VatBottomMargin); Vector2 vatScorebarLocation = vatLocation + new Vector2((vatTexture.Width * scaleVector.X - UIConstants.VatScorebarWidth) / 2, vatTexture.Height * scaleVector.Y * 7 / 10); scoreBar = new ScoreBar(ScreenManager.Game, 0, 300, vatScorebarLocation, UIConstants.VatScorebarHeight, UIConstants.VatScorebarWidth, Color.White, ScoreBar.ScoreBarOrientation.Horizontal, 0, this, true); vat = new Vat(ScreenManager.Game, this, vatTexture, vatLocation, scoreBar); ScreenManager.Game.Components.Add(vat); vatArrowPosition = vatLocation + new Vector2(vatTexture.Width * scaleVector.X / 2 - arrowTexture.Width * scaleVector.X / 2, UIConstants.VatArrowOffset); ScreenManager.Game.Components.Add(scoreBar); scoreBar.DrawOrder = vat.DrawOrder + 1; }
/// <summary> /// Creates a new instance of the component. /// </summary> /// <param name="game">The associated game object.</param> /// <param name="gamePlayScreen">The gameplay screen where the component will be rendered.</param> /// <param name="position">The position of the component.</param> /// <param name="score">Scorebar representing the amount of honey in the jar.</param> public HoneyJar(Game game, GameplayScreen gamePlayScreen, Vector2 position, ScoreBar score) : base(game, gamePlayScreen) { this.position = position; this.score = score; }