public void PressedButton(string optionName) { MenuController menuC = gameObject.GetComponent <MenuController> (); ItemsForPickup curTile = gameObject.GetComponent <PlayerMovement> ().currentTile.GetComponent <ItemsForPickup> (); PlayerEquipped eq = gameObject.GetComponent <PlayerEquipped> (); int curInvSlotIndex = (int)currentInvSlot; switch (optionName) { case "Drop": GameObject itemToDrop = menuC.curNode.children [menuC.index].item; curTile.AddItemToTile(itemToDrop); RemoveItem(menuC.curNode.children [menuC.index]); if (invNode.children [curInvSlotIndex].children.Count == 0) { invNode.children [curInvSlotIndex].AddChild(new Node("No Items found here.")); } break; case "Equip": GameObject itemToEquip = menuC.curNode.children [menuC.index].item; ItemInfo it = itemToEquip.GetComponent <ItemInfo> (); for (int i = 0; i < eq.slots.Length; i++) { if ((int)it.slotPos == (int)eq.slots[i].slot) { eq.EquipItem(itemToEquip, eq.slots [i].slot); } } break; } }
public void Activate() { PlayerEquipped eq = player.GetComponent <PlayerEquipped> (); if (app == application.None) { if (tileType == tileTypes.Grass && farmAble) { if (eq.slots [0].equippedItem.GetComponent <ItemInfo> ().toolType == ItemInfo.toolTypes.Hoe) { SillTile(); } } } if (app == application.Dialogue) { OpenDialoguePopUp(); } if (app == application.Inventory) { ItemsForPickup item = gameObject.GetComponent <ItemsForPickup> (); item.OpenTileInventory(); } if (app == application.Breakdown) { BreakDownAble brDown = gameObject.GetComponent <BreakDownAble> (); brDown.BreakDown(); } }
public void UpdateStatNodes(Node equippedNode) { PlayerEquipped eq = gameObject.GetComponent <PlayerEquipped> (); int statsIndexStart = eq.slots.Length + 1; equippedNode.children [statsIndexStart].title = "Health : " + curHealth + " / " + maxHealth; equippedNode.children [statsIndexStart + 1].title = "Stamina : " + curStamina + " / " + maxStamina; equippedNode.children [statsIndexStart + 2].title = "Mana : " + curMana + " / " + maxMana; }
public void MoveOut() { if (level > 0) { switch (curCat) { case categories.Inventory: PlayerInventory inv = gameObject.GetComponent <PlayerInventory> (); inv.MoveInOutInventory(false, level, index); break; case categories.Player: PlayerEquipped eq = gameObject.GetComponent <PlayerEquipped> (); eq.MoveInOutEquipped(false, level); break; } } }
public void MoveIn() { if (level == 0 && curNode.title == menuNode.title) { curCat = (categories)index; } switch (curCat) { case categories.Inventory: PlayerInventory inv = gameObject.GetComponent <PlayerInventory> (); inv.MoveInOutInventory(true, level, index); break; case categories.Player: PlayerEquipped eq = gameObject.GetComponent <PlayerEquipped> (); eq.MoveInOutEquipped(true, level); break; } }
public void BreakDown() { bool canBreakDown = true; GameObject player = GameObject.FindGameObjectWithTag("Player"); PlayerEquipped eq = player.GetComponent <PlayerEquipped> (); if (reqTool != tools.any) { if (eq.slots [0].equippedItem != null) { ItemInfo it = eq.slots [0].equippedItem.GetComponent <ItemInfo> (); if ((int)it.toolType != (int)reqTool) { canBreakDown = false; } } else { canBreakDown = false; } } if (canBreakDown) { gameObject.AddComponent(typeof(ItemsForPickup)); ItemsForPickup it = gameObject.GetComponent <ItemsForPickup> (); it.CreatePickUpNode(); foreach (GameObject item in drops) { it.AddItemToTile(item); } SpriteRenderer thisSprite = gameObject.GetComponent <SpriteRenderer> (); thisSprite.sprite = groundSprite; gameObject.tag = "Untagged"; } else { } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("M")) { OpenCloseMenuScreen(); if (menuShowing) { } else { ChangeCurrentNode(menuNode, 0); } } if (menuShowing) { if (Input.GetButtonDown("Down")) { MoveDown(); } if (Input.GetButtonDown("Up")) { MoveUp(); } if (Input.GetButtonDown("Right")) { MoveIn(); } if (Input.GetButtonDown("Left")) { MoveOut(); } if (curNode.children.Count > 0 && displayArrow) { menuObject.transform.GetChild(index).GetChild(1).gameObject.GetComponent <Text> ().text = ">"; } //Accounts for extra frame where the childCount hasnt caught up yet displayArrow = true; for (int i = 0; i < curOptions.Count; i++) { if (Input.GetButtonDown(curOptions [i].key.ToString())) { switch (curCat) { case categories.Inventory: PlayerInventory inv = gameObject.GetComponent <PlayerInventory> (); inv.PressedButton(curOptions[i].title); break; case categories.Player: PlayerEquipped eq = gameObject.GetComponent <PlayerEquipped> (); eq.PressedButton(i); break; case categories.Magic: break; case categories.Building: break; case categories.Crafting: break; case categories.Settings: break; case categories.PickUpScreen: ItemsForPickup it = altMenuObject.GetComponent <ItemsForPickup> (); it.PressedButton(i); break; } } } } }