Exemple #1
0
        public object Clone()
        {
            NextScene ns = (NextScene)this.MemberwiseClone();

            ns.conditions  = (conditions != null ? (Conditions)conditions.Clone() : null);
            ns.destinyX    = destinyX;
            ns.destinyY    = destinyY;
            ns.effects     = (effects != null ? (Effects)effects.Clone() : null);
            ns.look        = (look != null ? (ExitLook)look.Clone() : null);
            ns.nextSceneId = (nextSceneId != null ? nextSceneId : null);
            ns.postEffects = (postEffects != null ? (Effects)postEffects.Clone() : null);
            return(ns);
        }
Exemple #2
0
 /**
  * Adds a next scene to the list of next scenes
  *
  * @param nextScene
  *            the next scene to add
  */
 public void addNextScene(NextScene nextScene)
 {
     next           = NEWSCENE;
     idTarget       = nextScene.getTargetId();
     transitionTime = nextScene.getTransitionTime();
     transitionType = nextScene.getTransitionType();
     destinyX       = nextScene.getPositionX();
     destinyY       = nextScene.getPositionY();
     foreach (var effect in nextScene.getEffects())
     {
         effects.Add(effect);
     }
     foreach (var effect in nextScene.getPostEffects())
     {
         effects.Add(effect);
     }
 }
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            var chapter = parameters [0] as Chapter;

            string sceneId       = element.GetAttribute("id");
            bool   initialScene  = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false);
            bool   hideInventory = ExString.EqualsDefault(element.GetAttribute("hideInventory"), "yes", false);
            int    playerLayer   = ExParsers.ParseDefault(element.GetAttribute("playerLayer"), -1);
            float  playerScale   = ExParsers.ParseDefault(element.GetAttribute("playerScale"), CultureInfo.InvariantCulture, 1.0f);

            scene = new Scene(sceneId)
            {
                HideInventory = hideInventory
            };
            scene.setPlayerLayer(playerLayer);
            scene.setPlayerScale(playerScale);

            if (initialScene)
            {
                chapter.setTargetId(sceneId);
            }

            var name = element.SelectSingleNode("name");

            if (name != null)
            {
                scene.setName(name.InnerText);
            }

            var documentation = element.SelectSingleNode("documentation");

            if (documentation != null)
            {
                scene.setDocumentation(documentation.InnerText);
            }

            //XAPI ELEMENTS
            scene.setXApiClass(element.GetAttribute("class"));
            scene.setXApiType(element.GetAttribute("type"));
            //END OF XAPI

            foreach (var res in DOMParserUtility.DOMParse <ResourcesUni> (element.SelectNodes("resources"), parameters))
            {
                scene.addResources(res);
            }

            var defaultsinitialsposition = element.SelectSingleNode("default-initial-position") as XmlElement;

            if (defaultsinitialsposition != null)
            {
                int x = ExParsers.ParseDefault(defaultsinitialsposition.GetAttribute("x"), int.MinValue),
                    y = ExParsers.ParseDefault(defaultsinitialsposition.GetAttribute("y"), int.MinValue);

                scene.setDefaultPosition(x, y);
            }

            foreach (XmlElement el in  element.SelectNodes("exits/exit"))
            {
                int x                  = ExParsers.ParseDefault(el.GetAttribute("x"), 0),
                                y      = ExParsers.ParseDefault(el.GetAttribute("y"), 0),
                                width  = ExParsers.ParseDefault(el.GetAttribute("width"), 0),
                                height = ExParsers.ParseDefault(el.GetAttribute("height"), 0);

                bool rectangular  = ExString.EqualsDefault(el.GetAttribute("rectangular"), "yes", true);
                bool hasInfluence = ExString.EqualsDefault(el.GetAttribute("hasInfluenceArea"), "yes", false);

                int influenceX      = ExParsers.ParseDefault(el.GetAttribute("influenceX"), 0),
                    influenceY      = ExParsers.ParseDefault(el.GetAttribute("influenceY"), 0),
                    influenceWidth  = ExParsers.ParseDefault(el.GetAttribute("influenceWidth"), 0),
                    influenceHeight = ExParsers.ParseDefault(el.GetAttribute("influenceHeight"), 0);

                string idTarget = el.GetAttribute("idTarget");
                int    destinyX = ExParsers.ParseDefault(el.GetAttribute("destinyX"), int.MinValue),
                       destinyY = ExParsers.ParseDefault(el.GetAttribute("destinyY"), int.MinValue);

                float destinyScale = ExParsers.ParseDefault(el.GetAttribute("destinyScale"), CultureInfo.InvariantCulture, float.MinValue);

                int transitionType = ExParsers.ParseDefault(el.GetAttribute("transitionType"), 0),
                    transitionTime = ExParsers.ParseDefault(el.GetAttribute("transitionTime"), 0);
                bool notEffects    = ExString.EqualsDefault(el.GetAttribute("not-effects"), "yes", false);


                currentExit = new Exit(rectangular, x, y, width, height);
                currentExit.setNextSceneId(idTarget);
                currentExit.setDestinyX(destinyX);
                currentExit.setDestinyY(destinyY);
                currentExit.setDestinyScale(destinyScale);
                currentExit.setTransitionTime(transitionTime);
                currentExit.setTransitionType(transitionType);
                currentExit.setHasNotEffects(notEffects);

                if (hasInfluence)
                {
                    InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                    currentExit.setInfluenceArea(influenceArea);
                }

                foreach (XmlElement ell in el.SelectNodes("exit-look"))
                {
                    currentExitLook = new ExitLook();
                    string text       = ell.GetAttribute("text");
                    string cursorPath = ell.GetAttribute("cursor-path");
                    string soundPath  = ell.GetAttribute("sound-path");

                    currentExitLook.setCursorPath(cursorPath);
                    currentExitLook.setExitText(text);
                    currentExitLook.setSoundPath(soundPath);
                    currentExit.setDefaultExitLook(currentExitLook);
                }

                if (el.SelectSingleNode("documentation") != null)
                {
                    currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText);
                }

                foreach (XmlElement ell in el.SelectNodes("point"))
                {
                    currentPoint = new Vector2(
                        ExParsers.ParseDefault(ell.GetAttribute("x"), 0),
                        ExParsers.ParseDefault(ell.GetAttribute("y"), 0));
                    currentExit.addPoint(currentPoint);
                }

                currentExit.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters)      as Conditions ?? new Conditions());
                currentExit.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters)            as Effects ?? new Effects());
                currentExit.setNotEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("not-effect"), parameters) as Effects ?? new Effects());
                currentExit.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects());

                if (currentExit.getNextScenes().Count > 0)
                {
                    foreach (NextScene nextScene in currentExit.getNextScenes())
                    {
                        Exit exit = (Exit)currentExit;
                        exit.setNextScenes(new List <NextScene>());
                        exit.setDestinyX(nextScene.getPositionX());
                        exit.setDestinyY(nextScene.getPositionY());
                        exit.setEffects(nextScene.getEffects());
                        exit.setPostEffects(nextScene.getPostEffects());
                        if (exit.getDefaultExitLook() == null)
                        {
                            exit.setDefaultExitLook(nextScene.getExitLook());
                        }
                        else
                        {
                            if (nextScene.getExitLook() != null)
                            {
                                if (nextScene.getExitLook().getExitText() != null &&
                                    !nextScene.getExitLook().getExitText().Equals(""))
                                {
                                    exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText());
                                }
                                if (nextScene.getExitLook().getCursorPath() != null &&
                                    !nextScene.getExitLook().getCursorPath().Equals(""))
                                {
                                    exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath());
                                }
                            }
                        }
                        exit.setHasNotEffects(false);
                        exit.setConditions(nextScene.getConditions());
                        exit.setNextSceneId(nextScene.getTargetId());
                        scene.addExit(exit);
                    }
                }
                else
                {
                    scene.addExit(currentExit);
                }
            }


            foreach (XmlElement el in element.SelectNodes("next-scene"))
            {
                string idTarget       = el.GetAttribute("idTarget");
                int    x              = ExParsers.ParseDefault(el.GetAttribute("x"), int.MinValue),
                       y              = ExParsers.ParseDefault(el.GetAttribute("y"), int.MinValue),
                       transitionType = ExParsers.ParseDefault(el.GetAttribute("transitionType"), 0),
                       transitionTime = ExParsers.ParseDefault(el.GetAttribute("transitionTime"), 0);

                currentNextScene = new NextScene(idTarget, x, y);
                currentNextScene.setTransitionType((TransitionType)transitionType);
                currentNextScene.setTransitionTime(transitionTime);

                currentNextScene.setExitLook(currentExitLook);

                currentNextScene.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions());
                currentNextScene.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters)               as Effects ?? new Effects());
                currentNextScene.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects());
            }

            foreach (XmlElement el in element.SelectNodes("objects/object-ref"))
            {
                currentElementReference = parseElementReference(el, parameters);
                scene.addItemReference(currentElementReference);
            }

            foreach (XmlElement el in element.SelectNodes("characters/character-ref"))
            {
                currentElementReference = parseElementReference(el, parameters);
                scene.addCharacterReference(currentElementReference);
            }

            foreach (XmlElement el in element.SelectNodes("atrezzo/atrezzo-ref"))
            {
                currentElementReference = parseElementReference(el, parameters);
                scene.addAtrezzoReference(currentElementReference);
            }

            foreach (var activeArea in DOMParserUtility.DOMParse <ActiveArea>(element.SelectNodes("active-areas/active-area"), parameters).ToList())
            {
                scene.addActiveArea(activeArea);
            }

            foreach (var barrier in DOMParserUtility.DOMParse <Barrier>(element.SelectNodes("barriers/barrier"), parameters).ToList())
            {
                scene.addBarrier(barrier);
            }

            foreach (var trajectory in DOMParserUtility.DOMParse <Trajectory>(element.SelectNodes("trajectory"), parameters).ToList())
            {
                scene.setTrajectory(trajectory);
            }


            if (scene != null)
            {
                TrajectoryFixer.fixTrajectory(scene);
            }

            return(scene);
        }
