public void Init(Sprite backgroundSprite, Sprite itemSprite, InventoryUIManager parent, Item ie, bool isActiveSlot = false) { backgroundImage.sprite = backgroundSprite; itemImage.sprite = itemSprite; this.parent = parent; this.item = ie; this.isEquipmentSlot = isActiveSlot; //if(isActiveSlot == false) // gameObject.SetActive(ie == null ? false : true); }
//Singleton Instance void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public void OnPointerExit(PointerEventData eventData) { if (Occupied) { m_slotBackground.color = new Color(0.7f, 0.7f, 0.7f); } else { m_slotBackground.color = new Color(1.0f, 1.0f, 1.0f); } InventoryUIManager.ClearHighlightedCell(this); }
void Awake() { if (m_instance == null) { m_instance = this; } else if (m_instance != this) { Destroy(gameObject); return; } }
private void Awake() { if (InventoryUI != null) { Destroy(gameObject); } InventoryUI = this; inventory = new InventoryManager(); itemsHUD = new List <Image>(inventory.inventorySize); }
public void OnPointerEnter(PointerEventData eventData) { if (CanMove) { InventoryUIManager.SetHighlightedItem(this); m_image.color = Color.yellow; } else { m_image.color = Color.red; } }
// TESTING ONLY /*void Update() { * if (Input.GetKeyDown(KeyCode.Alpha1)) { * SampleKeyItem temp = new SampleKeyItem(); * temp.itemName = "Test Item"; * AddItem(temp); * } * }*/ // Only one instance of this should exist to prevent duplicating items to the UI void Awake() { if (instance == null) { instance = this; fade = Fade.CreateFade(gameObject); //SaveData.Load(); This will be done by the GameManager } else { Destroy(this); } }
private void Awake() { _eventSystem = new EventSystem(); _eventSystem.Initialize(); _inputSystem = new InputSystem(); _inputTranslator = new InputTranslator(); _audioManager = new AudioManager(); _audioManager.Initialize(); _bookManager = new BookManager(bookObject, bookCanvas); _worldCanvasManager = new WorldCanvasManager(worldCanvas, textField, scoreImage, sprites); _worldCanvasManager.Initialize(); _inventoryManager = new InventoryManager(); _inventoryManager.Initialize(); _inventoryUIManager = new InventoryUIManager(inventoryCanvas); _sceneMenuUIManager = new SceneMenuUIManager(menuPanel, icon); _jsonManager = new JSONReadManager(); _jsonManager.Initialize(); _jsonManager.LoadFile("FoodObjectFile"); _jsonManager.LoadFile("SceneObjectFile"); _sceneManager = new SceneManager(mainCamera); _sceneManager.Initialize(); // Assign EventTypes to EventListeners // and Add them to the EventSystem's list _eventSystem.addListener(EventType.KEY_PRESSED, _inputTranslator); _eventSystem.addListener(EventType.BOOK_INTERACT, _bookManager); _eventSystem.addListener(EventType.NUM_EVENT_TYPES, _bookManager); _eventSystem.addListener(EventType.BOOK_INTERACT, _audioManager); _eventSystem.addListener(EventType.PAGE_FLIPPED, _audioManager); _eventSystem.addListener(EventType.KNIFE_CUT, _audioManager); _eventSystem.addListener(EventType.POINTS_SCORED, _worldCanvasManager); _eventSystem.addListener(EventType.FOOD_INVENTORY, _inventoryUIManager); _eventSystem.addListener(EventType.SCREEN_PRESSED, _inventoryUIManager); _eventSystem.addListener(EventType.SCENE_MENU, _sceneMenuUIManager); _eventSystem.addListener(EventType.SCREEN_PRESSED, _sceneMenuUIManager); }
private void Awake() { instance = this; for (int i = 0; i < inventorySlots.Count; ++i) { if (!inventoryImages.Contains(inventorySlots[i].GetComponent <Image>())) { inventoryImages.Add(inventorySlots[i].GetComponent <Image>()); } } OnInventoryUpdate += UpdateSprite; }
public override void Init() { playerStats = PlayerStats._instance; craftingManager = CraftingManager._instance; inventoryManager = InventoryUIManager._instance; inputManager = InputManager._instance; UpdateUiState(InputManager.inputState); progressBarFillImage = progressBarFillObj.GetComponent <Image>(); barsDictionary = new Dictionary <StatType, Image> { { StatType.HP, hpFill }, { StatType.Food, foodFill }, { StatType.Water, waterFill }, { StatType.Air, airFill }, { StatType.Sleep, sleepFill }, { StatType.EXP, xpFill } }; }
void Start() { Empty(); inventory = GameObject.Find("GameManager").GetComponent <Inventory> (); inventoryUI = GameObject.Find("GameManager").GetComponent <InventoryUIManager> (); Image damageImage = transform.Find("Damage").transform.Find("DamageIndicator").GetComponent <Image> (); damageImage.fillAmount = 0; inventorySlot = GetComponent <InventorySlot> (); inventorySlot.slotChangedEvent += OnSlotChanged; inventoryLength = inventory.InventoryList.Count; }
public void OnDrag(PointerEventData eventData) { //Debug.Log("button down: " + eventData.button); if (eventData.button.ToString() == "Right") { InventoryUIManager.CreateItemMenu(this); } else { Vector2 newPos = Input.mousePosition - mouseoffset; float newX = Mathf.Min(Mathf.Max(0f, newPos.x), Screen.width); float newY = Mathf.Min(Mathf.Max(0f, newPos.y), Screen.height); transform.position = new Vector3(newX, newY, 0f); m_image.raycastTarget = false; } }
void Start() { _active = gameObject.activeSelf; tooltip = GameObject.Find("UI").transform.Find("Tooltip").gameObject.GetComponent <Tooltip>(); inventoryUI = GameObject.Find("GameManager").GetComponent <InventoryUIManager> (); inventorySelector = GameObject.Find("GameManager").GetComponent <InventorySelector> (); image = GetComponent <Image> (); icon = transform.Find("Icon").GetComponent <Image> (); defaultIcon = icon.sprite; mouseManager = GameObject.Find("GameManager").GetComponent <MouseManager> (); inventory = GameObject.Find("GameManager").GetComponent <Inventory> (); inventory.inventoryChangedEvent += OnInventoryChanged; item = inventory.InventoryList [slotID]; OnInventoryChanged(); }
public static void AttemptSwap(Item item1, Item item2) { InventoryContainer container1 = item1.GetContainer(); InventoryContainer container2 = item2.GetContainer(); GameObject newSlot = Instantiate(m_instance.SlotPrefab, m_instance.transform); InventorySlotUI tempSlot = newSlot.GetComponent <InventorySlotUI>(); tempSlot.m_container = m_instance.m_Container; container1.ClearItem(item1.GetSlot()); tempSlot.AddItem(item1); item1.CurrentSlot = tempSlot; InventoryUIManager.MoveItemTo(item2, container1, item1.GetSlot()); InventoryUIManager.MoveItemTo(item1, container2, item2.GetSlot()); Destroy(newSlot); }
private int currentAmmo; // used by AI only, not player void Start() { currentAmmo = clipSize; inventory = GameObject.Find("GameManager").GetComponent <Inventory> (); gunManager = GameObject.Find("GameManager").GetComponent <GunManager>(); inventoryUI = GameObject.Find("GameManager").GetComponent <InventoryUIManager>(); flashParticles = Instantiate(gunManager.flashParticles); flashParticles.transform.parent = transform; foreach (Transform muzzle in muzzles) { flashParticles.transform.position = muzzle.position; } inventorySelector = GameObject.Find("GameManager").GetComponent <InventorySelector> (); InventorySlotData data = inventorySelector.CurrentSlotObject.GetComponent <InventorySlotData> (); gunManager.ammoUI.SetCurrentAmmo(data.currentAmmo); }
public void OnPointerEnter(PointerEventData eventData) { if (InventoryUIManager.GetCurrentItem() == null) { m_slotBackground.color = new Color(0.5f, 0.5f, 0.5f); } else { ItemUIElement iui = InventoryUIManager.GetCurrentItem(); if (CanFitItem(iui.ItemInfo)) { m_slotBackground.color = new Color(0.5f, 1.0f, 0.5f); } else { m_slotBackground.color = new Color(1.0f, 0.5f, 0.5f); } } InventoryUIManager.SetHighlightedCell(this); }
public void ForceEquip(Item i, string slotname = "primary") { Vector2 targetSlot = new Vector2(-1, -1); InventoryContainer targetContainer = null; foreach (InventoryContainer m_container in m_containers.Values) { Vector2 slot = m_container.getSlot(slotname); if (slot != targetSlot) { targetSlot = slot; targetContainer = m_container; break; } } if (targetContainer == null) { return; } InventoryUIManager.MoveItemTo(i, targetContainer, targetSlot, true); }
public void OnEndDrag(PointerEventData eventData) { if (eventData.button.ToString() == "Left") { m_image.color = Color.gray; if (InventoryUIManager.GetCurrentCell() != null && InventoryUIManager.AttemptMoveItem(this)) { UpdateReturnPos(GetComponent <RectTransform>().localPosition); } else if (InventoryUIManager.GetHighlightedItem() != null) { InventoryUIManager.AttemptSwap(InventoryUIManager.GetHighlightedItem(), this); } else { ReturnPos(); } InventoryUIManager.SetHeldItem(null); m_image.raycastTarget = true; } }
public override void HandleInput(InputPacket ip) { if (m_container == null || InventoryUIManager.IsMenuOpen()) { return; } if (ip.leftMousePress) { m_container.EquipmentSlotUseUpdatePlayer(LeftMouseItem, ip); } if (ip.rightMousePress) { m_container.EquipmentSlotUseUpdatePlayer(RightMouseItem, ip); } if (ip.InputKeyPressed.ContainsKey(InputKey.Reload) && ip.InputKeyPressed[InputKey.Reload]) { bool reloaded = m_container.EquipmentReload(LeftMouseItem, ip); if (!reloaded) { m_container.EquipmentReload(RightMouseItem, ip); } } foreach (InputKey keyID in ButtonActions.Keys) { if (ip.InputKeyPressed.ContainsKey(keyID) && ip.InputKeyPressed[keyID]) { m_container.EquipmentSlotUseUpdatePlayer(ButtonActions[keyID], ip); } } foreach (string s in ip.itemSlotUse) { if (!m_container.EquipmentSlotUseUpdatePlayer(s, ip)) { m_container.ItemNameUseUpdatePlayer(s, ip); } } }
private void Awake() { S = this; Initialize(); }
// Start is called before the first frame update protected void Start() { ivnUIMng = InventoryUIManager.instance; }
protected void Awake() { ivnMng = InventoryHandler.instance; ivnUIMng = InventoryUIManager.instance; Init(); }
void Start() { toolDisplay = FindObjectOfType<ToolDisplayManager> (); inventoryUiManager = FindObjectOfType<InventoryUIManager> (); thoughtBubbleManager = FindObjectOfType<ThoughtBubbleManager> (); sprites = Resources.LoadAll<Sprite> ("Player/" + player.SpriteName); spriteRenderer = GetComponent<SpriteRenderer> (); spriteRenderer.sprite = sprites [4]; if (player.CurrentTool != null) { UpdateCurrentTool (); } if (InventoryInitialised) { inventoryUiManager.LinkInventoryToUI (player.Inventory); player.Inventory.Notify (); } }
private void Start() { PickUpObject = new PickUpObjectScript(); inventoryUI = InventoryUIManager.InventoryUI; }
// Use this for initialization void Start() { ui = FindObjectOfType<RecyclePointUI>(); inventoryUI = FindObjectOfType<InventoryUIManager>(); gameProgress = FindObjectOfType<GameManager>(); player = FindObjectOfType<PlayerAdapter> (); }
public void OnPointerExit(PointerEventData eventData) { InventoryUIManager.ClearHighlightedItem(this); m_image.color = Color.gray; }
public void DisplayContainer() { m_displaying = true; InventoryUIManager.CreateInventoryGUI(this); }
new private void Awake() { base.Awake(); inventoryManager = inventoryPanelGO.GetComponent <InventoryManager>(); inventoryUIManager = inventoryPanelGO.GetComponent <InventoryUIManager>(); }
public void UpdateInventory() { CloseInventoryMenu(); InventoryUIManager.CreateInventoryGUI(Container); }
//实现父类 /// <summary> /// 初始化数据 /// </summary> void InitData() { inventoryUIManager = this.gameObject.GetComponent <InventoryUIManager>(); sacleText = transform.Find("ScalPrice/Text").GetComponent <Text>(); knapcapInfoText = transform.Find("KnapcapInfoText").GetComponent <Text>(); }
private void Start() { inventoryUI = InventoryUIManager._instance; Vis = gameObject.GetComponent <DragNDropVisual>(); SetToggleOutline(true); }
public void CloseContainer() { m_displaying = false; InventoryUIManager.CloseGUIPanel(this); }