public void OnLoad(ConfigNode configNode)
        {
            name        = ConfigNodeUtil.ParseValue <string>(configNode, "name");
            aspectRatio = ConfigNodeUtil.ParseValue <float>(configNode, "aspectRatio");

            foreach (ConfigNode child in configNode.GetNodes())
            {
                Type nodeType = ConfigNodeUtil.ParseTypeValue(child.name);
                if (nodeType.IsSubclassOf(typeof(CutSceneCamera)))
                {
                    CutSceneCamera cameraDefinition = Activator.CreateInstance(nodeType) as CutSceneCamera;
                    cameraDefinition.OnLoad(child);
                    cameras.Add(cameraDefinition);
                }
                else if (nodeType.IsSubclassOf(typeof(Actor)))
                {
                    Actor actor = Activator.CreateInstance(nodeType) as Actor;
                    actor.OnLoad(child);
                    actors.Add(actor);
                }
                else if (nodeType.IsSubclassOf(typeof(CutSceneAction)))
                {
                    CutSceneAction action = Activator.CreateInstance(nodeType) as CutSceneAction;
                    action.cutSceneDefinition = this;
                    action.OnLoad(child);
                    actions.Add(action);
                }
                else
                {
                    LoggingUtil.LogError(this, "Couldn't load CutSceneDefinition - unknown type '{0}'.", child.name);
                }
            }
        }
        private void DeleteGUI(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.Label("Delete " + currentMode + " '" + currentItem.FullDescription() + "'?");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Yes"))
            {
                deleteCurrent = false;
                if (currentMode == Modes.Actor)
                {
                    currentCutScene.actors.Remove(currentActor);
                    currentActor = null;
                    currentItem = null;
                }
                else if (currentMode == Modes.Camera)
                {
                    currentCutScene.cameras.Remove(currentCamera);
                    currentCamera = null;
                    currentItem = null;
                }
                else
                {
                    currentCutScene.actions.Remove(currentAction);
                    currentAction = null;
                    currentItem = null;
                }
            }
            if (GUILayout.Button("No"))
            {
                deleteCurrent = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow();
        }
        private void WindowGUI(int windowID)
        {
            // TODO - real loading
            if (currentCutScene == null)
            {
                currentCutScene = new CutSceneDefinition();
                currentCutScene.Load("ContractConfigurator/CutScene/CameraTestCutScene.cfg");
            }

            GUILayout.BeginHorizontal();

            const int LIST_WIDTH = 500;
            GUILayout.BeginVertical(GUILayout.Width(LIST_WIDTH));

            // The different modes
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(currentMode == Modes.Camera, "Cameras", toggleCenteredStyle))
            {
                if (currentMode != Modes.Camera)
                {
                    currentMode = Modes.Camera;
                    scrollPosition = new Vector2(0, 0);
                    currentItem = currentCamera;
                }
            }
            if (GUILayout.Toggle(currentMode == Modes.Actor, "Actors", toggleCenteredStyle))
            {
                if (currentMode != Modes.Actor)
                {
                    currentMode = Modes.Actor;
                    scrollPosition = new Vector2(0, 0);
                    currentItem = currentActor;
                }
            }
            if (GUILayout.Toggle(currentMode == Modes.Action, "Actions", toggleCenteredStyle))
            {
                if (currentMode != Modes.Action)
                {
                    currentMode = Modes.Action;
                    scrollPosition = new Vector2(0, 0);
                    currentItem = currentAction;
                }
            }
            GUILayout.EndHorizontal();

            // Display the listing of entities
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Height(LIST_HEIGHT));
            int currentIndex = -1;
            int i = 0;
            int listCount = 0;

            // Display the listing of cameras
            if (currentMode == Modes.Camera)
            {
                listCount = currentCutScene.cameras.Count;
                foreach (CutSceneCamera camera in currentCutScene.cameras)
                {
                    if (currentCamera == camera)
                    {
                        currentIndex = i;
                    }
                    i++;

                    GUILayout.BeginHorizontal();
                    if (GUILayout.Toggle(camera == currentCamera, camera.FullDescription(), toggleStyle, GUILayout.Width(LIST_WIDTH - 36)))
                    {
                        currentCamera = camera;
                        currentItem = camera;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            // Display the listing of actors
            else if (currentMode == Modes.Actor)
            {
                listCount = currentCutScene.actors.Count;
                foreach (Actor actor in currentCutScene.actors)
                {
                    if (currentActor == actor)
                    {
                        currentIndex = i;
                    }
                    i++;

                    GUILayout.BeginHorizontal();
                    if (GUILayout.Toggle(actor == currentActor, actor.FullDescription(), toggleStyle, GUILayout.Width(LIST_WIDTH - 36)))
                    {
                        currentActor = actor;
                        currentItem = actor;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            // Display the listing of cut scene actions
            else if (currentMode == Modes.Action)
            {
                listCount = currentCutScene.actions.Count;
                foreach (CutSceneAction action in currentCutScene.actions)
                {
                    if (currentAction == action)
                    {
                        currentIndex = i;
                    }
                    i++;

                    GUILayout.BeginHorizontal();
                    if (GUILayout.Toggle(action == currentAction, action.FullDescription(), toggleStyle, GUILayout.Width(LIST_WIDTH - 72)))
                    {
                        currentAction = action;
                        currentItem = action;
                    }
                    GUILayout.BeginVertical();
                    GUILayout.Space(3);
                    action.async = GUILayout.Toggle(action.async, new GUIContent("", "If checked, moves to the next action before waiting for this one to complete."));
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            GUILayout.Button("New");
            if (GUILayout.Button("Up") && currentIndex > 0)
            {
                if (currentMode == Modes.Actor)
                {
                    currentCutScene.actors[currentIndex] = currentCutScene.actors[currentIndex - 1];
                    currentCutScene.actors[currentIndex - 1] = currentActor;
                }
                else if (currentMode == Modes.Camera)
                {
                    currentCutScene.cameras[currentIndex] = currentCutScene.cameras[currentIndex - 1];
                    currentCutScene.cameras[currentIndex - 1] = currentCamera;
                }
                else
                {
                    currentCutScene.actions[currentIndex] = currentCutScene.actions[currentIndex - 1];
                    currentCutScene.actions[currentIndex - 1] = currentAction;
                }
            }
            if (GUILayout.Button("Down") && currentIndex != -1 && currentIndex != listCount - 1)
            {
                if (currentMode == Modes.Actor)
                {
                    currentCutScene.actors[currentIndex] = currentCutScene.actors[currentIndex + 1];
                    currentCutScene.actors[currentIndex + 1] = currentActor;
                }
                else if (currentMode == Modes.Camera)
                {
                    currentCutScene.cameras[currentIndex] = currentCutScene.cameras[currentIndex + 1];
                    currentCutScene.cameras[currentIndex + 1] = currentCamera;
                }
                else
                {
                    currentCutScene.actions[currentIndex] = currentCutScene.actions[currentIndex + 1];
                    currentCutScene.actions[currentIndex + 1] = currentAction;
                }
            }
            if (GUILayout.Button("Delete") && currentIndex != -1)
            {
                deleteCurrent = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            DrawDetailPane();

            GUILayout.EndHorizontal();

            GUI.DragWindow();

            if (Event.current.type == EventType.Repaint && GUI.tooltip != toolTip)
            {
                toolTipTime = Time.fixedTime;
                toolTip = GUI.tooltip;
            }
        }
示例#4
0
        void Update()
        {
            if (state == State.IDLE)
            {
                return;
            }

            if (state == State.STARTING_CUTSCENE_FADE_OUT)
            {
                fadeTimer += Time.deltaTime;
                if (fadeTimer > FADE_TIME + EXTRA_TIME)
                {
                    state     = State.IN_CUTSCENE;
                    fadeTimer = FADE_TIME;

                    // Switch to the first cutscene camera
                    cutSceneDefinition.cameras.First().MakeActive();

                    // Invoke the first action
                    currentIndex  = 0;
                    currentAction = cutSceneDefinition.actions.First();
                    currentAction.InvokeAction();
                }

                return;
            }

            if (state == State.IN_CUTSCENE)
            {
                fadeTimer -= Time.deltaTime;
            }

            if (state == State.ENDING_CUTSCENE_FADE_OUT)
            {
                fadeTimer += Time.deltaTime;
                if (fadeTimer > FADE_TIME + EXTRA_TIME)
                {
                    state     = State.ENDING_CUTSCENE_FADE_IN;
                    fadeTimer = FADE_TIME;
                }

                return;
            }

            if (state == State.ENDING_CUTSCENE_FADE_IN)
            {
                fadeTimer -= Time.deltaTime;
                if (fadeTimer < 0)
                {
                    Destroy(gameObject);
                }

                return;
            }

            if (state != State.IN_CUTSCENE)
            {
                return;
            }

            while (currentAction != null)
            {
                currentAction.Update();

                // Move to the next action if necessary
                if (currentAction.async || currentAction.ReadyForNextAction())
                {
                    currentAction.OnDestroy();

                    if (++currentIndex < cutSceneDefinition.actions.Count)
                    {
                        LoggingUtil.LogVerbose(this, "Invoking action " + currentAction);
                        currentAction = cutSceneDefinition.actions[currentIndex];
                        currentAction.InvokeAction();
                    }
                    else
                    {
                        currentAction = null;
                        state         = State.ENDING_CUTSCENE_FADE_OUT;
                        fadeTimer     = 0;
                    }
                }
                else
                {
                    break;
                }
            }
        }
        void Update()
        {
            if (state == State.IDLE)
            {
                return;
            }

            if (state == State.STARTING_CUTSCENE_FADE_OUT)
            {
                fadeTimer += Time.deltaTime;
                if (fadeTimer > FADE_TIME + EXTRA_TIME)
                {
                    state = State.IN_CUTSCENE;
                    fadeTimer = FADE_TIME;

                    // Switch to the first cutscene camera
                    cutSceneDefinition.cameras.First().MakeActive();

                    // Invoke the first action
                    currentIndex = 0;
                    currentAction = cutSceneDefinition.actions.First();
                    currentAction.InvokeAction();
                }

                return;
            }

            if (state == State.IN_CUTSCENE)
            {
                fadeTimer -= Time.deltaTime;
            }

            if (state == State.ENDING_CUTSCENE_FADE_OUT)
            {
                fadeTimer += Time.deltaTime;
                if (fadeTimer > FADE_TIME + EXTRA_TIME)
                {
                    state = State.ENDING_CUTSCENE_FADE_IN;
                    fadeTimer = FADE_TIME;
                }

                return;
            }

            if (state == State.ENDING_CUTSCENE_FADE_IN)
            {
                fadeTimer -= Time.deltaTime;
                if (fadeTimer < 0)
                {
                    Destroy(gameObject);
                }

                return;
            }

            if (state != State.IN_CUTSCENE)
            {
                return;
            }

            while (currentAction != null)
            {
                currentAction.Update();

                // Move to the next action if necessary
                if (currentAction.async || currentAction.ReadyForNextAction())
                {
                    currentAction.OnDestroy();

                    if (++currentIndex < cutSceneDefinition.actions.Count)
                    {
                        LoggingUtil.LogVerbose(this, "Invoking action " + currentAction);
                        currentAction = cutSceneDefinition.actions[currentIndex];
                        currentAction.InvokeAction();
                    }
                    else
                    {
                        currentAction = null;
                        state = State.ENDING_CUTSCENE_FADE_OUT;
                        fadeTimer = 0;
                    }
                }
                else
                {
                    break;
                }
            }
        }