public GameClient(TcpClient selfClient, Guid onlineId, IClientKiller killer, ChatManager manager, GameLoop game) { _self = selfClient; _self.NoDelay = true; _self.Client.NoDelay = true; _reader = new BinaryReader(_self.GetStream()); _writer = new BinaryWriter(_self.GetStream()); _clientKiller = killer; _game = game; ChatManager chatManager = manager; chatManager.Join(this); _auth = AuthorisationManager.Resolve(); _packetReader = PacketReader.Resolve<ServerPacketReader>(); _packetReader.InitialiseMapping(); OnlineId = onlineId; _active = true; _subs = new List<PacketSubscriber> { this, _game, chatManager }; Task.Factory.StartNew(Receive); }
public Server() { Version = Convert.ToDouble(Resources.VERSION); _serverListener = new TcpListener(IPAddress.Any, Port); _clientManager = new GameClientManager(); _chatManager = ChatManager.Resolve(); _game = new GameLoop(); PacketReader.Resolve<ServerPacketReader>().InitialiseMapping(); }
public ServerInstance() { this.server = new SocketServer(); this.server.Instance = this; this.server.Start(); this.game = new GameLoop(); this.game.World = new GameWorld(); this.game.Map = new Map(40, 26); for (int y = 0; y < this.game.Map.Height; ++y) { for (int x = 0; x < this.game.Map.Width; ++x) { int type = 0; /*if ((x < 24 && y < 24) || * (x > 48 && y < 24) || * (x < 24 && y > 48) || * (x > 48 && y > 48)) {*/ /*if ((x < 3 && y < 3) || * (x > 5 && y < 3) || * (x < 3 && y > 5) || * (x > 5 && y > 5)) { * * type = 1; * }*/ this.game.Map.Cell(x, y).Type = Rand.Next(0, 2); } } for (int i = 0; i < 2; ++i) { Hero hero = new Hero(); hero.Cell = this.game.Map.Cell(Rand.Next(this.game.Map.Width), Rand.Next(this.game.Map.Height)); this.game.World.AddObject(hero); } this.game.CycleEnd += (packets) => this.server.PublishAsync(packets); this.game.Start(); }
public ServerInstance() { this.server = new SocketServer(); this.server.Instance = this; this.server.Start(); this.game = new GameLoop(); this.game.World = new GameWorld(); this.game.Map = new Map(40, 26); for(int y = 0; y < this.game.Map.Height; ++y) { for(int x = 0; x < this.game.Map.Width; ++x) { int type = 0; /*if ((x < 24 && y < 24) || (x > 48 && y < 24) || (x < 24 && y > 48) || (x > 48 && y > 48)) {*/ /*if ((x < 3 && y < 3) || (x > 5 && y < 3) || (x < 3 && y > 5) || (x > 5 && y > 5)) { type = 1; }*/ this.game.Map.Cell(x, y).Type = Rand.Next(0, 2); } } for(int i = 0; i < 2; ++i) { Hero hero = new Hero(); hero.Cell = this.game.Map.Cell(Rand.Next(this.game.Map.Width), Rand.Next(this.game.Map.Height)); this.game.World.AddObject(hero); } this.game.CycleEnd += (packets) => this.server.PublishAsync(packets); this.game.Start(); }