コード例 #1
0
 public void SetOverride(LevelID overrideID)
 {
     foreach (LevelSelectUI ui in uis)
     {
         ui.SetOverride(overrideID);
     }
 }
コード例 #2
0
 public static int MaxLevel()
 {
     LevelData[] levels = GetAllLevelData();
     return(levels
            .Select(level => LevelID.FromSceneName(level.Level.SceneName).LevelNumber)
            .Max());
 }
コード例 #3
0
        public static string GetLevelName(this LevelID levelId, GameSettings gameSettings)
        {
            switch (levelId)
            {
            case LevelID.SnowyPeaks:
                return(gameSettings.SnowyPeaksSceneName);

            case LevelID.Jimsterburg:
                return(gameSettings.JimsterburgSceneName);

            case LevelID.ParabeneForest:
                return(gameSettings.ParabeneForestSceneName);

            case LevelID.BlemburgCitadel:
                return(gameSettings.BlemburgCitadelSceneName);

            case LevelID.DarkTower:
                return(gameSettings.DarkTowerSceneName);

            case LevelID.RinfretVillage:
                return(gameSettings.RinfretVillageSceneName);

            case LevelID.TulipValley:
                return(gameSettings.TulipValleySceneName);

            case LevelID.Morktress:
                return(gameSettings.MorktressSceneName);

            default:
                throw new ArgumentOutOfRangeException(nameof(levelId), levelId, null);
            }
        }
コード例 #4
0
    public static LevelData GetLevelData(LevelID levelID)
    {
        // Setup the path to use the enclosure number only if it is not level 0
        string path = $"LevelData/Level{levelID.LevelNumber}/L{levelID.LevelNumber}";

        if (levelID.LevelNumber != 0)
        {
            path += $"E{levelID.EnclosureNumber}";
        }
        path += "Data";

        // Load the data at the computed path
        LevelData data = Resources.Load <LevelData>(path);

        // If you got level data then return it
        if (data)
        {
            return(data);
        }
        // If you did not get level data then throw an exception
        else
        {
            throw new MissingReferenceException($"{nameof(LevelDataLoader)}: " +
                                                $"Failed to load level {levelID.LevelName} from resource path {path}");
        }
    }
コード例 #5
0
    public override void Setup()
    {
        base.Setup();

        // Setup the bookmark target to get-set the enclosure id
        bookmarkTarget.Setup(() => CurrentLevelID, x => CurrentLevelID = (LevelID)x);

        // Clear out any existing options
        levelDropdown.ClearOptions();
        enclosureDropdown.ClearOptions();

        // Loop through all enclosure id's and add them to the list
        foreach (LevelID id in UIParent.Data.Levels)
        {
            TMP_Dropdown.OptionData option = LevelNumberToOptionData(id.LevelNumber);
            // If no option with the same text yet exists, then add it to the dropdown
            if (levelDropdown.options.FindIndex(x => x.text == option.text) < 0)
            {
                levelDropdown.options.Add(option);
            }
        }

        // Update the level dropdown to reflect the current level
        LevelID currentLevel = LevelID.Current();

        levelDropdown.value = currentLevel.LevelNumber;
        levelDropdown.RefreshShownValue();
        OnLevelDropdownValueChanged(levelDropdown.value);

        // Add listeners for the value changed events
        levelDropdown.onValueChanged.AddListener(OnLevelDropdownValueChanged);
        enclosureDropdown.onValueChanged.AddListener(OnEnclosureDropdownValueChanged);
    }
コード例 #6
0
ファイル: PlayerManager.cs プロジェクト: Ranackk/Plokoth
    ////////////////////////////////////////////////////////////////

    void ResetResetPlants(LevelID levelID)
    {
        for (int i = 0; i < m_ResetPlantSpawners.Count; i++)
        {
            m_ResetPlantSpawners[i].ResetSpawnTimer();
        }

        for (int i = 0; i < m_ResetPlantData.Count; i++)
        {
            ResetPlantData resetPlantData = m_ResetPlantData[i];

            if (resetPlantData._ResetPlant._LevelID != levelID)
            {
                continue;
            }

            if (!resetPlantData._Respawns)
            {
                // #destroySpawnedResetPlant
                GameObject.Destroy(resetPlantData._ResetPlant.gameObject);
                m_ResetPlantData.RemoveAt(i);
                i--;
                continue;
            }

            // Reset Timers
            resetPlantData._PloppedTimer = new GameTicks(0);
            resetPlantData._ResetPlant.TransitionToState(ResetPlantState.Default, false);
        }
    }
