//处理掉落 private void DoDrop() { if (drop == null) { return; } var items = drop.DropItem.SplitToInt(); var pors = drop.Pro.SplitToInt(); foreach (var i in this.BattlePlayers) { var notify = new Notify_Drop(); notify.UserID = i.Value.User.UserID; var gold = GRandomer.RandomMinAndMax(drop.GoldMin, drop.GoldMax); notify.Gold = gold; i.Value.AddGold(gold); if (items.Count > 0) { for (var index = 0; index < items.Count; index++) { if (GRandomer.Probability10000(pors[index])) { i.Value.AddDrop(items[index], 1); notify.Items.Add(new PlayerItem { ItemID = items[index], Num = 1 }); } } } Client client; if (this.Clients.TryToGetValue(i.Value.User.UserID, out client)) { var message = NetProtoTool.ToNetMessage(MessageClass.Notify, notify); client.SendMessage(message); } } }
//处理怪物生成 private void CreateMonster(BattlePerception per) { //process Drop; if (drop != null) { DoDrop(); } { var groupPos = Data.Monsters.Where(t => t != group) .ToArray(); group = GRandomer.RandomArray(groupPos); var groups = LevelData.MonsterGroupID.SplitToInt(); var monsterGroups = ExcelToJSONConfigManager.Current.GetConfigs <MonsterGroupData>(t => { return(groups.Contains(t.ID)); }); var monsterGroup = GRandomer.RandomArray(monsterGroups); drop = ExcelToJSONConfigManager.Current.GetConfigByID <DropGroupData>(monsterGroup.DropID); int maxCount = GRandomer.RandomMinAndMax(monsterGroup.MonsterNumberMin, monsterGroup.MonsterNumberMax); for (var i = 0; i < maxCount; i++) { var m = monsterGroup.MonsterID.SplitToInt(); var p = monsterGroup.Pro.SplitToInt().ToArray(); var monsterID = m[GRandomer.RandPro(p)]; var monsterData = ExcelToJSONConfigManager.Current.GetConfigByID <MonsterData>(monsterID); var data = ExcelToJSONConfigManager.Current.GetConfigByID <CharacterData>(monsterData.CharacterID); var magic = ExcelToJSONConfigManager.Current.GetConfigs <CharacterMagicData>(t => { return(t.CharacterID == data.ID); }); var Monster = per.CreateCharacter(monsterData.Level, data, magic.ToList(), 2, group.Pos.ToGVector3() + new UVector3(GRandomer.RandomMinAndMax(-1, 1), 0, GRandomer.RandomMinAndMax(-1, 1)) * i, new UVector3(0, 0, 0), -1); //data Monster[HeroPropertyType.DamageMax] .SetBaseValue(Monster[HeroPropertyType.DamageMax].BaseValue + monsterData.DamageMax); Monster[HeroPropertyType.DamageMin] .SetBaseValue(Monster[HeroPropertyType.DamageMin].BaseValue + monsterData.DamageMax); Monster[HeroPropertyType.Force] .SetBaseValue(Monster[HeroPropertyType.Force].BaseValue + monsterData.Force); Monster[HeroPropertyType.Agility] .SetBaseValue(Monster[HeroPropertyType.Agility].BaseValue + monsterData.Agility); Monster[HeroPropertyType.Knowledge] .SetBaseValue(Monster[HeroPropertyType.Knowledge].BaseValue + monsterData.Knowledeg); Monster[HeroPropertyType.MaxMP] .SetBaseValue(Monster[HeroPropertyType.MaxHP].BaseValue + monsterData.HPMax); Monster[HeroPropertyType.MaxMP] .SetBaseValue(Monster[HeroPropertyType.MaxMP].BaseValue + monsterData.HPMax); Monster.Name = string.Format("{0}.{1}", monsterData.NamePrefix, data.Name); Monster.Reset(); per.ChangeCharacterAI(data.AIResourcePath, Monster); AliveCount++; Monster.OnDead = (el) => { CountKillCount++; AliveCount--; }; } } }