예제 #1
0
 public static void StartNextScenario()
 {
     if (IsActive)
     {
         ActiveMode.FadeOut();
     }
     else
     {
         InitScenario(GameScenario.Get(NextScenarioIndex));
     }
 }
예제 #2
0
        protected virtual void Start(GameScenario scenario)
        {
            this.Scenario = scenario;

            var stream = ArenaClient.GetStream(ScriptMessages.ModeStart);

            stream.Write(scenario.Name);
            ArenaClient.ForEach(c => c.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered));
            Phase = GamePhase.None;

            phaseTimer.Stop();
        }
예제 #3
0
        public static GameMode InitScenario(GameScenario scenario)
        {
            if (scenario == null)
            {
                return(null);
            }

            if (IsActive)
            {
                NextScenarioIndex = GameScenario.Scenarios.IndexOf(scenario);
                ActiveMode.FadeOut();
                return(null);
            }

            Log.Logger.Log("Init game scenario " + scenario.Name);

            if (++NextScenarioIndex >= GameScenario.Count)
            {
                NextScenarioIndex = 0;
            }

            var mode = scenario.GetMode();

            ActiveMode = mode;

            var world = new WorldInst(null)
            {
                Path = scenario.WorldPath
            };

            world.Create();

            SetWorldGlobals(world, scenario);
            mode.World = world;

            if (!string.IsNullOrWhiteSpace(scenario.SpawnWorld))
            {
                var spawnWorld = new WorldInst(null)
                {
                    Path = scenario.SpawnWorld
                };
                spawnWorld.Create();

                SetWorldGlobals(spawnWorld, scenario);
                mode.SpawnWorld = spawnWorld;
            }

            mode.Start(scenario);

            return(mode);
        }
예제 #4
0
        public static void Start(string name)
        {
            var scenario = GameScenario.Get(name);

            if (scenario == null)
            {
                throw new Exception("GameScenario not found: " + name);
            }

            if (ActiveMode != null)
            {
                ActiveMode.End();
            }
            ActiveMode = scenario.GetMode();
            ActiveMode.Start(scenario);
        }
예제 #5
0
        protected virtual void End()
        {
            Log.Logger.Log("End");

            phaseTimer.Stop();

            // Reset game mode stats of players
            ArenaClient.ForEach(c =>
            {
                c.GMClass  = null;
                c.GMKills  = 0;
                c.GMScore  = 0;
                c.GMDeaths = 0;
            });

            var oldWorld      = this.World;
            var oldSpawnWorld = this.SpawnWorld;

            this.World      = null;
            this.SpawnWorld = null;

            var oldPlayers = new List <ArenaClient>(players);

            this.players.Clear();

            // initialize next scenario, creates a new world
            ActiveMode = null;
            var newMode = InitScenario(GameScenario.Get(NextScenarioIndex));

            // move players to next scenario
            oldPlayers.ForEach(p => newMode.JoinAsSpectator(p));

            ClearAgents();
            // delete old world
            oldWorld.Delete();

            if (oldSpawnWorld != null)
            {
                oldSpawnWorld.Delete();
            }
        }