public override void OnEnter() { base.OnEnter(); main.m_goBuyWindow.SetActive(true); DataWeaponParam data = DataManager.Instance.dataWeapon.list.Find(p => p.serial == weapon_serial.Value); MasterWeaponParam master = DataManager.Instance.masterWeapon.list.Find(p => p.weapon_id == data.weapon_id); main.icon_buy.Initialize(data, master); main.m_txtPrice.text = MasterWeapon.GetSellPrice(data, master).ToString(); main.m_btnBuyYes.onClick.AddListener(() => { DataWeaponParam remove_data = DataManager.Instance.dataWeapon.list.Find(p => p.serial == weapon_serial.Value); MasterWeaponParam remove_master = DataManager.Instance.masterWeapon.list.Find(p => p.weapon_id == remove_data.weapon_id); int add_gold = MasterWeapon.GetSellPrice(remove_data, remove_master); DataManager.Instance.AddCoin(add_gold); DataManager.Instance.dataWeapon.list.Remove(remove_data); DataManager.Instance.dataWeapon.Save(); DataManager.Instance.user_data.Save(); Fsm.Event("buy"); }); main.m_btnBuyCancel.onClick.AddListener(() => { Fsm.Event("cancel"); }); }
public override void OnEnter() { base.OnEnter(); main.m_goBulkBuyWindow.SetActive(true); main.m_btnBuyBulk.interactable = false; main.m_btnEquip.gameObject.SetActive(false); main.m_btnAlbum.gameObject.SetActive(false); main.m_btnBulk.gameObject.SetActive(false); main.m_btnCancel.onClick.RemoveAllListeners(); main.m_btnCancel.onClick.AddListener(() => { Finish(); }); main.m_txtBulkCoin.text = "0"; bulk_list.Clear(); foreach (IconInventry icon in main.weapon_list) { icon.OnSelect(false); icon.OnClickWeapon.AddListener(OnSelectListWeapon); } main.m_btnList.gameObject.SetActive(true); main.m_btnList.onClick.AddListener(() => { Fsm.Event("list"); }); main.m_btnBuyBulk.onClick.RemoveAllListeners(); main.m_btnBuyBulk.onClick.AddListener(() => { int total_price = 0; foreach (DataWeaponParam buy in bulk_list) { DataWeaponParam data = DataManager.Instance.dataWeapon.list.Find(p => p.serial == buy.serial); MasterWeaponParam master = DataManager.Instance.masterWeapon.list.Find(p => p.weapon_id == data.weapon_id); total_price += MasterWeapon.GetSellPrice(data, master); } DataManager.Instance.AddCoin(total_price); foreach (DataWeaponParam buy in bulk_list) { DataManager.Instance.dataWeapon.list.Remove(buy); } DataManager.Instance.dataWeapon.Save(); DataManager.Instance.user_data.Save(); Finish(); }); }
private void OnSelectListWeapon(DataWeaponParam arg0) { if (0 < arg0.equip) { return; } if (bulk_list.Contains(arg0)) { bulk_list.Remove(arg0); } else { bulk_list.Add(arg0); } foreach (IconInventry icon in main.weapon_list) { bool bFlag = false; foreach (DataWeaponParam w in bulk_list) { if (w.serial == icon.m_dataWeapon.serial) { bFlag = true; } } icon.OnSelect(bFlag); } int total_price = 0; foreach (DataWeaponParam buy in bulk_list) { DataWeaponParam data = DataManager.Instance.dataWeapon.list.Find(p => p.serial == buy.serial); MasterWeaponParam master = DataManager.Instance.masterWeapon.list.Find(p => p.weapon_id == data.weapon_id); total_price += MasterWeapon.GetSellPrice(data, master); } main.m_txtBulkCoin.text = total_price.ToString(); main.m_btnBuyBulk.interactable = 0 < bulk_list.Count; }