Exemplo n.º 1
0
    /// <summary>
    /// Adds the amount to the current progress if the given objectiveType matches the level objective.
    /// Also Updates the progress bar and tells the LevelManager when the Objective goals has been reached.
    /// </summary>
    /// <param name="amount">Amount to add to the objective progress.</param>
    /// <param name="objectiveType">Type of objective to add progress to.</param>
    public void AddObjectiveAmount(int amount, ObjectiveType objectiveType)
    {
        ObjectiveType currentObjectiveType = currentObjective.objective.objectiveType;

        if (currentObjectiveType.Equals(objectiveType))
        {
            objectiveProgress       += amount;
            currentProgressText.text = objectiveProgress.ToString();

            if (!objectiveReached)
            {
                if (objectiveProgress < progressBar.maxValue)
                {
                    progressBar.value = objectiveProgress;
                }
                else
                {
                    objectiveReached  = true;
                    progressBar.value = progressBar.maxValue;
                    levelManager.ObjectiveReached(objectiveReached);
                }
            }
        }
    }