public void draw()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(TC.get("Element.Name19"));
            effect.setTargetId(items[EditorGUILayout.Popup(Array.IndexOf(items, effect.getTargetId()), items)]);
            EditorGUILayout.EndHorizontal();

            xString        = effect.getX().ToString();
            yString        = effect.getY().ToString();
            translateSpeed = effect.getTranslateSpeed().ToString();
            scaleSpeed     = effect.getScaleSpeed().ToString();
            floatScale     = effect.getScale();

            xString = EditorGUILayout.TextField(xString);
            xString = Regex.Replace(xString, "[^0-9]", "");

            yString = EditorGUILayout.TextField(yString);
            yString = Regex.Replace(xString, "[^0-9]", "");

            translateSpeed = EditorGUILayout.TextField(translateSpeed);
            translateSpeed = Regex.Replace(translateSpeed, "[^0-9]", "");

            scaleSpeed = EditorGUILayout.TextField(scaleSpeed);
            scaleSpeed = Regex.Replace(scaleSpeed, "[^0-9]", "");

            floatScale = EditorGUILayout.FloatField(floatScale);

            effect.setX(int.Parse(xString));
            effect.setY(int.Parse(yString));
            effect.setTranslateSpeed(int.Parse(translateSpeed));
            effect.setScaleSpeed(int.Parse(scaleSpeed));
            effect.setScale(floatScale);

            EditorGUILayout.HelpBox(TC.get("MoveObjectEffect.Title"), MessageType.Info);
        }
