Exemplo n.º 1
0
        /// <summary>
        /// Creates a new NPCServer
        /// </summary>
        internal Framework(string OptionsFile = "settings.ini")
        {
            // Default PM
            this.NCMsg = CString.tokenize ("I am the npcserver for\nthis game server. Almost\nall npc actions are controled\nby me.");

            // Create Compiler
            Compiler = new GameCompiler (this);

            // Create Player Manager
            PlayerManager = new Players.PlayerList (this, GSConn);
            AppSettings settings = AppSettings.GetInstance ();
            settings.Load (OptionsFile);

            // Connect to GServer
            GSConn = new GServerConnection (this);

            this.ConnectToGServer();

            // Setup NPC-Control Listener
            cNCAccept = new AsyncCallback (NCControl_Accept);
            this.UPnPOpenPort();
            NCListen = new TcpListener (IPAddress.Parse (this.LocalIPAddress ()), settings.NCPort);
            NCListen.Start ();
            NCListen.BeginAcceptSocket (cNCAccept, NCListen);

            settings.Save ();

            // Setup Timer
            //timeBeginPeriod(50);
            //TimerHandle = new TimerEventHandler(RunServer);
            //TimerId = timeSetEvent(50, 0, TimerHandle, IntPtr.Zero, EVENT_TYPE);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add Player to Playerlist (or return player)
        /// </summary>
        public virtual Player AddPlayer(Int16 Id, GServerConnection socket)
        {
            this.GSConn = socket;
            Player pl = FindPlayer(Id);
            if (pl == null)
            {
                this.Server.SendGSPacket(new CString() + (byte)GServerConnection.PacketOut.NCQUERY + (byte)GServerConnection.NCREQ.PLGETWEPS + (short)Id);
                Player Player = new Player(this.Server,Id, socket);
                _PlayerList[Id] = Player;
                return Player;
            }

            return pl;
        }
Exemplo n.º 3
0
 public Player(Framework Server, short Id, GServerConnection socket)
     : base(Id, socket)
 {
     this.Server = Server;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PlayerList(Framework server, GServerConnection gsconn)
 {
     this.Server = server;
     this.GSConn = gsconn;
 }