public void updateScoring() { if (_playerFastest.transform.position.x > (_possmg + 1)) { _possmg = _playerFastest.transform.position.x; Scoring.AddToScore(1); } long tmpscore = Scoring.getScore(); if (tmpscore > 5 && tmpscore < 20) { _level = 2; } else if (tmpscore > 20 && tmpscore < 55) { _level = 3; } else if (tmpscore > 55 && tmpscore < 90) { _level = 4; } else if (tmpscore > 90 && tmpscore < 150) { _level = 5; } else if (tmpscore > 150) { _level = 6; } else { _level = 1; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name.Contains("Enemy")) { score.AddToScore(multiplier); Destroy(collision.gameObject); } }
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(); }
public void TwoCoversTurned() { GameData.numTries++; // look for a match matched = IsThereAMatch(); // if we match half a good sprite with a dynamite sprite, count it as no match if (atLeastOneGood && dynamiteFound) { dynamiteFound = false; } // don't match the skulls // yes, match them because they may be the last two pieces //if (skullFound) // matched = false; float pause = GameData.noMatchPause; if (matched) { pause = GameData.matchPause; } // do this if we found a match if (twoHalves) // found two halves of a whole { GameData.matchesFound++; randY = Random.Range(-2, 2); coversTurned[0].transform.DOMove(new Vector3(0f, randY, 0f), 0.5f); coversTurned[0].GetComponent <SpriteRenderer>().DOFade(0f, 0.5f).OnComplete(() => scoring.AddToScore(100, true)); StartCoroutine(DestroyCell(coversTurned[0], 1.5f)); coversTurned[1].transform.DOMove(new Vector3(0f, randY, 0f), 0.5f); coversTurned[1].GetComponent <SpriteRenderer>().DOFade(0f, 0.5f).OnComplete(() => scoring.AddToScore(100, true)); StartCoroutine(DestroyCell(coversTurned[1], 1.5f)); firstCardTurned = false; secondCardTurned = false; skullFound = false; dynamiteFound = false; atLeastOneGood = false; SoundManager.PlaySFX("mergehalvesalt"); Invoke("MakeNewSwimmer", 0.5f); if (tutorial != null) { Destroy(tutorial); } GameData.canClick = true; CheckForFinish(); } else if (matched) { skullFound = false; // no swapping if skulls were matched GameData.matchesFound++; dt.MakeDriftingText("50", coversTurned[0].transform.position, 2f); dt.MakeDriftingText("50", coversTurned[1].transform.position, 2f); coversTurned[0].GetComponent <Rigidbody2D>().DORotate(359f, 0.25f).SetDelay(0.2f); coversTurned[1].GetComponent <Rigidbody2D>().DORotate(359f, 0.25f).SetDelay(0.2f); Invoke("HandleMatchedPair", GameData.matchPause); } else // there was no match { if (!skullFound && !dynamiteFound) { if (GameData.playAudio) { SoundManager.PlaySFX("sinkDrain1"); } if (scoring.score > 0) { dt.MakeDriftingText("-20", new Vector2(1f, 3.33f), 1f, -0.5f); } scoring.AddToScore(-20); coversTurned[0].transform.DOShakeRotation(0.7f, 40f).SetDelay(0.2f); coversTurned[1].transform.DOShakeRotation(0.7f, 40f).SetDelay(0.2f); Invoke("HideObjects", pause); } } if (skullFound) { // get the row & col of the other object int2 posOne = coversTurned[0].GetComponent <GridCell>().gridPos; int2 posTwo = coversTurned[1].GetComponent <GridCell>().gridPos; bool swapRows = true; if (posOne.y == posTwo.y) //int2 x/y is row/col { swapRows = false; } SwapCells(swapRows, posOne, posTwo); firstCardTurned = false; secondCardTurned = false; skullFound = false; dynamiteFound = false; atLeastOneGood = false; Invoke("HideObjects", pause); } else if (dynamiteFound) { // get the color of the other object and see string nameOne = coversTurned[0].name; string nameTwo = coversTurned[1].name; string colorToGrab = nameOne; if (nameOne == "dynamite") { colorToGrab = nameTwo; } if (nameOne == nameTwo) { Invoke("HideObjects", pause); } else { StartCoroutine(KillAllMatchingGems(colorToGrab, "dynamite")); //Destroy(coversTurned[0]); //Destroy(coversTurned[1]); firstCardTurned = false; secondCardTurned = false; skullFound = false; dynamiteFound = false; atLeastOneGood = false; } } }