public Enemy(Vector2 position, Texture2D texture, int dimensions, Bank bank, Vector2 speed, MainStructure mainStructure, float maxHealth, List <Structure> structures, Player player) : base(position, texture, dimensions, speed) { // bank this.bank = bank; // Set this enemy to know where the main structure is this.mainStructure = mainStructure; // Set armor rating and health health this.armorRating = 0f; this.maxHealth = maxHealth; this.currentHealth = maxHealth; // Set this enemy to face the main structure this.SetAngle((int)mainStructure.Position.X, (int)mainStructure.Position.Y); // Get the distance from this structure to the main one distanceToStructure = this.GetDistanceVector(mainStructure); //Array For structures set this.structures = structures; // Combine structure distance vector with speed in some way so we can decide // where this enemy moves and how fast it moves there this.speed = distanceToStructure; this.speed.Normalize(); this.speed *= 1; this.player = player; }
public EnemyManager(Map map, int screenWidth, int screenHeight, Texture2D plugEnemyModel, Texture2D bar, Player player, Bank bank) { this.generator = new Random(); this.activeEnemies = new List <Enemy>(); this.screenWidth = screenWidth; this.screenHeight = screenHeight; this.map = map; this.listOfTurrets = map.Turrets; this.mainStructure = map.mainStructure; this.timeUntilNextWave = DELAY; this.bar = bar; this.plugEnemyModel = plugEnemyModel; //Starter Enemy this.player = player; this.bank = bank; }
private void Load(string filePath) { Stream inStream = File.OpenRead(filePath); BinaryReader input = new BinaryReader(inStream); int height = input.ReadInt32(); int width = input.ReadInt32(); //set enemy health to input.ReadInt32() //set enemy damage to input.ReadInt32() //set turret health to input.ReadInt32() //set enemy damage to input.ReadInt32() //set main structure health to input.ReadInt32() structures = new Structure[height, width]; sideLength = (int)((screenHeight / height) * 0.8); for (int r = 0; r < height; r++) { for (int c = 0; c < width; c++) { switch (input.ReadInt32()) { case 0: structures[r, c] = new EmptyTile(new Vector2( (int)((screenWidth / 2) - (4.5 - c) * sideLength), (int)((screenHeight / 2) - (4.5 - r) * sideLength)), groundTexture, bank, this, r, c, sideLength, true); break; case 1: structures[r, c] = new BasicTurret(new Vector2( (int)((screenWidth / 2) - (4.5 - c) * sideLength), (int)((screenHeight / 2) - (4.5 - r) * sideLength)), turretTexture, bulletTexture, groundTexture, healthBar, sideLength, r, c, this, bank); break; case 2: if (mainStructure == null) { mainStructure = new MainStructure(new Vector2( (int)((screenWidth / 2) - (4 - c) * sideLength), (int)((screenHeight / 2) - (4 - r) * sideLength)), mainStructureTexture, groundTexture, healthBar, sideLength * 2); structures[r, c] = mainStructure; } break; case 3: structures[r, c] = new Wall(new Vector2( (int)((screenWidth / 2) - (4.5 - c) * sideLength), (int)((screenHeight / 2) - (4.5 - r) * sideLength)), wallTexture, groundTexture, healthBar, bank, this, sideLength, r, c); break; } } } }
public StarterEnemy(Vector2 position, Texture2D texture, Texture2D healthBarTexture, MainStructure mainStructure, List <Structure> structures, Player player, Bank bank, int screenHeight) : base(position, texture, screenHeight / 50, bank, new Vector2(1, 1), mainStructure, 4f, structures, player) { // Set this enemy to do one damage per hit this.damage = 1; // Combine structure distance vector with speed in some way so we can decide // where this enemy moves and how fast it moves there this.speed *= screenHeight / 250; //value for starter Enemy this.texture = texture; healthBar = new HealthBar(new Rectangle(), healthBarTexture); }