Ejemplo n.º 1
0
        // Called when the Play button is pressed in Unity.
        public void Start()
        {
            Configuration.Networking.LinkProtocol      = NetworkConnectionType.Tcp;
            Configuration.Networking.TcpMultiplexLevel = 1;

            SpatialOS.ApplyConfiguration(Configuration);

            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;

            // Distinguishes between when the Unity is running as a client or a server.
            switch (SpatialOS.Configuration.WorkerPlatform)
            {
            case WorkerPlatform.UnityWorker:
                Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
                SpatialOS.OnDisconnected   += reason => Application.Quit();
                SpatialOS.Connect(gameObject);
                break;

            case WorkerPlatform.UnityClient:
                Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
                SpatialOS.OnConnected      += CreatePlayer;
                SceneManager.LoadSceneAsync(BuildSettings.SplashScreenScene, LoadSceneMode.Additive);
                break;
            }

            // Enable communication with the SpatialOS layer of the simulation.
            SpatialOS.Connect(gameObject);
        }
Ejemplo n.º 2
0
        private void Start()
        {
            List <string> assetsToPreCache = new List <string> {
                SimulationSettings.PlayerPrefabName,
                SimulationSettings.NPCPrefabName,
                SimulationSettings.NPCWizardPrefabName,
                SimulationSettings.HQPrefabName,
                SimulationSettings.TreePrefabName,
                SimulationSettings.BarracksPrefabName,
                SimulationSettings.PlayerSpawnerPrefabName
            };

            SpatialOS.AssetsToPrecache = assetsToPreCache;

            SpatialOS.ApplyConfiguration(Configuration);

            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;

            switch (SpatialOS.Configuration.WorkerPlatform)
            {
            case WorkerPlatform.UnityWorker:
                Application.targetFrameRate = SimulationSettings.TargetFramerateUnityWorker;
                SpatialOS.OnDisconnected   += reason => Application.Quit();
                SpatialOS.Connect(gameObject);
                break;

            case WorkerPlatform.UnityClient:
                SceneManager.LoadScene(SimulationSettings.SplashScreenScene, LoadSceneMode.Additive);
                Application.targetFrameRate = SimulationSettings.TargetFramerate;
                SpatialOS.OnConnected      += ClientPlayerSpawner.SpawnPlayer;
                break;
            }
        }
Ejemplo n.º 3
0
        private void Start()
        {
            SpatialOS.ApplyConfiguration(Configuration);

            Application.targetFrameRate = SimulationSettings.TargetFramerate;
            Time.fixedDeltaTime         = 1.0f / SimulationSettings.FixedFramerate;

            switch (SpatialOS.Configuration.EnginePlatform)
            {
            case EnginePlatform.FSim:
                SpatialOS.OnDisconnected += reason => Application.Quit();
                break;

            case EnginePlatform.Client:
                SpatialOS.OnConnected += ClientPlayerSpawner.SpawnPlayer;
                break;
            }
            SpatialOS.Connect(gameObject);
        }
        public void Start()
        {
            SpatialOS.ApplyConfiguration(Configuration);

            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;

            switch (SpatialOS.Configuration.WorkerPlatform)
            {
            case WorkerPlatform.UnityWorker:
                Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
                SpatialOS.OnDisconnected   += reason => Application.Quit();
                SpatialOS.Connect(gameObject);
                break;

            case WorkerPlatform.UnityClient:
                Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
                SpatialOS.OnConnected      += CreatePlayer;
                break;
            }
        }
Ejemplo n.º 5
0
        // Called when the Play button is pressed in Unity.
//        public void Start()
//        {
//            SpatialOS.ApplyConfiguration(Configuration);
//
//            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;
//
//            // Distinguishes between when the Unity is running as a client or a server.
//            switch (SpatialOS.Configuration.WorkerPlatform)
//            {
//                case WorkerPlatform.UnityWorker:
//                    Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
//                    SpatialOS.OnDisconnected += reason => Application.Quit();
//                    break;
//                case WorkerPlatform.UnityClient:
//                    Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
//                    SpatialOS.OnConnected += CreatePlayer;
//                    break;
//            }
//
//            // Enable communication with the SpatialOS layer of the simulation.
////            SpatialOS.Connect(gameObject);
//        }

        public void Start()
        {
            SpatialOS.ApplyConfiguration(Configuration);
            //
            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;
            switch (SpatialOS.Configuration.WorkerPlatform)
            {
            case WorkerPlatform.UnityWorker:
                Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
                SpatialOS.OnDisconnected   += reason => Application.Quit();
                SpatialOS.Connect(gameObject);
                break;

            case WorkerPlatform.UnityClient:
                Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
                SpatialOS.OnConnected      += CreatePlayer;
                SpatialOS.OnDisconnected   += reason => HandlePlayerDisconnect();
                SceneManager.LoadSceneAsync(BuildSettings.SplashScreenScene, LoadSceneMode.Additive);
                break;
            }
        }
Ejemplo n.º 6
0
        private void Start()
        {
            SpatialOS.ApplyConfiguration(Configuration);

            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;

            // Distinguishes between when the Unity is running as a client or a server.
            switch (SpatialOS.Configuration.WorkerPlatform)
            {
            case WorkerPlatform.UnityWorker:
                Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
                SpatialOS.OnDisconnected   += reason => Application.Quit();
                break;

            case WorkerPlatform.UnityClient:
                Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
                SpatialOS.OnConnected      += OnSpatialOsConnection;
                break;
            }

            SpatialOS.Connect(gameObject);
        }
Ejemplo n.º 7
0
    public void Start()
    {
        SpatialOS.ApplyConfiguration(Configuration);

        switch (SpatialOS.Configuration.EnginePlatform)
        {
        case EnginePlatform.FSim:
            SpatialOS.OnDisconnected += reason => Application.Quit();

            var targetFramerate = 120;
            var fixedFramerate  = 20;

            Application.targetFrameRate = targetFramerate;
            Time.fixedDeltaTime         = 1.0f / fixedFramerate;
            break;

        case EnginePlatform.Client:
            SpatialOS.OnConnected += OnConnected;
            break;
        }

        SpatialOS.Connect(gameObject);
    }
Ejemplo n.º 8
0
        private void OnEnable()
        {
            SpatialOS.ApplyConfiguration(Configuration);

            Application.targetFrameRate = _targetFramerate;
            switch (SpatialOS.Configuration.EnginePlatform)
            {
            case EnginePlatform.FSim:
            {
                Time.fixedDeltaTime       = 1.0f / _fixedFramerate;
                SpatialOS.OnDisconnected += reason => Application.Quit();
                break;
            }

            case EnginePlatform.Client:
            {
                SpatialOS.OnConnected += OnConnected;
                break;
            }
            }

            SpatialOS.Connect(this.gameObject);
        }
Ejemplo n.º 9
0
        // Called when the Play button is pressed in Unity.
        public void Start()
        {
            SceneManager.LoadScene(BuildSettings.SplashScreenScene, LoadSceneMode.Additive);

            SpatialOS.ApplyConfiguration(Configuration);

            Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;

            // Distinguishes between when the Unity is running as a client or a server.
            switch (SpatialOS.Configuration.WorkerPlatform)
            {
            case WorkerPlatform.UnityWorker:
                Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
                SpatialOS.OnDisconnected   += reason => Application.Quit();
                SpatialOS.Connect(gameObject);
                break;

            case WorkerPlatform.UnityClient:
                Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
                SpatialOS.OnConnected      += CreatePlayer;
                break;
            }
        }