コード例 #7
0
    private void OnLevelDropdownValueChanged(int value)
    {
        int selectedLevel = OptionDataToLevelNumber(levelDropdown.options[value]);

        // Clear out the options in the enclosure dropdown
        enclosureDropdown.ClearOptions();
        foreach (LevelID id in UIParent.Data.Levels)
        {
            if (id.LevelNumber == selectedLevel)
            {
                enclosureDropdown.options.Add(EnclosureNumberToOptionData(id.EnclosureNumber));
            }
        }

        // Get the enclosure represented in the current scene
        LevelID currentLevel = LevelID.Current();

        // If we selected the current level, then select the current enclosure number
        if (currentLevel.LevelNumber == selectedLevel)
        {
            enclosureDropdown.value = currentLevel.EnclosureNumber - 1;
        }
        else
        {
            enclosureDropdown.value = 0;
        }

        // Set the enclosure to the first one selected
        enclosureDropdown.RefreshShownValue();
        OnEnclosureDropdownValueChanged(enclosureDropdown.value);
    }
コード例 #8
0
    public void OnLevelEncountered(LevelID level)
    {
        // Get all entries with the given level
        Entry latestEntry = GetEntryWithLatestAttempt(level);

        if (latestEntry != null)
        {
            // Add an entry for the next attempt to the list of entries
            entries.Add(new Entry
            {
                level   = level,
                attempt = latestEntry.attempt + 1,
                reviews = new ReviewedResourceRequestList()
            });
        }
        // If no entries were found with this level, then we add the first one
        else
        {
            entries.Add(new Entry
            {
                level   = level,
                attempt = 1,
                reviews = new ReviewedResourceRequestList()
            });
        }
    }
コード例 #9
0
    public Entry GetEntryWithLatestAttempt(LevelID level)
    {
        IEnumerable <Entry> entries = GetEntriesWithLevel(level);

        // If some entries exist then search for the latest one
        if (entries.Count() > 0)
        {
            Entry maxEntry = null;

            foreach (Entry entry in entries)
            {
                // If max entry is not yet set then make it this entry
                if (maxEntry == null)
                {
                    maxEntry = entry;
                }
                // If this entry was attempted later than the max entry,
                // make the max entry this entry
                else if (entry.attempt > maxEntry.attempt)
                {
                    maxEntry = entry;
                }
            }

            return(maxEntry);
        }
        // If no entries exist then return null
        else
        {
            return(null);
        }
    }
コード例 #10
0
    private void OnEnclosureSelected(LevelID id)
    {
        // Destroy all existing editors
        foreach (TestAndMetricsEntryEditor editor in currentEditors)
        {
            Destroy(editor.gameObject);
        }
        // Clear out the list
        currentEditors.Clear();

        // Foreach entry in the selected list, add an editor
        foreach (TestAndMetricsEntryData entry in UIParent.Data.TestAndMetrics.GetEntryList(id).Entries)
        {
            TestAndMetricsEntryEditor editor = Instantiate(editorPrefab, editorParent.transform);
            editor.Setup(id, entry, editorScroller);
            currentEditors.Add(editor);
        }

        // If the enclosure selected is the current enclosure, then add a new editor
        // that we can use to add more entries
        if (id == LevelID.Current())
        {
            CreateAddingEntry();
        }
    }
コード例 #11
0
 public static void SetMessageLevel(MethodID messageMethod = MethodID.MESS_METHOD_GENERAL_ID,
                                    LevelID messageLevel   = LevelID.MESS_LEVEL_GENERAL)
 {
     //Call the version 6 and 7 set message level first, if the file is 6 then the ZSetMessageLevel will not work, and we can still use MethodIDs for 7.
     DSS.ZSet("mlvl", "", (int)messageLevel);
     DSS.ZSetMessageLevel((int)messageMethod, (int)messageLevel);
 }
コード例 #12
0
    /// <summary>
    /// Connects the player to the requested game level
    /// Will find the first open rooom with available slots
    /// </summary>
    public void JoinGameLevel(LevelID level)
    {
        SetStatus("Joining Level");

        m_levelJoined = level;
        PhotonNetwork.JoinLobby(m_lobbys[(int)level]);
    }
