public void Update(Player p, NodeManager worker) { if (!isDisabled) { //increment cooldown timer reload.update(); if (reload.ring()) { p.ammo++; worker.cash += 10+minerals; reload.set(rate); } } }
//private void Load(Game game) //{ // image = game.Content.Load<Texture2D>("Images/node"); // imageBox = new Rectangle(Xpos, Ypos, image.Width, image.Height); //} public void updateUpgrades(EnemyManager director, Player p, NodeManager worker) { ResourceRegen.update(); if (ResourceRegen.ring()) { p.ammo++; ResourceRegen.set(timer); } if (Trait1 != null) { Trait1.Update(director); } if (Trait2 != null) { Trait2.Update(director); } if (Trait3 != null) { Trait3.Update(p, worker); Trait3.workHarderBy(40); } }
public void update(Game game, LinkedList<Projectile> projectiles, NodeManager nodes) { foreach (Enemy e in minionsToBeAdded) { minions.AddLast(e); } minionsToBeAdded = new LinkedList<Enemy>(); foreach (Enemy curr in minions) { curr.Update(); } MinionSpawn.update(); Difficulty.update(); if (MinionSpawn.ring()) { MinionSpawn.set(MinionSpawnTime); add(game); } if (Difficulty.ring()) { if (MinionSpawnTime > 25) MinionSpawnTime--; if (DiffTime > 100) DiffTime -= 10; if (MinionSpeed < 2) MinionSpeed += 0.1f; Difficulty.set(DiffTime); } //new LinkedList<Enemy> killed = new LinkedList<Enemy>(); foreach (Enemy e in minions) { //Detects Collision for Explosion foreach (Projectile p in projectiles) { if (p.explode) { double dx = e.position.X - p.position.X; double dy = e.position.Y - p.position.Y; if (Math.Sqrt(dx * dx + dy * dy) < (p.currentRadius + e.image.Width / 2)) e.explode = true; } } if (e.explode) foreach (Enemy x in minions) { double dx = x.position.X - e.position.X; double dy = x.position.Y - e.position.Y; if (Math.Sqrt(dx * dx + dy * dy) < (e.currentRadius + x.image.Width / 2)) x.explode = true; } //<-------semi colon? if (e.isDead) { killed.AddLast(e); points += 100; //points per kill -V nodes.cash += 100; } if (e.position.Y > 650) killed.AddLast(e); } // Removes Killed Enemies foreach (Enemy e in killed) minions.Remove(e); }
public void Update(Game game, NodeManager nodes, EnemyManager director) { currentState = Mouse.GetState(); //check for collisions with player, stun if there are collisions if (updateCollision(director) && !isStunned) { isStunned = true; } if (isStunned) { stun.update(); if (stun.ring()) { isStunned = false; stun.set(stuntime); } } if (prevState.LeftButton == ButtonState.Pressed && currentState.LeftButton == ButtonState.Released) { // Check to see if mouse click was on a node (if so make it active) if (!nodes.isClicked(currentState, game)) { if(!(prevState.Y > 625)&&!(currentState.Y > 625)) { // Else fire projectile if (ammo >= 1 && !isStunned) { fireProjectile(game); shotsfired++; } } } } prevState = currentState; LinkedList<Projectile> deadProjectiles = new LinkedList<Projectile>(); foreach (Projectile p in projectiles) { p.Update(); //new if (p.isDead) deadProjectiles.AddLast(p); } // removes the dead projectiles from the active ones foreach (Projectile p in deadProjectiles) projectiles.Remove(p); //end new }