public override void Draw(int aID)
            {
                if (Controller.Instance.PlayerMode != Controller.FILE_ADVENTURE_3RDPERSON_PLAYER)
                {
                    EditorGUILayout.HelpBox("In first person mode there is no destination position.", MessageType.Info); // TODO LANG
                    return;
                }

                var exit = Target as ExitDataControl;


                EditorGUI.BeginChangeCheck();
                var has   = EditorGUILayout.Toggle(TC.get("NextSceneCell.UsePosition"), exit.hasDestinyPosition());
                var scene = exit.getSceneDataControl();

                if (EditorGUI.EndChangeCheck())
                {
                    var scenes           = Controller.Instance.SelectedChapterDataControl.getScenesList();
                    var destinationScene = scenes.getScenes()[scenes.getSceneIndexByID(exit.getNextSceneId())] ?? scene;

                    var defPlayerPos = destinationScene.getDefaultInitialPosition();
                    exit.setDestinyPosition(has ? (int)defPlayerPos.x : int.MinValue, has ? (int)defPlayerPos.y : int.MinValue);

                    if (has)
                    {
                        var scale = destinationScene.getPlayerAppropiateScale();
                        if (scale != 1)
                        {
                            exit.setDestinyScale(scale);
                        }
                    }
                }

                if (!has)
                {
                    EditorGUILayout.HelpBox("Destination position will be based on origin position.", MessageType.Info); // TODO LANG
                    return;
                }

                EditorGUI.BeginChangeCheck();
                var newPos = EditorGUILayout.Vector2Field(TC.get("Inventory.Position"), new Vector2(exit.getDestinyPositionX(), exit.getDestinyPositionY()));

                if (EditorGUI.EndChangeCheck())
                {
                    exit.setDestinyPosition(Mathf.RoundToInt(newPos.x), Mathf.RoundToInt(newPos.y));
                }

                EditorGUI.BeginChangeCheck();
                bool useDestinyScale = EditorGUILayout.Toggle("Use destiny scale", exit.getDestinyScale() >= 0); // TODO LANG

                if (EditorGUI.EndChangeCheck())
                {
                    var sceneScale = (scene != null ? scene.getPlayerAppropiateScale() : 1f);
                    exit.setDestinyScale(useDestinyScale ? sceneScale : float.MinValue);
                }

                if (useDestinyScale)
                {
                    EditorGUI.BeginChangeCheck();
                    var newScale = Mathf.Max(0.001f, EditorGUILayout.FloatField(TC.get("SceneLocation.Scale"), exit.getDestinyScale()));
                    if (EditorGUI.EndChangeCheck())
                    {
                        exit.setDestinyScale(newScale);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("The player size will stay as before entering the exit.", MessageType.Info); // TODO LANG
                }

                var scenesList = Controller.Instance.SelectedChapterDataControl.getScenesList();
                var sceneIndex = scenesList.getSceneIndexByID(exit.getNextSceneId());

                if (sceneIndex == -1)
                {
                    EditorGUILayout.HelpBox("Please select a valid destination!", MessageType.Error); // TODO LANG
                    return;
                }

                localSceneEditor.Components = SceneEditor.Current.Components;
                localSceneEditor.Scene      = scenesList.getScenes()[sceneIndex];
                playerDestination.setValues(exit.getDestinyPositionX(), exit.getDestinyPositionY(), exit.getDestinyScale() < 0 ? 1f : exit.getDestinyScale());

                localSceneEditor.Draw(GUILayoutUtility.GetRect(0, 200, GUILayout.ExpandWidth(true)));
                exit.setDestinyPosition(playerDestination.getX(), playerDestination.getY());
                if (useDestinyScale)
                {
                    exit.setDestinyScale(playerDestination.getScale());
                }
            }
        public virtual void draw()
        {
            scenes = Controller.Instance.IdentifierSummary.getIds <IChapterTarget>();
            scenes = scenes.Except(Controller.Instance.IdentifierSummary.getIds <Cutscene>()).ToArray();

            EditorGUI.BeginChangeCheck();
            var sceneIndex = EditorGUILayout.Popup(TC.get("Element.Name2"), Array.IndexOf(scenes, effect.getTargetId()), scenes);

            if (EditorGUI.EndChangeCheck())
            {
                SetDestinyScene(sceneIndex);
            }

            if (sceneIndex == -1)
            {
                EditorGUILayout.HelpBox("TriggerSceneEffectEditor.ValidDestination".Traslate(), MessageType.Error);
                return;
            }

            // Transition Type
            EditorGUI.BeginChangeCheck();
            var newType = EditorGUILayout.Popup(TC.get("NextScene.Transition"), (int)effect.getTransitionType(), transitionTypes);

            if (EditorGUI.EndChangeCheck())
            {
                effect.setTransitionType((TransitionType)newType);
            }

            // Transition Time
            EditorGUI.BeginChangeCheck();
            var time = Mathf.Clamp(EditorGUILayout.IntField(TC.get("NextScene.TransitionTime"), effect.getTransitionTime()), 0, 5000);

            if (EditorGUI.EndChangeCheck())
            {
                effect.setTransitionTime(time);
            }

            var scenesList = Controller.Instance.SelectedChapterDataControl.getScenesList();

            // If the selected scene IS a scene (not a cutscene or any other type)
            if (Controller.Instance.PlayerMode == Controller.FILE_ADVENTURE_3RDPERSON_PLAYER && sceneIndex < scenesList.getScenes().Count)
            {
                var pos = EditorGUILayout.Vector2IntField(TC.get("Inventory.Position"), new Vector2Int(effect.getX(), effect.getY()));
                effect.setPosition(pos.x, pos.y);

                EditorGUI.BeginChangeCheck();
                bool useDestinyScale = EditorGUILayout.Toggle("TriggerSceneEffectEditor.UseScale".Traslate(), effect.DestinyScale >= 0);
                if (EditorGUI.EndChangeCheck())
                {
                    effect.DestinyScale = useDestinyScale ? 1f : float.MinValue;
                }

                if (useDestinyScale)
                {
                    EditorGUI.BeginChangeCheck();
                    var newScale = Mathf.Max(0.001f, EditorGUILayout.FloatField(TC.get("SceneLocation.Scale"), effect.DestinyScale));
                    if (EditorGUI.EndChangeCheck())
                    {
                        effect.DestinyScale = newScale;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("TriggerSceneEffectEditor.SizeMaintained".Traslate(), MessageType.Info);
                }

                localSceneEditor.Components = EditorWindowBase.Components;
                localSceneEditor.Scene      = scenesList.getScenes()[sceneIndex];
                playerDestination.setValues(effect.getX(), effect.getY(), useDestinyScale ? effect.DestinyScale : 1f);

                var previousScale = playerDestination.getScale();

                localSceneEditor.Draw(GUILayoutUtility.GetRect(0, 200, GUILayout.ExpandWidth(true)));
                effect.setPosition(playerDestination.getX(), playerDestination.getY());
                if (previousScale != playerDestination.getScale())
                {
                    effect.DestinyScale = playerDestination.getScale();
                }
            }

            EditorGUILayout.HelpBox(TC.get("TriggerSceneEffect.Description"), MessageType.Info);
        }
Example #3
0
 public override void DrawPreview(Rect rect)
 {
     sceneEditor.Draw(rect);
 }