public static void bootstrapServers(NetworkAgent agent) { WWW www = new WWW(BootstrapURL); while (!www.isDone) { // oh, no! } string jsonRep = www.text; if (jsonRep.Equals("")) { agent.bootstrapData = new BootStrapData(fallbackLoginServer, fallbackLoginServerPort, fallbackSocketServer, fallbackSocketServerPort, fallbackCommandServer, fallbackCommandServerPort, fallbackExtraServer, fallbackExtraServerPort); } else { agent.bootstrapData = JsonUtility.FromJson <BootStrapData> (jsonRep); } }
/// <summary> /// Constructs a new GameNetworkListener object and initializes all values. /// </summary> /// <param name="customPort">The port to run the listener on</param> /// <param name="contentPackages">The content packages to be streamed to users on connection.</param> public GameNetworkListener(int customPort, List<ContentPackage> contentPackages) { WebUtility = new WebServiceClientUtility(); if (customPort <= 0) { customPort = GameServerConfiguration.DefaultGamePort; } Agent = new NetworkAgent(NetworkAgentRoleEnum.Server, GameServerConfiguration.ApplicationID, customPort); Agent.OnConnected += Agent_OnConnectionEstablished; Agent.OnDisconnected += Agent_OnDisconnected; this._contentPackages = contentPackages; _contentPackageNames = new List<string>(); _contentPackagePaths = new List<string>(); if (contentPackages != null) { foreach (ContentPackage package in contentPackages) { _contentPackageNames.Add(package.FileName); _contentPackagePaths.Add(DirectoryPaths.ContentPackageDirectoryPath + package.FileName); } } FileExtensionFactory = new FileExtensionFactory(); FileTransferClients = new Dictionary<NetConnection, FileTransferProgress>(); Model = new GameNetworkListenerModel(); }
public override void LoadContent() { _netAgent = BlackBoard.GetEntry <NetworkAgent>("NetworkAgent"); _updatesPerSecond = 10.0f; _nextSendUpdates = NetTime.Now; _sendUpdates = false; }
public void Initialize() { _networkAgent = new NetworkAgent(AgentRole.Server, "Umbra"); _networkAgent.OnPlayerConnect += OnPlayerConnect; _networkAgent.OnPlayerDisconnect += OnPlayerDisconnect; EntitySystem.BlackBoard.SetEntry("NetworkAgent", _networkAgent); _entityWorld = new EntityWorld(); _entityWorld.InitializeAll(new[] { GetType().Assembly }); CrawEntityManager.Instance.Initialize(_entityWorld, new ServerEntityFactory(_entityWorld)); }
protected override void Initialize() { spriteBatch = new SpriteBatch(GraphicsDevice); _netAgent = new NetworkAgent(AgentRole.Client, "Umbra"); EntitySystem.BlackBoard.SetEntry("Game", this); EntitySystem.BlackBoard.SetEntry("ContentManager", Content); EntitySystem.BlackBoard.SetEntry("SpriteBatch", spriteBatch); EntitySystem.BlackBoard.SetEntry("GraphicsDevice", GraphicsDevice); EntitySystem.BlackBoard.SetEntry("ContentManager", Content); EntitySystem.BlackBoard.SetEntry("NetworkAgent", _netAgent); _entityWorld = new EntityWorld(); // create camera Vector3 camPosition = new Vector3(0, 10, 5); Matrix camRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(-65.0f)); float aspectRatio = (float)GraphicsDevice.Viewport.Width / GraphicsDevice.Viewport.Height; CameraComponent cameraComponent = new CameraComponent(camPosition, camRotation, aspectRatio); Entity cameraEntity = _entityWorld.CreateEntity(); cameraEntity.AddComponent(cameraComponent); EntitySystem.BlackBoard.SetEntry("Camera", cameraComponent); //// TEMP //// Map map = new Map(100, 100); Entity mapEntity = _entityWorld.CreateEntity(); mapEntity.AddComponent(new TileMapComponent(map)); EntitySystem.BlackBoard.SetEntry("Map", map); //// TEMP //// _entityWorld.InitializeAll(new[] { GetType().Assembly }); CrawEntityManager.Instance.Initialize(_entityWorld, new ClientEntityFactory(_entityWorld)); _netAgent.Connect("127.0.0.1"); base.Initialize(); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { if (_content == null) _content = new ContentManager(ScreenManager.Game.Services, "Content"); // Add all components local to this screen // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); _eventManager.QueueEvent(new GameEvent(EventType.GetReady)); _game = (ClientGame)ScreenManager.Game; _agent = _game.Agent; _gameState = _game.GameState; _ui = _game.UI; _ui.LoadFile("Content\\html\\lobby.html"); _ui.WebView.LoadCompleted += WebViewLoadCompleted; }
/// <summary> /// Connects the game network client to the specified address. /// </summary> /// <param name="address"></param> public void Connect(ConnectionAddress address) { if (Agent == null) { Agent = new NetworkAgent(NetworkAgentRoleEnum.Client, GameServerConfiguration.ApplicationID, address.Port); // Refresh event hooks Agent.OnConnected -= RaiseOnAgentConnectedEvent; Agent.OnDisconnected -= RaiseAgentOnDisconnectedEvent; Agent.OnDisconnecting -= RaiseAgentOnDisconnectingEvent; Agent.OnConnected += RaiseOnAgentConnectedEvent; Agent.OnDisconnected += RaiseAgentOnDisconnectedEvent; Agent.OnDisconnecting += RaiseAgentOnDisconnectingEvent; } else { Agent.Port = address.Port; } Agent.Connect(address.IPAddress); }
public override void LoadContent() { _networkAgent = BlackBoard.GetEntry <NetworkAgent>("NetworkAgent"); }
public override void LoadContent() { _netAgent = BlackBoard.GetEntry <NetworkAgent>("NetworkAgent"); _camera = BlackBoard.GetEntry <CameraComponent>("Camera"); }
/// <summary> /// Constructor. /// </summary> /// <param name="server"></param> public GameServerState(Server server) { _server = server; _agent = server.Agent; _gameState = server.GameState; }
void Awake() { if( mInstance != null ) { Debug.LogError( string.Format( "Only one instance of NetworkAgent allowed! Destroying:" + gameObject.name +", Other:" + mInstance.gameObject.name ) ); return; } mInstance = this; }