private void handlePizzaComplete(int pizzaIndex) { Entity pizzaEntity = pizzaData.Entities[pizzaIndex]; PizzaGroup pizzaGroup = pizzaData.PizzaGroup[pizzaIndex]; Position2D pizzaPosition = pizzaData.Position[pizzaIndex]; PizzaCost pizzaCost = pizzaData.PizzaCost[pizzaIndex]; // Pizza is done. Debug.Log("PIZZA DONE - " + pizzaGroup.PizzaId + ": " + pizzaCost.OrderCost + " | " + pizzaCost.ActualCost); // Update global score. PostUpdateCommands.CreateEntity(); PostUpdateCommands.AddComponent(new DeductScore { Value = pizzaCost.ActualCost }); PostUpdateCommands.AddSharedComponent(new ScoringGroup { GroupId = 0 }); // Delete this Pizza. MoveSpeed toWindow = new MoveSpeed { speed = BootStrap.GameSettings.ArrowSpeed }; TimedLife timedLife = new TimedLife { TimeToLive = 10.0f }; PostUpdateCommands.AddComponent(pizzaEntity, toWindow); PostUpdateCommands.AddComponent(pizzaEntity, timedLife); PostUpdateCommands.RemoveComponent <PizzaGroup>(pizzaEntity); // TODO: While ingredients are flying off with the pizza, arrows could hit them. for (int i = 0; i < IngredientData.CalculateLength(); i++) { Entity ingredientEntity = IngredientData.GetEntityArray()[i]; //PostUpdateCommands.AddComponent(ingredientEntity, toWindow); //PostUpdateCommands.AddComponent(ingredientEntity, timedLife); //PostUpdateCommands.RemoveComponent<PizzaGroup>(ingredientEntity); PostUpdateCommands.DestroyEntity(ingredientEntity); } // Create new Pizza. createNewPizza(pizzaIndex); }
private void updatePizzaCost(int pizzaIndex) { List <int> currentIngredients = getIngredientsOnPizza(pizzaIndex); PizzaCost pizzaCost = pizzaData.PizzaCost[pizzaIndex]; IngredientList ingredientList = pizzaData.PizzaOrder[pizzaIndex]; List <int> missingIngredients = ingredientList.Value.Except <int>(currentIngredients).ToList(); List <int> extraIngredients = currentIngredients.Except <int>(ingredientList.Value).ToList(); var actualCost = pizzaCost.OrderCost - missingIngredients.Count * 5 - extraIngredients.Count * 5; pizzaCost.ActualCost = actualCost; pizzaData.PizzaCost[pizzaIndex] = pizzaCost; // Legacy BootStrap.SetPizzaOrderUIPrice( (float)pizzaCost.ActualCost / 100, pizzaData.PizzaGroup[pizzaIndex].PizzaId ); }