Пример #2
0
        private static XmlElement buildEffectNode(AbstractEffect effect, XmlDocument doc)
        {
            XmlElement effectElement = null;

            switch (effect.getType())
            {
            case EffectType.ACTIVATE:
                ActivateEffect activateEffect = (ActivateEffect)effect;
                effectElement = doc.CreateElement("activate");
                effectElement.SetAttribute("flag", activateEffect.getTargetId());
                break;

            case EffectType.DEACTIVATE:
                DeactivateEffect deactivateEffect = (DeactivateEffect)effect;
                effectElement = doc.CreateElement("deactivate");
                effectElement.SetAttribute("flag", deactivateEffect.getTargetId());
                break;

            case EffectType.SET_VALUE:
                SetValueEffect setValueEffect = (SetValueEffect)effect;
                effectElement = doc.CreateElement("set-value");
                effectElement.SetAttribute("var", setValueEffect.getTargetId());
                effectElement.SetAttribute("value", setValueEffect.getValue().ToString());
                break;

            case EffectType.INCREMENT_VAR:
                IncrementVarEffect incrementVarEffect = (IncrementVarEffect)effect;
                effectElement = doc.CreateElement("increment");
                effectElement.SetAttribute("var", incrementVarEffect.getTargetId());
                effectElement.SetAttribute("value", incrementVarEffect.getIncrement().ToString());
                break;

            case EffectType.DECREMENT_VAR:
                DecrementVarEffect decrementVarEffect = (DecrementVarEffect)effect;
                effectElement = doc.CreateElement("decrement");
                effectElement.SetAttribute("var", decrementVarEffect.getTargetId());
                effectElement.SetAttribute("value", decrementVarEffect.getDecrement().ToString());
                break;

            case EffectType.MACRO_REF:
                MacroReferenceEffect macroRefEffect = (MacroReferenceEffect)effect;
                effectElement = doc.CreateElement("macro-ref");
                effectElement.SetAttribute("id", macroRefEffect.getTargetId());
                break;

            case EffectType.CONSUME_OBJECT:
                ConsumeObjectEffect consumeObjectEffect = (ConsumeObjectEffect)effect;
                effectElement = doc.CreateElement("consume-object");
                effectElement.SetAttribute("idTarget", consumeObjectEffect.getTargetId());
                break;

            case EffectType.GENERATE_OBJECT:
                GenerateObjectEffect generateObjectEffect = (GenerateObjectEffect)effect;
                effectElement = doc.CreateElement("generate-object");
                effectElement.SetAttribute("idTarget", generateObjectEffect.getTargetId());
                break;

            case EffectType.CANCEL_ACTION:
                effectElement = doc.CreateElement("cancel-action");
                break;

            case EffectType.SPEAK_PLAYER:
                SpeakPlayerEffect speakPlayerEffect = (SpeakPlayerEffect)effect;
                effectElement = doc.CreateElement("speak-player");
                if (speakPlayerEffect.getAudioPath() != null && !speakPlayerEffect.getAudioPath().Equals(""))
                {
                    effectElement.SetAttribute("uri", speakPlayerEffect.getAudioPath());
                }
                effectElement.AppendChild(doc.CreateTextNode(speakPlayerEffect.getLine()));
                break;

            case EffectType.SPEAK_CHAR:
                SpeakCharEffect speakCharEffect = (SpeakCharEffect)effect;
                effectElement = doc.CreateElement("speak-char");
                effectElement.SetAttribute("idTarget", speakCharEffect.getTargetId());
                if (speakCharEffect.getAudioPath() != null && !speakCharEffect.getAudioPath().Equals(""))
                {
                    effectElement.SetAttribute("uri", speakCharEffect.getAudioPath());
                }
                effectElement.AppendChild(doc.CreateTextNode(speakCharEffect.getLine()));
                break;

            case EffectType.TRIGGER_BOOK:
                TriggerBookEffect triggerBookEffect = (TriggerBookEffect)effect;
                effectElement = doc.CreateElement("trigger-book");
                effectElement.SetAttribute("idTarget", triggerBookEffect.getTargetId());
                break;

            case EffectType.PLAY_SOUND:
                PlaySoundEffect playSoundEffect = (PlaySoundEffect)effect;
                effectElement = doc.CreateElement("play-sound");
                if (!playSoundEffect.isBackground())
                {
                    effectElement.SetAttribute("background", "no");
                }
                effectElement.SetAttribute("uri", playSoundEffect.getPath());
                break;

            case EffectType.PLAY_ANIMATION:
                PlayAnimationEffect playAnimationEffect = (PlayAnimationEffect)effect;
                effectElement = doc.CreateElement("play-animation");
                effectElement.SetAttribute("uri", playAnimationEffect.getPath());
                effectElement.SetAttribute("x", playAnimationEffect.getX().ToString());
                effectElement.SetAttribute("y", playAnimationEffect.getY().ToString());
                break;

            case EffectType.MOVE_PLAYER:
                MovePlayerEffect movePlayerEffect = (MovePlayerEffect)effect;
                effectElement = doc.CreateElement("move-player");
                effectElement.SetAttribute("x", movePlayerEffect.getX().ToString());
                effectElement.SetAttribute("y", movePlayerEffect.getY().ToString());
                break;

            case EffectType.MOVE_NPC:
                MoveNPCEffect moveNPCEffect = (MoveNPCEffect)effect;
                effectElement = doc.CreateElement("move-npc");
                effectElement.SetAttribute("idTarget", moveNPCEffect.getTargetId());
                effectElement.SetAttribute("x", moveNPCEffect.getX().ToString());
                effectElement.SetAttribute("y", moveNPCEffect.getY().ToString());
                break;

            case EffectType.TRIGGER_CONVERSATION:
                TriggerConversationEffect triggerConversationEffect = (TriggerConversationEffect)effect;
                effectElement = doc.CreateElement("trigger-conversation");
                effectElement.SetAttribute("idTarget", triggerConversationEffect.getTargetId());
                break;

            case EffectType.TRIGGER_CUTSCENE:
                TriggerCutsceneEffect triggerCutsceneEffect = (TriggerCutsceneEffect)effect;
                effectElement = doc.CreateElement("trigger-cutscene");
                effectElement.SetAttribute("idTarget", triggerCutsceneEffect.getTargetId());
                break;

            case EffectType.TRIGGER_LAST_SCENE:
                effectElement = doc.CreateElement("trigger-last-scene");
                break;

            case EffectType.TRIGGER_SCENE:
                TriggerSceneEffect triggerSceneEffect = (TriggerSceneEffect)effect;
                effectElement = doc.CreateElement("trigger-scene");
                effectElement.SetAttribute("idTarget", triggerSceneEffect.getTargetId());
                effectElement.SetAttribute("x", triggerSceneEffect.getX().ToString());
                effectElement.SetAttribute("y", triggerSceneEffect.getY().ToString());
                break;

            case EffectType.WAIT_TIME:
                WaitTimeEffect waitTimeEffect = (WaitTimeEffect)effect;
                effectElement = doc.CreateElement("wait-time");
                effectElement.SetAttribute("time", waitTimeEffect.getTime().ToString());
                break;

            case EffectType.SHOW_TEXT:
                ShowTextEffect showTextEffect = (ShowTextEffect)effect;
                effectElement = doc.CreateElement("show-text");
                effectElement.SetAttribute("x", showTextEffect.getX().ToString());
                effectElement.SetAttribute("y", showTextEffect.getY().ToString());
                effectElement.SetAttribute("frontColor", showTextEffect.getRgbFrontColor().ToString());
                effectElement.SetAttribute("borderColor", showTextEffect.getRgbBorderColor().ToString());
                effectElement.SetAttribute("uri", showTextEffect.getAudioPath());
                effectElement.AppendChild(doc.CreateTextNode(showTextEffect.getText()));
                break;

            case EffectType.MOVE_OBJECT:
                MoveObjectEffect moveObjectEffect = (MoveObjectEffect)effect;
                effectElement = doc.CreateElement("move-object");
                effectElement.SetAttribute("idTarget", moveObjectEffect.getTargetId());
                effectElement.SetAttribute("x", moveObjectEffect.getX().ToString());
                effectElement.SetAttribute("y", moveObjectEffect.getY().ToString());
                effectElement.SetAttribute("scale", moveObjectEffect.getScale().ToString());
                effectElement.SetAttribute("animated", (moveObjectEffect.isAnimated() ? "yes" : "no"));
                effectElement.SetAttribute("translateSpeed", moveObjectEffect.getTranslateSpeed().ToString());
                effectElement.SetAttribute("scaleSpeed", moveObjectEffect.getScaleSpeed().ToString());
                break;

            case EffectType.HIGHLIGHT_ITEM:
                HighlightItemEffect highlightItemEffect = (HighlightItemEffect)effect;
                effectElement = doc.CreateElement("highlight-item");
                effectElement.SetAttribute("idTarget", highlightItemEffect.getTargetId());
                effectElement.SetAttribute("animated", (highlightItemEffect.isHighlightAnimated() ? "yes" : "no"));
                switch (highlightItemEffect.getHighlightType())
                {
                case HighlightItemEffect.HIGHLIGHT_BLUE:
                    effectElement.SetAttribute("type", "blue");
                    break;

                case HighlightItemEffect.HIGHLIGHT_BORDER:
                    effectElement.SetAttribute("type", "border");
                    break;

                case HighlightItemEffect.HIGHLIGHT_RED:
                    effectElement.SetAttribute("type", "red");
                    break;

                case HighlightItemEffect.HIGHLIGHT_GREEN:
                    effectElement.SetAttribute("type", "green");
                    break;

                case HighlightItemEffect.NO_HIGHLIGHT:
                    effectElement.SetAttribute("type", "none");
                    break;
                }
                break;
            }
            return(effectElement);
        }
        public override void draw()
        {
            var items = Controller.Instance.IdentifierSummary.getIds <Item>();

            if (items == null || items.Length == 0)
            {
                EditorGUILayout.HelpBox(TC.get("Action.ErrorNoItems"), MessageType.Error);
                return;
            }

            effect.setTargetId(items[EditorGUILayout.Popup(TC.get("Element.Name19"), Array.IndexOf(items, effect.getTargetId()), items)]);

            var value = EditorGUILayout.Vector2IntField("", new Vector2Int(effect.getX(), effect.getY()));

            effect.setX(value.x);
            effect.setY(value.y);
            effect.setScale(EditorGUILayout.FloatField(TC.get("SceneLocation.Scale"), effect.getScale()));
            effect.setAnimated(EditorGUILayout.BeginToggleGroup(TC.get("MoveObjectEffect.Animated"), effect.isAnimated()));
            var prevLabelSize = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 95;
            effect.setTranslateSpeed(EditorGUILayout.IntField(TC.get("MoveObjectEffect.TranslateSpeed"), effect.getTranslateSpeed()));
            effect.setScaleSpeed(EditorGUILayout.IntField(TC.get("MoveObjectEffect.ScaleSpeed"), effect.getScaleSpeed()));
            EditorGUIUtility.labelWidth = prevLabelSize;
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.HelpBox(TC.get("MoveObjectEffect.Title"), MessageType.Info);
        }