public Toolbox(Sprite sprite, Vector2 position, InventoryHUD playerInventory, InventoryHUD toolboxInventory) : base(sprite, position) { _playerInventory = playerInventory; _toolboxInventory = toolboxInventory; _playerInventory.ToggleButtons(false); _toolboxInventory.SetActive(false); }
public void InitInventoryHandler(GameObject HUD) { if (HUD.GetComponent <InventoryHUD>() != null) { InventoryHUD = HUD.GetComponent <InventoryHUD>(); InventoryHUD.gameObject.SetActive(true); } }
public InventoryHUD() { if (instance != null) { //Debug.LogWarning("More than one instance of class InventoryHUD in scene."); return; } instance = this; }
private void Awake() { inventoryHUD = InventoryHUD.instance; if (instance != null) { Debug.LogWarning("More than one instance of class inventory in scene."); return; } instance = this; }
private void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } else if (instance != this) { // Then destroy this.This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } }
/// <summary> /// Generates the player inventory and HUD logic /// </summary> private void GenerateHud() { // Player and Toolbox Inventories Vector2 guiScale = new Vector2(_cameraScale, _cameraScale); Sprite btnSprite = new Sprite(_game.Content.Load <Texture2D>("GUI/inventory_slot")); Vector2 inventoryPos = new Vector2(900f, 100f); Inventory pInventory = new Inventory(); Vector2 toolboxInventoryPos = new Vector2(400f, 400f); Inventory tInventory = new Inventory { slots = 4 }; Sprite drillSprite = new Sprite(_game.Content.Load <Texture2D>("Items/drill")); Item drill = new Item(drillSprite, ItemType.Drill); tInventory.AddItem(drill); Sprite filterSprite = new Sprite(_game.Content.Load <Texture2D>("Items/O2Filter")); Item filter = new Item(filterSprite, ItemType.Filter); tInventory.AddItem(filter); Sprite swSprite = new Sprite(_game.Content.Load <Texture2D>("Items/screwdriver")); Item sw = new Item(swSprite, ItemType.Screwdriver); tInventory.AddItem(sw); Sprite wrenchSprite = new Sprite(_game.Content.Load <Texture2D>("Items/wrench")); Item wrench = new Item(wrenchSprite, ItemType.Wrench); tInventory.AddItem(wrench); tInventory.SetDepositInventory(pInventory); pInventory.SetDepositInventory(tInventory); _playerInventoryHud = new InventoryHUD(inventoryPos, btnSprite, guiScale, pInventory); _toolboxInventoryHud = new InventoryHUD(toolboxInventoryPos, btnSprite, guiScale, tInventory); // Player health bar Sprite hpBorder = new Sprite(_game.Content.Load <Texture2D>("GUI/healthbar_border")); Sprite hpFill = new Sprite(_game.Content.Load <Texture2D>("GUI/healthbar_fill")); _healthBar = new HealthBar(hpFill, hpBorder, new Vector2(180f, 50f), guiScale * 2); }
// Use this for initialization void Start() { inventoryInfo = GameObject.Find("ItemDatabase").GetComponent <InventoryHUD>(); }
private void Awake() { instance = this; }
void Start() { mInventoryHUD = GameObject.Find("InventoryHUD").GetComponent<InventoryHUD>(); }