public void Reset(int numCollectibles, CurriculumChallenge curriculumInfo) { var method = MethodBase.GetCurrentMethod(); var attr = (ServerAccess)method.GetCustomAttributes(typeof(ServerAccess), true)[0]; if (!attr.HasAccess) { return; } // Clear the current level ClearChildren(); CreateLevel(curriculumInfo.RequiredOperations, "+"); CreateLevel(curriculumInfo.ExtraOperations, "c"); // Generate the collectibles based on the level array GenerateCollectibles(CollectibleGameObject); GenerateObstacles(); var signActive = Convert.ToInt16(curriculumInfo.Level) > 3; Sign.SetActive(signActive); if (SP_Manager.Instance.IsSinglePlayer()) { ClientSetSignActive(signActive); } else { RpcSetSign(signActive); } GameObject.Find("LevelManager").GetComponent <LevelManager>().Target = curriculumInfo.Target.ToString(); }
/// <summary> /// Return the next challenge for the key stage and lesson /// </summary> /// <param name="year">Target key stage</param> /// <param name="lesson">Target lesson number</param> /// <returns>Next challenge, or null if reached end</returns> public CurriculumChallenge GetNextChallenge(string year, string lesson) { year = year.Substring(5, year.Length - 5); if (_challenges == null || _challenges.MathsProblems.Length == 0) { GetChallengeData(); } if (_challenges.MathsProblems.Length == 0) { return(null); } _levelIndex = (Convert.ToInt16(_levelIndex) + 1).ToString(); var challenge = _challenges.MathsProblems.FirstOrDefault(c => c.Year == year && c.Lesson == lesson && c.Level == _levelIndex); _currentChallenge = challenge; return(challenge); }
public static CurriculumChallenge GetNewChallenge(string year, string lesson) { year = year.Substring(5, year.Length - 5); if (_challenges == null || _challenges.MathsProblems.Length == 0) { GetChallengeData(); } if (_challenges.MathsProblems.Length == 0) { return(null); } var challenges = _challenges.MathsProblems.Where(c => c.Year == year && c.Lesson == lesson).ToList(); GameObject.Find("LevelManager").GetComponent <LevelManager>().TotalRounds = challenges.Count; _levelIndex = challenges[0].Level; #if PSL_ENABLED PSL_LRSManager.Instance.SetNumRounds(challenges.Count); #endif _currentChallenge = challenges[0]; return(challenges[0]); }
public void Restart(bool newRound = false) { var method = MethodBase.GetCurrentMethod(); var attr = (ServerAccess)method.GetCustomAttributes(typeof(ServerAccess), true)[0]; if (!attr.HasAccess) { return; } if (!_generatingLevel) { _generatingLevel = true; // Reset the obstacles if (_generateRocks) { GameObject.Find("LevelColliders/SpawnedObjects") .GetComponent <ObstacleGeneration>().GenerateNewLevel(_level.RoundNumber * 3); } else if (_gameComplete) { _postGameRounds += 1; GameObject.Find("LevelColliders/SpawnedObjects") .GetComponent <ObstacleGeneration>().GenerateNewLevel(_postGameRounds * 3); } else { CurriculumChallenge challenge = null; if (newRound) { if (SP_Manager.Instance.IsSinglePlayer()) { challenge = _curriculum.GetNextChallenge(SP_Manager.Instance.Get <SP_GameManager>().GetYear(), SP_Manager.Instance.Get <SP_GameManager>().GetLesson()); } else { challenge = _curriculum.GetNextChallenge(PSL_GameConfig.Level, PSL_GameConfig.LessonNumber); } } if (challenge == null) { // Reached the end of the game // Dont show game over until the time has run out _generatingLevel = false; _gameComplete = true; _level.RoundNumber -= 1; _level.MathsVersion = false; Restart(newRound: true); } else { GameObject.Find("LevelColliders/SpawnedObjects").GetComponent <CollectibleGeneration>().Setup(0, challenge); } } if (!SP_Manager.Instance.IsSinglePlayer()) { // No need to switch roles here, makes no difference to the player ChangeRoles(); } // Reset Player Posititions var players = GameObject.FindGameObjectsWithTag("Player"); // Reset Platform Positions var platforms = GameObject.FindGameObjectsWithTag("Platform"); foreach (var player in players) { player.GetComponent <Player>().Respawn(); player.GetComponent <Player>().OnPlatform = false; } foreach (var platform in platforms) { platform.GetComponent <FloatingPlatform>().Respawn(); } _generatingLevel = false; } }