private void Init(TextAsset mapFile) { GameManager.main.SetScore(score); GameManager.main.ShowLevelText(inASecretLevel, nextLevel + 1); if (inASecretLevel) { SoundManager.main.PlaySound(SoundType.SecretEnd); secretMusic.volume = 0.8f; normalMusic.volume = 0f; } else if (nextLevel > 0) { SoundManager.main.PlaySound(SoundType.End); secretMusic.volume = 0f; normalMusic.volume = 0.6f; } mapGrid.Clear(); GameManager.main.SetMapGrid(mapGrid); GameManager.main.SetLevelLoader(this); XDocument mapX = XDocument.Parse(mapFile.text); TmxMap map = new TmxMap(mapX); //PlayerMovement player = Instantiate(playerPrefab); //GameManager.main.SetPlayer(player); Debug.Log(string.Format("Opening {0}", mapFile.name)); TiledMap tiledMap = Instantiate(tiledMapPrefab); tiledMap.Init(map, this, mapGrid); //mapGrid.Activate(); }
static public TiledMap FromFile(string file) { TiledMap map = null; string jsonString; bool errCode = IOTools.LoadTextFromFile(file, out jsonString); if (jsonString == null || jsonString.Length <= 0) { Debug.LogAssertion("Can't open json file: " + file); } else { map = JsonUtility.FromJson <TiledMap> (jsonString); map.Init(); } return(map); }
// Use this for initialization void Start() { indicatorCursor = (Transform)Instantiate(indicatorCursor); indicatorSelected = (Transform)Instantiate(indicatorSelected); indicatorCursor.parent = transform; indicatorSelected.parent = transform; HideIndicator(); //TODO 暂时先放这里,应该放在加载地图后 if (_tileMap == null) { _tileMap = this.GetComponentInChildren <TiledMap>(); if (_tileMap) { _tileMap.Init(); } } }