private void OnClickLocation(GameObject btn, object sender) { if (MainView.instacne != null) { if (TimeManager.Instance.IsOver()) { var lastData = RankingModel.Instance.GetLast(); int curScore = PlayerData.Instance.Money; //判断是否上榜 //if上班 调用榜单 if (lastData != null && RankingModel.Instance.mPlayerInfoList.Count > 20 && int.Parse(lastData.Money.ToString()) > curScore) { //显示结束界面 TipProxy.ShowTip("GameOver"); } else { UIManager.Instance.ShowUIView(View.RankingTipView); //显示界面 } return; } //更新欠债 PlayerData.Instance.Debt = (int)(PlayerData.Instance.Debt * 1.1f); //倒计时 TimeManager.Instance.CountDown(); //更新商品 事件 MainView.instacne.UpdateMarket((int)sender, TimeManager.Instance.TimeCount == 0); UIManager.Instance.Hide(View.LocationSelectView); } }
private void OnClickConfirm(GameObject btn, object sender) { if (string.IsNullOrEmpty(inputName.text)) { TipProxy.ShowTip(Localization.Get("请输入你的名字")); return; } PlayerData.Instance.mName = inputName.text; UIManager.Instance.ShowUIView(View.RankingListView); RankingModel.Instance.UpdateRankingList(new BmobTab_RankingList(PlayerData.Instance.mName, PlayerData.Instance.Repute, PlayerData.Instance.Health, PlayerData.Instance.Money, inputMsg.text)); UIManager.Instance.Hide(View.RankingTipView); }
/// <summary> /// 存钱 /// </summary> private void SaveMoney(string text) { if (int.TryParse(text, out money)) { if (PlayerData.Instance.Cash >= money) { PlayerData.Instance.AddCach = -money; PlayerData.Instance.AddDeposit = money; } else { TipProxy.ShowTip(Localization.Get("Money_NotEnough")); } } }
/// <summary> /// 展示界面 /// </summary> public void ShoePostofficeView() { GetPostofficeEventList(); if (listPost == null || listPost.Count <= 0) { TipProxy.ShowTip(Localization.Get("出大事了")); return; } int idx = UnityEngine.Random.Range(0, listPost.Count); Tab_Postoffice tab = listPost[idx]; //显示通知 TextWrop.Instance.ShowContent(mNoticeText, String.Format(tab.Introduce, PlayerData.Instance.Debt)); //处理按钮 mConfirmObj.transform.Find("Text").GetComponent <Text>().text = PlayerData.Instance.Debt > 0 ? Localization.Get("Btn_Repay") : Localization.Get("Btn_Confirm"); }
/// <summary> /// 展示界面 /// </summary> public void ShowHospitalView() { GetHospitalEventList(); if (listEvent == null || listEvent.Count <= 0) { TipProxy.ShowTip(Localization.Get("UI_Function_Warn")); return; } int idx = UnityEngine.Random.Range(0, listEvent.Count); Tab_Hospial tab = listEvent[idx]; //显示通知 string msg = string.Format(tab.Introduce, tab.Cost); TextWrop.Instance.ShowContent(mNoticeText, msg); //加载确定方法 AddButtonEvent(mConfirmObj, OnClickConfirm, tab); }
/// <summary> /// 展示界面 /// </summary> public void ShowRentalView() { GetHospitalEventList(); if (listEvent == null || listEvent.Count <= 0) { TipProxy.ShowTip(Localization.Get("UI_Function_Warn")); return; } int idx = UnityEngine.Random.Range(0, listEvent.Count); Tab_Rental tab = listEvent[idx]; int price = Mathf.Max(tab.PriceMin, PlayerData.Instance.Cash / 2); string msg = string.Format(tab.Introduce, PlayerData.Instance.RoomMax, price, tab.Size); //显示通知 TextWrop.Instance.ShowContent(mNoticeText, msg); //加载确定方法 AddButtonEvent(mConfirmObj, OnClickConfirm, tab); }
private void OnClickConfirm(GameObject btn, object sender) { Tab_Hospial tab = sender as Tab_Hospial; if (tab == null) { return; } if (PlayerData.Instance.Cash >= tab.Cost) { PlayerData.Instance.Cash -= tab.Cost; PlayerData.Instance.Health = 100; } else { TipProxy.ShowTip(Localization.Get("UI_Hospital_Warn")); } UIManager.Instance.Hide(View.HospitalView); DetailDataView.instance.UpdatePlayData(); }
private void OnClickConfirm(GameObject btn, object sender) { Tab_Rental tab = sender as Tab_Rental; if (tab == null) { return; } if (PlayerData.Instance.Cash >= tab.PriceMin) { PlayerData.Instance.Cash -= Mathf.Max(tab.PriceMin, PlayerData.Instance.Cash / 2); PlayerData.Instance.RoomMax = tab.Size; } else { TipProxy.ShowTip(Localization.Get("UI_Hospital_Warn")); } UIManager.Instance.Hide(View.RentalView); DetailDataView.instance.UpdatePlayData(); }
public void Show(GoodItemData data) { gameObject.SetActive(true); goodData = data; goodNameText.text = Localization.Get("商品名称: ") + data.goodName; if (!data.isDepot) { //假如是仓库显示 // 标题 titleText.text = Localization.Get("买进"); // 当前价格 curPriceText.text = Localization.Get("当前价格: ") + data.goodPrice.ToString(); // 剩余资金 monseText.text = Localization.Get("剩余资金: ") + PlayerData.Instance.Cash.ToString(); // 最多购买 剩余空间 int leftNum = PlayerData.Instance.Cash / data.goodPrice; goodNumText.text = Localization.Get("最多购买: ") + (leftNum < PlayerData.Instance.LeftRoom ? leftNum : PlayerData.Instance.LeftRoom).ToString(); inputText.text = (leftNum < PlayerData.Instance.LeftRoom ? leftNum : PlayerData.Instance.LeftRoom).ToString(); } else { //标题 titleText.text = Localization.Get("出售"); // 当前价格 GoodItemData item = GoodData.Instance.mMarketGoods.Find(a => a.goodId == data.goodId); if (item == null) { //表示没卖的 TipProxy.ShowTip(Localization.Get("没卖的")); gameObject.SetActive(false); return; } curPriceText.text = Localization.Get("当前价格: ") + item.goodPrice.ToString(); // 买进均价 monseText.text = Localization.Get("买进均价: ") + data.goodPrice.ToString(); // 最大盈亏 goodNumText.text = Localization.Get("最大盈亏: ") + ((item.goodPrice - data.goodPrice) * data.goodNum).ToString(); inputText.text = data.goodNum.ToString(); } }
/// <summary> /// 购买商品 /// </summary> /// <param name="goodData">商品</param> public void BuyGoods(GoodItemData goodData, int buyNum) { if (goodData == null) { return; } //判断商品是否超出承受范围 if (buyNum > PlayerData.Instance.LeftRoom) { TipProxy.ShowTip("GoodNumOver"); return; } GoodItemData depotGood = mDepotGoods[goodData.goodId]; int allNum = (depotGood.goodNum + buyNum); depotGood.goodPrice = allNum > 0 ? (depotGood.goodPrice * depotGood.goodNum + goodData.goodPrice * buyNum) / allNum : 0; depotGood.goodNum = depotGood.goodNum + buyNum; mDepotGoods[goodData.goodId] = depotGood; this.Cash -= goodData.goodPrice * buyNum; this.GoodRoom += buyNum; }