public override void OnEnter() { base.OnEnter(); treasureMain.m_goBuyWindow.SetActive(true); DataTreasureParam data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == treasure_serial.Value); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id); treasureMain.icon_buy.Initialize(data, master); treasureMain.m_txtPrice.text = MasterTreasure.GetSellPrice(data, master).ToString(); treasureMain.m_btnBuyYes.onClick.AddListener(() => { DataTreasureParam remove_data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == treasure_serial.Value); MasterTreasureParam remove_master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == remove_data.treasure_id); int add_gold = MasterTreasure.GetSellPrice(remove_data, remove_master); DataManager.Instance.AddCoin(add_gold); DataManager.Instance.dataTreasure.list.Remove(remove_data); Fsm.Event("buy"); }); treasureMain.m_btnBuyCancel.onClick.AddListener(() => { Fsm.Event("cancel"); }); }
public override void OnEnter() { base.OnEnter(); treasureMain.m_btnEdit.gameObject.SetActive(false); treasureMain.m_btnAlbum.gameObject.SetActive(false); treasureMain.m_btnBuyBulk.interactable = false; treasureMain.m_txtBuyBulkPrice.text = "0"; treasureMain.m_goBulkPriceRoot.SetActive(true); treasureMain.m_btnBuyBulkCancel.onClick.RemoveAllListeners(); treasureMain.m_btnBuyBulkCancel.onClick.AddListener(() => { Finish(); }); treasureMain.m_btnBack.gameObject.SetActive(true); treasureMain.m_btnBack.onClick.RemoveAllListeners(); treasureMain.m_btnBack.onClick.AddListener(() => { Finish(); }); bulk_list.Clear(); foreach (IconInventry icon in treasureMain.treasure_list) { icon.OnSelect(false); icon.OnClickTreasure.RemoveAllListeners(); icon.OnClickTreasure.AddListener(OnSelectListTreasure); } treasureMain.m_btnBuyBulk.onClick.RemoveAllListeners(); treasureMain.m_btnBuyBulk.onClick.AddListener(() => { int total_price = 0; foreach (DataTreasureParam buy in bulk_list) { DataTreasureParam data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == buy.serial); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id); total_price += MasterTreasure.GetSellPrice(data, master); } DataManager.Instance.AddCoin(total_price); foreach (DataTreasureParam buy in bulk_list) { DataManager.Instance.dataTreasure.list.Remove(buy); } DataManager.Instance.dataTreasure.Save(); DataManager.Instance.user_data.Save(); Finish(); }); }
private void OnSelectListTreasure(DataTreasureParam arg0) { if (0 < arg0.equip) { return; } if (bulk_list.Contains(arg0)) { bulk_list.Remove(arg0); } else { bulk_list.Add(arg0); } foreach (IconInventry icon in treasureMain.treasure_list) { bool bFlag = false; foreach (DataTreasureParam w in bulk_list) { if (w.serial == icon.m_dataTreasure.serial) { bFlag = true; } } icon.OnSelect(bFlag); } int total_price = 0; foreach (DataTreasureParam buy in bulk_list) { DataTreasureParam data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == buy.serial); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id); total_price += MasterTreasure.GetSellPrice(data, master); } treasureMain.m_txtBuyBulkPrice.text = total_price.ToString(); treasureMain.m_btnBuyBulk.interactable = 0 < bulk_list.Count; }