void RandWeather(float prop = 0.2f) { if (Data.Count <= TotalCount) { if (RandUtil.Rand(prop)) { Spawn(WeatherType.Rand <WorldWeatherType>(), new Vector2(RandUtil.RandInt(0, RealCount), RandUtil.RandInt(0, RealCount))); } } }
// 是否可以触发 bool IsInProp(TDBaseEventData eventData) { if (Options.IsMustEvent) { return(true); } if (RandUtil.Rand(eventData.Prob)) { return(true); } return(false); }
public override void RandomTriggerAllAchievement() { ResetAllAchievement(); foreach (var item in SteamUserStats.Achievements) { bool b = RandUtil.Rand(0.5f); if (b) { item.Trigger(b); } } }
public TData Rand() { if (!RandUtil.Rand(GlobalProp)) { return(null); } if (CurRandCount >= MaxRandCount) { CurRandCount = 0; return(null); } CurRandCount++; if (Options.IsNoEvent) { return(null); } if (!SelfBaseUnit.IsPlayerCtrl()) { return(null); } if (TDLuaMgr.Keys.Count == 0) { return(null); } string key = TDLuaMgr.Keys.Rand(); TData config = TDLuaMgr.Get <TData>(key); //判断事件的触发条件 if (IsInTarget(config)) { //判断事件的概率 if (IsInProp(config)) { CurRandCount = 0; if (config.CD > 0) { if (!EventCD.ContainsKey(key)) { EventCD.Add(key, new CD()); } EventCD[key] = new CD(config.CD); } return(Add(config.TDID)); } else { return(null); } } return(Rand()); }