public override void OnCollided(Entity collidedWith) { if (collidedWith.IsBlocking && collidedWith.Type != EntityType.Obstacle) { OnBlockingCollisionResolvePosition(collidedWith); } Pickup pickup = collidedWith as Pickup; if (pickup != null) { Ingredient ingredient = pickup as Ingredient; if (ingredient != null) { if (!IsInventoryFull() && !(ingredient.IsFrog() && HeartMode)) { PizzaIngredients.Add(ingredient); Score += pickup.GetScore(); } } else { if (pickup.PickupType == PickupType.GS) { UpdateGas(200); } else if (pickup.PickupType == PickupType.TC) { //It's super effective Dictionary <IngredientType, Ingredient> ingredientsToKeep = new Dictionary <IngredientType, Ingredient>(); foreach (Ingredient currentIngredient in TheLastSliceGame.LevelManager.CurrentLevel.CurrentDelivery.Pizza) { foreach (Ingredient deliveryIngredient in PizzaIngredients) { if (deliveryIngredient.IngredientType == currentIngredient.IngredientType && !ingredientsToKeep.ContainsKey(deliveryIngredient.IngredientType)) { ingredientsToKeep.Add(currentIngredient.IngredientType, currentIngredient); } } } PizzaIngredients.Clear(); foreach (KeyValuePair <IngredientType, Ingredient> ingredientToKeep in ingredientsToKeep) { PizzaIngredients.Add(ingredientToKeep.Value); } IsBox = false; HeartMode = false; Speed = 200; } else if (pickup.PickupType == PickupType.CU) { //It’s dangerous to go alone, take this PizzaIngredients.Clear(); foreach (Ingredient pizzaIngredient in TheLastSliceGame.LevelManager.CurrentLevel.CurrentDelivery.Pizza) { PizzaIngredients.Add(pizzaIngredient); } } else if (pickup.PickupType == PickupType.BX) { IsBox = true; BoxTimer = TimeSpan.Zero; HeartMode = false; HeartTimer = TimeSpan.Zero; } else if (pickup.PickupType == PickupType.HE) { IsBox = false; BoxTimer = TimeSpan.Zero; HeartMode = true; HeartTimer = TimeSpan.Zero; } else { Inventory.Add(pickup); } Score += pickup.GetScore(); } } else if (!IsDead) { Obstacle obstacle = collidedWith as Obstacle; if (obstacle != null) { if (obstacle.ObstacleType == ObstacleType.PB) { HitPB = true; } OnCollidedWithObstacle(obstacle); } } }
public void AddEntity(EntityType type, int row, int column, string assetCode = null) { Vector2 pos = new Vector2(column * TheLastSliceGame.Instance.EntityWidth, TheLastSliceGame.MapManager.MapStartingYPos + (row * TheLastSliceGame.Instance.EntityHeight)); switch (type) { case EntityType.Road: { Road road = new Road(pos, assetCode); AddEntity(road); break; } case EntityType.House: { House house = new House(pos, assetCode); house.Map = this; TheLastSliceGame.MapManager.Houses.Add(house); AddEntity(house); break; } case EntityType.Car: { //TODO:: Are we going to even use cars? - H.E. Car car = new Car(pos); AddEntity(car); break; } case EntityType.Ingredient: { Ingredient ingredient = new Ingredient(pos, assetCode); //Debug.WriteLine(" Ingredient {0} - Pos On Grid: {1}, {2}", ingredient.IngredientType, column, row); AddEntity(ingredient); break; } case EntityType.Pickup: { Pickup pickup = new Pickup(pos, assetCode); //Debug.WriteLine(" Pickup {0} - Pos On Grid: {1}, {2}", pickup.PickupType, column, row); AddEntity(pickup); break; } case EntityType.Obstacle: { Obstacle obstacle = new Obstacle(pos, assetCode); AddEntity(obstacle); break; } case EntityType.None: default: { //Defaults to grass ¯\_(ツ)_/¯ Entity grass = new Entity(pos, "GA0"); AddEntity(grass); break; } } }