Esempio n. 1
0
    public void AddLevelCompletionInfo(SceneHandler.Scene scene, int score, float time)
    {
        bool sceneExists = false;
        LevelCompletionEntry levelCompletionEntry = new LevelCompletionEntry {
            scene = scene, score = score, time = time
        };
        LevelCompletionInfo levelCompletionInfo = new LevelCompletionInfo();

        levelCompletionInfo = levelCompletionInfo.Load();
        for (int i = 0; i < levelCompletionInfo.LevelCompletionEntryList.Count; i++)
        {
            if (levelCompletionInfo.LevelCompletionEntryList[i].scene == scene)
            {
                sceneExists = true;
                if (levelCompletionInfo.LevelCompletionEntryList[i].score < score)
                {
                    levelCompletionInfo.LevelCompletionEntryList[i] = levelCompletionEntry;
                }
                else if (levelCompletionInfo.LevelCompletionEntryList[i].score == score && levelCompletionInfo.LevelCompletionEntryList[i].time > time)
                {
                    levelCompletionInfo.LevelCompletionEntryList[i] = levelCompletionEntry;
                }
            }
        }

        if (!sceneExists)
        {
            levelCompletionInfo.LevelCompletionEntryList.Add(levelCompletionEntry);
        }
        SaveHandler <LevelCompletionInfo> .Save(levelCompletionInfo, SaveHandler <LevelCompletionInfo> .SaveFileName.levelCompletionInfo);
    }
Esempio n. 2
0
 /// <summary>
 /// Applies the selected <see cref="LevelCompletionInfo"/>, or makes a new one if it is null.
 /// </summary>
 /// <param name="completionInfo">The level completion status to apply, null makes a new one</param>
 /// <param name="timeRemaining">The time remaining for this level</param>
 public void LoadSave(LevelCompletionInfo completionInfo = default, float timeRemaining = LevelCompletionInfo.DefaultTime)
 {
     if (completionInfo == default)
     {
         if (SaveFileManager.IsFileOpened)
         {
             CurrentCompletionInfo = Level.GetSaveFileInfo(SaveFileManager.Current);
         }
         else
         {
             CurrentCompletionInfo = new LevelCompletionInfo()
             {
                 LevelName      = Level.Name,
                 LevelWorldName = Level.LevelWorldName,
                 TimeRemaining  = timeRemaining
             }
         };
     }
     else
     {
         CurrentCompletionInfo = completionInfo;
     }
     if (CurrentCompletionInfo != null)
     {
         CurrentCompletionInfo.TimeRemaining    = timeRemaining;
         CurrentCompletionInfo.PattiesCollected = 0;
         CurrentCompletionInfo.BonusesCollected = 0;
     }
     if (!Pickups.ContainsKey("TIME"))
     {
         Pickups.Add("TIME", new WorldPickupDefinition(timeRemaining, timeRemaining));
     }
 }
Esempio n. 3
0
    public void LevelHasBeenCompleted()
    {
        LevelCompletionInfo myLevelCompletionInfo = new LevelCompletionInfo();

        myLevelCompletionInfo = myLevelCompletionInfo.Load();
        myLevelCompletionInfo.AddLevelCompletionInfo(SceneHandler.GetActiveSceneEnum(), totalScore, Time.timeSinceLevelLoad);
        return;
    }
Esempio n. 4
0
    public LevelCompletionInfo Load()
    {
        LevelCompletionInfo myTempLevelCompletionInfo;

        myTempLevelCompletionInfo = SaveHandler <LevelCompletionInfo> .Load(SaveHandler <LevelCompletionInfo> .SaveFileName.levelCompletionInfo);

        if (myTempLevelCompletionInfo == null)
        {
            myTempLevelCompletionInfo = new LevelCompletionInfo();
            SaveHandler <LevelCompletionInfo> .Save(myTempLevelCompletionInfo, SaveHandler <LevelCompletionInfo> .SaveFileName.levelCompletionInfo);
        }
        return(myTempLevelCompletionInfo);
    }
Esempio n. 5
0
        /// <summary>
        /// Returns the <see cref="LevelCompletionInfo"/> for this level, or creates one if one does not exist
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public LevelCompletionInfo GetSaveFileInfo(SaveFile file)
        {
            if (file.LevelInfo.TryGetValue(LevelWorldName, out var value))
            {
                return(value);
            }
            var newInfo = new LevelCompletionInfo()
            {
                LevelWorldName = LevelWorldName,
                LevelName      = Name,
                TimeRemaining  = 0
            };

            file.UpdateInfo(newInfo);
            return(newInfo);
        }
