コード例 #1
0
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            frontcolors,
            bordercolors,
            textcolors = element.SelectNodes("textcolor"),
            conversationsref = element.SelectNodes("conversation-ref"),
            voices = element.SelectNodes("voice"),
            actionss = element.SelectNodes("actions");

        string tmpArgVal;

        string characterId = element.GetAttribute("id");

        npc = new NPC(characterId);

        descriptions = new List<Description>();
        npc.setDescriptions(descriptions);

        if (element.SelectSingleNode("documentation") != null)
            npc.setDocumentation(element.SelectSingleNode("documentation").InnerText);

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();
            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(el.GetAttribute(tmpArgVal));
            }

            assets = el.SelectNodes("asset");
            foreach (XmlElement ell in assets)
            {
                string type = "";
                string path = "";

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    type = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                currentResources.addAsset(type, path);
            }

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentResources.setConditions(currentConditions);
            }

            npc.addResources(currentResources);
        }

        foreach (XmlElement el in textcolors)
        {
            tmpArgVal = el.GetAttribute("showsSpeechBubble");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setShowsSpeechBubbles(tmpArgVal.Equals("yes"));
            }

            tmpArgVal = el.GetAttribute("bubbleBkgColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBkgColor(tmpArgVal);
            }

            tmpArgVal = el.GetAttribute("bubbleBorderColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBorderColor(tmpArgVal);
            }

            frontcolors = el.SelectNodes("frontcolor");
            foreach (XmlElement ell in frontcolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextFrontColor(color);
            }

            bordercolors = el.SelectNodes("bordercolor");
            foreach (XmlElement ell in bordercolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextBorderColor(color);
            }
        }

        foreach (XmlElement el in conversationsref)
        {
            string idTarget = "";

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }

            conversationReference = new ConversationReference(idTarget);

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);

                conversationReference.setConditions(currentConditions);
            }

            conversationReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

            Action action = new Action(Action.TALK_TO);
            action.setConditions(conversationReference.getConditions());
            action.setDocumentation(conversationReference.getDocumentation());
            TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
            action.getEffects().add(effect);
            npc.addAction(action);
        }

        foreach (XmlElement el in voices)
        {
            string voice = "";
            string response;
            bool alwaysSynthesizer = false;

            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                voice = tmpArgVal;
            }

            tmpArgVal = el.GetAttribute("synthesizeAlways");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                response = tmpArgVal;
                if (response.Equals("yes"))
                    alwaysSynthesizer = true;
            }

            npc.setAlwaysSynthesizer(alwaysSynthesizer);
            npc.setVoice(voice);
        }

        foreach (XmlElement el in actionss)
        {
            new ActionsSubParser_(chapter, npc).ParseElement(el);
        }

        foreach (XmlElement el in descriptionss)
        {
            description = new Description();
            new DescriptionsSubParser_(description, chapter).ParseElement(el);
            this.descriptions.Add(description);
        }

        chapter.addCharacter(npc);
    }
