public bool TryTap(TapPoint tapPoint) { int targetTap = m_LastTapped + 1; int currentTap = TapPoints.IndexOf(tapPoint) + 1; if (currentTap == targetTap) { GoodTap(targetTap, currentTap); return true; } BadTap(targetTap, currentTap, tapPoint); return false; }
/// <summary> /// Starts the game, selected from the Start button from mainmenu /// </summary> public void BeginGame(MainMenu m) { mainMenu = m; score = 0; health = maxHealth; mainMenu.SetHealthMeter(health); tapPoint = (Instantiate(tapPointPrefab) as GameObject).GetComponent <TapPoint>(); if (tapPoint == null) { Debug.LogError("creation of tap point object failed!"); } if (enemySpawner == null) { enemySpawner = (Instantiate(enemySpawnerPrefab) as GameObject).GetComponent <EnemySpawner>(); Debug.LogWarning("No enemy spawner found, creating one by default"); } enemySpawner.gameObject.SetActive(true); carActivate.GetComponent <AllCars>().callingAllcars(); }
private void BadTap(int targetTap, int currentTap, TapPoint tapPoint) { Debug.Log("Failed to tap #" + targetTap + ". Tapped #" + currentTap + " instead."); DrawingDirector.PlayBad(); TapPoint correctTap = TapPoints[m_GoodTaps]; correctTap.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1.2f), 1); m_ReadyForNextNow = true; this.GetOrAddComponent<Fader>().StartFadeOut(); SpriteRenderer spriteRenderer = tapPoint.GetComponent<SpriteRenderer>(); spriteRenderer.material.DOColor(Color.red, 1); Info.Fail(); }