void ConsumePellet() { GameObject o = GetTileAtPosition(transform.position); //pellet object created with correct coordinates if (o != null) { Pills tile = o.GetComponent <Pills>(); //gets pill information if (tile != null) { if (!tile.Consumed && (tile.isPellet || tile.isLargePellet)) { //tile has visible pellet and is a pellet of some form o.GetComponent <SpriteRenderer>().enabled = false; //make oill invisible tile.Consumed = true; //update system GameObject temp = GameObject.Find("Game"); //get the game object. gameBoard game = temp.GetComponent <gameBoard>(); //get the game state game.score(); //score game.munch(); if (tile.isLargePellet) { GhostController.ScaredTimer = 0f; GhostController.IsScared = true; } //game.addTime(BUFFER_PILL_TIME);// WORKS AT SPEED 5 or maybe sorta (.45f*(5/speed)) //if (!temp.GetComponent<AudioSource>().isPlaying) //{ // temp.GetComponent<AudioSource>().Play(); //} } } } }
void ConsumePellet() { GameObject o = GetTileAtPosition(transform.position); //pellet object created with correct coordinates if (o != null) { Pills tile = o.GetComponent <Pills>(); //gets pill information if (tile != null) { if (!tile.Consumed && (tile.isPellet || tile.isLargePellet)) { //tile has visible pellet and is a pellet of some form o.GetComponent <SpriteRenderer>().enabled = false; //make oill invisible tile.Consumed = true; //update system GameObject temp = GameObject.Find("Game"); //get the game object. gameBoard game = temp.GetComponent <gameBoard>(); //get the game state game.score(); //score game.munch(); totalPellets++; if (totalPellets == allPellets) // allPellets = 191 { GhostController.canCruise = false; GetComponent <Animator>().enabled = false; GetComponent <SpriteRenderer>().sprite = nextLevel; GameObject.Find("Game").GetComponent <gameBoard>().LevelUp(); } if (totalPellets == cruisePellets) // cruisePellets = 140, after 140 pellets blinky speeds up { GhostController.canCruise = true; //GhostController.cruiseElroy(); } if (tile.isLargePellet) { if (GhostController.IsScared) { Debug.Log("Ghost # = " + ghostCounter); } else { ghostCounter = 1; } GhostController.ScaredTimer = 0f; GhostController.IsScared = true; } //game.addTime(BUFFER_PILL_TIME);// WORKS AT SPEED 5 or maybe sorta (.45f*(5/speed)) //if (!temp.GetComponent<AudioSource>().isPlaying) //{ // temp.GetComponent<AudioSource>().Play(); //} } } } }