コード例 #2
0
        public override bool doTool()
        {
            bool effectEdited = false;

            EffectType effectType = effect.getType();

            // If a change has been made
            if (newProperties != null)
            {
                effectEdited = true;
                oldEffect    = (AbstractEffect)effect;

                switch (effectType)
                {
                case EffectType.ACTIVATE:
                    ActivateEffect activateEffect = (ActivateEffect)effect;
                    activateEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    Controller.getInstance().updateVarFlagSummary();
                    break;

                case EffectType.DEACTIVATE:
                    DeactivateEffect deactivateEffect = (DeactivateEffect)effect;
                    deactivateEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    Controller.getInstance().updateVarFlagSummary();
                    break;

                case EffectType.SET_VALUE:
                    SetValueEffect setValueEffect = (SetValueEffect)effect;
                    setValueEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    setValueEffect.setValue(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_VALUE]));
                    Controller.getInstance().updateVarFlagSummary();
                    break;

                case EffectType.INCREMENT_VAR:
                    IncrementVarEffect incrementVarEffect = (IncrementVarEffect)effect;
                    incrementVarEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    incrementVarEffect.setIncrement(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_VALUE]));
                    Controller.getInstance().updateVarFlagSummary();
                    break;

                case EffectType.DECREMENT_VAR:
                    DecrementVarEffect decrementVarEffect = (DecrementVarEffect)effect;
                    decrementVarEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    decrementVarEffect.setDecrement(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_VALUE]));
                    Controller.getInstance().updateVarFlagSummary();
                    break;

                case EffectType.MACRO_REF:
                    MacroReferenceEffect macroEffect = (MacroReferenceEffect)effect;
                    macroEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    break;

                case EffectType.CONSUME_OBJECT:
                    ConsumeObjectEffect consumeObjectEffect = (ConsumeObjectEffect)effect;
                    consumeObjectEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    break;

                case EffectType.GENERATE_OBJECT:
                    GenerateObjectEffect generateObjectEffect = (GenerateObjectEffect)effect;
                    generateObjectEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    break;

                case EffectType.SPEAK_PLAYER:
                    SpeakPlayerEffect speakPlayerEffect = (SpeakPlayerEffect)effect;
                    speakPlayerEffect.setLine((string)newProperties[EffectsController.EFFECT_PROPERTY_TEXT]);
                    speakPlayerEffect.setAudioPath((string)newProperties[EffectsController.EFFECT_PROPERTY_PATH]);
                    break;

                case EffectType.SPEAK_CHAR:
                    SpeakCharEffect speakCharEffect = (SpeakCharEffect)effect;
                    speakCharEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    speakCharEffect.setLine((string)newProperties[EffectsController.EFFECT_PROPERTY_TEXT]);
                    speakCharEffect.setAudioPath((string)newProperties[EffectsController.EFFECT_PROPERTY_PATH]);
                    break;

                case EffectType.TRIGGER_BOOK:
                    TriggerBookEffect triggerBookEffect = (TriggerBookEffect)effect;
                    triggerBookEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    break;

                case EffectType.PLAY_SOUND:
                    PlaySoundEffect playSoundEffect = (PlaySoundEffect)effect;
                    playSoundEffect.setPath((string)newProperties[EffectsController.EFFECT_PROPERTY_PATH]);
                    playSoundEffect.setBackground(bool.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_BACKGROUND]));
                    break;

                case EffectType.PLAY_ANIMATION:
                    PlayAnimationEffect playAnimationEffect = (PlayAnimationEffect)effect;
                    playAnimationEffect.setPath((string)newProperties[EffectsController.EFFECT_PROPERTY_PATH]);
                    playAnimationEffect.setDestiny(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_X]), int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_Y]));
                    break;

                case EffectType.MOVE_PLAYER:
                    MovePlayerEffect movePlayerEffect = (MovePlayerEffect)effect;
                    movePlayerEffect.setDestiny(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_X]), int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_Y]));
                    break;

                case EffectType.MOVE_NPC:
                    MoveNPCEffect moveNPCEffect = (MoveNPCEffect)effect;
                    moveNPCEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    moveNPCEffect.setDestiny(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_X]), int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_Y]));
                    break;

                case EffectType.TRIGGER_CONVERSATION:
                    TriggerConversationEffect triggerConversationEffect = (TriggerConversationEffect)effect;
                    triggerConversationEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    break;

                case EffectType.TRIGGER_CUTSCENE:
                    TriggerCutsceneEffect triggerCutsceneEffect = (TriggerCutsceneEffect)effect;
                    triggerCutsceneEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    break;

                case EffectType.TRIGGER_SCENE:
                    TriggerSceneEffect triggerSceneEffect = (TriggerSceneEffect)effect;
                    triggerSceneEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    triggerSceneEffect.setPosition(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_X]), int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_Y]));
                    break;

                case EffectType.RANDOM_EFFECT:
                    RandomEffect randomEffect = (RandomEffect)effect;
                    randomEffect.setProbability(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_PROBABILITY]));
                    randomEffect.setPositiveEffect(pos);
                    randomEffect.setNegativeEffect(neg);
                    break;

                case EffectType.WAIT_TIME:
                    WaitTimeEffect waitTimeEffect = (WaitTimeEffect)effect;
                    waitTimeEffect.setTime(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_TIME]));
                    break;

                case EffectType.SHOW_TEXT:
                    ShowTextEffect showTextEffect = (ShowTextEffect)effect;
                    showTextEffect.setText((string)newProperties[EffectsController.EFFECT_PROPERTY_TEXT]);
                    showTextEffect.setTextPosition(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_X]), int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_Y]));
                    showTextEffect.setRgbFrontColor((string)newProperties[EffectsController.EFFECT_PROPERTY_FRONT_COLOR]);
                    showTextEffect.setRgbBorderColor((string)newProperties[EffectsController.EFFECT_PROPERTY_BORDER_COLOR]);
                    showTextEffect.setAudioPath((string)newProperties[EffectsController.EFFECT_PROPERTY_PATH]);
                    break;

                case EffectType.HIGHLIGHT_ITEM:
                    HighlightItemEffect highlightItemEffect = (HighlightItemEffect)effect;
                    highlightItemEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    highlightItemEffect.setHighlightAnimated((bool)newProperties[EffectsController.EFFECT_PROPERTY_ANIMATED]);
                    highlightItemEffect.setHighlightType((int)newProperties[EffectsController.EFFECT_PROPERTY_HIGHLIGHT_TYPE]);
                    break;

                case EffectType.MOVE_OBJECT:
                    MoveObjectEffect moveObjectEffect = (MoveObjectEffect)effect;
                    moveObjectEffect.setTargetId((string)newProperties[EffectsController.EFFECT_PROPERTY_TARGET]);
                    moveObjectEffect.setX(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_X]));
                    moveObjectEffect.setY(int.Parse((string)newProperties[EffectsController.EFFECT_PROPERTY_Y]));
                    moveObjectEffect.setScale((float)newProperties[EffectsController.EFFECT_PROPERTY_SCALE]);
                    moveObjectEffect.setAnimated((bool)newProperties[EffectsController.EFFECT_PROPERTY_ANIMATED]);
                    moveObjectEffect.setScaleSpeed((int)newProperties[EffectsController.EFFECT_PROPERTY_SCALE_SPEED]);
                    moveObjectEffect.setTranslateSpeed((int)newProperties[EffectsController.EFFECT_PROPERTY_TRANSLATION_SPEED]);
                    break;
                }
                effectEdited = true;
                Controller.getInstance().updatePanel();
            }

            return(effectEdited);
        }
