private void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(this.transform.gameObject); } // --------------- inventory_Panel = GameObject.Find("Inventory_Panel"); inventory_Slot_Panel = inventory_Panel.transform.Find("Slot_Panel").gameObject; item_DataBase = GameObject.Find("Inventory_Json_Data").GetComponent <Item_Json_DataBase>(); }
public void Init(Item producerAsItem, Producer _producer, Tile_Data _baseTile) { producer = _producer; if (_baseTile.AddProducer(producer) == false) { return; } base.InitMachine(producerAsItem, producer, _baseTile, ShipManager.instance); // The machine controller sets the list of Neighbor tiles, // then we Add the producers on neighbor tiles as well foreach (Tile_Data tile in neighborTiles) { tile.AddProducer(producer); } item_Manager = Item_Manager.instance; timer = new CountdownHelper(0); //storage_inventory = new Inventory(1); inventory_Controller = GetComponentInChildren <Inventory_Controller>(); inventory_Controller.Initialize(ID_Generator.instance.GetMachineID(this), 1); // Position the growth visuals X correctly according to the machine's tile width if (growth_visuals != null) { growth_visuals.transform.localPosition = new Vector2(producer.tileWidth > 1 ? 0.5f : 0, 0.5f); } Debug.Log("Initialized a producer with a blueprint for " + producer.current_Blueprint.itemProduced.itemName); // This runs when a producer has already started producing before if (producer.current_Blueprint.itemProduced.count > 0 && producer.productionStage >= 0) { if (producer.productionStage >= 3) { itemInProduction = item_Manager.CreateInstance(item_Manager.GetPrototype(producer.current_Blueprint.itemProduced.itemName)); SetGrowthVisuals(); CompleteProduction(); return; } StartProduction(true); return; } SetProductionStage(0); // Debug.Log("Producer INITIALIZED: " + " key ingredient = " + producer.productionBlueprints[0].keyIngredient.count + " " + producer.productionBlueprints[0].keyIngredient.itemName + // " secondary ingredient " + producer.productionBlueprints[0].secondaryIngredients[0].count + " " + producer.productionBlueprints[0].secondaryIngredients[0].itemName); }
public void InitCargo(int maxSpacesInNewCargo) { if (currMachine == null) { return; } inventory_Controller = currMachine.gameObject.GetComponentInChildren <Inventory_Controller>(); if (inventory_Controller == null) { Debug.LogError(currMachine.machine.name + " does not have the required Inventory Controller as a child! Did Buildable Manager not add it?"); return; } inventory_Controller.Initialize(ID_Generator.instance.GetMachineID(currMachine), maxSpacesInNewCargo); inventoryUI.Initialize(inventory_Controller.inventory, UI_Manager.instance.shipInventoryPanel); /* if (active_inventory != null){ * // If the new inventory does not match the old, it needs to re-init * // and place any items in active inventory into the new inventory * if (maxSpacesInNewCargo != active_inventory.maxSpaces){ * ReInitInventory(maxSpacesInNewCargo); * } * return; * } * else{ * // Check if there's a saved inventory and LOAD it from there * Inventory savedInventory = Inventory_Manager.instance.LoadInventory(ID_Generator.instance.GetMachineID(currMachine)); * if (savedInventory != null){ * active_inventory = savedInventory; * } * else{ * // Make a new one * active_inventory = new Inventory(maxSpacesInNewCargo); * } * } */ //inventoryUI.Initialize(active_inventory, UI_Manager.instance.shipInventoryPanel); }
// Start is called before the first frame update private void Start() { invCon = GameObject.FindGameObjectWithTag("EventController").GetComponent <Inventory_Controller>(); pickupPrompt = GameObject.FindGameObjectWithTag("InteractPrompt").GetComponent <CanvasGroup>(); }
private void Awake() { amount = 1; inventory = GameObject.Find("Inventory_Controller").GetComponent <Inventory_Controller>(); }
public void Start() { inv = GameObject.FindGameObjectWithTag("EventController").GetComponent <Inventory>(); invCon = GameObject.FindGameObjectWithTag("EventController").GetComponentInChildren <Inventory_Controller>(); }