Пример #1
0
        public void OnGameOver()
        {
            //I used to be an adventurer like you, until I took an arrow to the knee.
            Velocity = Vector2.Zero;
            Gas      = MaxGas;
            Score    = 0;
            Inventory.Clear();
            PizzaIngredients.Clear();
            Position   = InitialPosition;
            GasTimer   = TimeSpan.Zero;
            HeartTimer = TimeSpan.Zero;
            BoxTimer   = TimeSpan.Zero;
            DeathTimer = TimeSpan.Zero;
            IsDead     = false;
            IsBox      = false;
            HeartMode  = false;
            Animation anim = Animations[DOWN];

            Width  = anim.FrameWidth;
            Height = anim.FrameHeight;
            AnimationManager.Play(anim);
            Speed   = 200;
            CanMove = true;
            HitPB   = false;
        }
Пример #2
0
 public void Reset()
 {
     TheLastSliceGame.MapManager.ChangeMap(TheLastSliceGame.MapManager.Maps[0]);
     Position = InitialPosition;
     Inventory.RemoveAll(pickup => pickup is Ingredient);
     PizzaIngredients.Clear();
 }
Пример #3
0
 public void OnDeliveryComplete()
 {
     Inventory.RemoveAll(pickup => pickup is Ingredient);
     PizzaIngredients.Clear();
     Score += 50;
 }
Пример #4
0
        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);
                }
            }
        }