Пример #1
0
    private IEnumerable <ILogic> GetLogicsFor(ObjectivesScriptableObject.Objective o, List <string> objectIds)
    {
        for (int i = 0; i < objectIds.Count; i++)
        {
            string p = objectIds[i];

            List <ILogic> logics = new List <ILogic>();

            string[] splitByAnd = p.Split('&');
            foreach (var splt in splitByAnd)
            {
                string[]   or  = splt.Split('|');
                List <int> ids = new List <int>();
                foreach (var id_s in or)
                {
                    int result;
                    if (int.TryParse(id_s, out result))
                    {
                        ids.Add(result);
                    }
                }
                logics.Add(new Or(ids.ToArray()));
            }
            if (logics.Count == 1)
            {
                yield return(logics[0]);
            }
            else if (logics.Count > 1)
            {
                ILogic logic = new And(logics[0], logics[1]);
                for (int l = 2; l < logics.Count; l++)
                {
                    logic = new And(logic, logics[i]);
                }
                yield return(logic);
            }


            /*
             * List<string> numbers = new List<string>();
             * {
             *  List<string> n = new List<string>(p.Split('&'));
             *  foreach (var _n in n) {
             *      numbers.AddRange(_n.Split('|'));
             *  }
             * }
             * string[] operators;
             * {
             *  string ops = p;
             *  foreach (var n in numbers) {
             *      ops = ops.Replace(n, " ");
             *  }
             *  operators = ops.Split(' ');
             * }
             */
        }
    }
Пример #2
0
    private void Reward(ObjectivesScriptableObject.Objective o, rank r)
    {
        if (completed.Contains(o))
        {
            return;
        }

        completed.Add(o);

        MonoBehaviour.print(@"Player achieved """ + o.objectiveDescription + @""" with a " + r.ToString() + " rank!");

        recentCleared.Add(o);
        recentClearedRanks.Add(r);

        {
            string t = "";
            switch (r)
            {
            case rank.bronze:
                t = o.feedbackOnBronze;
                bronzeCompleted++;
                break;

            case rank.silver:
                t = o.feedbackOnSilver;
                silverCompleted++;
                break;

            case rank.gold:
                t = o.feedbackOnGold;
                goldCompleted++;
                break;
            }

            if (objectivesScriptableObject.objectives.IndexOf(o) == 0)
            {
                objective0.text = t;
            }
            else if (objectivesScriptableObject.objectives.IndexOf(o) == 1)
            {
                objective1.text = t;
            }

            bronzeCompletedText.text = bronzeCompleted.ToString();
            silverCompletedText.text = silverCompleted.ToString();
            goldCompletedText.text   = goldCompleted.ToString();
        }

        OptionsMenu.RequestOpen();
    }