protected override void Update(GameTime gameTime) { performanceDateTime = DateTime.Now; performanceDateTimeTotal = DateTime.Now; keyboardStatePrev = keyboardState; keyboardState = Keyboard.GetState(); mouseStatePrev = mouseState; mouseState = Mouse.GetState(); drawBatch.Begin(); camera.Update(agents[0].PositionXY + agents[0].origin.ToVector2(), mousePosInWorld); if (KeyDown(Keys.H)) { gameObjects.Add(new DroppedItem(new Vector3(mousePosInWorld.X, mousePosInWorld.Y, 16), new Vector3(random.Next(10) - 5, random.Next(10) - 5, (float)(random.NextDouble() * 4)), Item.GetItem(Item.ItemID.Turd, 1))); } if (KeyDown(Keys.J)) { gameObjects.Add(new ExpOrb(new Vector3(mousePosInWorld.X, mousePosInWorld.Y, 16), new Vector3(random.Next(10) - 5, random.Next(10) - 5, (float)(random.NextDouble() * 4)), 50)); } if (KeyDown(Keys.L)) { gameObjects.Add(new Particle.Ember(new Vector3(mousePosInWorld.X, mousePosInWorld.Y, 16), new Vector3(random.Next(10) - 5, random.Next(10) - 5, (float)(random.NextDouble() * 4)), random.Next(50) + 40, Color.Gold, (float)random.NextDouble() + .5f)); } if (KeyPressed(Keys.X)) { switch (SelectionHandler.CurrentTarget) { case SelectionHandler.Target.Tile: SelectionHandler.CurrentTarget = SelectionHandler.Target.GameObject; break; case SelectionHandler.Target.GameObject: SelectionHandler.CurrentTarget = SelectionHandler.Target.Tile; break; default: break; } } if (KeyPressed(Keys.E)) { agents.Add(new Agent(mousePosInWorld, "Gypsit", Agent.Tag.Enemy, CharacterStats.Default)); } //if (KeyPressed(Keys.D1)) // gameObjects.Add(new Projectile.Fireball(agents[0].position + new Vector3(0,0,8), Extensions.GetVector2(new Vector2(mousePosInWorld.X - agents[0].position.X, mousePosInWorld.Y - agents[0].position.Y).GetAngle(), 6f).ToVector3(0), 0, Agent.Tag.Player)); //if (KeyPressed(Keys.D2)) // gameObjects.Add(new Projectile.BouncingBall(agents[0].position + new Vector3(0, 0, 8), Extensions.GetVector2(new Vector2(mousePosInWorld.X - agents[0].position.X, mousePosInWorld.Y - agents[0].position.Y).GetAngle(), 4f).ToVector3(4), 0, Agent.Tag.Player)); mousePosInWorld = new Vector2(((mouseState.X - displayWidth / 2) * ((float)screenWidth / displayWidth) / camera.zoom + camera.pos.X), ((mouseState.Y - displayHeight / 2) * ((float)screenHeight / displayHeight)) / camera.zoom + camera.pos.Y); mouseTile = WorldPosToTile(mousePosInWorld.ToPoint()); if (KeyPressed(Keys.Q)) { if (KeyDown(Keys.LeftShift) && KeyDown(Keys.LeftControl)) { for (int i = 0; i < random.Next(100); i++) { SpawnExplosionEffect(new Vector3(mousePosInWorld.X + random.Next(200) - 100, mousePosInWorld.Y + random.Next(200) - 100, 8), 5f); } for (int i = 0; i < random.Next(100); i++) { SpawnExplosionEffect(new Vector3(mousePosInWorld.X + random.Next(200) - 100, mousePosInWorld.Y + random.Next(300) - 150, 8), 1.2f); } } else if (KeyDown(Keys.LeftShift)) { for (int i = 0; i < random.Next(100); i++) { SpawnExplosionEffect(new Vector3(mousePosInWorld.X + random.Next(200) - 100, mousePosInWorld.Y + random.Next(400) - 200, 8), 1.2f); } } else if (KeyDown(Keys.LeftControl)) { for (int i = 0; i < random.Next(50); i++) { SpawnExplosionEffect(new Vector3(mousePosInWorld.X + random.Next(400) - 200, mousePosInWorld.Y + random.Next(400) - 200, 8), 1f); } } else { SpawnExplosionEffect(new Vector3(mousePosInWorld.X, mousePosInWorld.Y, 8), 1f); } } if (KeyPressed(Keys.K)) { renderShadows = !renderShadows; } if (KeyPressed(Keys.Y)) { renderTargetToDraw = RTFinal; } if (KeyPressed(Keys.U)) { renderTargetToDraw = RTLights; } if (KeyPressed(Keys.I)) { renderTargetToDraw = RTDepthMask; } if (KeyPressed(Keys.O)) { renderTargetToDraw = RTGameWorld; } SelectionHandler.Update(); if (Game1.MouseButtonPressedRight()) { if (SelectionHandler.tag == GameObject.Type.Agent) { int index = GetAgentIndex(SelectionHandler.selectedID); if (index >= 0) { //agents[index].WalkTowardsTile(new Point((int)(mousePosInWorld.X / World.tileSize), (int)(mousePosInWorld.Y / World.tileSize))); agents[index].PathFind(terrain, mouseTile); } } } for (int i = 0; i < damageZones.Count; i++) { if (damageZones[i].lifeSpan > 0) { damageZones[i].Update(); } else { damageZones.RemoveAt(i); i--; } } for (int i = 0; i < gameObjects.Count; i++) { if (!gameObjects[i].remove) { gameObjects[i].Update(); } else { gameObjects.RemoveAt(i); i--; } } for (int i = 0; i < agents.Count; i++) { if (agents[i].GetCurrentHealth() > 0) { if (SelectionHandler.TrySelect && agents[i].SelectionHitBox.Contains(mousePosInWorld)) { SelectionHandler.SelectGameObject(agents[i].ID, agents[i].type); } agents[i].Update(); for (int j = 0; j < damageZones.Count; j++) { if (!damageZones[j].IsTagIgnored(agents[i].tag) && damageZones[j].collider.CollisionCheck(agents[i].collider, false)) { agents[i].TakeDamage(damageZones[j].TakeDamage(agents[i].ID)); } } } else { agents[i].Die(); agents.RemoveAt(i); i--; } } base.Update(gameTime); PerformanceUpdateMSUpdate(); }