Beispiel #1
0
		protected Chapter(LevelMaps levelMap)
		{
			GameLevel = ContentLoader.Load<GameLevel>(levelMap.ToString());
			if (GameLevel == null)
				return;
			GameLevel.ChapterFinished += Completed;
			CreateLevel();
		}
Beispiel #2
0
 protected Chapter(LevelMaps levelMap)
 {
     GameLevel = ContentLoader.Load <GameLevel>(levelMap.ToString());
     if (GameLevel == null)
     {
         return;
     }
     GameLevel.ChapterFinished += Completed;
     CreateLevel();
 }
Beispiel #3
0
    public void SetThisLevel()
    {
        scoring.AddToScore(-scoring.score);             // erase any current score

        levelMaps = GameObject.Find("SceneCode").GetComponent <LevelMaps>();

        Debug.Log("GameData.currWorldNum " + GameData.currWorldNum);
        Debug.Log("GameData.currLevelNum " + GameData.currLevelNum);
        //currLevel = levelMaps.levels.ElementAt(GameData.currLevelNum);
        currLevel = levelMaps.worlds.ElementAt(GameData.currWorldNum).ElementAt(GameData.currLevelNum);

        GameData.numGamesInLevel = levelMaps.worlds.ElementAt(GameData.currWorldNum).Count;

        // get the dimensions of the grid from the level map
        numRows = currLevel.GetLength(0);
        numCols = currLevel.GetLength(1);

        GameData.matchesFound = 0;
        GameData.numTries     = 0;

        totalActiveCells = 0;

        numCells = numCols * numRows;

        GameData.gridPieces = new Dictionary <int2, GameObject>();
        GameData.gridCells  = new Dictionary <int2, GameObject>();

        //--------------------------
        // change size of objects and spacing based on numRows * numCols

        if (numCells >= 41)
        {
            print("numCells >= 41");
            rowSpacing   = 1f;
            colSpacing   = 1f;
            coverWidth   = 0.6f;
            coverHeight  = 0.5f;
            numBadCells  = 2;
            numGoodCells = 5;
        }

        if (numCells <= 40)
        {
            print("numCells <= 40");
            rowSpacing   = 1.2f;
            colSpacing   = 1.25f;
            coverWidth   = 0.8f;
            coverHeight  = 0.65f;
            numBadCells  = 2;
            numGoodCells = 3;
        }

        if (numCells <= 24)
        {
            print("numCells <= 24");
            rowSpacing   = 1.5f;
            colSpacing   = 1.65f;
            coverWidth   = 1f;
            coverHeight  = 0.85f;
            numBadCells  = 0;
            numGoodCells = 1;
        }

        if (GameData.currWorldNum == 0)
        {
            numBadCells  = 0;
            numGoodCells = 2;
        }
        if (GameData.currWorldNum == 1)
        {
            numBadCells  = 1;
            numGoodCells = 3;
        }
        if (GameData.currWorldNum == 2)
        {
            numBadCells  = 2;
            numGoodCells = 4;
        }
        if (GameData.currWorldNum == 3)
        {
            numBadCells  = 2;
            numGoodCells = 5;
        }

        if (GameData.isBetaOnlyGood)
        {
            numBadCells  = 0;
            numGoodCells = 0;
        }


        CountActiveSprites();
        availableSprites = new Sprite[totalActiveCells];

        int idx     = 0;
        int halfway = (totalActiveCells - (numGoodCells * 2) - (numBadCells * 2)) / 2;

        for (int x = 0; x < totalActiveCells; x++)
        {
            if (x % halfway == 0)
            {
                idx = 0;
            }

            availableSprites[x] = cellSprites[idx++];
            if (idx > cellSprites.Length - 1)
            {
                idx = 0;
            }
        }

        if (!GameData.isBetaOnlyGood)
        {
            // do we need to add any goodCells?
            if (numGoodCells > 0)
            {
                idx = 0;
                int thisMany = numGoodCells * 2;
                for (int x = 0; x < thisMany; x++)
                {
                    availableSprites[x++] = goodSprites[idx++];
                    availableSprites[x]   = goodSprites[idx++];
                }
            }

            // do we need to add any badCells?
            if (numBadCells > 0)
            {
                idx = 0;
                int thisMany = numBadCells * 2;
                for (int x = (numGoodCells) * 2; x < (numGoodCells * 2) + thisMany; x++)
                {
                    availableSprites[x++] = badSprites[idx];
                    availableSprites[x]   = badSprites[idx++];
                }
            }
        }

        ShuffleSprites();
        CreateAGrid();
    }