Пример #1
0
    private void AddCookedIngredient(int playerWhoCooked, SO_Tag ingredient, SO_Tag cookingMethod)
    {
        // Checking if the cooking pot belongs to the player who cooked the ingredients
        if (playerWhoCooked != _CookingPotOwner.ViewID)
        {
            return;
        }

        CookedIngredient cookedIngredient = new CookedIngredient(ingredient, cookingMethod);

        DishesBeingPrepared[_CurrentDishBeingCooked].Add(cookedIngredient);

        // Checking if there is progress after adding ingredient to the pot
        int preUpdateNumber = _NumberOfIngredientsInPlace;

        UpdateDishStatus();

        if (preUpdateNumber == _NumberOfIngredientsInPlace)
        {
            Debug.Log("Ingredient Wasted");
            // Letting the spawner know that the current ingredient cooked was not used properly and needs to be spawned again
            _IngredientWastedEvent.Invoke(ingredient);
        }
        else
        {
            if (PhotonView.Find(playerWhoCooked).IsMine)
            {
                Debug.Log("Ingredient added to the cooking pot");
                _IngredientAddedToCookingPotEvent.Invoke(cookedIngredient);
            }
        }
    }
Пример #2
0
 public void ValidateAndUpdate(SO_Tag cookingStep)
 {
     if (!IsCompleted && cookingStep == _CookingStepData.CookingStep)
     {
         IsCompleted = true;
         StartCoroutine(MarkAsCompleted());
     }
 }
Пример #3
0
    public void Initialize(SO_Tag cookingMethod)
    {
        CookingStep                  = cookingMethod;
        _CookingStepsData            = Resources.Load <SO_CookingStepsData>("CookingStepsData");
        _CookingStepData.CookingStep = cookingMethod;
        _CookingStepData.Icon        = _CookingStepsData.GetCookingStepSprite(cookingMethod);

        // Displaying the image
        _StepImage.sprite = _CookingStepData.Icon;
    }
Пример #4
0
 public void SetScreen(SO_Tag screenTag)
 {
     // In case the current screen is animating
     if (_CurrentScreen != null && _CurrentScreen.IsAnimating)
     {
         StopAllCoroutines();
         _CurrentScreen.HideScreen();
     }
     StartCoroutine(StartScreenTransition(_RegisteredScreens[screenTag]));
 }
Пример #5
0
    public void PickUpCookedFood(int playerViewID, bool isLocalPlayer)
    {
        if (_CookedIngredient == null)
        {
            return;
        }

        OnPickedUpCookedFood(playerViewID, isLocalPlayer);
        _CookedIngredient = null;
    }
Пример #6
0
 public void RemoveIngredientFromSpawnable(SO_Tag ingredientTag)
 {
     // Removing the ingredient so that it does not spawn
     if (IngredientsToSpawn.ContainsKey(ingredientTag))
     {
         --IngredientsToSpawn[ingredientTag];
         if (IngredientsToSpawn[ingredientTag] <= 0)
         {
             IngredientsToSpawn.Remove(ingredientTag);
         }
     }
 }
Пример #7
0
    protected IEnumerator CookingDelay(float cookingTime, IngredientMinion minion)
    {
        yield return(new WaitForSeconds(cookingTime));

        HideClock();
        minion.GetCooked();
        _CookedIngredient = minion.Tag;
        _IngredientCookedEvent.Invoke(null);
        _IngredientFinishedCookingEvent.Invoke();
        State = CookingStationState.COOKED_FOOD_AVAILABLE;
        _CookingStationUI.UpdateUI();
    }
Пример #8
0
 public void AddIngredientToSpawnable(SO_Tag ingredientTag)
 {
     // Adding the ingredient so that it spawns
     if (IngredientsToSpawn.ContainsKey(ingredientTag))
     {
         ++IngredientsToSpawn[ingredientTag];
     }
     else
     {
         IngredientsToSpawn[ingredientTag] = 1;
     }
 }
Пример #9
0
 public void SetScreen(SO_Tag screenTag)
 {
     // In case the current screen is animating
     if (_CurrentScreen != null)
     {
         _CurrentScreen.HideScreen();
     }
     if (_RegisteredScreens.ContainsKey(screenTag))
     {
         _RegisteredScreens[screenTag].ShowScreen();
         _CurrentScreen = _RegisteredScreens[screenTag];
     }
 }
Пример #10
0
    public Sprite GetIngredientIcon(SO_Tag ingredient)
    {
        Sprite icon = null;

        foreach (var ingredientData in IngredientsData)
        {
            if (ingredientData.Ingredient == ingredient)
            {
                icon = ingredientData.Icon;
                break;
            }
        }
        return(icon);
    }