コード例 #13
0
    public void Setup(NotebookTab tab, ToggleGroup parent, UnityAction <NotebookTab> callback)
    {
        // Setup the notebook child base
        base.Setup();

        // Set the tab
        this.tab = tab;

        // Setup the toggle
        myToggle.group = parent;
        myToggle.onValueChanged.AddListener(OnToggleStateChanged);
        // Listen for the callback when selected event is raised
        selectedEvent.AddListener(callback);

        // Set the text on the GUI element
        tabName.text = tab.ToString();

        if (GameManager.Instance)
        {
            // This toggle is only interactable if the tab scaffold says so
            LevelID current = LevelID.Current();
            myToggle.interactable = UIParent.Config.TabScaffold.GetMask(current).Get(tab);
        }
        else
        {
            myToggle.interactable = true;
        }
    }
コード例 #14
0
    public void Setup(LevelID levelID)
    {
        // Check if the interactability is based on completion or not
        if (basedOnCompletion)
        {
            // Get the id of the previous level
            LevelID previous = new LevelID(levelID.Type, levelID.Index - 1);

            // If it is valid, the button is interactable if the previous level has been completed
            if (previous.IsValid)
            {
                button.interactable = PlayerData.GetCompletionData(previous).Completed;
            }
            else
            {
                button.interactable = true;
            }
        }
        else
        {
            button.interactable = true;
        }

        // Add listener to the button if it is interactable
        if (button.interactable)
        {
            button.onClick.AddListener(() => GameplayManager.PlayLevel(levelID));
        }

        // Set the text on the component
        text.text = levelID.Data.Name;
    }
コード例 #15
0
ファイル: SaveData.cs プロジェクト: tg1230/Space-Zoologist
 public static void QualifyForLevel(LevelID level)
 {
     if (level > Instance.latestLevelQualified)
     {
         Instance.latestLevelQualified = level;
     }
 }
コード例 #16
0
    public override void Setup()
    {
        base.Setup();

        // Add listener for the enclosure picked event
        enclosurePicker.OnLevelIDPicked.AddListener(OnEnclosureSelected);
        OnEnclosureSelected(LevelID.Current());
    }
コード例 #17
0
    private void CreateAddingEntry()
    {
        TestAndMetricsEntryEditor editor = Instantiate(editorPrefab, editorParent.transform);

        editor.Setup(LevelID.Current(), null, editorScroller);
        editor.OnNewEntryCreated.AddListener(OnNewEntryCreated);
        currentEditors.Add(editor);
    }
コード例 #18
0
    public void SetOverride(LevelID levelOverride)
    {
        overridden         = true;
        this.levelOverride = levelOverride;

        // Disable outline in case this makes the ui not interactable anymore
        outline.SetActive(false);
    }
コード例 #19
0
ファイル: SaveData.cs プロジェクト: tg1230/Space-Zoologist
 public static void TrySetLatestLevelIntro(LevelID id)
 {
     //If the latest level Intro finished is less, than update
     if (Instance.latestLevelIntroFinished < id)
     {
         Instance.latestLevelIntroFinished = id;
     }
 }
コード例 #20
0
    public override void Setup()
    {
        base.Setup();

        // Add listnener to enclosure id picked event and select the enclosure for the current scene
        enclosurePicker.OnLevelIDPicked.AddListener(OnEnclosureSelected);
        OnEnclosureSelected(LevelID.Current());
    }
コード例 #21
0
    public ObservationsEntryListData(NotebookConfig config, LevelID id) : base(config)
    {
        // Copy the list from the initial entries to this one
        LevelScaffold scaffold = config.Observations.Scaffold;
        List <ObservationsEntryListData> initialEntries = config.Observations.InitialEntries;
        ObservationsEntryListData        copyList       = initialEntries[scaffold.ScaffoldLevel(id)];

        entries = new List <ObservationsEntryData>(copyList.entries);
    }
コード例 #22
0
    private void OnEnclosureDropdownValueChanged(int value)
    {
        TMP_Dropdown.OptionData levelOptionSelected     = levelDropdown.options[levelDropdown.value];
        TMP_Dropdown.OptionData enclosureOptionSelected = enclosureDropdown.options[value];
        LevelID levelSelected = new LevelID(OptionDataToLevelNumber(levelOptionSelected), OptionDataToEnclosureNumber(enclosureOptionSelected));

        onLevelIDPicked.Invoke(levelSelected);
        UIParent.OnContentChanged.Invoke();
    }
