public Player(Vector2 location, WorldBase world) : base(location, world) { state = new State_Standing(); state.enter(this); rand = new Random(); width = 20; hunger = 100; health = 100; warmth = 100; craftingControlManager = new CraftingScreen(this); guitarControlManager = new GuitarControlManager(this); movementControlManger = new StandardPlayerControlManager(this); currentControlManager = movementControlManger; selectedFrame = texture_player_default_stand; hasLeveledUpThisWorld = false; }
/** * * in actuality, a UI drawer overriden to take advantage of delayedRender. * * */ public virtual void draw(SpriteBatch batch, GameTime time, Point offset) { drawDarkness(batch, time, offset); drawHealthBar(batch, time, offset); drawHungerBar(batch, time, offset); drawColdBar(batch, time, offset); drawSelectedTileIndicator(batch, time, offset); //draw the inventory if (drawInventory) { inventory.draw(batch, time, new Point()); } if (currentControlManager is StandardPlayerControlManager) { StandardPlayerControlManager current = (StandardPlayerControlManager)currentControlManager; if (current.percentageTicksHarvesting > 0) { batch.Draw(Game1.block, new Rectangle(Game1.instance.graphics.PreferredBackBufferWidth / 2, Game1.instance.graphics.PreferredBackBufferHeight / 2, 30, 20), Color.DarkGray); batch.Draw(Game1.block, new Rectangle(Game1.instance.graphics.PreferredBackBufferWidth / 2 + 3, Game1.instance.graphics.PreferredBackBufferHeight / 2, 24, (int)(current.percentageTicksHarvesting * 20)), world.decorator.colorManager.groundColor); } } batch.Draw(Game1.texture_entity_fire_mask, new Rectangle(0, 0, Game1.instance.graphics.PreferredBackBufferWidth, Game1.instance.graphics.PreferredBackBufferHeight), Color.White * (timeNextToAFire / 100) * .9f); currentControlManager.draw(batch); if (cards[0] != null && cards[0].usable) { batch.Draw(Game1.abilityUIElement, new Rectangle(0, Game1.instance.graphics.PreferredBackBufferHeight - Game1.abilityUIElement.Height, Game1.abilityUIElement.Width, Game1.abilityUIElement.Height), Color.DarkGray); batch.Draw(cards[0].iconTex, new Rectangle(42, Game1.instance.graphics.PreferredBackBufferHeight - Game1.abilityUIElement.Height + 5, cards[0].iconTex.Width, cards[0].iconTex.Height), Color.White); for (int i = 0; i < cardCharges; i++) { Color chargeColor = Color.DarkGray; if (cards[0].charges - 1 < i) { chargeColor = Color.DarkGray * .5f; } batch.Draw(Game1.texture_item_charmstone, new Rectangle(20 + 40 * i, Game1.instance.graphics.PreferredBackBufferHeight - Game1.abilityUIElement.Height - 45, Game1.texture_item_charmstone.Width, Game1.texture_item_charmstone.Height), chargeColor); } } if (cards[1] != null && cards[1].usable) { batch.Draw(Game1.abilityUIElement, new Rectangle(Game1.instance.graphics.PreferredBackBufferWidth - Game1.abilityUIElement.Width, Game1.instance.graphics.PreferredBackBufferHeight - Game1.abilityUIElement.Height, Game1.abilityUIElement.Width, Game1.abilityUIElement.Height), null, Color.DarkGray, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0); batch.Draw(cards[1].iconTex, new Rectangle(Game1.instance.graphics.PreferredBackBufferWidth + 5 - Game1.abilityUIElement.Width, Game1.instance.graphics.PreferredBackBufferHeight - Game1.abilityUIElement.Height + 5, cards[1].iconTex.Width, cards[1].iconTex.Height), Color.White); for (int i = 0; i < cardCharges; i++) { Color chargeColor = Color.DarkGray; if (cards[1].charges - 1 < i) { chargeColor = Color.DarkGray * .5f; } batch.Draw(Game1.texture_item_charmstone, new Rectangle(Game1.instance.graphics.PreferredBackBufferWidth - Game1.abilityUIElement.Width - 20 - 40 * i, Game1.instance.graphics.PreferredBackBufferHeight - Game1.abilityUIElement.Height - 45, Game1.texture_item_charmstone.Width, Game1.texture_item_charmstone.Height), chargeColor); } } //draw the items tied to keys if ((craftingControlManager == null || currentControlManager != craftingControlManager) && !(currentControlManager is GuitarControlManager)) { int spaceBetweenKeyedItems = 20; int keyedItemWidth = Game1.UIInventory_KeyedItem.Width; int totalKeyedItemSpace = spaceBetweenKeyedItems * 3 + keyedItemWidth * keyedItems.Length; int keyedItemStartRenderingX = Game1.instance.graphics.PreferredBackBufferWidth / 2 - totalKeyedItemSpace / 2; for (int i = 0; i < keyedItems.Length; i++) { Color keyedItemUIElementColor = Color.DarkGray; if (Game1.keyBindManager.bindings["Inventory_" + i].isDown()) { keyedItemUIElementColor = Color.White; } ; Rectangle drawUIElementRect = new Rectangle( keyedItemStartRenderingX + keyedItemWidth * i + spaceBetweenKeyedItems * i, Game1.instance.graphics.PreferredBackBufferHeight - Game1.UIInventory_KeyedItem.Height, Game1.UIInventory_KeyedItem.Width, Game1.UIInventory_KeyedItem.Height ); batch.Draw(Game1.UIInventory_KeyedItem, drawUIElementRect, keyedItemUIElementColor); if (keyedItems[i] != null) { Rectangle drawItemRect = new Rectangle( drawUIElementRect.X + 15, drawUIElementRect.Y + 15, keyedItems[i].texture.Width, keyedItems[i].texture.Height ); Color color = Color.DarkGray * .5f; if (inventory.getItemOfType(keyedItems[i]) != null) { color = Color.White; batch.DrawString(Game1.gamefont_24, "" + Game1.decimalToBase6(inventory.getItemOfType(keyedItems[i]).uses), drawItemRect.Location.ToVector2() + new Vector2(-15, -15), Color.White); } batch.Draw(keyedItems[i].texture, drawItemRect, color); } } } speechManager.draw(batch, time, offset); }