/// <summary> /// Calculates the score /// </summary> public void CalculateScore(CollectionBoxes box) { gatheredPlants = Game.Services.GetService <Player>().itemsInInventory; foreach (GameComponent item in gatheredPlants) { if (box.IsMatchingItemType(item)) { AddPointToScore(2); } else { AddPointToScore(-2); } } if (Score < 0) { Score = 0; } }
/// <summary> /// Checks if the passed box collider is touching with players collider for item insertion /// </summary> private void InsertItemsFromHandToBox(CollectionBoxes box) { if (InventoryItem.InventoryItems > 0) { foreach (GameComponent component in itemsInInventory) { if (component is InventoryItem) { // we have to cycle through scene componnents to find out which box box.Insert(component); Game.Components.Remove(component); insertSound = new BaseSound(Game, "Sounds/insert"); insertSound.PlaySound(0.02f); } } // We reset the static varaible in the inventory item class so it draws on the correct position in screen Game.Services.GetService <ScoreManager>().CalculateScore(box); InventoryItem.InventoryItems = 0; itemsInInventory = new List <GameComponent>(); } }