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 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; } }
// Use this for initialization void Start() { location = transform.position; ItemsForPickup it = gameObject.GetComponent <ItemsForPickup> (); if (it) { if (it.items.Count > 0) { app = application.Inventory; gameObject.GetComponent <SpriteRenderer> ().color = Color.yellow; } } while (player == null) { player = GameObject.FindGameObjectWithTag("Player"); } }
// 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; } } } } }