Пример #11
0
    public Sprite GetCookingStepSprite(SO_Tag cookingStep)
    {
        Sprite icon = null;

        foreach (var cookingStepData in CookingStepsData)
        {
            if (cookingStepData.CookingStep == cookingStep)
            {
                icon = cookingStepData.Icon;
                break;
            }
        }
        return(icon);
    }
Пример #12
0
    public SO_Tag ChooseIngredientToSpawn()
    {
        if (IngredientsToSpawn == null || IngredientsToSpawn.Count == 0)
        {
            return(null);
        }

        int randomIndex = Random.Range(0, IngredientsToSpawn.Count);
        KeyValuePair <SO_Tag, int> ingredientCountData = IngredientsToSpawn.ElementAt(randomIndex);
        SO_Tag ingredientToSpawn = ingredientCountData.Key;

        RemoveIngredientFromSpawnable(ingredientToSpawn);
        return(ingredientToSpawn);
    }
Пример #13
0
    public void Cook(int playerWhoIsCooking, CookingStation cookingStation, SO_Tag cookingStepPerformed)
    {
        cookingStation.Use(this);
        MinionStartedCookingEvent.Invoke();

        // Recording the task performed
        CookingStationStepsPerformed.Add(cookingStepPerformed);
        CookingStationStepsToPerform.Remove(cookingStepPerformed);

        // Listening to cooked event
        cookingStation.StationInCoolDownEvent.AddListener(OnIngredientCooked);

        GetCooked();
    }
Пример #14
0
    private IEnumerator SpawnIngredients()
    {
        while (true)
        {
            if (_CanSpawn)
            {
                SO_Tag           ingredientToSpawn = _IngredientSpawnData.ChooseIngredientToSpawn();
                GameObject       spawnedObject     = PhotonNetwork.Instantiate("Minion_" + ingredientToSpawn.name.Replace("Tag_", ""), transform.position + Vector3.up, Quaternion.identity);
                IngredientMinion ingredient        = spawnedObject.GetComponent <IngredientMinion>();
                ingredient.PickedUpEvent.AddListener(OnIngredientPickedUp);
                ingredient.IngredientExpiredEvent.AddListener(OnIngredientExpired);
                _CanSpawn = false;
            }

            yield return(null);
        }
    }
Пример #15
0
 private void OnLocalPlayerCollectedCookedFood(SO_Tag collectedIngredient)
 {
     foreach (var ingredientContainer in _IngredientContainerReferences)
     {
         if (ingredientContainer.Reference.Ingredient == collectedIngredient)
         {
             foreach (var cookingStep in ingredientContainer.Reference.CookingStepsIcon)
             {
                 if (cookingStep.CookingStep == CookingStepPerformed)
                 {
                     var particles = Instantiate(_GuidedParticles, transform.position, _GuidedParticles.transform.rotation);
                     particles.InitiateParticleFlow(cookingStep.transform);
                     return;
                 }
             }
         }
     }
 }
Пример #16
0
    public void Initialize(SO_Tag ingredient, SO_Tag[] cookingSteps)
    {
        CookingStepsIcon     = new List <CookingStepsIcon>();
        _CookingStepsToTrack = cookingSteps;
        _IngredientData      = Resources.Load <SO_IngredientData>("IngredientsData");
        Ingredient           = ingredient;

        foreach (var cookingStep in _CookingStepsToTrack)
        {
            // Adding step icons to the container
            var cookingStepIcon = Instantiate(_CookingStepsIconPrefab, _StepsContainer);
            cookingStepIcon.Initialize(cookingStep);
            CookingStepsIcon.Add(cookingStepIcon);
        }

        // Displaying the ingredient icon
        _IngredientImage.sprite = _IngredientData.GetIngredientIcon(Ingredient);
    }
Пример #17
0
 public bool Validate(SO_Tag cookingStep)
 {
     return(!IsCompleted && cookingStep == _CookingStepData.CookingStep);
 }
Пример #18
0
 public bool CheckIfCompatible(SO_Tag cookingStep)
 {
     // Checking if the cooking steps can be performed on the Ingredient
     return(CookingStationStepsToPerform.Contains(cookingStep));
 }
Пример #19
0
    public void OnIngredientWasted(object data)
    {
        SO_Tag ingredientTag = (SO_Tag)data;

        AddIngredientToSpawnable(ingredientTag);
    }
Пример #20
0
 public CookedIngredient(SO_Tag ingredient, SO_Tag cookingMethod)
 {
     Ingredient    = ingredient;
     CookingMethod = cookingMethod;
 }