public override void deleteIdentifierReferences(string id)
 {
     if (id.Equals(score.getId()))
     {
         score.setId("");
     }
     scoreDataControls.ForEach(s => s.deleteIdentifierReferences(id));
 }
        public override bool addElement(int type, string id)
        {
            var elementAdded = false;

            if (type == Controller.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);
        }
Exemplo n.º 3
0
        protected void Awake()
        {
            Game.instance = this;
            executeStack  = new Stack <KeyValuePair <Interactuable, ExecutionEvent> >();

            skin = Resources.Load("basic") as GUISkin;

            if (!string.IsNullOrEmpty(gamePath))
            {
                ResourceManager = ResourceManagerFactory.CreateExternal(gamePath + gameName);
            }
            else
            {
                if (!string.IsNullOrEmpty(gameName))
                {
                    ResourceManager = ResourceManagerFactory.CreateLocal(gameName, useSystemIO ? ResourceManager.LoadingType.SYSTEM_IO : ResourceManager.LoadingType.RESOURCES_LOAD);
                }
                else
                {
                    ResourceManager = ResourceManagerFactory.CreateLocal("CurrentGame/", useSystemIO ? ResourceManager.LoadingType.SYSTEM_IO : ResourceManager.LoadingType.RESOURCES_LOAD);
                }
            }

            if (Game.GameToLoad != "")
            {
                gameName    = Game.GameToLoad;
                gamePath    = ResourceManager.getCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "Games" + System.IO.Path.DirectorySeparatorChar;
                useSystemIO = true;
            }

            AdventureData    data       = new AdventureData();
            var              incidences = new List <Incidence>();
            AdventureHandler adventure  = new AdventureHandler(data, ResourceManager, incidences);

            adventure.Parse("descriptor.xml");
            PrepareTracker(data.getTrackerConfig());

            game_state = new GameState(data);

            //Create Main game completable

            Completable mainGame = new Completable();

            Completable.Milestone gameStart = new Completable.Milestone();
            gameStart.setType(Completable.Milestone.MilestoneType.SCENE);
            gameStart.setId(data.getChapters()[0].getInitialChapterTarget().getId());
            mainGame.setStart(gameStart);
            mainGame.setId(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);

            foreach (Completable part in GameState.GetCompletables())
            {
                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);

            GameState.GetCompletables().Insert(0, mainGame);

            CompletablesController.Instance.SetCompletables(GameState.GetCompletables());

            bookDrawer = new BookDrawer(ResourceManager);
        }