Beispiel #1
0
    public static string GetIngredientName(IngredientType ingredientType, bool capitalize = false)
    {
        string allCaps  = ingredientType.ToString().Replace('_', ' ');
        string allSmall = allCaps.ToLower();

        if (capitalize)
        {
            StringBuilder sb = new StringBuilder();

            bool nextIsCap = true;
            for (int i = 0; i < allSmall.Length; i++)
            {
                if (nextIsCap)
                {
                    sb.Append(allCaps[i]);
                    nextIsCap = false;
                }
                else
                {
                    sb.Append(allSmall[i]);
                    nextIsCap |= allSmall[i] == ' ';
                }
            }

            return(sb.ToString());
        }
        else
        {
            return(allSmall);
        }
    }
 // Creating new ingredient in mouse position
 private GameObject SpawnIngredient(IngredientType type)
 {
     return(Instantiate(
                Resources.Load <GameObject>($"Ingredients/Ingredient{type.ToString()}") as GameObject,
                MousePointInWorld,
                Quaternion.Euler(0, 0, Random.Range(-15, 15)),
                null));
 }
    private void animateScoringIcon(IngredientType ingredientType)
    {
        //Animation scoreAnim = ScoringIcon.GetComponent<Animation>();
        //scoreAnim.Play();
        Animator scoreAnim = ScoringIcon.GetComponent <Animator>();

        scoreAnim.SetTrigger(ingredientType.ToString());
    }
Beispiel #4
0
        public void CreateRandomPickups()
        {
            foreach (Map map in TheLastSliceGame.MapManager.Maps)
            {
                int numPickups     = TheLastSliceGame.Random.Next(1, 1);
                int numIngredients = TheLastSliceGame.Random.Next(1, 1);

                for (int i = 0; i < numIngredients; i++)
                {
                    IngredientType type = (IngredientType)TheLastSliceGame.Random.Next(0, Enum.GetNames(typeof(IngredientType)).Length);

                    Vector2 cell = GetRandomValidCell(map);
                    if (!cell.Equals(Vector2.Zero))
                    {
                        map.AddEntity(EntityType.Ingredient, (int)cell.Y, (int)cell.X, type.ToString());
                    }
                }

                for (int i = 0; i < numPickups; i++)
                {
                    PickupType type = (PickupType)TheLastSliceGame.Random.Next(1, Enum.GetNames(typeof(PickupType)).Length);
                    Vector2    cell = GetRandomValidCell(map);
                    if (!cell.Equals(Vector2.Zero))
                    {
                        map.AddEntity(EntityType.Pickup, (int)cell.Y, (int)cell.X, type.ToString());
                    }
                }
            }
        }
Beispiel #5
0
        public void CreateRandomDeliveries()
        {
            int numDeliveres = TheLastSliceGame.Random.Next(1, 3);

            if (numDeliveres > TheLastSliceGame.MapManager.Houses.Count)
            {
                numDeliveres = TheLastSliceGame.Random.Next(1, TheLastSliceGame.MapManager.Houses.Count);
            }

            for (int i = 0; i < numDeliveres;)
            {
                House house = TheLastSliceGame.MapManager.Houses.ElementAt(TheLastSliceGame.Random.Next(1, TheLastSliceGame.MapManager.Houses.Count - 1));
                if (house.DeliveryState == PizzaDeliveryState.None)
                {
                    int numIngredients      = TheLastSliceGame.Random.Next(1, 4);
                    List <Ingredient> pizza = new List <Ingredient>();
                    for (int j = 0; j < numIngredients; j++)
                    {
                        IngredientType ingredientType = (IngredientType)TheLastSliceGame.Random.Next(0, Enum.GetNames(typeof(IngredientType)).Length);
                        Ingredient     ingredient     = new Ingredient(new Vector2(house.Position.X, house.Position.Y), ingredientType.ToString());
                        ingredient.Map    = house.Map;
                        ingredient.Hidden = true;
                        pizza.Add(ingredient);
                    }

                    AddDelivery(house, pizza);
                    i++;
                }
            }
        }