示例#1
0
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            XmlElement tmpXmlElement;

            var completable = new Completable();

            completable.setId(element.GetAttribute("id"));

            completable.setRepeatable(element.GetAttribute("repeatable") == "true");

            switch (element.GetAttribute("type"))
            {
            case "combat": completable.setType(Completable.TYPE_COMBAT); break;

            case "completable": completable.setType(Completable.TYPE_COMPLETABLE); break;

            case "game": completable.setType(Completable.TYPE_GAME); break;

            case "level": completable.setType(Completable.TYPE_LEVEL); break;

            case "quest": completable.setType(Completable.TYPE_QUEST); break;

            case "race": completable.setType(Completable.TYPE_RACE); break;

            case "session": completable.setType(Completable.TYPE_SESSION); break;

            case "stage": completable.setType(Completable.TYPE_STAGE); break;

            case "storynode": completable.setType(Completable.TYPE_STORYNODE); break;

            default: completable.setType(Completable.TYPE_COMPLETABLE); break;
            }

            tmpXmlElement = (XmlElement)element.SelectSingleNode("start-milestone");
            if (tmpXmlElement != null)
            {
                completable.setStart(parseMilestone(tmpXmlElement, parameters));
            }

            tmpXmlElement = (XmlElement)element.SelectSingleNode("end-milestone");
            if (tmpXmlElement != null)
            {
                completable.setEnd(parseMilestone(tmpXmlElement, parameters));
            }

            tmpXmlElement = (XmlElement)element.SelectSingleNode("progress");
            if (tmpXmlElement != null)
            {
                completable.setProgress(parseProgress(tmpXmlElement, parameters));
            }

            tmpXmlElement = (XmlElement)element.SelectSingleNode("score");
            if (tmpXmlElement != null)
            {
                completable.setScore(parseScore(tmpXmlElement, parameters));
            }

            return(completable);
        }
 public CompletableDataControl(Completable completable)
 {
     this.completable         = completable;
     this.startDataControl    = new MilestoneDataControl(completable.getStart());
     this.endDataControl      = new MilestoneDataControl(completable.getEnd());
     this.progressDataControl = new ProgressDataControl(completable.getProgress());
     this.scoreDataControl    = new ScoreDataControl(completable.getScore());
 }
示例#3
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;
        }
        public CompletableController(Completable completable)
        {
            this.Completable = completable;

            this.startController = new MilestoneController(completable.getStart());
            this.endController   = new MilestoneController(completable.getEnd());

            this.progressControllers = completable
                                       .getProgress()
                                       .getMilestones()
                                       .ConvertAll(c => new MilestoneController(c));
        }
示例#5
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);
        }
        public void Reset()
        {
            if (Completable.getRepeatable())
            {
                if (Start != null)
                {
                    Start.Reset();
                }

                if (End != null)
                {
                    End.Reset();
                }

                completed = false;

                foreach (var milestoneController in progressControllers)
                {
                    milestoneController.Reset();
                }
            }
        }
示例#7
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();
        }
        public bool UpdateMilestones(IChapterTarget target)
        {
            if (completed)
            {
                return(false);
            }

            if (completeOnExit && target.getId() != Start.Milestone.getId())
            {
                completed = true;
                AnalyticsExtension.Instance.TrackCompleted(this, DateTime.Now - startTime);
            }
            else
            {
                var wasStarted = Started;
                completed = UpdateMilestones(milestone => milestone.Update(target));
                if (wasStarted != Started && Completable.getEnd() == null)
                {
                    completeOnExit = true;
                }
            }

            return(completed);
        }
示例#9
0
        //#################################################
        //#################################################
        //#################################################

        public object Clone()
        {
            Completable nc = new Completable();

            return(nc);
        }
 internal void SetCompletable(Completable value)
 {
     completable = value;
 }