コード例 #3
0
        public TriggerConversationEffectEditor()
        {
            var conversations = Controller.Instance.IdentifierSummary.getIds <Conversation>();

            this.effect = new TriggerConversationEffect(conversations.Length > 0 ? conversations[0] : "");
        }
コード例 #4
0
 public TriggerCutsceneEffectEditor()
 {
     cutscenes   = Controller.getInstance().getSelectedChapterDataControl().getCutscenesList().getCutscenesIDs();
     this.effect = new TriggerConversationEffect(cutscenes[0]);
 }
コード例 #5
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {

            // If it is a character tag, store the character in the game data
            if (qName.Equals("character"))
            {
                chapter.addCharacter(npc);
            }

            // If it is a documentation tag, hold the documentation in the character
            else if (qName.Equals("documentation"))
            {
                if (reading == READING_NONE)
                    npc.setDocumentation(currentstring.ToString().Trim());
                else if (reading == READING_CONVERSATION_REFERENCE)
                    conversationReference.setDocumentation(currentstring.ToString().Trim());
            }

            // If it is a resources tag, add the resources in the character
            else if (qName.Equals("resources"))
            {
                npc.addResources(currentResources);
                reading = READING_NONE;
            }

            // If it is a conversation reference tag, add the reference to the character
            else if (qName.Equals("conversation-ref"))
            {

                //npc.addConversationReference( conversationReference );
                Action action = new Action(Action.TALK_TO);
                action.setConditions(conversationReference.getConditions());
                action.setDocumentation(conversationReference.getDocumentation());
                TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
                action.getEffects().add(effect);
                npc.addAction(action);
                reading = READING_NONE;
            }

            // Reset the current string
            currentstring = "";
        }

        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {

            // Spread the end element call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition is being closed
            if (qName.Equals("condition"))
            {
                // Add the condition to the resources
                if (reading == READING_RESOURCES)
                    currentResources.setConditions(currentConditions);

                // Add the condition to the conversation reference
                if (reading == READING_CONVERSATION_REFERENCE)
                    conversationReference.setConditions(currentConditions);

                // Stop subparsing
                subParsing = SUBPARSING_NONE;
            }
        }
        else if (subParsing == SUBPARSING_ACTIONS)
        {
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("actions"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }

        // If it is a description tag, create the new description (with its id)
        else if (subParsing == SUBPARSING_DESCRIPTION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("description"))
            {
                this.descriptions.Add(description);
                subParsing = SUBPARSING_NONE;
            }
        }
    }
