当前位置: 首页>>代码示例>>C#>>正文


C# Action.setEffects方法代码示例

本文整理汇总了C#中Action.setEffects方法的典型用法代码示例。如果您正苦于以下问题:C# Action.setEffects方法的具体用法?C# Action.setEffects怎么用?C# Action.setEffects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Action的用法示例。


在下文中一共展示了Action.setEffects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseElement

    public override void ParseElement(XmlElement element)
    {
        string tmpArgVal;
        XmlElement tmpXmlEl;

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

        foreach (XmlElement action in element.ChildNodes) {
            //First we parse the elements every action haves:
            tmpArgVal = action.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = action.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("click-effects");

            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }

            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();
            tmpXmlEl = (XmlElement) action.SelectSingleNode ("condition");
            if (tmpXmlEl != null)
                new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl);
            tmpXmlEl = (XmlElement) action.SelectSingleNode ("effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = (XmlElement) action.SelectSingleNode ("click-effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = (XmlElement) action.SelectSingleNode ("not-effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl);

            //Then we instantiate the correct action by name.
            //We also parse the elements that are unique of that action.
            Action currentAction = new Action(0);
            switch (action.Name) {
            case "examines":        currentAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); break;
            case "grabs":           currentAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); break;
            case "use":             currentAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); break;
            case "talk-to":         currentAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); break;
            case "use-with":        currentAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
            case "give-to":         currentAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
            case "drag-to":         currentAction = new Action (Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
            case "custom":
            case "custom-interact":
                CustomAction customAction = new CustomAction ((action.Name == "custom") ? Action.CUSTOM : Action.CUSTOM_INTERACT);

                tmpArgVal = action.GetAttribute ("name");
                if (!string.IsNullOrEmpty (tmpArgVal)) {
                    currentName = tmpArgVal;
                }
                customAction.setName (currentName);

                tmpXmlEl = (XmlElement) action.SelectSingleNode ("resources");
                if (tmpXmlEl != null)
                    customAction.addResources (parseResources (tmpXmlEl));

                currentAction = customAction;
                break;
            }

            //Finally we set al the attributes to the action;
            currentAction.setConditions(currentConditions);
            currentAction.setEffects(currentEffects);
            currentAction.setNotEffects(currentNotEffects);
            currentAction.setKeepDistance(currentKeepDistance);
            currentAction.setNeedsGoTo(currentNeedsGoTo);
            currentAction.setActivatedNotEffects(activateNotEffects);
            currentAction.setClickEffects(currentClickEffects);
            currentAction.setActivatedClickEffects(activateClickEffects);

            this.element.addAction(currentAction);
        }

//.........这里部分代码省略.........
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:101,代码来源:ActionsSubParser_.cs

