public void AdjustScore(FoodItem food, bool addToScore) { int scoreValue = 1; float totalCategoryMultiplierBonuses = 0; // Checking here because the food scriptable objects have not been set up yet if (food.foodScriptableObject != null) { scoreValue = food.foodScriptableObject.pointValue; foreach (sFood.FoodCategory category in food.foodScriptableObject.foodCategories) { totalCategoryMultiplierBonuses += _foodCategoryMultiplierBonus[category]; } } else { Debug.Log("ScoreSystem::AdjustScore - Food Object does not have food scriptable object set: " + food.gameObject.name); } if (!addToScore) { scoreValue *= -1; } scoreValue += (int)(scoreValue * Math.Max(totalCategoryMultiplierBonuses - 1, 0)); scoreValue += (int)(scoreValue * Math.Max(_globalScoreMultiplierBonus - 1, 0)); _currentScore += scoreValue; // Debugging purposes. Remove when UI is added. Debug.Log("ScoreSystem::AdjustScore - Player Score is now: " + _currentScore); UpdateTotalScoreDisplay(); if (_gameStateController != null) { if (_gameStateController.GetScoreToWin() <= _currentScore) { _gameStateController.EndGame(); } } }