IEnumerator SelectLevel(int selectionID) { selectSound.Play(); itemSelected = true; float endTime = Time.time + delayAfterSelect; LevelReference level = levels[selectionID]; string nextScene = level.sceneName; GameObject o = level.sign; RotateConstantly rotator = o.GetComponent <RotateConstantly>(); Blink blink = o.GetComponent <Blink>(); Animator anim = o.GetComponent <Animator>(); if (rotator != null) { rotator.enabled = true; } if (blink != null) { blink.enabled = true; } if (anim != null) { anim.SetTrigger("Selected"); } yield return(new WaitForSeconds(delayAfterSelect)); UnityEngine.SceneManagement.SceneManager.LoadScene(nextScene); }
public RPGWorld(LevelReference levelRef) : base() { if (levelRef != null) { this.m_DiskLevel = levelRef.Source.LoadLevel(levelRef.Name); } this.m_Octree = new ChunkOctree(); new Chunk(this.m_DiskLevel, this.m_Octree, 0, 0, 0); this.m_Player = new Player(this); this.m_Player.SearchForTerrain = true; this.Entities.Add(this.m_Player); }
public void GetLevels(string inputJson) { allLevels.Clear(); levRef = JsonUtility.FromJson <LevelReference>(inputJson); //Load pre-existing scores GameManager.Instance.GetScoreManager().LoadScores(); //link level int ids to each level reference object foreach (LevelReferenceObject lrObj in levRef.levels.required) { if (lrObj.levelId == -1) { lrObj.levelId = GetLevelId(lrObj.file); } lrObj.completionRank = GameManager.Instance.GetScoreManager().GetCalculatedScore(lrObj.levelId); } foreach (LevelReferenceObject lrObj in levRef.levels.previous) { if (lrObj.levelId == -1) { lrObj.levelId = GetLevelId(lrObj.file); } lrObj.completionRank = GameManager.Instance.GetScoreManager().GetCalculatedScore(lrObj.levelId); } foreach (LevelReferenceObject lrObj in levRef.levels.optional) { if (lrObj.levelId == -1) { lrObj.levelId = GetLevelId(lrObj.file); } lrObj.completionRank = GameManager.Instance.GetScoreManager().GetCalculatedScore(lrObj.levelId); } Object[] loadedObjects = Resources.LoadAll("Levels"); foreach (Object o in loadedObjects) { //TextAsset t = o as TextAsset; allLevels.Add(o); allLevelNames.Add(o.name); } Debug.Log(allLevels.Count + " is all files in resources folder"); }
public void GetLevels(string inputJson) { allLevels.Clear(); levRef = JsonUtility.FromJson <LevelReference>(inputJson); //Load pre-existing scores //GameManager.Instance.GetScoreManager().LoadScores(); try{ //link level int ids to each level reference object foreach (LevelReferenceObject lrObj in levRef.levels.required) { if (lrObj.levelId == -99999) { lrObj.levelId = GetLevelId(lrObj.file); } lrObj.completionRank = GameManager.Instance.GetScoreManager().GetCalculatedScore(lrObj.levelId); } foreach (LevelReferenceObject lrObj in levRef.levels.previous) { if (lrObj.levelId == -99999) { lrObj.levelId = GetLevelId(lrObj.file); } lrObj.completionRank = GameManager.Instance.GetScoreManager().GetCalculatedScore(lrObj.levelId); } foreach (LevelReferenceObject lrObj in levRef.levels.optional) { if (lrObj.levelId == -99999) { lrObj.levelId = GetLevelId(lrObj.file); } lrObj.completionRank = GameManager.Instance.GetScoreManager().GetCalculatedScore(lrObj.levelId); } GetPCGLevels(GameManager.Instance.GetSaveManager().currentSave.pcgLevels); } catch (System.Exception e) { Debug.Log(e); TextAsset lr_text = null; switch (GameManager.Instance.currentGameMode) { case GameManager.GameMode.Class: lr_text = Resources.Load("ClassLoadSelection") as TextAsset; break; case GameManager.GameMode.Demo: lr_text = Resources.Load("DemoLoadSelection") as TextAsset; break; case GameManager.GameMode.Test: lr_text = Resources.Load("TestLoadSelection") as TextAsset; break; case GameManager.GameMode.Study: lr_text = Resources.Load("StudyLoadSelection") as TextAsset; break; } GetLevels(lr_text.text); } }
public void ListenToCurrentReference(LevelReference currentReference) { referenceImage.sprite = currentReference.RefSprite; }
public void ListenToReference(LevelReference currentLevelReference) { _levelProgression.Color_Changed += OnColorChanging; foreach (var item in _levelReference.RefColorsWithPercents) { _levelColors.Add(new ColorAndPercent(item)); } _levelProgression.ColorAndPercents.Clear(); _levelProgression.StarsCount = -1; _levelProgression.Progress = 0; _modelMeshFilter.mesh = currentLevelReference.Mesh; _ghostMeshFiler.mesh = currentLevelReference.Mesh; _levelProgression.IsPainting = false; OnColorChanging(new ColorAndPercent(_levelReference.RefColorsWithPercents[0])); if (_levelColors.Count != _levelButtons.Count) { Debug.LogError("Match Level Colors and Level Buttons count to begin game, D-Head"); return; } foreach (ColorAndPercent item in _levelColors) { item.color.a = 1f; item.percent = 0f; item.pixelsCounter = 0f; item.compared = false; _levelProgression.ColorAndPercents.Add(item); } int counter = _levelColors.Count; for (int i = 0; i < counter; i++) { AssociatedColor associated = _levelButtons[i].gameObject.GetComponent <AssociatedColor>(); if (associated == null) { _levelButtons[i].gameObject.AddComponent <AssociatedColor>().Color = _levelColors[i].color; } else { associated.Color = _levelColors[i].color; } } _myTex = TransferAlpha(_modelTex); //_uvFilledPoints = _modelUVFilled.UVs; //_mappedPoints = _modelUVFilled.MappedPoints; _mappedPoints = GetModelWorldPositionPointsBasedOnKnittingSpeed(_modelMeshFilter, _myTex, _knittingStep, _knittingHeight); if (_mappedPoints == null) { return; } _mappedPointsMax = _mappedPoints.Count; _mappedPointsCounter = 0; _material.mainTexture = _myTex; ManipulateAlpha(_myTex, 0f); }