Esempio n. 1
0
        public override bool addElement(int type, string id)
        {
            var elementAdded = false;

            if (type == AnalyticsController.SCORE)
            {
                var newSubScore = new Completable.Score();
                newSubScore.setMethod(Completable.Score.ScoreMethod.SINGLE);
                string target = null;
                var    vars   = controller.VarFlagSummary.getVars();
                if (vars != null && vars.Length > 0)
                {
                    target = vars[0];
                    newSubScore.setType(Completable.Score.ScoreType.VARIABLE);
                }
                else
                {
                    var completables = controller.IdentifierSummary.getIds <Completable>();
                    if (completables != null && completables.Length > 0)
                    {
                        target = completables[0];
                        newSubScore.setType(Completable.Score.ScoreType.COMPLETABLE);
                    }
                }

                if (!string.IsNullOrEmpty(target))
                {
                    newSubScore.setId(target);
                    score.addSubScore(newSubScore);
                    scoreDataControls.Add(new ScoreDataControl(newSubScore));
                }
            }

            return(elementAdded);
        }
Esempio n. 2
0
        public void Awake()
        {
            instance = this;
            //Create Main game completable
            var trackerConfigs = Game.Instance.GameState.Data.getObjects <TrackerConfig>();

            PrepareTracker(trackerConfigs.Count == 0 ? new TrackerConfig() : trackerConfigs[0]);

            Completable mainGame = new Completable();

            Completable.Milestone gameStart = new Completable.Milestone();
            gameStart.setType(Completable.Milestone.MilestoneType.SCENE);
            gameStart.setId(Game.Instance.GameState.InitialChapterTarget.getId());
            mainGame.setStart(gameStart);
            mainGame.setId(Game.Instance.GameState.Data.getTitle());
            mainGame.setType(Completable.TYPE_GAME);

            Completable.Milestone gameEnd = new Completable.Milestone();
            gameEnd.setType(Completable.Milestone.MilestoneType.ENDING);
            mainGame.setEnd(gameEnd);

            Completable.Progress gameProgress = new Completable.Progress();
            gameProgress.setType(Completable.Progress.ProgressType.SUM);

            Completable.Score mainScore = new Completable.Score();
            mainScore.setMethod(Completable.Score.ScoreMethod.AVERAGE);

            var completables = Game.Instance.GameState.GetObjects <Completable>();

            foreach (Completable part in completables)
            {
                Completable.Milestone tmpMilestone = new Completable.Milestone();
                tmpMilestone.setType(Completable.Milestone.MilestoneType.COMPLETABLE);
                tmpMilestone.setId(part.getId());
                gameProgress.addMilestone(tmpMilestone);

                Completable.Score tmpScore = new Completable.Score();
                tmpScore.setMethod(Completable.Score.ScoreMethod.SINGLE);
                tmpScore.setType(Completable.Score.ScoreType.COMPLETABLE);
                tmpScore.setId(part.getId());
                mainScore.addSubScore(tmpScore);
            }
            mainGame.setProgress(gameProgress);
            mainGame.setScore(mainScore);

            completables.Insert(0, mainGame);

            SetCompletables(completables);

            Game.Instance.GameState.OnConditionChanged += (_, __) => ConditionChanged();
            Game.Instance.OnTargetChanged     += TargetChanged;
            Game.Instance.OnElementInteracted += ElementInteracted;
        }
Esempio n. 3
0
        // #########################################
        // ############### COMPLETABLES ############
        // #########################################



        private void InitCompletables()
        {
            //Create Main game completabl
            Completable mainGame = new Completable();

            Completable.Milestone gameStart = new Completable.Milestone();
            gameStart.setType(Completable.Milestone.MilestoneType.SCENE);
            gameStart.setId(Game.Instance.GameState.InitialChapterTarget.getId());
            mainGame.setStart(gameStart);
            mainGame.setId(Game.Instance.GameState.Data.getTitle());
            mainGame.setType(Completable.TYPE_GAME);

            Completable.Milestone gameEnd = new Completable.Milestone();
            gameEnd.setType(Completable.Milestone.MilestoneType.ENDING);
            mainGame.setEnd(gameEnd);

            Completable.Progress gameProgress = new Completable.Progress();
            gameProgress.setType(Completable.Progress.ProgressType.SUM);

            Completable.Score mainScore = new Completable.Score();
            mainScore.setMethod(Completable.Score.ScoreMethod.AVERAGE);

            completables = new List <Completable>(Game.Instance.GameState.GetObjects <Completable>());

            foreach (Completable part in completables)
            {
                Completable.Milestone tmpMilestone = new Completable.Milestone();
                tmpMilestone.setType(Completable.Milestone.MilestoneType.COMPLETABLE);
                tmpMilestone.setId(part.getId());
                gameProgress.addMilestone(tmpMilestone);

                Completable.Score tmpScore = new Completable.Score();
                tmpScore.setMethod(Completable.Score.ScoreMethod.SINGLE);
                tmpScore.setType(Completable.Score.ScoreType.COMPLETABLE);
                tmpScore.setId(part.getId());
                mainScore.addSubScore(tmpScore);
            }
            mainGame.setProgress(gameProgress);
            mainGame.setScore(mainScore);

            completables.Insert(0, mainGame);

            SetCompletables(completables);
        }
Esempio n. 4
0
        private Completable.Score parseScore(XmlElement element, params object[] parameters)
        {
            Completable.Score score = new Completable.Score();

            string tmpString = "";

            tmpString = element.GetAttribute("type");
            if (!string.IsNullOrEmpty(tmpString))
            {
                score.setType(ParseEnum <Completable.Score.ScoreType>(tmpString));
            }

            tmpString = element.GetAttribute("method");
            if (!string.IsNullOrEmpty(tmpString))
            {
                score.setMethod(ParseEnum <Completable.Score.ScoreMethod>(tmpString));
            }

            if (score.getMethod() == Completable.Score.ScoreMethod.SINGLE)
            {
                tmpString = element.GetAttribute("id");
                if (!string.IsNullOrEmpty(tmpString))
                {
                    score.setId(tmpString);
                }
            }
            else
            {
                XmlNode subscores = element.SelectSingleNode("sub-scores");

                if (subscores != null)
                {
                    foreach (XmlElement subscore in subscores.ChildNodes)
                    {
                        score.addSubScore(parseScore(subscore, parameters));
                    }
                }
            }

            return(score);
        }
Esempio n. 5
0
        private void performAddElement(object sender, string id)
        {
            // If some value was typed and the identifier is valid
            if (!controller.isElementIdValid(id))
            {
                id = controller.makeElementValid(id);
            }

            // Add thew new scene
            var newCompletable = new Completable();

            newCompletable.setId(id);
            var score = new Completable.Score();

            score.setMethod(Completable.Score.ScoreMethod.SINGLE);
            score.setType(Completable.Score.ScoreType.VARIABLE);
            newCompletable.setScore(score);
            completables.Add(newCompletable);
            completableDataControls.Add(new CompletableDataControl(newCompletable));
            controller.IdentifierSummary.addId <Completable>(id);
            controller.DataModified();
        }