コード例 #6
0
    public bool execute()
    {
        bool forcewait = false;

        if (!(runs_once && times_runed > 0))
        {
            if (effect == null || effect.getConditions() == null)
            {
                Debug.Log("Asd");
            }
            else
            {
                if (!validated)
                {
                    is_valid  = ConditionChecker.check(effect.getConditions());
                    validated = true;
                }

                if (is_valid)
                {
                    switch (effect.getType())
                    {
                    case EffectType.ACTIVATE:
                        Game.Instance.GameState.setFlag(((ActivateEffect)effect).getTargetId(), FlagCondition.FLAG_ACTIVE);
                        break;

                    case EffectType.DEACTIVATE:
                        Game.Instance.GameState.setFlag(((DeactivateEffect)effect).getTargetId(), FlagCondition.FLAG_INACTIVE);
                        break;

                    case EffectType.SPEAK_PLAYER:
                        Game.Instance.talk(((SpeakPlayerEffect)effect).getLine(), null);
                        forcewait = true;
                        break;

                    case EffectType.SPEAK_CHAR:
                        Game.Instance.talk(((SpeakCharEffect)effect).getLine(), ((SpeakCharEffect)effect).getTargetId());
                        forcewait = true;
                        break;

                    case EffectType.TRIGGER_SCENE:
                        runs_once = false;
                        Game.Instance.renderScene(((TriggerSceneEffect)effect).getTargetId());
                        break;

                    case EffectType.TRIGGER_CUTSCENE:
                        runs_once = false;
                        TriggerCutsceneEffect tce = (TriggerCutsceneEffect)effect;
                        if (times_runed > 0)
                        {
                            forcewait = ((SceneMB)aditional_info ["scene"]).Interacted() == InteractuableResult.REQUIRES_MORE_INTERACTION;
                        }
                        else
                        {
                            aditional_info = new Dictionary <string, object> ();
                            aditional_info.Add("lastscene", Game.Instance.GameState.CurrentScene);
                            aditional_info.Add("scene", Game.Instance.renderScene(tce.getTargetId()).GetComponent <SceneMB> ());
                            forcewait = true;
                        }

                        if (!forcewait && ((Slidescene)((SceneMB)aditional_info ["scene"]).sceneData).getNext() == Slidescene.GOBACK)
                        {
                            string last = (string)aditional_info ["lastscene"];
                            Game.Instance.renderScene(last);
                        }

                        break;

                    case EffectType.TRIGGER_LAST_SCENE:
                        runs_once = false;
                        Game.Instance.renderLastScene();
                        break;

                    case EffectType.TRIGGER_CONVERSATION:
                        runs_once = false;
                        runs_once = false;
                        if (times_runed == 0)
                        {
                            TriggerConversationEffect tcoe = (TriggerConversationEffect)effect;
                            this.aditional_info.Add("conversation", new GraphConversationHolder(Game.Instance.GameState.getConversation(tcoe.getTargetId())));
                        }
                        forcewait = ((GraphConversationHolder)this.aditional_info ["conversation"]).execute();
                        break;

                    case EffectType.RANDOM_EFFECT:
                        runs_once = false;
                        RandomEffect re = (RandomEffect)effect;

                        if (!aditional_info.ContainsKey("first"))
                        {
                            aditional_info.Add("first", new EffectHolderNode(re.getPositiveEffect()));
                            aditional_info.Add("second", new EffectHolderNode(re.getNegativeEffect()));
                        }

                        if (times_runed == 0)
                        {
                            int pro = re.getProbability(), now = Random.Range(0, 100);
                            if (aditional_info.ContainsKey("current"))
                            {
                                aditional_info.Remove("current");
                            }

                            if (pro <= now)
                            {
                                aditional_info.Add("current", "first");
                            }
                            else
                            {
                                aditional_info.Add("current", "second");
                            }

                            forcewait = ((EffectHolderNode)aditional_info [((string)aditional_info ["current"])]).execute();
                        }
                        else
                        {
                            forcewait = ((EffectHolderNode)aditional_info [((string)aditional_info ["current"])]).execute();
                        }

                        break;

                    case EffectType.SET_VALUE:
                        SetValueEffect sve = (SetValueEffect)effect;
                        Game.Instance.GameState.setVariable(sve.getTargetId(), sve.getValue());
                        break;

                    case EffectType.INCREMENT_VAR:
                        IncrementVarEffect ive = (IncrementVarEffect)effect;
                        Game.Instance.GameState.setVariable(ive.getTargetId(), Game.Instance.GameState.getVariable(ive.getTargetId()) + ive.getIncrement());
                        break;

                    case EffectType.DECREMENT_VAR:
                        DecrementVarEffect dve = (DecrementVarEffect)effect;
                        Game.Instance.GameState.setVariable(dve.getTargetId(), Game.Instance.GameState.getVariable(dve.getTargetId()) - dve.getDecrement());
                        break;

                    case EffectType.MACRO_REF:
                        runs_once = false;
                        if (times_runed == 0)
                        {
                            MacroReferenceEffect mre = (MacroReferenceEffect)effect;
                            this.aditional_info.Add("macro", new EffectHolder(Game.Instance.GameState.getMacro(mre.getTargetId())));
                        }
                        forcewait = ((EffectHolder)this.aditional_info ["macro"]).execute();
                        break;

                    case EffectType.MOVE_OBJECT:
                        MoveObjectEffect moe = (MoveObjectEffect)effect;
                        Game.Instance.GameState.Move(moe.getTargetId(), new Vector2(moe.getX(), 600 - moe.getY()) / 10f);
                        break;
                    }
                }
            }
        }

        if (!forcewait)
        {
            times_runed = 0;
        }
        else
        {
            times_runed++;
        }

        return(forcewait);
    }
