private void InteractWithObject(Toon toon) { Console.WriteLine("cat smacking the bitch: " + toon.GetId()); interactionOffCooldown = DateTime.Now.AddMilliseconds(interactionCooldown); //<--- this allows the interaction to define the cooldown, ie chopping may take longer than attacking AttackMob(toon); }
/// <summary> /// True if given point is within the inventory bounds /// </summary> public bool inventoryClick(MouseState nowState, Toon dude) { // If click not within inventory return if (!boundsOnScreen.Contains(new Point(nowState.X, nowState.Y))) return false; // Else work out where the click was and then which index that is inside slots int x = (nowState.X - boundsOnScreen.X) / inventorySlotSize; int y = (nowState.Y - boundsOnScreen.Y) / inventorySlotSize; int clickedSlot = x + (y * inventoryCols); // Left and Right Click if (nowState.LeftButton == ButtonState.Pressed) selectedSlot = clickedSlot; else if (nowState.RightButton == ButtonState.Pressed) slots[clickedSlot].dropSlot(dude.Position, dude.GetId()); else if (nowState.MiddleButton == ButtonState.Pressed) slots[clickedSlot].useSlot(dude); return true; }
public void useSlot(Toon dude) { if (items.Count != 0) { if (items.First().Value.Use(dude)) Client.SendEvent(new DestroyItemEvent(dude.GetId(), items.First().Value.Id)); } }
protected override void Initialize() { Thread.Sleep(1000); Console.WriteLine("Guid size: " + Guid.NewGuid().ToByteArray().Length); Data.Initialize(Content); Map.Initialize(12); //the renderWidth should be dynamic to the resolution Client.Initialize(); dude = new Toon(Guid.NewGuid(), new Vector2(100, 100), "link"); Data.Dude = dude; input = new Input(dude); camera = new Camera(); graphicsDevice = graphics.GraphicsDevice; IsMouseVisible = true; graphics.IsFullScreen = false; graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; graphics.ApplyChanges(); HUD = new HUD(this.Content, dude, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferWidth); spriteBatch = new SpriteBatch(GraphicsDevice); Console.WriteLine("published SpawnToonEvent"); Client.SendEvent(new SpawnToonEvent(dude.GetId())); base.Initialize(); }