コード例 #23
0
ファイル: PlayerManager.cs プロジェクト: Ranackk/Plokoth
    ////////////////////////////////////////////////////////////////

    private void InitializePlayerForLevel(LevelID level)
    {
        if (m_PlayerController == null || m_PlayerController.gameObject == null)
        {
            // Get player asset
            AssetDataPlayer assetData = AssetManager.GetAssetData <AssetDataPlayer>();

            // Spawn the player
            GameObject playerObject = GameObject.Instantiate(assetData.PlayerPrefab, GameCore.Get().transform);
            m_PlayerController = playerObject.GetComponentInChildren <PlayerController>();
        }

        AssetDataLevels assetDataLevels      = AssetManager.GetAssetData <AssetDataLevels>();
        bool            isIntroCutsceneLevel = level == assetDataLevels.LevelWithIntroCutscene;

        m_GameState = isIntroCutsceneLevel ? GameState.Pregameplay : GameState.Gameplay;

        ////////////////////////////////////////////////////////////////

        // 1st prio: current spawn point (set by loading level)
        if (m_CurrentPlayerSpawnPoint != null)
        {
            m_PlayerController.Reset(m_CurrentPlayerSpawnPoint.transform.position);
            return;
        }

        // 2nd prio: spawn at first spawnpoint in this level

        //Find all spawn points in level
        List <PlayerSpawnPoint> validSpawnPoints = m_PlayerSpawnPoints.FindAll((PlayerSpawnPoint psp) => {
            return(psp._LevelID == level);
        });

        bool success = validSpawnPoints.Count != 0;

        if (success)
        {
            // Sort by ID
            validSpawnPoints.Sort((PlayerSpawnPoint lhs, PlayerSpawnPoint rhs) => {
                if (lhs.Index == rhs.Index)
                {
                    return(0);
                }

                return((lhs.Index < rhs.Index) ? -1 : 1);
            });

            m_PlayerController.Reset(validSpawnPoints[0].transform.position);
        }
        else
        {
            m_PlayerController.Reset(Vector3.zero);
        }

        m_PlayerController.SetVisible(!isIntroCutsceneLevel);
    }
コード例 #24
0
 public void ToggleOverride(LevelID overrideID)
 {
     if (Overridden)
     {
         ClearOverride();
     }
     else
     {
         SetOverride(overrideID);
     }
 }
コード例 #25
0
    public static LevelID[] GetAllLevelIDsOfType(LevelType type)
    {
        LevelID[] ids = new LevelID[Instance.levelDatas.Get(type).list.Length];

        for (int i = 0; i < ids.Length; i++)
        {
            ids[i] = new LevelID(type, i);
        }

        return(ids);
    }
コード例 #26
0
 public string GetLevelHash()
 {
     if (IsOST)
     {
         return("");
     }
     else
     {
         return(LevelID.Substring(CustomLevelLoader.kCustomLevelPrefixId.Length, 40));
     }
 }
コード例 #27
0
ファイル: DebuggingUI.cs プロジェクト: tg1230/Space-Zoologist
    private void ToggleLevelSelectOverride()
    {
        LevelNavigator navigator = FindObjectOfType <LevelNavigator>();

        // If the navigator exists then toggle its override
        if (navigator)
        {
            LevelID maxID = new LevelID(LevelDataLoader.MaxLevel() + 1, 1);
            navigator.ToggleOverride(maxID);
        }
    }
コード例 #28
0
ファイル: PlayerManager.cs プロジェクト: Ranackk/Plokoth
    ////////////////////////////////////////////////////////////////

    private bool InitializePlayerSpawnPointToStartFrom(LevelID level)
    {
        SetPlayerSpawnPoint(m_PlayerSpawnPoints.Find((PlayerSpawnPoint psp) => {
            return(psp.Index == m_PlayerSpawnPointToStartFrom.Value.ID && psp._LevelID == m_PlayerSpawnPointToStartFrom.Value.Level);
        }));

        SoundManager.Get().FitSoundToArea(m_CurrentPlayerSpawnPoint._AreaID);

        Debug.Assert(m_CurrentPlayerSpawnPoint != null, "Could not find serialized player spawnpoint ID " + m_PlayerSpawnPointToStartFrom.Value.ID + " in level " + level.ToString());

        return(m_CurrentPlayerSpawnPoint != null);
    }
