public void ReceiveEvent(MoveToGameObjectEvent leEvent) { goalGameObject = Map.GetGameObject(leEvent.GoalGameObject); }
//check if the dude clicked on something //if he clicked on something then move him to that thing //move him to where he clicked private void LeftClick(MouseState nowState) { // Do inventory click if (dude.Inventory.inventoryClick(nowState, dude)) return; Vector2 clickPosition = new Vector2(nowState.X - (Game1.graphicsDevice.Viewport.Width * 0.5f), nowState.Y - (Game1.graphicsDevice.Viewport.Height * 0.5f)); clickPosition = dude.Position + clickPosition; List<Tile> tiles = Map.GetRenderedTiles(dude.Position); //NOT YET IMPLEMENTED: find all gameObjects that you have clicked on, find which one you are closest to //the center of and click on that one, this allows you to click on something behind something else foreach (Tile tile in tiles) { foreach (GameObject gameObject in tile.GetGameObjects()) { if (gameObject.IsInteractable) { //if you clicked on a game object, go to that game object if (gameObject.GetHitBox().Contains((int)clickPosition.X, (int)clickPosition.Y)) { Event LeftClickEventz = new MoveToGameObjectEvent(dude.GetId(), gameObject.GetId()); Client.SendEvent(LeftClickEventz); return; } } } } Event LeftClickEvent = new MoveToPositionEvent(dude.GetId(), clickPosition); Client.SendEvent(LeftClickEvent); }