public void SwitchLevelEnd(int lvlId) { LvlMode = 1; LevelData data = LevelDataBase.LoadLevelData(lvlId); GameManager.Instance.LoadLevel(lvlId, data, true); GameManager.Instance.EnableWinCheck = false; }
public void PlayLevel(int levelId) { LevelData data = LevelDataBase.LoadLevelData(levelId); LoadLevel(levelId, data, false); EnableWinCheck = true; CheckWinGrids = new bool[GridRowCount, GridColCount]; foreach (ElementData eleData in data.LevelEnd) { if (eleData.Catagory == 2) { CheckGreenGrid = new Vector2(eleData.GridX, eleData.GridY); continue; } if (eleData.Catagory == 3) { CheckRedGrid = new Vector2(eleData.GridX, eleData.GridY); continue; } ElementInfo eleInfo = ElementFactory.ElementInfos.First(ei => ei.Catagory == eleData.Catagory && ei.Type == eleData.Type); int eleGridX = eleData.GridX; int eleGridY = eleData.GridY; foreach (Vector2 pos in eleInfo.OccupyGridsL) { int eleSegX = (int)(eleGridX + pos.x); int eleSegY = (int)(eleGridY + pos.y); if (GetGridWorldIndex(eleSegX) == 0) { CheckWinGrids[eleSegY, eleSegX] = true; } } foreach (Vector2 pos in eleInfo.OccupyGridsR) { int eleSegX = (int)(eleGridX + pos.x); int eleSegY = (int)(eleGridY + pos.y); if (GetGridWorldIndex(eleSegX) == 1) { CheckWinGrids[eleSegY, eleSegX] = true; } } } // add guides for (int i = 0; i < GridRowCount; i++) { for (int j = 0; j < GridColCount; j++) { if (CheckWinGrids[i, j]) { GameObject guide = (GameObject)Instantiate(Resources.Load <GameObject>("guideElement")); Guides.Add(guide); guide.transform.position = new Vector3(PosStartX + GridWorldSize * j, PosStartY + GridWorldSize * i, -0.05f); } } } GuideGreen = (GameObject)Instantiate(Resources.Load <GameObject>("guideGreen")); GuideGreen.transform.position = new Vector3(PosStartX + GridWorldSize * (CheckGreenGrid.x + 0.5f), PosStartY + GridWorldSize * (CheckGreenGrid.y - 0.5f), -0.05f); GuideRed = (GameObject)Instantiate(Resources.Load <GameObject>("guideRed")); GuideRed.transform.position = new Vector3(PosStartX + GridWorldSize * (CheckRedGrid.x + 0.5f), PosStartY + GridWorldSize * (CheckRedGrid.y - 0.5f), -0.05f); // show intro Transform introTrans = PanelGame.transform.Find("Intro"); if (introTrans) { Destroy(introTrans.gameObject); } GameObject intro = new GameObject("Intro"); intro.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Intros/intro_" + levelId.ToString("D2")); intro.transform.parent = PanelGame.transform; }