Exemplo n.º 1
0
        public static void HandlePacket(object session, string packet)
        {
            string[] packetSplit = packet.Split(' ');
            if (packetSplit.Length < 4)
            {
                return;
            }
            TreqPacket packetDefinition = new TreqPacket();

            if (int.TryParse(packetSplit[2], out int x) &&
                int.TryParse(packetSplit[3], out int y))
            {
                packetDefinition.X          = x;
                packetDefinition.Y          = y;
                packetDefinition.StartPress = packetSplit.Length >= 5 &&
                                              byte.TryParse(packetSplit[4], out byte startPress) ? startPress : (byte?)null;
                packetDefinition.StartPress = packetSplit.Length >= 5 &&
                                              byte.TryParse(packetSplit[4], out byte recordPress) ? recordPress : (byte?)null;
                packetDefinition.ExecuteHandler(session as ClientSession);
            }
        }
Exemplo n.º 2
0
        private void ExecuteHandler(ClientSession session)
        {
            foreach (ScriptedInstance portal in session.CurrentMapInstance.ScriptedInstances)
            {
                if (session.Character.PositionY >= portal.PositionY - 1 &&
                    session.Character.PositionY <= portal.PositionY + 1 &&
                    session.Character.PositionX >= portal.PositionX - 1 &&
                    session.Character.PositionX <= portal.PositionX + 1)
                {
                    switch (Value)
                    {
                    case 0:
                        if (session.Character.Group?.Characters.Any(s =>
                                                                    s.CurrentMapInstance.InstanceBag?.Lock == false &&
                                                                    s.CurrentMapInstance.MapInstanceType == MapInstanceType.TimeSpaceInstance &&
                                                                    s.Character.MapId == portal.MapId &&
                                                                    s.Character.CharacterId != session.Character.CharacterId &&
                                                                    s.Character.MapX == portal.PositionX &&
                                                                    s.Character.MapY == portal.PositionY) == true)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                   $"#wreq^3^{session.Character.CharacterId} #wreq^0^1 {Language.Instance.GetMessageFromKey("ASK_JOIN_TEAM_TS")}"));
                        }
                        else
                        {
                            session.SendPacket(portal.GenerateRbr());
                        }

                        break;

                    case 1:
                        if (!Parameter.HasValue)
                        {
                            session.EnterInstance(portal);
                        }
                        else if (Parameter.Value == 1)
                        {
                            TreqPacket.HandlePacket(session, $"1 treq {portal.PositionX} {portal.PositionY} 1 1");
                        }
                        break;

                    case 3:
                        if (!Parameter.HasValue)
                        {
                            return;
                        }
                        ClientSession clientSession =
                            session.Character.Group?.Characters.Find(s => s.Character.CharacterId == Parameter.Value);
                        if (clientSession != null)
                        {
                            if (session.Character.Level < portal.LevelMinimum)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("NOT_REQUIERED_LEVEL"), 0));
                                return;
                            }

                            MapCell mapcell = clientSession.CurrentMapInstance.Map.GetRandomPosition();
                            session.Character.MapX = portal.PositionX;
                            session.Character.MapY = portal.PositionY;
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                     clientSession.CurrentMapInstance.MapInstanceId, mapcell.X, mapcell.Y);
                            session.SendPacket(portal.GenerateMainInfo());
                            session.SendPackets(portal.GenerateMinimap());
                            session.SendPacket(portal.FirstMap.InstanceBag.GenerateScore());
                            session.Character.Timespace = portal;
                        }

                        // TODO: Implement
                        break;
                    }
                }
            }
        }