Esempio n. 1
0
        public override void Awake()
        {
            base.Awake();

            if (s_IsCreated)
            {
                Destroy(gameObject);
                return;
            }
            else
            {
                DontDestroyOnLoad(gameObject);

                RegisterServices();
                SetupServices();

                SceneManager.sceneLoaded += (scene, mode) => {
                    var gameModeService = GetService <IGameModeService>()?.Cast <RavenhillGameModeService>();

                    if (gameModeService != null)
                    {
                        var roomData = GetService <IResourceService>()?.Cast <RavenhillResourceService>()?.GetRoomDataBySceneName(scene.name, gameModeService.roomMode);
                        if (roomData != null)
                        {
                            switch (roomData.roomType)
                            {
                            case Data.RoomType.hallway: {
                                gameModeService.SetGameModeName(GameModeName.hallway);
                            }
                            break;

                            case Data.RoomType.map: {
                                gameModeService.SetGameModeName(GameModeName.map);
                            }
                            break;

                            case Data.RoomType.search: {
                                gameModeService.SetGameModeName(GameModeName.search);
                            }
                            break;
                            }
                        }
                    }

                    RavenhillEvents.OnSceneLoaded(scene.name);
                };



                s_IsCreated = true;

                var resourceSerice = GetService <IResourceService>().Cast <RavenhillResourceService>();
                var mapData        = resourceSerice.GetRoomData(RoomType.map);
                if (mapData != null)
                {
                    LoadScene(mapData.id);
                }
            }
        }