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();
        }
Exemplo n.º 2
0
        public override void Draw(int aID)
        {
            var windowWidth  = Rect.width;
            var windowHeight = Rect.height;

            tableRect      = new Rect(0f, 200, 0.8f * windowWidth, windowHeight * 0.33f);
            rightPanelRect = new Rect(0.85f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.33f * windowHeight);

            GUILayout.Label(TC.get("Analytics.GameStart") + Controller.getInstance().getSelectedChapterDataControl().getInitialScene());
            GUILayout.Label(TC.get("Analytics.GameEnd"));

            end = EditorGUILayout.Popup(end, endoptions);

            GUILayout.Label(TC.get("Analytics.GameProgress"));

            progress = EditorGUILayout.Popup(progress, progressoptions);

            if (progress == 1)
            {
                GUILayout.Button(TC.get("Analytics.EditProgress"));
            }

            //GUILayout.BeginArea(tableRect);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("Analytics.Completable.Id"), GUILayout.Width(windowWidth * col_width));
            GUILayout.Box(TC.get("Analytics.Completable.Start"), GUILayout.Width(windowWidth * col_width));
            GUILayout.Box(TC.get("Analytics.Completable.End"), GUILayout.Width(windowWidth * col_width));
            GUILayout.Box(TC.get("Analytics.Completable.Progress"), GUILayout.Width(windowWidth * col_width));
            GUILayout.Box(TC.get("Analytics.Completable.Score"), GUILayout.Width(windowWidth * col_width));
            GUILayout.EndHorizontal();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            foreach (Completable completable in completables)
            {
                GUILayout.BeginHorizontal();
                completable.setId(GUILayout.TextField(completable.getId(), GUILayout.Width(windowWidth * col_width)));

                if (GUILayout.Button(completable.getStart().ToString(), GUILayout.Width(windowWidth * col_width)))
                {
                    MilestoneEditorWindow window = ScriptableObject.CreateInstance <MilestoneEditorWindow>();
                    window.Init(completable.getStart());
                }

                if (GUILayout.Button(completable.getEnd().ToString(), GUILayout.Width(windowWidth * col_width)))
                {
                    MilestoneEditorWindow window = ScriptableObject.CreateInstance <MilestoneEditorWindow>();
                    window.Init(completable.getEnd());
                }

                if (GUILayout.Button(TC.get("Analytics.Completable.Define"), GUILayout.Width(windowWidth * col_width)))
                {
                    ProgressEditorWindow window = ScriptableObject.CreateInstance <ProgressEditorWindow>();
                    window.Init(completable.getProgress());
                }
                selected_variable[completable] = EditorGUILayout.Popup(selected_variable[completable], variables, GUILayout.Width(windowWidth * col_width));
                completable.getScore().setId(variables[selected_variable[completable]]);

                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();


            //GUILayout.EndArea();


            //GUILayout.BeginArea(rightPanelRect);
            GUILayout.BeginVertical(GUILayout.Width(0.1f * windowWidth));
            if (GUILayout.Button(addTexture))
            {
                Completable       nc    = new Completable();
                Completable.Score score = new Completable.Score();
                score.setMethod(Completable.Score.ScoreMethod.SINGLE);
                score.setType(Completable.Score.ScoreType.VARIABLE);
                nc.setScore(score);
                completables.Add(nc);
                selected_variable.Add(nc, 0);
            }
            if (GUILayout.Button(moveUp))
            {
                int pos = completables.IndexOf(selectedCompletable);
                if (pos > 0)
                {
                    Completable tmp = completables[pos - 1];
                    completables[pos - 1] = completables[pos];
                    completables[pos]     = tmp;
                }
            }
            if (GUILayout.Button(moveDown))
            {
                int pos = completables.IndexOf(selectedCompletable);
                if (pos < completables.Count - 1)
                {
                    Completable tmp = completables[pos + 1];
                    completables[pos + 1] = completables[pos];
                    completables[pos]     = tmp;
                }
            }
            if (GUILayout.Button(clearImg))
            {
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
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);
        }