示例2: Interacted

    public InteractuableResult Interacted(RaycastHit hit = new RaycastHit())
    {
        InteractuableResult ret = InteractuableResult.IGNORES;

        if (interactable) {
            if (Element.isReturnsWhenDragged ()) {
                switch (((Item)Element).getBehaviour ()) {
                case Item.BehaviourType.FIRST_ACTION:
                    foreach (Action a in Element.getActions()) {
                        if (ConditionChecker.check (a.getConditions ())) {
                            Game.Instance.Execute (new EffectHolder (a.getEffects ()));
                            break;
                        }
                    }
                    ret = InteractuableResult.DOES_SOMETHING;
                    break;
                case Item.BehaviourType.NORMAL:
                    List<Action> available = new List<Action> ();
                    foreach (Action a in Element.getActions()) {
                        if (ConditionChecker.check (a.getConditions ())) {
                            bool addaction = true;
                            foreach (Action a2 in available) {
                                if ((a.getType () == Action.CUSTOM || a.getType () == Action.CUSTOM_INTERACT) && (a2.getType () == Action.CUSTOM || a2.getType () == Action.CUSTOM_INTERACT)) {
                                    if (((CustomAction)a).getName () == ((CustomAction)a2).getName ()) {
                                        addaction = false;
                                        break;
                                    }
                                } else if (a.getType () == a2.getType ()) {
                                    addaction = false;
                                    break;
                                }
                            }

                            if (addaction)
                                available.Add (a);
                        }
                    }

            //We check if it's an examine action, otherwise we create one and add it
                    bool addexamine = true;
                    foreach (Action a in available) {
                        if (a.getType () == Action.EXAMINE) {
                            addexamine = false;
                            break;
                        }
                    }

                    if (addexamine) {
                        Action ex = new Action (Action.EXAMINE);
                        Effects exeff = new Effects ();
                        exeff.add (new SpeakPlayerEffect (Element.getDescription (0).getDetailedDescription ()));
                        ex.setEffects (exeff);
                        available.Add (ex);
                    }

            //if there is an action, we show them
                    if (available.Count > 0) {
                        Game.Instance.showActions (available, Input.mousePosition);
                        ret = InteractuableResult.DOES_SOMETHING;
                    }
                    break;
                case Item.BehaviourType.ATREZZO:
                default:
                    ret = InteractuableResult.IGNORES;
                    break;
                }
            } else {
                if (drag == null) {
                    foreach (Action action in Element.getActions()) {
                        if (action.getType () == Action.DRAG_TO) {
                            drag = action;
                            break;
                        }
                    }
                }
                if (ConditionChecker.check (drag.getConditions ())) {
                    dragging = true;
                    ret = InteractuableResult.DOES_SOMETHING;
                }
            }
        }

        return ret;
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:84,代码来源:ObjectMB.cs

示例3: Interacted

    public InteractuableResult Interacted(RaycastHit hit = new RaycastHit())
    {
        InteractuableResult ret = InteractuableResult.IGNORES;

        if (aad.getInfluenceArea () != null) {

        }

        switch(aad.getBehaviour()) {
        case Item.BehaviourType.FIRST_ACTION:
            foreach (Action a in aad.getActions()) {
                if (ConditionChecker.check (a.getConditions ())) {
                    Game.Instance.Execute (new EffectHolder(a.getEffects()));
                    break;
                }
            }
            ret = InteractuableResult.DOES_SOMETHING;
            break;
        case Item.BehaviourType.NORMAL:
            List<Action> available = new List<Action> ();
            foreach (Action a in aad.getActions()) {
                if (ConditionChecker.check (a.getConditions ())) {
                    bool addaction = true;
                    foreach (Action a2 in available) {
                        if ((a.getType () == Action.CUSTOM || a.getType () == Action.CUSTOM_INTERACT) && (a2.getType () == Action.CUSTOM || a2.getType () == Action.CUSTOM_INTERACT)) {
                            if (((CustomAction)a).getName () == ((CustomAction)a2).getName ()) {
                                addaction = false;
                                break;
                            }
                        } else if (a.getType () == a2.getType ()) {
                            addaction = false;
                            break;
                        }
                    }

                    if (addaction)
                        available.Add (a);
                }
            }

            //We check if it's an examine action, otherwise we create one and add it
            bool addexamine = true;
            string desc = aad.getDescription (0).getDetailedDescription ();
            if (desc != "") {
                foreach (Action a in available) {
                    if (a.getType () == Action.EXAMINE) {
                        addexamine = false;
                        break;
                    }
                }

                if (addexamine) {
                    Action ex = new Action (Action.EXAMINE);
                    Effects exeff = new Effects ();
                    exeff.add (new SpeakPlayerEffect (desc));
                    ex.setEffects (exeff);
                    available.Add (ex);
                }
            }

            if (available.Count > 0) {
                Game.Instance.showActions (available, Input.mousePosition);
                ret = InteractuableResult.DOES_SOMETHING;
            }
            break;
        case Item.BehaviourType.ATREZZO:
        default:
            ret = InteractuableResult.IGNORES;
            break;
        }

        return ret;
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:73,代码来源:ActiveAreaMB.cs


注:本文中的Action.setEffects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。