public static UIWindow 作る(Vector2 場所, bool tickedUp = false, bool visible = true) { Textbox xBox = new Textbox(30, "0"); Textbox yBox = new Textbox(30, "0"); HorizontalGroupBox locBox = new HorizontalGroupBox(0, 0); locBox.Add(new UIText("X:")); locBox.Add(xBox); locBox.Add(new UIText("Y:")); locBox.Add(yBox); Textbox itemIDBox = new Textbox(30, "0"); Button spawnNewItem = new Button("Spawn an item", delegate(EventArgs e) { tryToSpawnItem(itemIDBox.text, xBox.text, yBox.text); }); Itembox spawnedItemBox = new Itembox((Item)null, true); Button boxItemSpawner = new Button("Box item", delegate(EventArgs e) { spawnedItemBox.itemHolder.held = tryToParseItem(itemIDBox.text); }); UIWindow window = new UIWindow(場所, "cheats", 5, 8, (uint)windowTopButtons.titlebar | (uint)windowTopButtons.tickDown | (uint)windowTopButtons.close) { new UIText("Coordinates:"), locBox, new UIText("Item ID:"), itemIDBox, spawnNewItem, spawnedItemBox, boxItemSpawner }; window.Visible = visible; window.tickedUp = tickedUp; return(window); }
public void AddItem(string _name, int _quantity) { Itembox newitem = new Itembox(_name, _quantity, boxorder_gave); list_itemboxs.Add(newitem); boxorder_gave++; Debug.Log("Add"); Sort_Itembox(); if (OnItemChange != null) { OnItemChange(list_itemboxs); } }
public static UIWindow 作る(Vector2 場所, bool tickedUp = false, bool visible = true) { UIWindow window = new UIWindow(場所, "inventory", 5, 8, (uint)windowTopButtons.titlebar | (uint)windowTopButtons.tickDown); const int inventoryRows = 5; const int slotsInRow = Player.inventorySlots / inventoryRows; for (int i = 0; i < inventoryRows; i++) { HorizontalGroupBox row = new HorizontalGroupBox(8, 0); for (int j = 0; j < slotsInRow; j++) { Itembox box = new Itembox((Item)null, true); int loc = slotsInRow * i + j; Main.refmain.localPlayerLoaded += delegate { box.itemHolder = Main.currentPlayer.inventory[loc]; }; row.Add(box); } window.Add(row); } window.Visible = visible; window.tickedUp = tickedUp; return(window); }
/// <summary> /// 不夠/沒有該物件 回傳false /// </summary> /// <returns><c>true</c>, if item was removed, <c>false</c> otherwise.</returns> /// <param name="_n">N.</param> /// <param name="_q">Q.</param> public bool RemoveItem(string _n, int _q) { bool rtn; Itembox removeitem = list_itemboxs.Find(x => x.name == _n); if (removeitem == null) { Debug.LogWarning("remove item not exist"); rtn = false; } removeitem.quantity -= _q; if (removeitem.quantity > 0) { rtn = true; //成功刪除,有剩 } else if (removeitem.quantity == 0) { list_itemboxs.Remove(removeitem); rtn = true; } else { Debug.LogWarning("remove item not enough"); list_itemboxs.Remove(removeitem); rtn = false; } Debug.Log("Remove"); if (OnItemChange != null) { OnItemChange(list_itemboxs); } return(rtn); }