예제 #1
0
        public void Initialize(Unity.Entities.World space)
        {
            // stat bars
            cameraOrbitStartSystem = space.GetOrCreateSystem <CameraOrbitStartSystem>();
            AddSystemToUpdateList(cameraOrbitStartSystem);

            cameraSystem = space.GetOrCreateSystem <CameraSystem>();
            AddSystemToUpdateList(cameraSystem);

            cameraInputSystem = space.GetOrCreateSystem <CameraInputSystem>();
            AddSystemToUpdateList(cameraInputSystem);
            cameraMovementSystem = space.GetOrCreateSystem <CameraMovementSystem>();
            AddSystemToUpdateList(cameraMovementSystem);
            cameraFollowSystem = space.GetOrCreateSystem <CameraFollowSystem>();
            AddSystemToUpdateList(cameraFollowSystem);

            characterToCameraSystem = space.GetOrCreateSystem <CharacterToCameraSystem>();
            AddSystemToUpdateList(characterToCameraSystem);
            cameraFirstPersonSystem = space.GetOrCreateSystem <CameraFirstPersonSystem>();
            AddSystemToUpdateList(cameraFirstPersonSystem);
            cameraSynchSystem = space.GetOrCreateSystem <CameraSynchSystem>();
            AddSystemToUpdateList(cameraSynchSystem);

            //cameraProxySystem = space.GetOrCreateSystem<CameraProxySystem>();
            //AddSystemToUpdateList(cameraProxySystem);
            cameraOrbitSystem = space.GetOrCreateSystem <CameraOrbitSystem>();
            AddSystemToUpdateList(cameraOrbitSystem);
            cameraFacerSystem = space.GetOrCreateSystem <CameraFacerSystem>();
            AddSystemToUpdateList(cameraFacerSystem);
            SetLinks();
        }
예제 #2
0
        private void OnStateChanged(Entity world, int metaID, GameState oldState, GameState newState)
        {
            Debug.Log("New Game state: " + newState);
            if (oldState == GameState.StartScreen && newState == GameState.MainMenu)
            {
                OnStarted.Invoke();
            }
            if (newState == GameState.MainMenu)
            {
                OnStarted.Invoke();
                //Debug.LogError("Game starting with: " + playerSpawnSystem.controllers.Count + " Players.");
                foreach (KeyValuePair <int, Entity> KVP in playerSpawnSystem.controllers)
                {
                    if (World.EntityManager.Exists(KVP.Value))
                    {
                        CameraSystem.SpawnCameraController(World.EntityManager, meta[metaID].startingCamera.Value,
                                                           EntityManager.GetComponentData <Controller>(KVP.Value), KVP.Key);
                    }
                }
            }


            //int cameraID = cameraSystem.SpawnCamera(meta[metaID].startingCamera.Value);
            //Entity camera = cameraSystem.cameras[cameraID];    // systemsManager.cameraSystem.cam
            //EntityManager.AddComponentData(camera, EntityManager.GetComponentData<Controller>(KVP.Value));
            //newEntites.Add(KVP.Key, camera);

            /*try
             * {
             *  worldSpawnSystem.OnAddedStreamer(camera, worldID);
             * }
             * catch (System.Exception e)
             * {
             *  Debug.LogError(e.ToString());
             * }*/
            /*else if (newState == GameState.NewGameScreen)
             * {
             *  Debug.LogError("Spawn New Game UI for players (they should both be able to edit new game data)");
             *  //mainScreen.DeinitializeIt();
             *  // spawn a character
             *  // remove its controller
             *  // move camera to new character
             *  //newGameScreen.InitializeIt();
             *  // edit colours of character model
             *  // spawn a character to edit
             * }*/
            else if (newState == GameState.PauseScreen)
            {
                foreach (Entity entity in playerSpawnSystem.controllers.Values)
                {
                    //Controller controller = EntityManager.GetComponentData<Controller>(entity);
                    MenuSpawnSystem.SpawnUI(World.EntityManager, entity, "PauseMenu");
                    //systemsManager.menuSpawnSystem.QueueSpawnUI(entity, "PauseMenu");
                }
            }
            else if (newState == GameState.GameUI)
            {
                foreach (Entity entity in playerSpawnSystem.controllers.Values)
                {
                    Controller controller = EntityManager.GetComponentData <Controller>(entity);
                    gameUISystem.AddGameUI(entity, controller.gameUIIndex);  // spawn the game ui
                }
            }
            else if (newState == GameState.InGame)
            {
                menuSpawnSystem.Clear();
                gameUISystem.Clear();
                //pauseScreen.DeinitializeIt();
            }
            else if (newState == GameState.RespawnScreen)
            {
                //Debug.LogError("TODO: Spawn Player Respawn UI");
                // detatch camera from character
                // add in dead post processing effects
                //systemsManager.menuSpawnSystem.QueueSpawnUI(entity, "Respawn");
                //endOfGameScreen.InitializeIt();
            }
        }