public bool Initialize(Address address, string baseKey) { _logger.LogCoreInfo("Loading Config."); Config = new Config("Settings/GameInfo.json"); _server = new Host(); _server.Create(address, 32, 32, 0, 0); var key = System.Convert.FromBase64String(baseKey); if (key.Length <= 0) { return(false); } Blowfish = new BlowFish(key); PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager); Map = new SummonersRift(this); PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager); ApiFunctionManager.SetGame(this); IsRunning = false; foreach (var p in Config.Players) { _playerManager.AddPlayer(p); } return(true); }
public void Initialize(Address address, string blowfishKey, Config config) { _logger.LogCoreInfo("Loading Config."); Config = config; _chatCommandManager.LoadCommands(); _server = new Host(); _server.Create(address, 32, 32, 0, 0); var key = Convert.FromBase64String(blowfishKey); if (key.Length <= 0) { throw new InvalidKeyException("Invalid blowfish key supplied"); } Blowfish = new BlowFish(key); PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager); RegisterMap((byte)Config.GameConfig.Map); PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager); ApiFunctionManager.SetGame(this); IsRunning = false; foreach (var p in Config.Players) { _playerManager.AddPlayer(p); } _logger.LogCoreInfo("Game is ready."); }
public void Initialize(Address address, string blowfishKey, Config config) { _logger.LogCoreInfo("Loading Config."); Config = config; _gameScriptTimers = new List <GameScriptTimer>(); _chatCommandManager.LoadCommands(); _server = new Host(); _server.Create(address, 32, 32, 0, 0); var key = Convert.FromBase64String(blowfishKey); if (key.Length <= 0) { throw new InvalidKeyException("Invalid blowfish key supplied"); } Blowfish = new BlowFish(key); PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager, _packetHandlerProvider); ObjectManager = new ObjectManager(this); Map = new Map(this); PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager); ApiFunctionManager.SetGame(this); ApiEventManager.SetGame(this); IsRunning = false; disconnectedPlayers = 0; _logger.LogCoreInfo("Loading C# Scripts"); LoadScripts(); Map.Init(); foreach (var p in Config.Players) { _playerManager.AddPlayer(p); } _pauseTimer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--; PauseTimeLeft = 30 * 60; // 30 minutes _logger.LogCoreInfo("Game is ready."); }
public bool Initialize(Address address, string baseKey) { Logger.LogCoreInfo("Loading Config."); Config = new Config("Settings/GameInfo.json"); ItemManager = ItemManager.LoadItems(this); ChatboxManager = new ChatboxManager(this); _server = new Host(); _server.Create(address, 32, 32, 0, 0); var key = System.Convert.FromBase64String(baseKey); if (key.Length <= 0) { return(false); } Blowfish = new BlowFish(key); PacketHandlerManager = new PacketHandlerManager(this); _map = new SummonersRift(this); PacketNotifier = new PacketNotifier(this); ApiFunctionManager.SetGame(this); var id = 1; foreach (var p in Config.Players) { var player = new ClientInfo(p.Value.Rank, ((p.Value.Team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE), p.Value.Ribbon, p.Value.Icon); player.SetName(p.Value.Name); player.SetSkinNo(p.Value.Skin); player.UserId = id; // same as StartClient.bat id++; player.SetSummoners(StrToId(p.Value.Summoner1), StrToId(p.Value.Summoner2)); var c = new Champion(this, p.Value.Champion, GetNewNetID(), (uint)player.UserId); var pos = c.getRespawnPosition(); c.setPosition(pos.Item1, pos.Item2); c.setTeam((p.Value.Team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE); c.LevelUp(); player.SetChampion(c); var pair = new Pair <uint, ClientInfo>(); pair.Item2 = player; _players.Add(pair); } return(true); }
public void Initialize(ushort port, string blowfishKey, Config config) { _logger.Info("Loading Config."); Config = config; _gameScriptTimers = new List <GameScriptTimer>(); ChatCommandManager.LoadCommands(); ObjectManager = new ObjectManager(this); Map = new Map(this); ApiFunctionManager.SetGame(this); ApiEventManager.SetGame(this); IsRunning = false; _logger.Info("Loading C# Scripts"); LoadScripts(); Map.Init(); _logger.Info("Add players"); foreach (var p in Config.Players) { ((PlayerManager)PlayerManager).AddPlayer(p); } _pauseTimer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--; PauseTimeLeft = 30 * 60; // 30 minutes _packetServer = new PacketServer(); _packetServer.InitServer(port, blowfishKey, this); PacketNotifier = new PacketNotifier(_packetServer.PacketHandlerManager, Map.NavGrid); // TODO: make lib to only get API types and not byte[], start from removing this line PacketReader = new PacketReader(); _logger.Info("Game is ready."); }
public void Initialize(Config config, PacketServer server) { _logger.Info("Loading Config."); Config = config; _gameScriptTimers = new List <GameScriptTimer>(); ChatCommandManager.LoadCommands(); ObjectManager = new ObjectManager(this); Map = new Map(this); ApiFunctionManager.SetGame(this); ApiEventManager.SetGame(this); IsRunning = false; _logger.Info("Loading C# Scripts"); LoadScripts(); Map.Init(); _logger.Info("Add players"); foreach (var p in Config.Players) { ((PlayerManager)PlayerManager).AddPlayer(p); } _pauseTimer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--; PauseTimeLeft = 30 * 60; // 30 minutes // TODO: GameApp should send the Response/Request handlers _packetServer = server; // TODO: switch the notifier with ResponseHandler PacketNotifier = new PacketNotifier(_packetServer.PacketHandlerManager, Map.NavGrid); InitializePacketHandlers(); _logger.Info("Game is ready."); }