protected override void Start(GameScenario scenario) { base.Start(scenario); if (Scenario.SpawnBarriers != null) { foreach (var bar in Scenario.SpawnBarriers) { if (!bar.AddAfterEvent) { spawnBarriers.Add(CreateBarrier(bar)); } } } foreach (var hi in Scenario.Items) { ItemInst item = new ItemInst(ItemDef.Get(hi.ItemDef)); item.Spawn(World, hi.Position, hi.Angles); } for (int i = 0; i < Scenario.Stands.Length; i++) { var stand = Scenario.Stands[i]; StandInst inst = new StandInst() { Index = i, Stand = stand, }; if (stand.Boss != null) { inst.Boss = SpawnNPC(stand.Boss, stand.Position); inst.Boss.AllowHitTarget.Add(BossProtection); } inst.Barriers = new List <VobInst>(stand.Barriers.Length); foreach (var bar in stand.Barriers) { if (!bar.AddAfterEvent) { inst.Barriers.Add(CreateBarrier(bar)); } } Stands.Add(inst); } }
static void SpawnItem(WorldInst world, PosAng posAng) { var item = BRScenario.Items.GetRandom(); ItemDef def = ItemDef.Get(item.Definition); if (def == null) { return; } ItemInst inst = new ItemInst(def); inst.SetAmount(item.Amount); inst.Spawn(world, posAng.Position, posAng.Angles); }
public static void StartHorde(HordeDef def) { if (def == null) { return; } Log.Logger.Log("horde init"); ArenaClient.ForEach(c => { var client = (ArenaClient)c; client.HordeScore = 0; client.HordeDeaths = 0; client.HordeKills = 0; client.HordeClass = null; }); players.ForEach(c => c.Spectate()); players.Clear(); if (activeWorld != null) { activeWorld.BaseWorld.ForEachVob(v => v.Despawn()); } var stream = ArenaClient.GetScriptMessageStream(); stream.Write((byte)ScriptMessages.HordeStart); stream.Write(def.Name); ArenaClient.ForEach(c => c.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered)); activeDef = def; activeWorld = WorldInst.List.Find(w => w.Path == def.WorldPath); spawnBarriers.Clear(); foreach (var bar in activeDef.SpawnBarriers) { if (!bar.AddAfterEvent) { spawnBarriers.Add(CreateBarrier(bar)); } } ActiveStands.Clear(); for (int i = 0; i < activeDef.Stands.Length; i++) { var stand = activeDef.Stands[i]; StandInst inst = new StandInst() { Index = i, Stand = stand, }; if (stand.Boss != null) { inst.Boss = SpawnEnemy(stand.Boss, stand.Position); inst.Boss.CanGetHit += BossProtection; } inst.Barriers = new List <VobInst>(stand.Barriers.Length); foreach (var bar in stand.Barriers) { if (!bar.AddAfterEvent) { inst.Barriers.Add(CreateBarrier(bar)); } } ActiveStands.Add(inst); } foreach (var hi in activeDef.Items) { ItemInst item = new ItemInst(ItemDef.Get(hi.ItemDef)); item.Spawn(activeWorld, hi.Position, hi.Angles); } standEnemyCount = 0; ActiveStandInst = null; gameTimer.SetInterval(30 * TimeSpan.TicksPerSecond); gameTimer.SetCallback(Start); gameTimer.Stop(); SetPhase(HordePhase.WarmUp); }