protected override void Update(GameTime gameTime) { FlatRedBallServices.Update(gameTime); Screens.ScreenManager.Activity(); Entity entChar = (Entity)alEntities[0]; sDebugInfo = "Character( X: " + entChar.X.ToString() + " Y: " + entChar.Y.ToString() + " )\n"; sDebugInfo += "Mouse( X: " + InputManager.Mouse.WorldXAt(0) + " Y: " + InputManager.Mouse.WorldYAt(0) + " )\n"; sDebugInfo += "Camera Z: " + SpriteManager.Camera.Z.ToString() + "\n"; sDebugInfo += "Viewable Tiles: " + spriteGrid.VisibleSprites.Count + "\n"; sDebugInfo += "Total Entities: " + alEntities.Count.ToString() + "\n"; #region MouseOver Detection foreach (Entity ent in alEntities) { if (GuiManager.Cursor.IsOn(ent.Collision)) { sDebugInfo += "Mouse over: " + ent.Name; if (ent.Interactive) sDebugInfo += " [Interactive]\n"; else sDebugInfo += "\n"; if (ent.Interactive) ent.Collision.Visible = true; if (GuiManager.Cursor.PrimaryDown) { if (ent.Interactive) { if (Vector3.Distance(entChar.Position, ent.Position) < 6.0f) { sDebugInfo += "Mouse grabbing : " + ent.Name + "\n\n[Holding]\n"; sDebugInfo += ent.ToString() + "\n\n"; ent.Grabbed = true; ent.X = GuiManager.Cursor.WorldXAt(0); ent.Y = GuiManager.Cursor.WorldYAt(0); entChar.HoldID = ent.Name; ent.RotationZ -= InputManager.Mouse.ScrollWheel / 4; ent.Collision.RotationZ -= InputManager.Mouse.ScrollWheel / 4; ent.Collision.UpdateDependencies(TimeManager.CurrentTime); } else { ent.Grabbed = false; entChar.HoldID = null; } } } else { ent.Grabbed = false; entChar.HoldID = null; } } else { if (!ent.DebugHitbox) ent.Collision.Visible = false; } } #endregion #region Collisions foreach (Entity ent in alEntities) { foreach (Entity ent2 in alEntities) { if (!ent.Equals(ent2)) { if (ent.Collision.CollideAgainst(ent2.Collision)) { if (ent.Grabbed != true && ent2.Grabbed != true) { if (ent.Equals(entChar)) { sDebugInfo += "Player colliding with: " + ent2.Name; sDebugInfo += " [Mass: " + ent2.Mass.ToString() + "]\n"; } ent.Collision.CollideAgainstMove(ent2.Collision, ent.Mass, ent2.Mass); } } } } } #endregion #region Player Control Handling Vector3 vDest; entChar.Velocity = new Vector3(0f, 0f, 0f); entChar.Instructions.Clear(); if (InputManager.Mouse.ButtonDown(FlatRedBall.Input.Mouse.MouseButtons.RightButton)) { vDest = new Vector3(InputManager.Mouse.WorldXAt(0), InputManager.Mouse.WorldYAt(0), 0); float fMoveTime = entChar.MovementSpeed * Vector3.Distance(entChar.Position, vDest); if (Vector3.Distance(entChar.Position, vDest) > 6.0) fMoveTime /= 2; InstructionManager.MoveToAccurate(entChar, vDest.X, vDest.Y, 0, fMoveTime); } else { if (InputManager.Keyboard.KeyDown(Keys.Left) && InputManager.Keyboard.KeyDown(Keys.Up)) { InstructionManager.MoveToAccurate(entChar, entChar.X - fWorldUnit, entChar.Y + fWorldUnit, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Left) && InputManager.Keyboard.KeyDown(Keys.Down)) { InstructionManager.MoveToAccurate(entChar, entChar.X - fWorldUnit, entChar.Y - fWorldUnit, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Right) && InputManager.Keyboard.KeyDown(Keys.Up)) { InstructionManager.MoveToAccurate(entChar, entChar.X + fWorldUnit, entChar.Y + fWorldUnit, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Right) && InputManager.Keyboard.KeyDown(Keys.Down)) { InstructionManager.MoveToAccurate(entChar, entChar.X + fWorldUnit, entChar.Y - fWorldUnit, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Left)) { InstructionManager.MoveToAccurate(entChar, entChar.X - fWorldUnit, entChar.Y, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Right)) { InstructionManager.MoveToAccurate(entChar, entChar.X + fWorldUnit, entChar.Y, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Up)) { InstructionManager.MoveToAccurate(entChar, entChar.X, entChar.Y + fWorldUnit, 0, entChar.MovementSpeed); } else if (InputManager.Keyboard.KeyDown(Keys.Down)) { InstructionManager.MoveToAccurate(entChar, entChar.X, entChar.Y - fWorldUnit, 0, entChar.MovementSpeed); } } SpriteManager.Camera.X = entChar.X; SpriteManager.Camera.Y = entChar.Y; if (entChar.HoldID == null) { SpriteManager.Camera.Z -= InputManager.Mouse.ScrollWheel * 2; } #endregion tDebugInfo.SetPixelPerfectScale(SpriteManager.Camera); tDebugInfo.DisplayText = sDebugInfo; spriteGrid.Manage(); base.Update(gameTime); }