コード例 #7
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);
        }
コード例 #8
0
 public TriggerConversationEffectEditor()
 {
     conversations = Controller.getInstance().getSelectedChapterDataControl().getConversationsList().getConversationsIDs();
     Debug.Log(conversations.Length);
     this.effect = new TriggerConversationEffect(conversations[0]);
 }
コード例 #9
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a character tag, store the character in the game data
            if (qName.Equals("character"))
            {
                chapter.addCharacter(npc);
            }

            // If it is a documentation tag, hold the documentation in the character
            else if (qName.Equals("documentation"))
            {
                if (reading == READING_NONE)
                {
                    npc.setDocumentation(currentstring.ToString().Trim());
                }
                else if (reading == READING_CONVERSATION_REFERENCE)
                {
                    conversationReference.setDocumentation(currentstring.ToString().Trim());
                }
            }

            // If it is a resources tag, add the resources in the character
            else if (qName.Equals("resources"))
            {
                npc.addResources(currentResources);
                reading = READING_NONE;
            }

            // If it is a conversation reference tag, add the reference to the character
            else if (qName.Equals("conversation-ref"))
            {
                //npc.addConversationReference( conversationReference );
                Action action = new Action(Action.TALK_TO);
                action.setConditions(conversationReference.getConditions());
                action.setDocumentation(conversationReference.getDocumentation());
                TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
                action.getEffects().add(effect);
                npc.addAction(action);
                reading = READING_NONE;
            }

            // Reset the current string
            currentstring = "";
        }

        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {
            // Spread the end element call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition is being closed
            if (qName.Equals("condition"))
            {
                // Add the condition to the resources
                if (reading == READING_RESOURCES)
                {
                    currentResources.setConditions(currentConditions);
                }

                // Add the condition to the conversation reference
                if (reading == READING_CONVERSATION_REFERENCE)
                {
                    conversationReference.setConditions(currentConditions);
                }

                // Stop subparsing
                subParsing = SUBPARSING_NONE;
            }
        }
        else if (subParsing == SUBPARSING_ACTIONS)
        {
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("actions"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }

        // If it is a description tag, create the new description (with its id)
        else if (subParsing == SUBPARSING_DESCRIPTION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("description"))
            {
                this.descriptions.Add(description);
                subParsing = SUBPARSING_NONE;
            }
        }
    }
