/// <summary> /// Draws the vehicle info out to screen depending on the controls used /// </summary> /// <param name="spriteBatch"></param> protected void DrawInfo(SpriteBatch spriteBatch) { if (GameWorld.Instance.GetGameState == GameState.Game) { if (control == Controls.WASD) { spriteBatch.DrawString(font, TowerPlacer.ToString(), new Vector2(2, 2), Color.CornflowerBlue); spriteBatch.DrawString(font, "$" + money, new Vector2(2, 20), Color.CornflowerBlue); spriteBatch.DrawString(font, weapon.ToString(), new Vector2(2, Constant.hight - 20), Color.CornflowerBlue); spriteBatch.DrawString(font, "HP: " + Health.ToString(), new Vector2(2, Constant.hight - 40), Color.CornflowerBlue); spriteBatch.DrawString(font, this.ToString(), new Vector2(2, Constant.hight - 60), Color.CornflowerBlue); } else if (control == Controls.UDLR) { spriteBatch.DrawString(font, TowerPlacer.ToString(), new Vector2(Constant.width - font.MeasureString(TowerPlacer.ToString()).X - 2, 2), Color.YellowGreen); spriteBatch.DrawString(font, "$" + money, new Vector2(Constant.width - font.MeasureString(money + " $").X - 2, 20), Color.YellowGreen); spriteBatch.DrawString(font, weapon.ToString(), new Vector2(Constant.width - font.MeasureString(weapon.ToString()).X - 2, Constant.hight - 20), Color.YellowGreen); spriteBatch.DrawString(font, "HP: " + Health.ToString(), new Vector2(Constant.width - font.MeasureString("HP: " + Health.ToString()).X - 2, Constant.hight - 40), Color.YellowGreen); spriteBatch.DrawString(font, this.ToString(), new Vector2(Constant.width - font.MeasureString(this.ToString()).X - 2, Constant.hight - 60), Color.YellowGreen); } DrawLootToString(spriteBatch); spriteBatch.DrawString(font, "Towers: " + GameWorld.Instance.TowerAmount + "/" + Constant.maxTowerAmount, new Vector2(Constant.width / 2 - 50, Constant.hight - 50), Color.Gold); spriteBatch.DrawString(font, "Wave: " + GameWorld.Instance.GetSpawn.Wave, new Vector2(Constant.width / 2 - 50, Constant.hight - 70), Color.Gold); } }
/// <summary> /// Spawns a tower on the vehicle's postition, if the spawn button is pressed and the vehicle has sufficient amount of money. /// </summary> private void BuildTower() { KeyboardState keyState = Keyboard.GetState(); if (((keyState.IsKeyDown(Keys.LeftAlt) || (keyState.IsKeyDown(Keys.G))) && control == Controls.WASD) || ((keyState.IsKeyDown(Keys.OemPeriod) || (keyState.IsKeyDown(Keys.Back))) && control == Controls.UDLR)) { if (builtTimeStamp + Constant.buildTowerCoolDown <= GameWorld.Instance.TotalGameTime) { TowerPlacer.PlaceTower(); builtTimeStamp = GameWorld.Instance.TotalGameTime; } } }
/// <summary> /// creates a vehicle /// </summary> /// <param name="gameObject"></param> /// <param name="control"></param> /// <param name="health"></param> /// <param name="movementSpeed"></param> /// <param name="fireRate"></param> public Vehicle(GameObject gameObject, Controls control, int health, float movementSpeed, float rotateSpeed, int money, TowerType towerType, int playerNumber) : base(gameObject) { this.control = control; this.health = health; this.maxHealth = health; this.movementSpeed = movementSpeed; this.rotateSpeed = rotateSpeed; this.money = money; this.stats = new Stats(this); this.PlayerNumber = playerNumber; this.towerPlacer = new TowerPlacer(this, TowerType.BasicTower, 100000); this.weapon = new BasicWeapon(this.GameObject); IsAlive = true; spriteRenderer = (SpriteRenderer)GameObject.GetComponent("SpriteRenderer"); spriteRenderer.UseRect = true; }