Exemple #4
0
 /**
  * Adds a next scene to the list of next scenes
  *
  * @param nextScene
  *            the next scene to add
  */
 public void addNextScene(NextScene nextScene)
 {
     nextScenes.Add(nextScene);
 }
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            var chapter = parameters [0] as Chapter;

            Cutscene cutscene;

            XmlNodeList
                endsgame   = element.SelectNodes("end-game"),
                nextsscene = element.SelectNodes("next-scene");

            string slidesceneId = element.GetAttribute("id");
            bool   initialScene = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false);

            if (element.Name.Equals("slidescene"))
            {
                cutscene = new Slidescene(slidesceneId);
            }
            else
            {
                cutscene = new Videoscene(slidesceneId);
            }
            if (initialScene)
            {
                chapter.setTargetId(slidesceneId);
            }

            //XAPI ELEMENTS
            cutscene.setXApiClass(element.GetAttribute("class"));
            cutscene.setXApiType(element.GetAttribute("type"));
            //END OF XAPI

            cutscene.setTargetId(element.GetAttribute("idTarget"));
            cutscene.setPositionX(ExParsers.ParseDefault(element.GetAttribute("destinyX"), int.MinValue));
            cutscene.setPositionY(ExParsers.ParseDefault(element.GetAttribute("destinyY"), int.MinValue));
            cutscene.setTransitionType((TransitionType)ExParsers.ParseDefault(element.GetAttribute("transitionType"), 0));
            cutscene.setTransitionTime(ExParsers.ParseDefault(element.GetAttribute("transitionTime"), 0));

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

            cutscene.setEffects(DOMParserUtility.DOMParse(element.SelectSingleNode("effect"), parameters) as Effects ?? new Effects());

            if (cutscene is Videoscene)
            {
                ((Videoscene)cutscene).setCanSkip(ExString.EqualsDefault(element.GetAttribute("canSkip"), "yes", true));
            }

            string next = ExString.Default(element.GetAttribute("next"), "go-back");

            if (next.Equals("go-back"))
            {
                cutscene.setNext(Cutscene.GOBACK);
            }
            else if (next.Equals("new-scene"))
            {
                cutscene.setNext(Cutscene.NEWSCENE);
            }
            else if (next.Equals("end-chapter"))
            {
                cutscene.setNext(Cutscene.ENDCHAPTER);
            }

            // RESOURCES
            foreach (var res in DOMParserUtility.DOMParse <ResourcesUni> (element.SelectNodes("resources"), parameters))
            {
                cutscene.addResources(res);
            }

            for (int i = 0; i < endsgame.Count; i++)
            {
                cutscene.setNext(Cutscene.ENDCHAPTER);
            }

            foreach (XmlElement el in nextsscene)
            {
                var currentNextScene = new NextScene(el.GetAttribute("idTarget"),
                                                     ExParsers.ParseDefault(element.GetAttribute("destinyX"), int.MinValue),
                                                     ExParsers.ParseDefault(element.GetAttribute("destinyY"), int.MinValue));

                currentNextScene.setTransitionType((TransitionType)ExParsers.ParseDefault(element.GetAttribute("transitionType"), 0));
                currentNextScene.setTransitionTime(ExParsers.ParseDefault(element.GetAttribute("transitionTime"), 0));
                currentNextScene.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions());
                currentNextScene.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters) as Effects ?? new Effects());
                currentNextScene.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects());

                cutscene.addNextScene(currentNextScene);
            }

            return(cutscene);
        }