public void PrevMenu() { SceneManager.LoadScene("Menu"); Server s = FindObjectOfType <Server>(); if (s != null) { Destroy(s.gameObject); } Client c = FindObjectOfType <Client>(); if (c != null) { Destroy(c.gameObject); } GameManager gm = FindObjectOfType <GameManager>(); if (gm != null) { Destroy(gm.gameObject); } NextScene nextScene = FindObjectOfType <NextScene>(); if (nextScene != null) { Destroy(nextScene.gameObject); } }
private HealthController healthControllerClassReference; //Referencia a la clase "HealthController". void Awake() { UXControllerClassReference = GameObject.FindWithTag("GameController").GetComponent <UXController> (); spawnEnemiesClassReference = GameObject.FindWithTag("GameController").GetComponent <SpawnEnemies> (); nextSceneClass = GameObject.FindWithTag("GameController").GetComponent <NextScene>(); healthControllerClassReference = gameObject.GetComponent <HealthController>(); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { PreviousScene.SetActive(false); NextScene.SetActive(true); } }
void Start() { pp = gameObject.GetComponent <SpriteRenderer>(); player = transform.GetComponent <Rigidbody2D>(); //获取刚体 ani = GetComponent <Animator>(); //获取动画状态机 escapeMenu = GameObject.Find("Scripts").GetComponent <EscapeMenu>(); NextScene = GameObject.Find("NextScene").GetComponent <NextScene>(); }
public ExitLookDataControl(NextScene nextScene) { if (nextScene.getExitLook() == null) { nextScene.setExitLook(new ExitLook()); } this.exitLook = nextScene.getExitLook(); }
void Awake() { uxControllerClassReference = GetComponent <UXController> (); nextSceneClass = GetComponent <NextScene>(); spawnEnemiesClassReference = GameObject.FindWithTag("GameController").GetComponent <SpawnEnemies> (); playerTransformReference = GameObject.FindWithTag("Player").GetComponent <Transform>(); playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>(); }
private void Awake() { jump = GetComponent <Jump>(); finalAct = GetComponent <FinalAct>(); nextScene = GetComponent <NextScene>(); inputState = GetComponent <InputState>(); walkBehavior = GetComponent <Walk>(); animator = GetComponent <Animator>(); collisionState = GetComponent <CollisionState>(); }
public void SwitchToNextScene() { // Ensure that the active scene cleans up after itself if it needs to. ActiveScene?.Finish(); // Ensure that the next scene starts before required. NextScene?.Start(); ActiveScene = NextScene; NextScene = null; }
public override void OnInspectorGUI() { NextScene ns = (NextScene)target; DrawDefaultInspector(); if (GUILayout.Button("Next")) { ns.Next(); } }
//ChangeScene next; void Start() { boss = GameObject.Find("Boss"); bossScript = boss.GetComponent <Boss> (); dialog = GameObject.FindGameObjectWithTag("Dialogue").GetComponentsInChildren <Text>()[0]; status = 0; onPlane = false; boss.SetActive(false); next = GameObject.Find("NextScene").GetComponent <NextScene>(); next.enable = false; }
protected override async void Update() { //読み込み画面が必要な場合 if (IsNeedLoadingScreen) { //読み込み画面へ移行 CurrentState = RenderState.FadeToLoadScreen; await SkipTick(FadingAnimation, FadeTime); //読み込み待機 CurrentState = RenderState.LoadScreen; Overlay.IsShown = true; await SkipTick(Task.Run(() => { CurrentScene?.Dispose(); CurrentScene = null; NextScene = (Scene)Container.Resolve(NextSceneType); Container.GameWindow.SetActionAndWaitNextFrame(() => NextScene.UpdateDevice(Container)); //todo FormsのDLLを使用しないといけないのはいささか不本意である。 })); Overlay.IsShown = false; //新しい画面へ移行 CurrentState = RenderState.FadeFromLoadScreen; await SkipTick(FadingAnimation, FadeTime); //移行完了で役目は終了 Container.CurrentScene = NextScene; return; } //ロード画面を必要としないのであればインスタンスを生成する Overlay.IsShown = true; await SkipTick(Task.Run(() => { NextScene = (Scene)Container.Resolve(NextSceneType); Container.GameWindow.SetActionAndWaitNextFrame(() => NextScene.UpdateDevice(Container)); //todo FormsのDLLを使用しないといけないのはいささか不本意である。 })); //(読み込み画面が必要ないときに)読み込みが完了したので移行開始 CurrentState = RenderState.FadeFromPreviousSceneToNextScene; Overlay.IsShown = false; await SkipTick(FadingAnimation, FadeTime); //移行完了したら役目は終了 昔のシーンは破棄する ThreadPool.QueueUserWorkItem(s => { CurrentScene.Dispose(); CurrentScene = null; }); Container.CurrentScene = NextScene; }
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); }
void Awake() { UXControllerClass = GameObject.FindWithTag("GameController").GetComponent <UXController> (); spawnEnemiesClass = GameObject.FindWithTag("GameController").GetComponent <SpawnEnemies> (); nextSceneClass = GameObject.FindWithTag("GameController").GetComponent <NextScene>(); if (!UXController.isGameOver) { playerCollisionControllerClass = GameObject.FindWithTag("Player").GetComponent <PlayerCollisionController>(); } healthControllerClass = gameObject.GetComponent <HealthController>(); }
// Use this for initialization void Start() { //get GlobalPlayerInfo if it exists gPlayerInfo = FindObjectOfType <GlobalPlayerInfo>(); //get attached NextScene component nextScene = GetComponent <NextScene>(); if (nextScene == null) { Debug.LogError("No NextScene script attached to this object!"); } currentHoldTime = HoldTime; }
/** * 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 (AbstractEffect effect in nextScene.getEffects().getEffects()) { effects.add(effect); } foreach (AbstractEffect effect in nextScene.getPostEffects().getEffects()) { effects.add(effect); } }
public override void Render() { switch (CurrentState) { case RenderState.PreviousScene: CurrentScene.Render(); break; case RenderState.LoadScreen: RenderLoadingScreen(); break; case RenderState.FadeToLoadScreen: CurrentScene?.Render(); using (var layer = new Layer(DeviceContext)) { parameter.Opacity = FadingAnimation.Value; DeviceContext.PushLayer(ref parameter, layer); RenderLoadingScreen(); DeviceContext.PopLayer(); } break; case RenderState.FadeFromLoadScreen: RenderLoadingScreen(); using (var layer = new Layer(DeviceContext)) { parameter.Opacity = FadingAnimation.Value; DeviceContext.PushLayer(ref parameter, layer); NextScene.Render(); DeviceContext.PopLayer(); } break; case RenderState.FadeFromPreviousSceneToNextScene: CurrentScene.Render(); using (var layer = new Layer(DeviceContext)) { parameter.Opacity = FadingAnimation.Value; DeviceContext.PushLayer(ref parameter, layer); NextScene.Render(); DeviceContext.PopLayer(); } break; } }
private void Start() { _ns = FindObjectOfType <NextScene>(); _checkers = new CheckersBoard { Client = FindObjectOfType <Client>() }; if (_ns.mode == GameMode.MultiPlayer) { Alert(_checkers.Client.players[0].Name + " versus " + _checkers.Client.players[1].Name); } else { Alert("White player's turn"); } _checkers.MovePieces += (p, x, y) => MovePiece(pieces[p], x, y); _checkers.OnDestr += (p) => DestroyImmediate(pieces[p].gameObject); _checkers.OnKing += (p) => pieces[p].transform.Rotate(Vector3.right * 180); //checkers.client.OnTryMove += (x1, y1, x2, y2) => TryMove(x1, y1, x2, y2); _checkers.OnEndTurn += (isWhiteTurn, client) => { string str; if (client) { str = isWhiteTurn ? _checkers.Client.players[0].Name : _checkers.Client.players[1].Name; } else { str = isWhiteTurn ? "White" : "Black"; } Alert(str + " players turn"); }; if (_checkers.Client != null) { _checkers.Client.OnTryMove += TryMove; } GenerateBoard(); }
public static void LoadScene(uint id) { if (!SceneService.Scenes.TryGetValue(id, out Scene NextScene)) { return; } foreach (var instance in InstanceService.Instances) { instance.Dispose(); } InstanceService.Instances.Clear(); InstanceService.Instances.TrimExcess(); NextScene.Initialize(); ActiveScene = NextScene; }
public override void Start() { NextScene.Where(scene => !string.IsNullOrEmpty(scene)).Subscribe(s => GetComponent <FadeScreen>().OutConfig.SceneToLoad = s).AddTo(this); base.Start(); ActiveMenu.Subscribe(active => { if (active == 0) { TransitionHelper.TransitionIn(Wheels); } else { TransitionHelper.TransitionOut(Wheels); } Menus.ForEach(m => m.Shown.Value = false); Menus[active].Shown.Value = true; }).AddTo(this); }
public void Commit() { if (Engine.CurrentScene != null) { Engine.CurrentScene.RaiseOnTransitionBegin(); } if (NextScene != null) { NextScene.RaiseOnRegistered(); } Engine.transitionState.ForceToComplete(); if (Transition != null) { Engine.transitionState = new FadingOutState(Transition, NextScene, DoAutoDispose); } else { Engine.transitionState = new QuicklyChangingState(NextScene, DoAutoDispose); } }
void Scene3() { if (back1) { FinalEmpty[1] = DI_Done2[Random.Range(0, DI_Done2.Length)]; FinalEmpty[0] = DI_Done1[Random.Range(1, DI_Done1.Length)]; Guard1_con.SetSeq(FinalEmpty, true); } else { Guard1_con.PlaySound(DI_Done1[0], true); } Door3.GetComponent <Object_Door>().DoorSwitch(); Guard1_con.SetLookAt(playerHead); Guard2_con.StopLookAt(); Guard2_con.PausePath(); Check2 = false; NextScene.SetActive(true); }
void die() { Debug.Log("Oops, my system crashed!"); Destroy(this.gameObject); if (SceneManager.GetActiveScene().name == "SurviveMission") { Debug.Log("xd"); EndScreen = GameObject.Find("EndScreen"); EndScreen.GetComponentsInChildren <RawImage>(true)[0].enabled = true; return; } else { NextScene sceneChanger = new NextScene(); sceneChanger.persistentScript = persistentScript; persistentScript.PlayerHealth = persistentScript.PlayerMaxHealth; SceneManager.LoadScene(SceneManager.GetActiveScene().name); } //SceneManager.LoadScene(SceneManager.GetActiveScene().name); }
IEnumerator LoginUser(string username, string password) { string createUserURL = "http://localhost/nsirpg/login.php"; WWWForm form = new WWWForm(); form.AddField("username", username); form.AddField("password", password); UnityWebRequest webRequest = UnityWebRequest.Post(createUserURL, form); yield return(webRequest.SendWebRequest()); Debug.Log(webRequest.downloadHandler.text); if (webRequest.downloadHandler.text == "Login Successful") { NextScene.LoadSceneNext(); } else { basePanel.SetActive(true); loginPanel.SetActive(false); } }
public void GotoScene(NextScene nextScene) { this.Pop(); switch (nextScene.Type) { case "story": this.Push(new StoryScene(nextScene.File)); break; case "stage": this.GotoStage(nextScene.File); break; case "title": this.Push(new TitleScene()); break; default: throw new InvalidOperationException("Unknown scene type"); } }
public override void ParseElement(XmlElement element) { XmlNodeList endsgame = element.SelectNodes("end-game"), nextsscene = element.SelectNodes("next-scene"), resourcess = element.SelectNodes("resources"), descriptionss = element.SelectNodes("description"), assets, conditions = element.SelectNodes("condition"), effects = element.SelectNodes("effect"), postseffects = element.SelectNodes("post-effect"); string tmpArgVal; string slidesceneId = ""; bool initialScene = false; string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; string next = "go-back"; bool canSkip = true; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { slidesceneId = tmpArgVal; } tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { initialScene = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = element.GetAttribute("destinyX"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("destinyY"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("next"); if (!string.IsNullOrEmpty(tmpArgVal)) { next = tmpArgVal; } tmpArgVal = element.GetAttribute("canSkip"); if (!string.IsNullOrEmpty(tmpArgVal)) { canSkip = tmpArgVal.Equals("yes"); } if (element.Name.Equals("slidescene")) { cutscene = new Slidescene(slidesceneId); } else { cutscene = new Videoscene(slidesceneId); } if (initialScene) { chapter.setTargetId(slidesceneId); } cutscene.setTargetId(idTarget); cutscene.setPositionX(x); cutscene.setPositionY(y); cutscene.setTransitionType((NextSceneEnumTransitionType)transitionType); cutscene.setTransitionTime(transitionTime); if (element.SelectSingleNode("name") != null) { cutscene.setName(element.SelectSingleNode("name").InnerText); } if (element.SelectSingleNode("documentation") != null) { cutscene.setDocumentation(element.SelectSingleNode("documentation").InnerText); } foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); cutscene.setEffects(currentEffects); } if (cutscene is Videoscene) { ((Videoscene)cutscene).setCanSkip(canSkip); } 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); } 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); } XmlNodeList conditonss = el.SelectNodes("condition"); foreach (XmlElement ell in conditonss) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } cutscene.addResources(currentResources); } foreach (XmlElement el in endsgame) { cutscene.setNext(Cutscene.ENDCHAPTER); } foreach (XmlElement el in nextsscene) { string idTarget_ = ""; int x_ = int.MinValue, y_ = int.MinValue; int transitionType_ = 0, transitionTime_ = 0; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget_ = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime_ = int.Parse(tmpArgVal); } currentNextScene = new NextScene(idTarget_, x_, y_); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType_); currentNextScene.setTransitionTime(transitionTime_); XmlNodeList conditionss = el.SelectNodes("condition"); foreach (XmlElement ell in conditionss) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentNextScene.setConditions(currentConditions); } XmlNodeList effectsss = el.SelectNodes("effect"); foreach (XmlElement ell in effectsss) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setEffects(currentEffects); } XmlNodeList postseffectsss = el.SelectNodes("post-effect"); foreach (XmlElement ell in postseffects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setPostEffects(currentEffects); } cutscene.addNextScene(currentNextScene); } chapter.addCutscene(cutscene); }
/// <summary> /// シーン切り替え処理 /// </summary> /// <returns></returns> IEnumerator SceneChange() { isBooting = false; // シーンを非アクティブで読み込み開始 string sceneName = NextScene.ToString(); if (NextScene == SceneType.Game) { sceneName = $"Stage{GameParams.SelectedStage+1}"; } loadingSceneOperations[loadingSceneOperationCount] = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); loadingSceneOperations[loadingSceneOperationCount].allowSceneActivation = false; loadingSceneOperationCount++; // フェードアウト yield return(Fade.StartFade(Fade.FadeStateType.Out, fadeTime, true)); // 不要になったシーンを解放する if (loadedSceneName.Length > 0) { unloadSceneOperations[unloadSceneCount] = SceneManager.UnloadSceneAsync(loadedSceneName); unloadSceneCount++; } loadedSceneName = sceneName; // シーン切り替え NowScene = NextScene; NextScene = SceneType.None; // シーンをアクティブにする loadingSceneOperations[0].allowSceneActivation = true; // シーンの読み込みと解放の完了を待つ for (int i = 0; i < loadingSceneOperationCount; i++) { if (!loadingSceneOperations[i].isDone) { yield return(loadingSceneOperations[i]); } } for (int i = 0; i < unloadSceneCount; i++) { if (!unloadSceneOperations[i].isDone) { yield return(unloadSceneOperations[i]); } } // シーンの初期化を待つ while (loadingSceneManagerCount < loadingSceneOperationCount) { yield return(null); } // フェードアウト完了処理を呼び出す for (int i = 0; i < loadingSceneManagerCount; i++) { loadingSceneManagers[i].OnFadeOutDone(); } // カメラ切り替え if (Camera.main != null) { SetMainCamera(Camera.main); } else { SetSubCamera(); } // フェードイン yield return(Fade.StartFade(Fade.FadeStateType.In, fadeTime)); // フェードイン完了処理を呼び出す for (int i = 0; i < loadingSceneManagerCount; i++) { loadingSceneManagers[i].OnFadeInDone(); } // シーン切り替え完了 loadingSceneOperationCount = 0; loadingSceneManagerCount = 0; unloadSceneCount = 0; IsChanging = false; enabled = false; }
/// <summary> /// シーン切り替え処理 /// </summary> /// <returns></returns> IEnumerator SceneChange() { // シーンを非アクティブで読み込み開始 loadingSceneOperations[loadingSceneOperationCount] = SceneManager.LoadSceneAsync(NextScene.ToString(), LoadSceneMode.Additive); loadingSceneOperations[loadingSceneOperationCount].allowSceneActivation = false; loadingSceneOperationCount++; // フェードアウト yield return(Fade.StartFade(Fade.FadeStateType.Out, fadeTime, true)); // 不要になったシーンを解放する if (NowScene != SceneType.None) { unloadSceneOperations[unloadSceneCount] = SceneManager.UnloadSceneAsync(NowScene.ToString()); unloadSceneCount++; } if (loadedStageName.Length > 0) { unloadSceneOperations[unloadSceneCount] = SceneManager.UnloadSceneAsync(loadedStageName); unloadSceneCount++; loadedStageName = ""; } // シーン切り替え NowScene = NextScene; NextScene = SceneType.None; // シーンをアクティブにする loadingSceneOperations[0].allowSceneActivation = true; // シーンの解放の完了を待つ for (int i = 0; i < unloadSceneCount; i++) { if (!unloadSceneOperations[i].isDone) { yield return(unloadSceneOperations[i]); } } // ゲームならステージ読み込み if (NowScene == SceneType.Game) { loadedStageName = GameParams.StageName; loadingSceneOperations[loadingSceneOperationCount] = SceneManager.LoadSceneAsync(loadedStageName, LoadSceneMode.Additive); loadingSceneOperationCount++; } // シーンの読み込みと解放の完了を待つ for (int i = 0; i < loadingSceneOperationCount; i++) { if (!loadingSceneOperations[i].isDone) { yield return(loadingSceneOperations[i]); } } // シーンの初期化を待つ while (loadingSceneManagerCount < loadingSceneOperationCount) { yield return(null); } // フェードアウト完了処理を呼び出す for (int i = 0; i < loadingSceneManagerCount; i++) { loadingSceneManagers[i].OnFadeOutDone(); } // フェードイン yield return(Fade.StartFade(Fade.FadeStateType.In, fadeTime)); // フェードイン完了処理を呼び出す for (int i = 0; i < loadingSceneManagerCount; i++) { loadingSceneManagers[i].OnFadeInDone(); } // シーン切り替え完了 loadingSceneOperationCount = 0; loadingSceneManagerCount = 0; unloadSceneCount = 0; IsChanging = false; isBooting = false; enabled = false; }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), assets, conditions, effects, postseffects, notseffect, defaultsinitialsposition = element.SelectNodes("default-initial-position"), exits = element.SelectNodes("exits/exit"), exitslook, nextsscene = element.SelectNodes("next-scene"), points, objectsrefs = element.SelectNodes("objects/object-ref"), charactersrefs = element.SelectNodes("characters/character-ref"), atrezzosrefs = element.SelectNodes("atrezzo/atrezzo-ref"), activesareas = element.SelectNodes("active-areas/active-area"), barriers = element.SelectNodes("barrier"), trajectorys = element.SelectNodes("trajectory"); string tmpArgVal; string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { sceneId = tmpArgVal; } tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { initialScene = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("playerLayer"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerLayer = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("playerScale"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerScale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) { chapter.setTargetId(sceneId); } if (element.SelectSingleNode("name") != null) { scene.setName(element.SelectSingleNode("name").InnerText); } if (element.SelectSingleNode("documentation") != null) { scene.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); } scene.addResources(currentResources); } foreach (XmlElement el in defaultsinitialsposition) { int x = int.MinValue, y = int.MinValue; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } scene.setDefaultPosition(x, y); } foreach (XmlElement el in exits) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; tmpArgVal = el.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("destinyX"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("destinyY"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { notEffects = tmpArgVal.Equals("yes"); } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } exitslook = el.SelectNodes("exit-look"); foreach (XmlElement ell in exitslook) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; tmpArgVal = ell.GetAttribute("text"); if (!string.IsNullOrEmpty(tmpArgVal)) { text = tmpArgVal; } tmpArgVal = ell.GetAttribute("cursor-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { cursorPath = tmpArgVal; } tmpArgVal = ell.GetAttribute("sound-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } currentExit.setDefaultExitLook(currentExitLook); } if (el.SelectSingleNode("documentation") != null) { currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText); } points = el.SelectNodes("point"); foreach (XmlElement ell in points) { int x_ = 0; int y_ = 0; tmpArgVal = ell.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = ell.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } currentPoint = new Vector2(x_, y_); currentExit.addPoint(currentPoint); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentExit.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setEffects(currentEffects); } notseffect = el.SelectNodes("not-effect"); foreach (XmlElement ell in notseffect) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setNotEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in postseffects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setPostEffects(currentEffects); } 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 nextsscene) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); currentNextScene.setExitLook(currentExitLook); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentNextScene.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setPostEffects(currentEffects); } } foreach (XmlElement el in objectsrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } if (el.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addItemReference(currentElementReference); } foreach (XmlElement el in charactersrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } if (el.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addCharacterReference(currentElementReference); } foreach (XmlElement el in atrezzosrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } if (el.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addAtrezzoReference(currentElementReference); } foreach (XmlElement el in activesareas) { new ActiveAreaSubParser_(chapter, scene, scene.getActiveAreas().Count).ParseElement(el); } foreach (XmlElement el in barriers) { new BarrierSubParser_(chapter, scene, scene.getBarriers().Count).ParseElement(el); } foreach (XmlElement el in trajectorys) { new TrajectorySubParser_(chapter, scene).ParseElement(el); } if (scene != null) { TrajectoryFixer.fixTrajectory(scene); } chapter.addScene(scene); }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), assets, conditions, effects, postseffects, notseffect, defaultsinitialsposition = element.SelectNodes("default-initial-position"), exits = element.SelectNodes("exits/exit"), exitslook, nextsscene = element.SelectNodes("next-scene"), points, objectsrefs = element.SelectNodes("objects/object-ref"), charactersrefs = element.SelectNodes("characters/character-ref"), atrezzosrefs = element.SelectNodes("atrezzo/atrezzo-ref"), activesareas = element.SelectNodes("active-areas/active-area"), barriers = element.SelectNodes("barrier"), trajectorys = element.SelectNodes("trajectory"); string tmpArgVal; string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { sceneId = tmpArgVal; } tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { initialScene = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("playerLayer"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerLayer = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("playerScale"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerScale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) chapter.setTargetId(sceneId); if (element.SelectSingleNode("name") != null) scene.setName(element.SelectSingleNode("name").InnerText); if (element.SelectSingleNode("documentation") != null) scene.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); } scene.addResources(currentResources); } foreach (XmlElement el in defaultsinitialsposition) { int x = int.MinValue, y = int.MinValue; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } scene.setDefaultPosition(x, y); } foreach (XmlElement el in exits) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; tmpArgVal = el.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("destinyX"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("destinyY"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { notEffects = tmpArgVal.Equals("yes"); } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } exitslook = el.SelectNodes("exit-look"); foreach (XmlElement ell in exitslook) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; tmpArgVal = ell.GetAttribute("text"); if (!string.IsNullOrEmpty(tmpArgVal)) { text = tmpArgVal; } tmpArgVal = ell.GetAttribute("cursor-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { cursorPath = tmpArgVal; } tmpArgVal = ell.GetAttribute("sound-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } currentExit.setDefaultExitLook(currentExitLook); } if (el.SelectSingleNode("documentation") != null) currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText); points = el.SelectNodes("point"); foreach (XmlElement ell in points) { int x_ = 0; int y_ = 0; tmpArgVal = ell.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = ell.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } currentPoint = new Vector2(x_, y_); currentExit.addPoint(currentPoint); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentExit.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setEffects(currentEffects); } notseffect = el.SelectNodes("not-effect"); foreach (XmlElement ell in notseffect) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setNotEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in postseffects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setPostEffects(currentEffects); } 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 nextsscene) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType) transitionType); currentNextScene.setTransitionTime(transitionTime); currentNextScene.setExitLook(currentExitLook); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentNextScene.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setPostEffects(currentEffects); } } foreach (XmlElement el in objectsrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); if (el.SelectSingleNode("documentation") != null) currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addItemReference(currentElementReference); } foreach (XmlElement el in charactersrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); if (el.SelectSingleNode("documentation") != null) currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addCharacterReference(currentElementReference); } foreach (XmlElement el in atrezzosrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); if (el.SelectSingleNode("documentation") != null) currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addAtrezzoReference(currentElementReference); } foreach (XmlElement el in activesareas) { new ActiveAreaSubParser_(chapter, scene, scene.getActiveAreas().Count).ParseElement(el); } foreach (XmlElement el in barriers) { new BarrierSubParser_(chapter, scene, scene.getBarriers().Count).ParseElement(el); } foreach (XmlElement el in trajectorys) { new TrajectorySubParser_(chapter, scene).ParseElement(el); } if (scene != null) { TrajectoryFixer.fixTrajectory(scene); } chapter.addScene(scene); }
public override void ParseElement(XmlElement element) { XmlNodeList endsgame = element.SelectNodes("end-game"), nextsscene = element.SelectNodes("next-scene"), resourcess = element.SelectNodes("resources"), descriptionss = element.SelectNodes("description"), assets, conditions = element.SelectNodes("condition"), effects = element.SelectNodes("effect"), postseffects = element.SelectNodes("post-effect"); string tmpArgVal; string slidesceneId = ""; bool initialScene = false; string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; string next = "go-back"; bool canSkip = true; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { slidesceneId = tmpArgVal; } tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { initialScene = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = element.GetAttribute("destinyX"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("destinyY"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("next"); if (!string.IsNullOrEmpty(tmpArgVal)) { next = tmpArgVal; } tmpArgVal = element.GetAttribute("canSkip"); if (!string.IsNullOrEmpty(tmpArgVal)) { canSkip = tmpArgVal.Equals("yes"); } if (element.Name.Equals("slidescene")) cutscene = new Slidescene(slidesceneId); else cutscene = new Videoscene(slidesceneId); if (initialScene) chapter.setTargetId(slidesceneId); cutscene.setTargetId(idTarget); cutscene.setPositionX(x); cutscene.setPositionY(y); cutscene.setTransitionType((NextSceneEnumTransitionType) transitionType); cutscene.setTransitionTime(transitionTime); if(element.SelectSingleNode("name")!= null) cutscene.setName(element.SelectSingleNode("name").InnerText); if (element.SelectSingleNode("documentation") != null) cutscene.setDocumentation(element.SelectSingleNode("documentation").InnerText); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); cutscene.setEffects(currentEffects); } if (cutscene is Videoscene) ((Videoscene) cutscene).setCanSkip(canSkip); 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); } 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); } XmlNodeList conditonss = el.SelectNodes("condition"); foreach (XmlElement ell in conditonss) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } cutscene.addResources(currentResources); } foreach (XmlElement el in endsgame) { cutscene.setNext(Cutscene.ENDCHAPTER); } foreach (XmlElement el in nextsscene) { string idTarget_ = ""; int x_ = int.MinValue, y_ = int.MinValue; int transitionType_ = 0, transitionTime_ = 0; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget_ = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime_ = int.Parse(tmpArgVal); } currentNextScene = new NextScene(idTarget_, x_, y_); currentNextScene.setTransitionType((NextSceneEnumTransitionType) transitionType_); currentNextScene.setTransitionTime(transitionTime_); XmlNodeList conditionss = el.SelectNodes("condition"); foreach (XmlElement ell in conditionss) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentNextScene.setConditions(currentConditions); } XmlNodeList effectsss = el.SelectNodes("effect"); foreach (XmlElement ell in effectsss) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setEffects(currentEffects); } XmlNodeList postseffectsss = el.SelectNodes("post-effect"); foreach (XmlElement ell in postseffects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setPostEffects(currentEffects); } cutscene.addNextScene(currentNextScene); } chapter.addCutscene(cutscene); }
public override void UpdateDevice(GameContainer container) { base.UpdateDevice(container); CurrentScene?.UpdateDevice(container); NextScene?.UpdateDevice(container); }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a slidescene tag, create a new slidescene with its id if (qName.Equals("slidescene") || qName.Equals("videoscene")) { string slidesceneId = ""; bool initialScene = false; string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; string next = "go-back"; bool canSkip = true; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("id")) slidesceneId = entry.Value.ToString(); if (entry.Key.Equals("start")) initialScene = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("destinyX")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("destinyY")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionType")) transitionType = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionTime")) transitionTime = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("next")) next = entry.Value.ToString(); if (entry.Key.Equals("canSkip")) canSkip = entry.Value.ToString().Equals("yes"); } if (qName.Equals("slidescene")) cutscene = new Slidescene(slidesceneId); else cutscene = new Videoscene(slidesceneId); if (initialScene) chapter.setTargetId(slidesceneId); cutscene.setTargetId(idTarget); cutscene.setPositionX(x); cutscene.setPositionY(y); cutscene.setTransitionType((NextSceneEnumTransitionType) transitionType); cutscene.setTransitionTime(transitionTime); if (cutscene is Videoscene) ((Videoscene)cutscene).setCanSkip(canSkip); 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); } } // If it is a resources tag, create new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("name")) currentResources.setName(entry.Value.ToString()); } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("type")) type = entry.Value.ToString(); if (entry.Key.Equals("uri")) path = entry.Value.ToString(); } currentResources.addAsset(type, path); } // If it is an end-game tag, store it in the slidescene else if (qName.Equals("end-game")) { cutscene.setNext(Cutscene.ENDCHAPTER); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionType")) transitionType = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionTime")) transitionTime = int.Parse(entry.Value.ToString()); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/** * 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); }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a slidescene tag, create a new slidescene with its id if (qName.Equals("slidescene") || qName.Equals("videoscene")) { string slidesceneId = ""; bool initialScene = false; string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; string next = "go-back"; bool canSkip = true; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { slidesceneId = entry.Value.ToString(); } if (entry.Key.Equals("start")) { initialScene = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("destinyX")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("destinyY")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("next")) { next = entry.Value.ToString(); } if (entry.Key.Equals("canSkip")) { canSkip = entry.Value.ToString().Equals("yes"); } } if (qName.Equals("slidescene")) { cutscene = new Slidescene(slidesceneId); } else { cutscene = new Videoscene(slidesceneId); } if (initialScene) { chapter.setTargetId(slidesceneId); } cutscene.setTargetId(idTarget); cutscene.setPositionX(x); cutscene.setPositionY(y); cutscene.setTransitionType((NextSceneEnumTransitionType)transitionType); cutscene.setTransitionTime(transitionTime); if (cutscene is Videoscene) { ((Videoscene)cutscene).setCanSkip(canSkip); } 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); } } // If it is a resources tag, create new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } currentResources.addAsset(type, path); } // If it is an end-game tag, store it in the slidescene else if (qName.Equals("end-game")) { cutscene.setNext(Cutscene.ENDCHAPTER); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void changeScene(NextScene next) { Const.ChangeScene = true; Const.Nextscene = next; NowLoading.NOW_LOADING(this.scene); }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs) { Debug.Log("START: " + sName + " " + qName + " sub:" + subParsing + ", reading: " + reading); // If no element is being parsed if (subParsing == SUBPARSING_NONE) { // If it is a scene tag, create a new scene with its id if (qName.Equals("scene")) { string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("id")) sceneId = entry.Value.ToString(); if (entry.Key.Equals("start")) initialScene = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("playerLayer")) playerLayer = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("playerScale")) playerScale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) chapter.setTargetId(sceneId); } // If it is a resources tag, create the new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("name")) currentResources.setName(entry.Value.ToString()); } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("type")) type = entry.Value.ToString(); if (entry.Key.Equals("uri")) path = entry.Value.ToString(); } currentResources.addAsset(type, path); } // If it is a default-initial-position tag, store it in the scene else if (qName.Equals("default-initial-position")) { int x = int.MinValue, y = int.MinValue; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); } scene.setDefaultPosition(x, y); } // If it is an exit tag, create the new exit else if (qName.Equals("exit")) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("rectangular")) rectangular = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("width")) width = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("height")) height = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("hasInfluenceArea")) hasInfluence = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("influenceX")) influenceX = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceY")) influenceY = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceWidth")) influenceWidth = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceHeight")) influenceHeight = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("destinyX")) destinyX = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("destinyY")) destinyY = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionType")) transitionType = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionTime")) transitionTime = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("not-effects")) notEffects = entry.Value.ToString().Equals("yes"); } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } reading = READING_EXIT; } else if (qName.Equals("exit-look")) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("text")) { text = entry.Value.ToString(); } if (entry.Key.Equals("cursor-path")) cursorPath = entry.Value.ToString(); if (entry.Key.Equals("sound-path")) soundPath = entry.Value.ToString(); } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } // Debug.Log("311" + currentExitLook.getExitText()); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionType")) transitionType = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionTime")) transitionTime = int.Parse(entry.Value.ToString()); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } else if (qName.Equals("point")) { int x = 0; int y = 0; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); } currentPoint = new Vector2(x, y); } // If it is a object-ref or character-ref, create the new element reference else if (qName.Equals("object-ref") || qName.Equals("character-ref") || qName.Equals("atrezzo-ref")) { Debug.Log("SceneReference Start"); string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("scale")) scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); if (entry.Key.Equals("layer")) layer = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("hasInfluenceArea")) hasInfluence = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("influenceX")) influenceX = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceY")) influenceY = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceWidth")) influenceWidth = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceHeight")) influenceHeight = int.Parse(entry.Value.ToString()); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); reading = READING_ELEMENT_REFERENCE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("not-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("active-area")) { subParsing = SUBPARSING_ACTIVE_AREA; subParser = new ActiveAreaSubParser(chapter, scene, scene.getActiveAreas().Count); } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("barrier")) { subParsing = SUBPARSING_BARRIER; subParser = new BarrierSubParser(chapter, scene, scene.getBarriers().Count); } else if (qName.Equals("trajectory")) { subParsing = SUBPARSING_TRAJECTORY; subParser = new TrajectorySubParser(chapter, scene); } } // If it is subparsing an effect or condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }