void onClick_Btn_nowgain_Btn(GameObject caster) { MineDataBase db = GameTableManager.Instance.GetTableItem <MineDataBase>(homeDM.StoneID); if (db != null) { int count = (int)Math.Ceiling((double)homeDM.MineLeftTime / db.immediatelyGainTime); int gainTime = (int)homeDM.MineGainTime; if (homeDM.IsMineVIP) { gainTime = (int)homeDM.VipGainTime; } IncreaseDataBase idb = GameTableManager.Instance.GetTableItem <IncreaseDataBase>(3, gainTime); if (idb != null) { count = (int)Math.Ceiling(count * idb.increase); } string tips = DataManager.Manager <TextManager>().GetLocalFormatText(114531, count); TipsManager.Instance.ShowTipWindow(TipWindowType.CancelOk, tips, () => { if (homeDM.HasEnoughDianJuan(count)) { stImmediMineHomeUserCmd_CS cmd = new stImmediMineHomeUserCmd_CS(); cmd.is_vip = homeDM.IsMineVIP; NetService.Instance.Send(cmd); } else { Log.Error("元宝不足"); } }); } }
/// <summary> /// 通过[索引ID]二分快速查表 /// </summary> /// <param name="dwID">索引ID</param> /// <returns></returns> public static IEnumerable <IncreaseDataBase> Query(this List <IncreaseDataBase> sorted, uint dwID) { var key = new IncreaseDataBase() { dwID = dwID }; var comparer = new Comparer1(); var from = sorted.BinarySearch(key, comparer); if (from < 0) { yield break; } var to = from + 1; while (from > 0 && comparer.Compare(key, sorted[from - 1]) == 0) { from--; } while (to < sorted.Count && comparer.Compare(key, sorted[to]) == 0) { to++; } for (var i = from; i < to; i++) { yield return(sorted[i]); } }
/// <summary> /// 通过[索引ID + 每日使用次数]二分快速查表 /// </summary> /// <param name="dwID">索引ID</param> /// <param name="useTimes">每日使用次数</param> /// <returns></returns> public static IncreaseDataBase Query(this List <IncreaseDataBase> sorted, uint dwID, uint useTimes) { var key = new IncreaseDataBase() { dwID = dwID, useTimes = useTimes }; var comparer = new Comparer2(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(IncreaseDataBase)); }
void OnClickPlant(HomeEntityInfo info) { uint index = (uint)info.index; if (info.state != (int)CreatureSmallState.CanGain && info.state != (int)CreatureSmallState.None) { uint seedID = 0; if (seedIndexDic.TryGetValue(index, out seedID)) { SeedAndCubDataBase sdb = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID); if (sdb != null && sdb.type == 0) { uint leftTime = 0; if (plantAndAnimalRemainTimeDic.TryGetValue((int)index, out leftTime)) { Double c = (double)leftTime / sdb.growUnitTime; c = c * sdb.growUnitCostCoupons; IncreaseDataBase idb = GameTableManager.Instance.GetTableItem <IncreaseDataBase>(1, (int)PlantFastRipeNum); int count = 0; if (idb != null) { count = (int)Math.Ceiling(c * idb.increase); } Engine.Utility.Log.LogGroup("LC", "剩余时间:" + leftTime.ToString() + " 立即成熟单位时长:" + sdb.growUnitTime + " 基础单位费用:" + sdb.growUnitCostCoupons + " 使用次数:" + PlantFastRipeNum + " 涨 幅:" + idb.increase.ToString() + " 元宝数:" + count.ToString()); if (HasEnoughDianJuan(count)) { string tips = DataManager.Manager <TextManager>().GetLocalFormatText(114533, count); TipsManager.Instance.ShowTipWindow(TipWindowType.CancelOk, tips, () => { stImmediRipeHomeUserCmd_CS cmd = new stImmediRipeHomeUserCmd_CS(); cmd.land_id = index; NetService.Instance.Send(cmd); info.state = (int)CreatureSmallState.CanGain; }); } else { TipsManager.Instance.ShowTips("目前还没有通用充值界面,此处后期再做处理"); } } } } } else if (info.state == (int)CreatureSmallState.CanGain) { this.GainOnePlant(info.index); } }