public FoodController(FoodManager _foodManager) { foodManager = _foodManager; PopulatefoodDataFromFile(_foodManager.foodDataFile); foodParticleModel = new FoodModel(); foodparticleview = GameObject.Instantiate <FoodView>(foodManager.foodParticlePrefab, UtilityFunctions.GetTransformsForCoordinatesOnBoardPlane(new Coordinate(8, 8), 0.6f), Quaternion.identity); foodParticleModel.SetFoodProperties(new Coordinate(8, 8), Color.red, foodData[Color.red]); foodparticleview.GetComponent <Renderer>().material.color = Color.red; }
public void ResetFoodParticleProperties() { List <Color> colourList = new List <Color>(foodData.Keys); System.Random rand = new System.Random(); Color randomColor = colourList[rand.Next(0, colourList.Count)]; if (foodParticleModel.foodColor == randomColor) { foodManager.GetScoreManager().IncrementStreak(); } else { foodManager.GetScoreManager().ResetStreak(); } //Generating a random position for food particle Coordinate newFoodCoordinate = GetRandomCoordinateOutsideSnake(); foodParticleModel.SetFoodProperties(new Coordinate((int)newFoodCoordinate.row, (int)newFoodCoordinate.column), randomColor, foodData[randomColor]); foodparticleview.transform.position = UtilityFunctions.GetTransformsForCoordinatesOnBoardPlane(newFoodCoordinate, 0.6f); foodparticleview.GetComponent <Renderer>().material.color = randomColor; }