public virtual void Start() { if (Started) { return; } Started = true; Asda2EventMgr.SendMessageToWorld("Deffence town event started in {0}. [{1}-{2}]", Town, MinLevel, MaxLevel); _spawnTasks.IsRunning = true; _map.DefenceTownEvent = this; foreach (var npcSpawnEntry in NpcEntries) { var entry = npcSpawnEntry; _spawnTasks.CallDelayed(entry.TimeToSpawnMillis, () => { var npc = entry.NpcEntry.SpawnAt(_map, entry.MovingPoints[0]); npc.Brain.State = BrainState.DefenceTownEventMove; npc.Brain.MovingPoints = entry.MovingPoints; npc.Brain.DefaultState = BrainState.DefenceTownEventMove; }); } _spawnTasks.CallDelayed(1000, () => World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 1 stated.", _map.Name), Color.Red)); _spawnTasks.CallDelayed(180000, () => World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 2 stated.", _map.Name), Color.Red)); _spawnTasks.CallDelayed(360000, () => World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 3 stated.", _map.Name), Color.Red)); _spawnTasks.CallDelayed(540000, () => World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 4 stated.", _map.Name), Color.Red)); _spawnTasks.CallDelayed(720000, () => World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 5 stated.", _map.Name), Color.Red)); _spawnTasks.CallDelayed(940000, () => World.BroadcastMsg("Event Manager", string.Format("{0} town defence FINAL BOSS WAVE!", _map.Name), Color.Red)); _spawnTasks.CallDelayed(1400000, () => Stop(true)); }
/// <summary>Начинает эвент угадай слово</summary> /// <param name="word">секретное слово</param> /// <param name="precison">точность от 50 до 100 в процентах</param> public static void StartGueesWordEvent(string word, int precison, string gmName) { if (Asda2EventMgr.IsGuessWordEventStarted || word == null) { return; } Asda2EventMgr.SendMessageToWorld( "Guess word event started. {0} is event manager. Type your answer to global chat.", (object)gmName); Asda2EventMgr.IsGuessWordEventStarted = true; Asda2EventMgr._percision = 100f / (float)precison; Asda2EventMgr._word = word.ToLower(); }
public virtual void Start() { if (this.Started) { return; } this.Started = true; Asda2EventMgr.SendMessageToWorld("Deffence town event started in {0}. [{1}-{2}]", (object)this.Town, (object)this.MinLevel, (object)this.MaxLevel); this._spawnTasks.IsRunning = true; this._map.DefenceTownEvent = this; foreach (NpcSpawnEntry npcEntry in this.NpcEntries) { NpcSpawnEntry entry = npcEntry; this._spawnTasks.CallDelayed(entry.TimeToSpawnMillis, (Action)(() => { NPC npc = entry.NpcEntry.SpawnAt(this._map, entry.MovingPoints[0], false); npc.Brain.State = BrainState.DefenceTownEventMove; npc.Brain.MovingPoints = entry.MovingPoints; npc.Brain.DefaultState = BrainState.DefenceTownEventMove; })); } this._spawnTasks.CallDelayed(1000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 1 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(180000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 2 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(360000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 3 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(540000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 4 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(720000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence WAVE 5 stated.", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(940000, (Action)(() => WCell.RealmServer.Global.World.BroadcastMsg("Event Manager", string.Format("{0} town defence FINAL BOSS WAVE!", (object)this._map.Name), Color.Red))); this._spawnTasks.CallDelayed(1400000, (Action)(() => this.Stop(true))); }
public static void TryGuess(string word, Character senderChr) { lock (typeof(Asda2EventMgr)) { if (!Asda2EventMgr.IsGuessWordEventStarted) { return; } string lower = word.ToLower(); float num = 0.0f; for (int index = 0; index < lower.Length && index < Asda2EventMgr._word.Length; ++index) { if ((int)lower[index] == (int)Asda2EventMgr._word[index]) { ++num; } } if ((double)num / (double)Asda2EventMgr._word.Length < (double)Asda2EventMgr._percision) { return; } int experience = CharacterFormulas.CalcExpForGuessWordEvent(senderChr.Level); int eventItems = CharacterFormulas.EventItemsForGuessEvent; Asda2EventMgr.SendMessageToWorld("{0} is winner. Prize is {1} exp and {2} event items.", (object)senderChr.Name, (object)experience, (object)eventItems); senderChr.GainXp(experience, "guess_event", false); ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => senderChr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId), eventItems, "guess_event", false))); Asda2EventMgr.StopGueesWordEvent(); Log.Create(Log.Types.EventOperations, LogSourceType.Character, senderChr.EntryId) .AddAttribute("win", (double)eventItems, "guess_event").Write(); } }
public static void StopGueesWordEvent() { Asda2EventMgr.SendMessageToWorld("Guess word event ended."); Asda2EventMgr.IsGuessWordEventStarted = false; }
public virtual void Stop(bool success) { if (!this.Started) { return; } this.Started = false; Asda2EventMgr.SendMessageToWorld("Deffence town event stoped in {0} [{2}-{3}]. Status : {1}", (object)this.Town, success ? (object)"Win" : (object)"Loose", (object)this.MinLevel, (object)this.MaxLevel); this._spawnTasks.IsRunning = false; this._spawnTasks.Clear(); this._map.DefenceTownEvent = (DeffenceTownEvent)null; if (success) { float num1 = (float)this._lives / (float)CharacterFormulas.DefenceTownLives; float num2 = (float)this.ExpPortionsTotal * num1; float num3 = (float)this.EventItemsTotal * num1; this.NotifyBestDamagers(); List <object> objectList = new List <object>(); Dictionary <object, long> dictionary = new Dictionary <object, long>(); foreach (KeyValuePair <object, long> damage in this.Damages) { Group key = damage.Key as Group; if (key != null) { List <GroupMember> list = key.Where <GroupMember>((Func <GroupMember, bool>)(m => { if (m.Character != null && m.Character.Level >= this.MinLevel) { return(m.Character.Level <= this.MaxLevel); } return(false); })).ToList <GroupMember>(); foreach (GroupMember groupMember in list) { if (this.Damages.ContainsKey((object)groupMember.Character)) { objectList.Add((object)groupMember.Character); } dictionary.Add((object)groupMember.Character, damage.Value / (long)list.Count); } objectList.Add(damage.Key); } } WCell.RealmServer.Global.World.BroadcastMsg("Rewarder", string.Format("Damagers count is {0}.", (object)this.Damages.Count), Color.OrangeRed); foreach (object key in objectList) { this.Damages.Remove(key); } foreach (KeyValuePair <object, long> keyValuePair in dictionary) { this.Damages.Add(keyValuePair.Key, keyValuePair.Value); } long num4 = this.Damages.Sum <KeyValuePair <object, long> >( (Func <KeyValuePair <object, long>, long>)(d => d.Value)); WCell.RealmServer.Global.World.BroadcastMsg("Rewarder", string.Format("Total damage is {0}.", (object)num4), Color.OrangeRed); foreach (KeyValuePair <object, long> keyValuePair in (IEnumerable <KeyValuePair <object, long> >) this .Damages.OrderByDescending <KeyValuePair <object, long>, long>( (Func <KeyValuePair <object, long>, long>)(kvp => kvp.Value))) { Character chr = keyValuePair.Key as Character; try { if (chr != null) { if (chr.Asda2Inventory != null) { float num5 = (float)keyValuePair.Value / (float)num4; int experience = (int)((double)num5 * (double)num2 * (double)XpGenerator.GetBaseExpForLevel(chr.Level)); int num6 = (int)((double)num5 * (double)num3); chr.GainXp(experience, "defence_town_event", false); if (num6 > 0) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => chr.Asda2Inventory.AddDonateItem( Asda2ItemMgr.GetTemplate(CharacterFormulas.DonationItemId), 100, "defence_town_event", false))); } WCell.RealmServer.Global.World.BroadcastMsg("Rw", string.Format("{2} gain {0} coins and {1} exp for {3} dmg.", (object)100, (object)experience, (object)chr.Name, (object)keyValuePair.Value), Color.OrangeRed); } } } catch (Exception ex) { WCell.RealmServer.Global.World.BroadcastMsg("Event manager", "exception when rewarding." + ex.Message, Color.Red); } } } this.Damages.Clear(); }
public virtual void Stop(bool success) { if (!Started) { return; } Started = false; Asda2EventMgr.SendMessageToWorld("Deffence town event stoped in {0} [{2}-{3}]. Status : {1}", Town, success ? "Win" : "Loose", MinLevel, MaxLevel); _spawnTasks.IsRunning = false; _spawnTasks.Clear(); _map.DefenceTownEvent = null; if (success)//getting prizies to players { var livesPrc = (float)_lives / CharacterFormulas.DefenceTownLives; var expPortionsTotal = ExpPortionsTotal * livesPrc; var eventItemsTotal = EventItemsTotal * livesPrc; NotifyBestDamagers(); var objectsToDelete = new List <object>(); var objectsToAdd = new Dictionary <object, long>(); foreach (var damage in Damages) { var grp = damage.Key as Group; if (grp != null) { var receivers = grp.Where(m => m.Character != null && m.Character.Level >= MinLevel && m.Character.Level <= MaxLevel).ToList(); foreach (var member in receivers) { if (Damages.ContainsKey(member.Character)) { objectsToDelete.Add(member.Character); } objectsToAdd.Add(member.Character, damage.Value / receivers.Count); } objectsToDelete.Add(damage.Key); } } World.BroadcastMsg("Rewarder", string.Format("Damagers count is {0}.", Damages.Count), Color.OrangeRed); foreach (var o in objectsToDelete) { Damages.Remove(o); } foreach (var l in objectsToAdd) { Damages.Add(l.Key, l.Value); } var totalDamage = Damages.Sum(d => d.Value); World.BroadcastMsg("Rewarder", string.Format("Total damage is {0}.", totalDamage), Color.OrangeRed); foreach (var damage in Damages.OrderByDescending(kvp => kvp.Value)) { var chr = damage.Key as Character; try { if (chr != null && chr.Asda2Inventory != null) { var prcFromMainPrize = (float)damage.Value / totalDamage; var exp = (int)(prcFromMainPrize * expPortionsTotal * XpGenerator.GetBaseExpForLevel(chr.Level)); var eventItemsCount = (int)(prcFromMainPrize * eventItemsTotal); chr.GainXp(exp, "defence_town_event"); if (eventItemsCount > 0) { RealmServer.IOQueue.AddMessage(() => chr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId), eventItemsCount, "defence_town_event")); } World.BroadcastMsg("Rw", string.Format("{2} gain {0} coins and {1} exp for {3} dmg.", eventItemsCount, exp, chr.Name, damage.Value), Color.OrangeRed); } } catch (Exception ex) { World.BroadcastMsg("Event manager", "exception when rewarding." + ex.Message, Color.Red); } } } Damages.Clear(); }