示例#1
0
        public void Active()
        {
            if (Stopwatch == null || !Stopwatch.IsRunning)
            {
                Stopwatch = Stopwatch.StartNew();
            }

            GameClient.SendToPlayerView(Controller.Npc, LegacyModule.write("0|n|fx|start|RAGE|" + Controller.Npc.Id));
            GameClient.SendToPlayerView(Controller.Npc, LegacyModule.write("0|n|fx|start|RAGE|" + Controller.Npc.Id));

            if (Stopwatch.ElapsedMilliseconds == 5000)
            {
                Controller.Npc.Destroy();
                Exit();
            }
        }
示例#2
0
        public void Tick()
        {
            try
            {
                var npc = Controller.Npc;
                if (npc.SelectedCharacter != null)
                {
                    if (npc.CurrentHealth < npc.MaxHealth * 0.2)
                    {
                        Active();
                    }
                    else
                    {
                        Inactive();
                    }

                    if (!npc.SelectedCharacter.InRange(npc, 401))
                    {
                        if (!npc.InRange(npc.SelectedCharacter))
                        {
                            npc.Selected = null;
                            GameClient.SendToPlayerView(Controller.Npc,
                                                        LegacyModule.write("0|n|fx|end|RAGE|" + Controller.Npc.Id));
                            GameClient.SendToPlayerView(Controller.Npc,
                                                        LegacyModule.write("0|n|fx|end|RAGE|" + Controller.Npc.Id));
                        }
                        else
                        {
                            MovementController.Move(npc,
                                                    Vector.GetPosOnCircle(npc.SelectedCharacter.Position, 400));
                        }
                    }
                }
                else
                {
                    Paused();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private static void MessageHandler(Character character, int roomId, string message)
        {
            //if (character is Moderator) ModeratorMessage(character,roomId, message);
            var session = ServerManager.GetGameSession(character.Id);
            if (message.Contains(' '))
            {
                var splitMessage = message.Split(' ');
                switch (splitMessage[0])
                {
                    case "/cam":
                        if (session == null) return;
                        switch (splitMessage[1])
                        {
                            case "cords":
                                session.Client.Send(CameraLockToCoordinatesCommand.write(int.Parse(splitMessage[2]) * 100, int.Parse(splitMessage[3]) * 100, 1));
                                break;
                            case "selected":
                                session.Client.Send(CameraLockToShipCommand.write(session.Player.Selected.Id, 1, 1));
                                break;
                            case "hero":
                                session.Client.Send(CameraLockToHeroCommand.write());
                                break;
                            default:
                                Send(character, "cords: x/y; selected; hero");
                                break;
                        }
                        break;
                    case "/send":
                        if (session == null) return;

                        var replaced = message.Replace("ATRIBUTE_SEPERATOR", "|");

                        session.Client.Send(LegacyModule.write(replaced));
                        break;
                    case "/global":
                        if (character.IsRcon())
                        {
                            byte[] packet;
                            string cutMessage;
                            switch (splitMessage[1])
                            {
                                case "big":
                                    cutMessage = message.Replace("/global big ", "");
                                    packet = Net.netty.PacketBuilder.BigMessage(cutMessage);
                                    break;
                                default:
                                    cutMessage = message.Replace("/global ", "");
                                    packet = Net.netty.PacketBuilder.LegacyModule("0|A|STD|" + cutMessage);
                                    break;
                            }
                            foreach (var gameClient in ServerManager.GameSessions.Values)
                            {
                                gameClient.Client.Send(packet);
                            }
                        }
                        break;
                    case "/rcon":
                        switch (splitMessage[1])
                        {
                            case "login":
                                if (splitMessage[2] != ServerManager.RCON_PW)
                                    break;

                                character.Rcon = true;
                                MessagesController.Send(character, "Logged in as RCON");
                                break;
                            case "auth":
                                if (character.IsRcon())
                                {
                                    if (splitMessage[2] == null)
                                    {
                                        Send(character, "/rcon auth [edit/delete]");
                                        break;
                                    }
                                    switch (splitMessage[2])
                                    {
                                        case "edit":
                                            Send(character, "Not done yet.");
                                            break;
                                        case "delete":
                                            File.Delete(Directory.GetCurrentDirectory() + "/p.auth");
                                            File.Delete(Directory.GetCurrentDirectory() + "/k.auth");
                                            Send(character, "Successfully deleted auth files.");
                                            break;
                                    }
                                }
                                break;
                            case "lock":
                                if (character.IsRcon())
                                {
                                    if (!ServerManager.RCON_LOGIN_ONLY)
                                    {
                                        Send(character, "Locking the server to RCONs only.");
                                        ServerManager.RCON_LOGIN_ONLY = true;
                                        break;
                                    }

                                    Send(character, "Unlocking..");
                                    ServerManager.RCON_LOGIN_ONLY = false;

                                    foreach (var entry in ServerManager.GameSessions)
                                    {
                                        var chatEntry = ServerManager.GetChatSession(entry.Key);
                                        if (chatEntry != null)
                                            if (chatEntry.Player.Rcon)
                                                return;

                                        entry.Value.CloseSession();
                                    }
                                }
                                break;
                            case "restart":
                                if (character.IsRcon())
                                {
                                    Send(character, "Server is restarting...");
                                    Process.Start(Directory.GetCurrentDirectory() + "/NettyRestarter.exe");
                                }
                                break;
                            case "exit":
                                if (character.IsRcon())
                                    Environment.Exit(0);
                                break;
                        }
                        break;
                    default:
                        //Console.WriteLine(splitMessage[0]);
                        break;
                }

            }
            else
            {
                switch (message)
                {
                    case "/online":
                        Send(character, "Currently there are " + ServerManager.ChatSessions.Count + " users connected to chat.");
                        break;
                }
            }
        }