protected void AddItemForUI(UIInventory uIInventory) { foreach (Item item in characterItems) { uIInventory.AddNewItem(item); } }
public void SpawnInventory() { UIInventory newInv = Instantiate(invPrefab); newInv.transform.SetParent(transform, false); newInv.transform.position = Input.mousePosition; }
private void Awake() { instance = this; // Singleton sprites_items = new Image[5]; sprites_items[0] = (GameObject.FindGameObjectWithTag("slot_1") .GetComponent <Image>()); sprites_items[1] = (GameObject.FindGameObjectWithTag("slot_2") .GetComponent <Image>()); sprites_items[2] = (GameObject.FindGameObjectWithTag("slot_3") .GetComponent <Image>()); sprites_items[3] = (GameObject.FindGameObjectWithTag("slot_4") .GetComponent <Image>()); sprites_items[4] = (GameObject.FindGameObjectWithTag("slot_5") .GetComponent <Image>()); window_slots = new Image[5]; window_slots[0] = GameObject.FindGameObjectWithTag("window_slot_1") .GetComponent <Image>(); window_slots[1] = GameObject.FindGameObjectWithTag("window_slot_2") .GetComponent <Image>(); window_slots[2] = GameObject.FindGameObjectWithTag("window_slot_3") .GetComponent <Image>(); window_slots[3] = GameObject.FindGameObjectWithTag("window_slot_4") .GetComponent <Image>(); window_slots[4] = GameObject.FindGameObjectWithTag("window_slot_5") .GetComponent <Image>(); item_name.text = ""; inventory_container.SetActive(false); actionButtonsText.text = ""; }
private void Awake() { itemImage = this.gameObject.GetComponent <Image>(); selectedItem = GameObject.Find("SelectedItem").GetComponent <UIItem>(); toolTipObject = GameObject.Find("ItemToolTip"); toolTip = GameObject.Find("ItemToolTipText").GetComponent <ItemToolTip>(); ui = GameObject.Find("InventoryPanel").GetComponent <UIInventory>(); }
public void Start() { gameObject.GetComponent <Animator>().runtimeAnimatorController = item.ani; if (inventory is null) { inventory = FindObjectOfType <UIInventory>(); } StartCoroutine(AssignHitBox()); }
/// <summary> /// 只要是使用过的道具,都要进入背包 /// 使用标记来区分是否显示在界面的背包中 /// </summary> /// <param name="data"></param> public void AddProp(PropData data) { m_allProps.Add(data.Id, data); if (data.GetData <PropGetAction>("how_to_get") == PropGetAction.INVENTORY) { UIInventory.AddProp(data); } }
private void Start() { uIInventory = GameObject.FindGameObjectWithTag("UIInventory").GetComponent <UIInventory>(); selectedItem = 0; // 9 is the amount items this iventory can hold storedItems = new StoredItem[9]; }
private void Awake() { itemDatabase = FindObjectOfType <ItemDatabase>(); string inventoryName = craftInventory ? "CraftInventory" : "StoreInventory"; GameObject hud = GameObject.FindGameObjectWithTag("HUD"); GameObject inventory = hud.transform.Find(inventoryName).gameObject; inventoryUI = inventory.GetComponent <UIInventory>(); }
public UIInventory() { // assign singleton only once (to work with DontDestroyOnLoad when // using Zones / switching scenes) if (singleton == null) { singleton = this; } }
public UIInventory PerformSelectCorrectInventoryUI(Item item) { UIInventory uIInventory = FindObjectOfType <ConsumableInventory>().GetUIInventory(); if (IsCraftingItem(item)) { uIInventory = FindObjectOfType <CraftingInventory>().GetUIInventory(); } return(uIInventory); }
void Start() { playerController = GetComponentInParent <PlayerController>(); currentArmor = armor.GetComponent <PlayerArmor>(); currentWeapon = playerController.gameObject.GetComponentInChildren <PlayerWeapon>(); inventoryUI = FindObjectOfType <UIInventory>(); storedArmor.Add(currentArmor.currentArmor); storedWeapons.Add(currentWeapon.currentWeapon); }
private void Start() { uIInventory = GetComponentInParent <UIInventory>(); //quantityText = transform.parent.GetComponentInChildren<Text>(); //spriteImage = GetComponent<Image>(); itemQuantityFull = false; inventory = FindObjectOfType <Inventory>(); inventoryController = FindObjectOfType <InventoryUIController>(); UpdateItem(null, 0); }
public void SetupFor(EquipableItem item, UIInventory inv) { m_Item = item; m_Text.text = item.ItemName; m_SlotSelected.onClick.AddListener(() => { inv.OnEquipmentSelected(item); }); }
public UIInventory SelectCorrectInventoryUI(string itemName) { Item item = itemDatabase.GetItem(itemName); UIInventory uIInventory = FindObjectOfType <ConsumableInventory>().GetUIInventory(); if (IsCraftingItem(item)) { uIInventory = FindObjectOfType <CraftingInventory>().GetUIInventory(); } return(uIInventory); }
private void InitUI() { GameObject UICanvas = GameObject.Find("UICanvas/UI"); GameObject uiObj = GameObject.Instantiate <GameObject>(Resources.Load(UIPREFAB_PATH) as GameObject); uiObj.transform.SetParent(UICanvas.transform, false); UIInventory = uiObj.AddComponent <UIInventory>(); // test //UIInventory.AddProp(new PropData(105)); }
// Use this for initialization void Awake() { Input.backButtonLeavesApp = true; self = this; colorMap[0] = Color.green; colorMap[1] = Color.blue; colorMap[2] = new Color(0f, 1f, 1f); colorMap[3] = Color.black; colorMap[4] = Color.red; colorMap[5] = new Color(1f, 0f, 1f); colorMap[6] = new Color(1f, 1f, 0f); Mesh tileMesh = TilePrefab.GetComponent <MeshFilter>().sharedMesh; baseMainVerts = tileMesh.vertices; convertToSides(tileMesh, baseMainVerts, ref sideVerts); tileMesh.vertices = baseMainVerts; sideView = false; inventory = new Inventory(GameObject.FindGameObjectWithTag("inventory"), false); equipment = new Inventory(GameObject.FindGameObjectWithTag("equipS"), true); myCam = GameObject.FindGameObjectWithTag("Cam2").GetComponent <Camera> (); mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera> (); soundUI = myCam.transform.GetChild(1).GetComponent <AudioSource> (); soundEquip = myCam.transform.GetChild(2).GetComponent <AudioSource> (); playerLocation = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform> (); //playerAnim = playerLocation.GetComponent<Animator> (); //playerFollowL = GameObject.FindGameObjectWithTag ("PlayerFollow").GetComponent<Transform> (); UIInventory.SetActive(false); UINormal.SetActive(false); UIEdit.SetActive(false); UIMove.SetActive(false); UIChat.SetActive(false); UIStats.SetActive(false); UIHaS.SetActive(false); UICompass.SetActive(false); UIOptions.SetActive(false); chCam = chatCam.GetComponent <Camera> (); chCam.enabled = false; //chatCam.SetActive (false); selBox = GameObject.FindGameObjectWithTag("selectBox"); selCirc = GameObject.FindGameObjectWithTag("selectCircle"); selBox.SetActive(false); selCirc.SetActive(false); selectBox = selBox; foreach (EnemyType type in Enum.GetValues(EnemyType.archer.GetType())) { GameObject prefab = Resources.Load <GameObject>("Prefabs/enemy/" + type.ToString()); enemyPrefabs.Add(type, prefab); } }
public void RemoveProp(int id) { if (m_allProps.ContainsKey(id)) { PropData data = m_allProps[id]; m_allProps.Remove(id); if (data.GetData <PropGetAction>("how_to_get") == PropGetAction.INVENTORY) { UIInventory.RemoveProp(id); } } }
protected override void OnInitialize(ModuleConfiguration configuration) { if (InventoryPrefab == null) { InventoryPrefab = Resources.Load <GameObject>(DEFAULT_INVENTORY_PREFAB).GetComponent <UIInventory>(); } InventoryConfig containerConfig = configuration as InventoryConfig; Rows = containerConfig.Rows; Cols = containerConfig.Cols; Storage = new InventorySpace(SlotCount); }
public void OpenCloseContainer() { if (InventoryPanel == null) { InventoryPanel = UIPanel.InstantiatePanel(InventoryPrefab) as UIInventory; InventoryPanel.CreateInventoryGrid(this); UIManager.Manager.AddPanel(InventoryPanel); } else { UIManager.Manager.RemovePanel(InventoryPanel); InventoryPanel = null; } }
private void Awake() { if (SceneManager.GetActiveScene().buildIndex == 1) { player = GameObject.FindGameObjectWithTag("Player"); abilities = player.GetComponent <PlayerAbilities>(); health = player.GetComponent <PlayerHealth>(); exp = player.GetComponent <PlayerExperience>(); equip = player.GetComponent <PlayerEquip>(); movement = player.GetComponent <PlayerMovement>(); inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); uiInventory = GameObject.Find("InventoryPanel").GetComponent <UIInventory>(); abilityBar = GameObject.Find("AbilityBarPanel").GetComponent <UIAbilityBar>(); //skillCanvas = GameObject.Find("SkillPanel").GetComponent<SkillCanvas>(); } }
public UIItemController(UIItemData data) { m_Data = data; m_GameManager = TDCGameManager.GetInstance(); m_Inventory = UIInventory.GetInstance(); m_EffectManager = new EffectManager(); m_EffectManager.LoadEffect(m_Data.EffectPath); m_EffectManager.RegisterCondition("CanActiveEffect", CanActiveEffect); m_EffectManager.RegisterExcuteMethod("PrintDebug", PrintDebug); m_EffectManager.RegisterExcuteMethod("CreateObjectEffect", CreateObjectEffect); m_EffectManager.RegisterExcuteMethod("DropItSelfEffect", DropItSelfEffect); m_EffectManager.RegisterExcuteMethod("AddValueEffect", AddValueEffect); m_EffectManager.RegisterExcuteMethod("SubtractValueEffect", SubtractValueEffect); }
private void Awake() { Instance = this; inventoryUIItemList.SetActive(false); inventoryUICategoryList.SetActive(false); inventoryUISelected.SetActive(false); for (int i = 0; i < (int)ItemCategory.LengthOfEnum; i++) { GameObject obj = Instantiate(categoryItemPrefab, categoryListParent); CategoryItem item = obj.GetComponent <CategoryItem>(); item.Set((ItemCategory)i); allCategories.Add(item); } }
private void SetupInventory() { IUIPanel mainInventoryPanel = UIManager.Instance.MainInventoryUIPanel; UIInventory uiMainInventory = mainInventoryPanel.TheTransform.GetComponent <UIInventory>(); IInventory mainInventory = InventoryManager.Instance.GetInventoryByUUID(inventory_uuid); uiMainInventory.InventoryUUID = mainInventory.InventoryUUID; uiMainInventory.SetupSlots(); IUIPanel actionBarPanel = UIManager.Instance.ActionBarUIPanel; UIInventory uiActionBarInventory = actionBarPanel.TheTransform.GetComponent <UIInventory>(); IInventory actionBarInventory = InventoryManager.Instance.GetInventoryByUUID(actionBayInventory_uuid); uiActionBarInventory.InventoryUUID = actionBarInventory.InventoryUUID; uiActionBarInventory.SetupSlots(); }
private void InitUIInventory() { Canvas canvas = GetComponentInParent <Canvas>(); UIInventory = new UIInventory( inventoryName: InventoryName, dragAreaIndicator: UIInventory_Panel.UIInventoryDragAreaIndicator, dragProcessor: DragProcessor_UIInventoryItem, canvasDistance: canvas.planeDistance, gridSize: GridSize, // UI units rows: Rows, columns: Columns, x_Mirror: X_Mirror, z_Mirror: Z_Mirror, unlockedPartialGrids: UnlockPartialGrids, unlockedGridCount: UnlockedGridCount, dragOutDrop: DragOutDrop, enableScreenClamp: EnableScreenClamp, enableLog: false, toggleUIInventoryKeyDownHandler: () => Input.GetKeyDown(ToggleKey), // Toggle uiInventory rotateItemKeyDownHandler: () => Input.GetKeyDown(KeyCode.R), // Rotate uiInventory item instantiateUIInventoryGridHandler: (parent) => Instantiate(UIInventoryGridPrefab, parent).GetComponent <UIInventoryGrid>(), instantiateUIInventoryItemHandler: (parent) => Instantiate(UIInventoryItemPrefab, parent).GetComponent <UIInventoryItem>(), instantiateUIInventoryItemGridHandler: (parent) => Instantiate(UIInventoryItemGridPrefab, parent).GetComponent <UIInventoryItemGrid>(), instantiateUIInventoryItemVirtualOccupationQuadHandler: (parent) => Instantiate(UIInventoryVirtualOccupationQuadPrefab, parent).GetComponent <UIInventoryVirtualOccupationQuad>() ); UIInventory.ToggleDebugKeyDownHandler = () => Input.GetKeyDown(KeyCode.BackQuote); // Toggle debug log UIInventory.ToggleUIInventoryCallback = ToggleUIInventory; // toggle uiInventory callback UIInventory.ToggleDebugCallback = null; UIInventory_Panel.Init(UIInventory, delegate(UIInventoryItem item) { //Debug.Log($"On Mouse Hover UIInventoryItem {item.name}"); UIInventory_Panel.UIInventoryItemInfoPanel.Show(); UIInventory_Panel.UIInventoryItemInfoPanel.Initialize(item.InventoryItem.ItemContentInfo); }, delegate(UIInventoryItem item) { //Debug.Log($"On Mouse Leave UIInventoryItem {item.name}"); UIInventory_Panel.UIInventoryItemInfoPanel.Hide(); }); UIInventory_Panel.gameObject.SetActive(false); UIInventoryManager.Instance.AddInventory(UIInventory); }
void Start() { playerWeaponController = gameObject.GetComponent <PlayerWeaponController> (); //moveHorizontal = "moveHorizontal" + playerNumber; //moveVertical = "moveVertical" + playerNumber; cursorPointer = Instantiate(cursorPointerPrefab); //cursorPointer.GetComponent<SpriteRenderer> ().color = playerColor; cursorPointer.SetActive(true); minimapIndicator = Instantiate(minimapIndicator, transform.position + new Vector3(0f, -3.5f, 0f), Quaternion.Euler(-90f, 180f, 0f), transform) as GameObject; //minimapIndicator.GetComponentInChildren<Image> ().color = playerColor; //playerIndicator.color = playerColor; SetColor(playerColor); //setup controller and key buttons in UI. uiInventory = UIInventory.Instance; if (playerNumber == 1) { playerControllerButtons = uiInventory.ControllerButtonsP1; playerKeyboardButtons = uiInventory.KeyboardButtonsP1; generalControllerButtons = uiInventory.ControllerButtonsGeneral; generalKeyboardButtons = uiInventory.KeyboardButtonsGeneral; foreach (Image img in playerControllerButtons) { img.gameObject.SetActive(false); } } if (playerNumber == 2) { ToggleInput(); } /* * HorizontalAxis = "Horizontal" + playerNumber; * VerticalAxis = "Vertical" + playerNumber; * ControllerTurningHorizontalAxis = "TurningControllerHorizontal" + playerNumber; * ControllerTurningVerticalAxis = "TurningControllerVertical" + playerNumber; * ControllerMovingHorizontalAxis = "MovingControllerHorizontal" + playerNumber; * ControllerMovingVerticalAxis = "MovingControllerVertical" + playerNumber; */ }
// Start is called before the first frame update public void SetItem(UIItem item) { if (null == item) { if (null != this.item) { this.item.transform.SetParent(null, false); Object.Destroy(this.item.gameObject); } this.item = null; return; } this.item = item; this.item.inventory = this.inventory; item.transform.SetParent(transform, false); item.transform.localPosition = Vector3.zero; item.rectTransform.sizeDelta = new Vector2(rectTransform.rect.width, rectTransform.rect.height); }
private void Update() { if (Input.GetKeyDown("space") && isGrabable && UIInventory.thisUIInventory.GetEmptySlot() >= 0) { isGrabable = true; UIInventory.addOrder(spriteOrder); InitialPosition.IsAvailable = true; Destroy(this.gameObject); } if (isGrabable) { thisGameObject.color = new Color(1, 1, 1, 1f); } else { thisGameObject.color = new Color(1, 1, 1, .4f); } }
void Awake() { m_Instance = this; }
protected override void Start() { base.Start (); m_Inventory = UIInventory.GetInstance (); m_Inventory.SetPlayer(this); UIManager.Instance.Init(this); }