コード例 #29
0
ファイル: NotebookUI.cs プロジェクト: tg1230/Space-Zoologist
    private void Start()
    {
        // Load the notebook from save, or create a new one if save data doesn't exist
        data = GameManager.Instance.LoadNotebook() ?? new NotebookData(config);

        // Set the configuration of the notebook data
        data.SetConfig(config);

        // Add the current level
        data.OnLevelEncountered(LevelID.Current());

        // Try to get an instance of the game manager
        GameManager instance = GameManager.Instance;

        // If the instance exists then unlock all item id's that exist in the list of items
        if (instance)
        {
            foreach (LevelData.ItemData item in instance.LevelData.ItemQuantities)
            {
                data.UnlockItem(item.itemObject.ItemID);
            }
        }

        // Setup the tab picker first of all children
        tabPicker.Setup();

        // Get the resource request editor manually
        resourceRequestEditor = GetComponentInChildren <ResourceRequestEditor>(true);

        // Setup all children, ensuring correct initialization order
        NotebookUIChild[] children = GetComponentsInChildren <NotebookUIChild>(true);
        foreach (NotebookUIChild child in children)
        {
            child.Setup();
        }

        // Map all bookmark targets to their corresponding game object names
        BookmarkTarget[] allBookmarkTargets = GetComponentsInChildren <BookmarkTarget>(true);
        foreach (BookmarkTarget bookmarkTarget in allBookmarkTargets)
        {
            nameTargetMap.Add(bookmarkTarget.name, bookmarkTarget);
        }

        // Setup sound events after all children are set up
        soundManager.SetupSoundEvents();

        // This line of code prevents the notebook from turning off the first time that it is turned on,
        // while also making sure it is turned off at the start
        if (!isOpen)
        {
            SetIsOpen(false);
        }
    }
コード例 #30
0
 public static LevelData GetLevelData(LevelID id)
 {
     LevelData[] list = Instance.levelDatas.Get(id.Type).list;
     if (id.Index >= 0 && id.Index < list.Length)
     {
         return(list[id.Index]);
     }
     else
     {
         return(null);
     }
 }
コード例 #31
0
    /// <summary>
    /// Selects the level
    /// </summary>
    private void SelectNewLevel(GameObject level)
    {
        m_selectedLevel = (LevelID)(int.Parse(level.name) - 1); // Levels start at 0
        selectedLevel = level;

        SetMaxPlayerSlider(true);

        slider.GetComponentInParent<GUIMaxPlayers>().SetMaxPlayers(
            Utilities.GetMaxPlayersForLevel(m_selectedLevel));

        if (m_firstSelection)
        {
            m_unselectedColor = GetSelectedBackground().color;
            m_firstSelection = false;
        }
        GetSelectedBackground().color = m_selectedColour;

        isReady.isOn = false;
    }
コード例 #32
0
    /// <summary>
    /// Connects the player to the requested game level
    /// Will find the first open rooom with available slots
    /// </summary>
    public void JoinGameLevel(LevelID level)
    {
        SetStatus("Joining Level");

        m_levelJoined = level;
        PhotonNetwork.JoinLobby(m_lobbys[(int)level]);
    }
コード例 #33
0
    /// <summary>
    /// Called after the connection to the master is established and 
    /// authenticated but only when PhotonNetwork.autoJoinLobby is false.
    /// </summary>
    public override void OnConnectedToMaster()
    {
        SetStatus("Connected to server");

        if(Utilities.IsLevelLoaded() && !IsConnectedToLevel())
        {
            // Level has not been joined using the lobby (for development)
            // Or level joined can be easily rejoined
            if(m_levelJoined == LevelID.NO_LEVEL ||
               Utilities.IsOpenLeveL(m_levelJoined))
            {
                JoinGameLevel(Utilities.GetLoadedLevel());
            }
            else
            {
                // Player has disconnected during a closed level
                // Force move the player back to the lobby
                m_levelJoined = LevelID.NO_LEVEL;
                Application.LoadLevel((int)SceneID.LOBBY);
            }
        }
    }