Esempio n. 1
0
        void SelectTeam(int index)
        {
            if (!TDMMode.IsActive)
            {
                return;
            }

            var teams = TDMMode.ActiveMode.Scenario.Teams;

            if (index < 0 || index >= teams.Length)
            {
                return;
            }

            if ((int)PlayerInfo.HeroInfo.TeamID == index)
            {
                MenuClassSelect.Instance.Open();
                Close();
                return;
            }

            if (!lockTimer.IsReady)
            {
                return;
            }

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

            stream.Write((byte)index);
            ArenaClient.SendScriptMessage(stream, NetPriority.Low, NetReliability.Reliable);
        }
Esempio n. 2
0
        void SelectClass(int index)
        {
            if (!HordeMode.IsActive || PlayerInfo.HeroInfo.TeamID < TeamIdent.GMSpectator || GameMode.ActiveMode.Phase == GamePhase.FadeOut)
            {
                Close();
                return;
            }

            if (!HordeMode.ActiveMode.Scenario.PlayerClasses.TryGet(index, out NPCClass classDef))
            {
                return;
            }

            if (classDef == NPCClass.Hero)
            {
                Close();
                return;
            }

            if (!lockTimer.IsReady)
            {
                return;
            }

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

            stream.Write((byte)index);
            ArenaClient.SendScriptMessage(stream, NetPriority.Low, NetReliability.Reliable);

            NPCClass.Hero = classDef;

            Close();
        }
Esempio n. 3
0
        public static void DuelWin(ArenaClient winner)
        {
            if (!winner.IsDueling)
            {
                return;
            }

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

            stream.Write((ushort)winner.Character.ID);
            winner.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered);
            if (winner.DuelEnemy.IsConnected)
            {
                winner.DuelEnemy.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered);
            }

            winner.DuelEnemy.DuelDeaths++;
            winner.DuelEnemy.DuelScore--;

            winner.DuelKills++;
            winner.DuelScore += 2;

            winner.DuelEnemy.DuelEnemy = null;
            winner.DuelEnemy           = null;
        }
Esempio n. 4
0
 void Spectate()
 {
     if (PlayerInfo.HeroInfo.TeamID != TeamIdent.GMSpectator)
     {
         var stream = ArenaClient.GetStream(ScriptMessages.ModeSpectate);
         ArenaClient.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered);
     }
     Close();
 }
Esempio n. 5
0
 void Join()
 {
     if (PlayerInfo.HeroInfo.TeamID < TeamIdent.GMPlayer)
     {
         var stream = ArenaClient.GetStream(ScriptMessages.BRJoin);
         ArenaClient.SendScriptMessage(stream, NetPriority.Low, NetReliability.Reliable);
     }
     Close();
 }
Esempio n. 6
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. 7
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. 8
0
        void GameModeStart()
        {
            if (ArenaClient.GMJoined)
            {
                GameMode.ActiveMode.OpenJoinMenu();
                return;
            }

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

            ArenaClient.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered);
            Close();
        }
Esempio n. 9
0
        void HordeFadeOut(bool playersWon)
        {
            if (Phase == GamePhase.FadeOut)
            {
                return;
            }

            standSpawnTimer.Stop();
            standTimer.Stop();
            if (playersWon)
            {
                var stream = ArenaClient.GetStream(ScriptMessages.HordeWin);
                players.ForEach(p =>
                {
                    p.SendScriptMessage(stream, NetPriority.Low, NetReliability.Reliable);
                    if (p.IsCharacter)
                    {
                        p.Character.LiftUnconsciousness();
                    }
                });

                var agent = CreateAgent();
                foreach (var npc in AmbientNPCs)
                {
                    npc.BaseInst.SetNeedsClientGuide(true);
                    agent.Add(npc);
                }
            }
            else
            {
                var stream = ArenaClient.GetStream(ScriptMessages.HordeLoss);
                players.ForEach(p =>
                {
                    p.SendScriptMessage(stream, NetPriority.Low, NetReliability.Reliable);
                    if (p.IsCharacter)
                    {
                        p.Character.SetHealth(0);
                    }
                });

                ClearAgents();
            }
            base.FadeOut();
        }
Esempio n. 10
0
        protected override void FadeOut()
        {
            int max    = teams.Max(t => t.Score);
            int count  = teams.Count(t => t.Score == max);
            var stream = ArenaClient.GetStream(ScriptMessages.TDMWin);

            stream.Write((byte)count);
            for (byte i = 0; i < teams.Count; i++)
            {
                if (teams[i].Score == max)
                {
                    stream.Write(i);
                }
            }

            players.ForEach(p => p.SendScriptMessage(stream, NetPriority.Low, NetReliability.Reliable));

            base.FadeOut();

            respawnTimer.Stop();
            NPCInst.sOnHit -= OnHit;
        }