Esempio n. 1
0
        protected override void WriteBoard(PacketWriter stream)
        {
            // players
            byte count    = 0;
            int  countPos = stream.Position++;

            ArenaClient.ForEach(c =>
            {
                if (c.GMTeamID >= TeamIdent.GMPlayer)
                {
                    WritePlayer(c, stream);
                    count++;
                }
            });
            stream.Edit(countPos, count);

            // spectators
            count    = 0;
            countPos = stream.Position++;
            ArenaClient.ForEach(c =>
            {
                if (c.GMTeamID == TeamIdent.GMSpectator)
                {
                    WritePlayer(c, stream);
                    count++;
                }
            });
            stream.Edit(countPos, count);
        }
Esempio n. 2
0
        protected void SetPhase(GamePhase phase)
        {
            this.Phase = phase;
            Log.Logger.Log("Set Phase " + phase);

            // send phase update to clients
            var stream = ArenaClient.GetStream(ScriptMessages.ModePhase);

            stream.Write((byte)Phase);
            ArenaClient.ForEach(c => c.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered));
        }
Esempio n. 3
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();
        }
Esempio n. 4
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();
            }
        }