コード例 #10
0
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess    = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            frontcolors,
            bordercolors,
            textcolors       = element.SelectNodes("textcolor"),
            conversationsref = element.SelectNodes("conversation-ref"),
            voices           = element.SelectNodes("voice"),
            actionss         = element.SelectNodes("actions");

        string tmpArgVal;

        string characterId = element.GetAttribute("id");

        npc = new NPC(characterId);

        descriptions = new List <Description>();
        npc.setDescriptions(descriptions);

        if (element.SelectSingleNode("documentation") != null)
        {
            npc.setDocumentation(element.SelectSingleNode("documentation").InnerText);
        }

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();
            tmpArgVal        = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(el.GetAttribute(tmpArgVal));
            }

            assets = el.SelectNodes("asset");
            foreach (XmlElement ell in assets)
            {
                string type = "";
                string path = "";

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    type = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                currentResources.addAsset(type, path);
            }

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentResources.setConditions(currentConditions);
            }

            npc.addResources(currentResources);
        }


        foreach (XmlElement el in textcolors)
        {
            tmpArgVal = el.GetAttribute("showsSpeechBubble");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setShowsSpeechBubbles(tmpArgVal.Equals("yes"));
            }

            tmpArgVal = el.GetAttribute("bubbleBkgColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBkgColor(tmpArgVal);
            }

            tmpArgVal = el.GetAttribute("bubbleBorderColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBorderColor(tmpArgVal);
            }

            frontcolors = el.SelectNodes("frontcolor");
            foreach (XmlElement ell in frontcolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextFrontColor(color);
            }

            bordercolors = el.SelectNodes("bordercolor");
            foreach (XmlElement ell in bordercolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextBorderColor(color);
            }
        }


        foreach (XmlElement el in conversationsref)
        {
            string idTarget = "";

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }

            conversationReference = new ConversationReference(idTarget);

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);

                conversationReference.setConditions(currentConditions);
            }

            conversationReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

            Action action = new Action(Action.TALK_TO);
            action.setConditions(conversationReference.getConditions());
            action.setDocumentation(conversationReference.getDocumentation());
            TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
            action.getEffects().add(effect);
            npc.addAction(action);
        }

        foreach (XmlElement el in voices)
        {
            string voice = "";
            string response;
            bool   alwaysSynthesizer = false;

            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                voice = tmpArgVal;
            }

            tmpArgVal = el.GetAttribute("synthesizeAlways");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                response = tmpArgVal;
                if (response.Equals("yes"))
                {
                    alwaysSynthesizer = true;
                }
            }

            npc.setAlwaysSynthesizer(alwaysSynthesizer);
            npc.setVoice(voice);
        }

        foreach (XmlElement el in actionss)
        {
            new ActionsSubParser_(chapter, npc).ParseElement(el);
        }

        foreach (XmlElement el in descriptionss)
        {
            description = new Description();
            new DescriptionsSubParser_(description, chapter).ParseElement(el);
            this.descriptions.Add(description);
        }

        chapter.addCharacter(npc);
    }