Esempio n. 6
0
 void LoadLevel(LevelCompletionInfo completionInfo = default)
 {
     if (!IsDone)
     {
         screenBlocker        = GameObject.Find("ScreenBlocker");
         CurrentObjectManager = this;
         World.SetCurrent(new World(LoadLevelName + ".lv5")); // set the current world
         PlayMusic(Context);                                  // play the level music
         LoadingPercentage = 0;                               // update the percent complete of level layer loading
         isLoadingLevel    = true;
         int timeRemaining = World.Current.Level.LevelTime;   // set the time remaining for the level
         levelTime = TimeSpan.FromSeconds(timeRemaining);
         World.Current.LoadSave(completionInfo);              // load save information for the current world
         Player.CurrentPlayer = Assets.Scripts.Game.PlayerEnum.ANYONE;
         LoadNext();
     }
 }
Esempio n. 7
0
    //[SerializeField] Scene[] myScene = new Scene[0];

    //private List<Transform> SceneLevelEntryTransformList;

    private void Awake()
    {
        entryContainer = GameObject.Find("Container_SceneLevelEntry").transform;
        entryTemplate  = GameObject.Find("Template_SceneLevelEntry").transform;

        entryTemplate.gameObject.SetActive(false);



        LevelCompletionInfo levelCompletionInfo = new LevelCompletionInfo();

        levelCompletionInfo = levelCompletionInfo.Load();;



        InstantiateSceneLevelEntryTable(entryContainer, levelCompletionInfo.LevelCompletionEntryList);
    }
        private void PopulateHighScores(LevelCompletionInfo info)
        {
            ExtraHighScores.Children.Clear();
            if (info.HighScores == null)
            {
                return;
            }
            var source = info.HighScores.OrderByDescending(x => x);
            int total  = source.Count();

            for (int count = 0; count < info.HighScores.Length; count++)
            {
                int score = 0;
                if (count < total)
                {
                    score = source.ElementAt(count);
                }
                if (count == 0)
                {
                    HighScore1.Text = score.ToString();
                    continue;
                }
                if (count == 1)
                {
                    HighScore2.Text = score.ToString();
                    continue;
                }
                if (count == 2)
                {
                    HighScore3.Text = score.ToString();
                    continue;
                }
                Border b = new Border()
                {
                    Child = new TextBlock()
                    {
                        Text = $"#{count + 1} - {score}",
                        HorizontalAlignment = HorizontalAlignment.Center
                    }
                };
                ExtraHighScores.Children.Add(b);
            }
        }
 private void ShowInfo(LevelCompletionInfo info)
 {
     LevelFileTitle.Text   = info.LevelName + ", ID: " + info.LevelWorldName;
     LevelScore.Text       = info.LevelScore.ToString();
     PattiesCollected.Text = info.PattiesCollected.ToString();
     BonusesCollected.Text = info.BonusesCollected.ToString();
     if (info.WasSuccessful)
     {
         if (info.WasPerfect)
         {
             Rating.Text = "Perfected";
         }
         Rating.Text = "Completed";
     }
     else if (info.IsAvailable)
     {
         Rating.Text = "Unlocked";
     }
     else
     {
         Rating.Text = "Locked";
     }
     TimeCompleted.Text  = info.TimeRemaining.ToString();
     SaveLevel.IsEnabled = !IsProtectedViewing;
     SaveLevel.Content   = "Apply Changes";
     if (!info.IsAvailable)
     {
         SaveLevel.Content = "Unlock Level and Apply Changes";
     }
     else if (!info.WasSuccessful)
     {
         SaveLevel.Content = "Complete Level and Apply Changes";
     }
     SaveToFile.IsEnabled = !IsProtectedViewing;
     OpenInfo             = info;
     PopulateHighScores(info);
 }
Esempio n. 10
0
    private void PopulateNodeMap()
    {
        LevelCompletionInfo levelCompletionInfo = new LevelCompletionInfo();

        levelCompletionInfo = levelCompletionInfo.Load();

        var temp = GameObject.FindGameObjectsWithTag("Node");

        nodeArray = new Node[temp.Length];

        for (int i = 0; i < temp.Length; i++)
        {
            nodeArray[i] = temp[i].GetComponent <Node>();
        }

        foreach (var o in nodeArray)
        {
            o.IsAccessible = false;
        }

        foreach (var o in nodeArray)
        {
            if (!o.IsTravelNode)
            {
                foreach (var i in levelCompletionInfo.LevelCompletionEntryList)
                {
                    if (o.GetScene() == i.scene)
                    {
                        o.BestScore = i.score;
                        o.BestTime  = i.time;
                        MakeThisAndAllNearbyAccessible(o);
                    }
                }
            }
        }
    }