void CheckThiefActivities() { //开始日期 if (GameData._playerData.dayNow <= GameConfigs.StartThiefEvent) { return; } //上次盗贼光顾时间 if (GameData._playerData.lastThiefTime >= GameData._playerData.dayNow - 2) { return; } //触发盗贼概率 int r = Algorithms.GetIndexByRange(0, 100); // Debug.Log(r); if (r >= (int)(GameData._playerData.ThiefDefence * 100f)) { return; } GameData._playerData.lastThiefTime = GameData._playerData.dayNow; _gameData.StoreData("LastThiefTime", GameData._playerData.lastThiefTime); Thief[] tList = LoadTxt.GetThiefList(); int[] weight = new int[tList.Length]; int[] ids = new int[weight.Length]; int i = 0; for (int key = 0; key < tList.Length; key++) { weight [i] = tList[key].weight; ids [i] = key; i++; } i = Algorithms.GetResultByWeight(weight); Thief _thisThief = tList[ids [i]]; int antiAlert = LoadTxt.GetMonster(_thisThief.monsterId).level; int alert = GetGuardAlert(); //发现概率 int p = 0; if (alert > 2 * antiAlert) { p = 10000; } else if (antiAlert > alert * 5) { p = 0; } else { p = alert * 10000 / (alert + antiAlert); } r = Random.Range(0, 10000); if (r <= p) { CatchThief(_thisThief); } else { BeStolen(_thisThief); } }