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(); }
public void GotChopped(Toon dude) { if (!Data.IsServer) { Sounds.PlaySound(Data.FindSound["WoodChop"]); } health -= (int)dude.GetAttackDamage(); if (health < 0) { if (!Data.IsServer) { Sounds.PlaySound(Data.FindSound["WoodFall"]); } textureKey = "PalmStump"; this.isInteractable = false; Console.WriteLine(health); if (Data.IsServer) { Client.SendEvent(new SpawnWoodEvent(Guid.NewGuid(), new Vector2(position.X - 10, position.Y))); Client.SendEvent(new SpawnCoconutEvent(Guid.NewGuid(), new Vector2(position.X + 20, position.Y + 10))); Console.WriteLine("tesT"); } } }
public Input(Toon dude) { oldState = Mouse.GetState(); this.dude = dude; this.keyboardKeys = new Dictionary<Keys, Action>(); }
public HUD(ContentManager content, Toon dude, int screenHeight, int screenWidth) { spriteFont = content.Load<SpriteFont>("TestFont"); this.dude = dude; topLeftPosition = new Vector2(-screenWidth / 2, -screenHeight / 2); bottomLeftPosition = new Vector2(-screenWidth / 2, screenHeight / 2); bottomRightPosition = new Vector2(screenWidth / 2, screenHeight / 2); bottomMiddlePosition = new Vector2(0, screenHeight / 2); }
public override bool Use(Toon dude) { return false; }
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); }
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)); } }
/// <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 abstract bool Use(Toon dude);
public override bool Use(Toon dude) { dude.replenishHunger(HUNGER_AMOUNT); dude.replenishThirst(THIRST_AMOUNT); return true; }