public void ItemSell(int selectedViewNum, int selectedID, int price, Stack <ItemUndoData> upgradeList, bool undo = false) { if (!purchaseState) { return; } // 장신구가 아니면 if (selectedViewNum != 7) { gold += Mathf.RoundToInt(price * 0.7f); item[selectedViewNum - 1] = 0; } else { gold += Mathf.RoundToInt(price * 0.7f); accessoryItem = 0; } if (!undo) { ItemUndoData iud = new ItemUndoData(); iud.type = "sell"; iud.ViewNum = selectedViewNum; iud.itemID = selectedID; iud.price = Mathf.RoundToInt(price * 0.7f); upgradeList.Push(iud); } ItemUpdate(); }
public void ItemPurchase(int selectedID, int price, bool accessory, Stack <ItemUndoData> upgradeList, bool undo = false) { if (!purchaseState) { return; } if (!BootsCheck(selectedID)) { return; } if (gold < price) { return; } if (!accessory) { for (int i = 0; i < item.Length; i++) { if (item[i] == 0) { gold -= price; item[i] = selectedID; if (!undo) { ItemUndoData iud = new ItemUndoData(); iud.type = "buy"; iud.ViewNum = i + 1; iud.itemID = selectedID; iud.price = price; upgradeList.Push(iud); } break; } } } else { if (accessoryItem == 0) { gold -= price; accessoryItem = selectedID; if (!undo) { ItemUndoData iud = new ItemUndoData(); iud.type = "buy"; iud.ViewNum = 7; iud.itemID = selectedID; iud.price = price; upgradeList.Push(iud); } } } ItemUpdate(); }
public void ItemPurchase(int selectedID, int price, bool accessory, bool undo = false) { if (!purchaseState) { return; } if (gold < price) { SoundManager.instance.PlaySound(SoundManager.instance.Button_Click); return; } if (!accessory) { for (int i = 0; i < item.Length; i++) { if (item[i] == 0) { gold -= price; item[i] = selectedID; if (!undo) { ItemUndoData iud = new ItemUndoData(); iud.type = "buy"; iud.ViewNum = i + 1; iud.itemID = selectedID; iud.price = price; ItemUndoList.Push(iud); SoundManager.instance.PlaySound(SoundManager.instance.Shop_Buy); } break; } } } else { if (accessoryItem == 0) { gold -= price; accessoryItem = selectedID; if (!undo) { ItemUndoData iud = new ItemUndoData(); iud.type = "buy"; iud.ViewNum = 7; iud.itemID = selectedID; iud.price = price; ItemUndoList.Push(iud); SoundManager.instance.PlaySound(SoundManager.instance.Shop_Buy); } } } ItemUpdate(); }
public void ItemUpgrade(bool[] search, int selectedID, int price, bool accessory) { ItemUndoData iud = new ItemUndoData(); iud.type = "upgrade"; iud.upgradeList = new Stack <ItemUndoData>(); ItemUndoList.Push(iud); ItemDelete(search, iud.upgradeList); ItemPurchase(selectedID, price, accessory, iud.upgradeList); }
public bool ItemUndo() { if (!purchaseState) { return(false); } if (ItemUndoList.Count > 0) { ItemUndoData lastaction = ItemUndoList.Pop(); if (lastaction.type == "buy") { ItemSell(lastaction.ViewNum, lastaction.itemID, lastaction.price, true); //gold += Mathf.RoundToInt(lastaction.price * 0.3f); ItemUpdate(); return(true); } else if (lastaction.type == "sell") { ItemPurchase(lastaction.ViewNum, lastaction.itemID, lastaction.price, true); } else if (lastaction.type == "upgrade") { while (lastaction.upgradeList.Count > 0) { ItemUndoData lastupgrade = lastaction.upgradeList.Pop(); if (lastupgrade.type == "buy") { ItemSell(lastupgrade.ViewNum, lastupgrade.itemID, lastupgrade.price, true); //gold += Mathf.RoundToInt(lastupgrade.price * 0.3f); } else if (lastupgrade.type == "sell") { ItemPurchase(lastupgrade.ViewNum, lastupgrade.itemID, lastupgrade.price, true); } } ItemUpdate(); return(true); } } ItemUpdate(); return(false); }
public void ItemSell(int selectedViewNum, int selectedID, int price, bool undo = false) { // 장신구가 아니면 if (selectedViewNum != 7) { gold += Mathf.RoundToInt(price * 0.7f); item[selectedViewNum - 1] = 0; } else { gold += Mathf.RoundToInt(price * 0.7f); accessoryItem = 0; } if (!undo) { ItemUndoData iud = new ItemUndoData(); iud.type = "sell"; iud.ViewNum = selectedViewNum; iud.itemID = selectedID; iud.price = Mathf.RoundToInt(price * 0.7f); ItemUndoList.Push(iud); } }