private void performCreateCutscene(int type, string cutsceneId) { // If some value was typed and the identifier is valid if (!controller.isElementIdValid(cutsceneId)) { cutsceneId = controller.makeElementValid(cutsceneId); } Cutscene newCutscene = null; // Create the new cutscene switch (type) { default: case Controller.CUTSCENE_SLIDES: newCutscene = new Slidescene(cutsceneId); break; case Controller.CUTSCENE_VIDEO: newCutscene = new Videoscene(cutsceneId); break; } // Add the new cutscene cutscenesList.Add(newCutscene); cutscenesDataControlList.Add(new CutsceneDataControl(newCutscene)); controller.IdentifierSummary.addId <Cutscene>(cutsceneId); }
public override bool addElement(int type, string cutsceneId) { bool elementAdded = false; ////if (type == Controller.CUTSCENE) ////{ // //TODO: implement // //CutsceneTypesDialog cutscenesTypesDialog = new CutsceneTypesDialog(); // //type = cutscenesTypesDialog.getOptionSelected(); // //TODO: tmp, delete // type = Controller.CUTSCENE_SLIDES; if (type == Controller.CUTSCENE_SLIDES) { // Show a dialog asking for the cutscene id if (cutsceneId == null || cutsceneId.Equals("")) { cutsceneId = controller.showInputDialog(TC.get("Operation.AddCutsceneTitle"), TC.get("Operation.AddCutsceneMessage"), TC.get("Operation.AddCutsceneDefaultValue")); } // If some value was typed and the identifier is valid if (!controller.isElementIdValid(cutsceneId)) { cutsceneId = controller.makeElementValid(cutsceneId); } Cutscene newCutscene = null; // Create the new cutscene if (type == Controller.CUTSCENE_SLIDES) { newCutscene = new Slidescene(cutsceneId); } // Add the new cutscene cutscenesList.Add(newCutscene); cutscenesDataControlList.Add(new CutsceneDataControl(newCutscene)); controller.getIdentifierSummary().addCutsceneId(cutsceneId); //controller.dataModified( ); elementAdded = true; } else if (type == Controller.CUTSCENE_VIDEO) { // Show a dialog asking for the cutscene id if (cutsceneId == null) { cutsceneId = controller.showInputDialog(TC.get("Operation.AddCutsceneTitle"), TC.get("Operation.AddCutsceneMessage"), TC.get("Operation.AddCutsceneDefaultValue")); } // If some value was typed and the identifier is valid if (!controller.isElementIdValid(cutsceneId)) { cutsceneId = controller.makeElementValid(cutsceneId); } Cutscene newCutscene = null; // Create the new cutscene if (type == Controller.CUTSCENE_VIDEO) { newCutscene = new Videoscene(cutsceneId); } // Add the new cutscene cutscenesList.Add(newCutscene); cutscenesDataControlList.Add(new CutsceneDataControl(newCutscene)); controller.getIdentifierSummary().addCutsceneId(cutsceneId); //controller.dataModified( ); elementAdded = true; } //} return(elementAdded); }
public void RenderScene() { ready = false; this.transform.position = new Vector3(0, 0, 0); LoadParents(); switch (SceneData.getType()) { default: Debug.LogError("Wrong scene type: " + SceneData.GetType()); ready = true; break; case GeneralScene.GeneralSceneSceneType.VIDEOSCENE: InventoryManager.Instance.Show = false; movie = Game.Instance.ResourceManager.getVideo(((Videoscene)SceneData).getResources()[0].getAssetPath(Videoscene.RESOURCE_TYPE_VIDEO)); movieplayer = MovieState.LOADING; SetBackground(movie.Movie); break; case GeneralScene.GeneralSceneSceneType.SCENE: InventoryManager.Instance.Show = true; Scene scene = (Scene)SceneData; Texture2D backgroundTexture = null; foreach (ResourcesUni sr in scene.getResources()) { if (ConditionChecker.check(sr.getConditions())) { backgroundTexture = Game.Instance.ResourceManager.getImage(sr.getAssetPath(Scene.RESOURCE_TYPE_BACKGROUND)); SetBackground(backgroundTexture); var foregroundPath = sr.getAssetPath(Scene.RESOURCE_TYPE_FOREGROUND); if (!string.IsNullOrEmpty(foregroundPath)) { Texture2D foregroundTexture = Game.Instance.ResourceManager.getImage(foregroundPath); foreground.GetComponent <Renderer>().material.SetTexture("_MainTex", backgroundTexture); foreground.GetComponent <Renderer>().material.SetTexture("_AlphaTex", foregroundTexture); foreground.localScale = background.localScale; var foreGroundPos = background.localPosition; foreGroundPos.z = 1; foreground.localPosition = foreGroundPos; } LoadBackgroundMusic(sr); break; } } LoadZBoundaries(); //###################### REFERENCES ###################### DeleteChilds(referencesHolder); // Characters foreach (var context in Game.Instance.GameState .GetElementReferences(scene.getId()) .Where(tc => !tc.IsRemoved()) .Checked()) { InstanceElement(context); } //###################### ACTIVEAREAS ###################### DeleteChilds(activeAreasHolder); foreach (var activeArea in scene.getActiveAreas().NotRemoved() .Where(a => ConditionChecker.check(a.getConditions()))) { InstanceRectangle <ActiveArea>(activeArea); } //###################### EXITS ###################### DeleteChilds(exitsHolder); foreach (var exit in scene.getExits() .Where(e => e.isHasNotEffects() || ConditionChecker.check(e.getConditions()))) { InstanceRectangle <Exit>(exit); } if (!Game.Instance.GameState.IsFirstPerson && scene.isAllowPlayerLayer()) { var playerContext = Game.Instance.GameState.PlayerContext; //###################### BARRIERS ###################### var barriers = scene.getBarriers().FindAll(b => ConditionChecker.check(b.getConditions())).ToArray(); var trajectory = scene.getTrajectory(); if (trajectory == null) { barriers = barriers.ToList().ConvertAll(b => { Barrier r = b.Clone() as Barrier; r.setValues(r.getX(), 0, r.getWidth(), backgroundTexture.height); return(r); }).ToArray(); trajectory = new Trajectory(); var width = backgroundTexture ? backgroundTexture.width : Screen.width; trajectory.addNode("leftSide", 0, playerContext.getY(), playerContext.Scale); trajectory.addNode("rightSide", width, playerContext.getY(), playerContext.Scale); trajectory.addSide("leftSide", "rightSide", width); } trajectoryHandler = new TrajectoryHandler(TrajectoryHandler.CreateBlockedTrajectory(trajectory, barriers)); Representable player = GameObject.Instantiate(playerPrefab, referencesHolder).GetComponent <Representable>(); player.Element = Game.Instance.GameState.Player; player.Context = playerContext; var scenePositioner = player.gameObject.AddComponent <ScenePositioner>(); scenePositioner.Scene = this; scenePositioner.Representable = player; scenePositioner.Context = playerContext; // Force the start player.SendMessage("Start"); ready = true; } else { ready = true; } Camera.main.GetComponent <PlayerFollower>().SettleInstant(); break; case GeneralScene.GeneralSceneSceneType.SLIDESCENE: InventoryManager.Instance.Show = false; Slidescene ssd = (Slidescene)SceneData; currentSlide = 0; foreach (ResourcesUni r in ssd.getResources()) { if (ConditionChecker.check(r.getConditions())) { this.slides = Game.Instance.ResourceManager.getAnimation(r.getAssetPath(Slidescene.RESOURCE_TYPE_SLIDES)); SetSlide(0); LoadBackgroundMusic(r); ready = true; break; } } break; } firstRender = false; }
//private SlidesceneResource current_resource; public void RenderScene() { switch (sd.getType()) { case GeneralScene.GeneralSceneSceneType.VIDEOSCENE: movie = ResourceManager.Instance.getVideo(((Videoscene)sd).getResources()[0].getAssetPath(Videoscene.RESOURCE_TYPE_VIDEO)); movieplayer = MovieState.LOADING; this.transform.FindChild("Background").localPosition = new Vector3(40, 30, 20); break; case GeneralScene.GeneralSceneSceneType.SCENE: loadParents(); Scene rsd = (Scene)sd; foreach (ResourcesUni sr in rsd.getResources()) { if (ConditionChecker.check(sr.getConditions())) { Texture2D tmp = ResourceManager.Instance.getImage(sr.getAssetPath(Scene.RESOURCE_TYPE_BACKGROUND)); Transform background = this.transform.FindChild("Background"); background.GetComponent <Renderer>().material.mainTexture = tmp; float scale = (tmp.width / (tmp.height / 600f)) / 800f; this.transform.position = new Vector3(40, 30, 20); background.localPosition = new Vector3(((80 * scale) - 80) / 2f, 0, 20); background.transform.localScale = new Vector3(scale * 80, 60, 1); break; } } //###################### CHARACTERS ###################### deleteChilds(Characters); foreach (ElementReference context in rsd.getCharacterReferences()) { instanceElement <NPC>(context); } //###################### OBJECTS ###################### deleteChilds(Objects); foreach (ElementReference context in rsd.getItemReferences()) { instanceElement <Item>(context); } //###################### ATREZZOS ###################### deleteChilds(Atrezzos); foreach (ElementReference context in rsd.getAtrezzoReferences()) { instanceElement <Atrezzo>(context); } //###################### ACTIVEAREAS ###################### deleteChilds(ActiveAreas); foreach (ActiveArea ad in rsd.getActiveAreas()) { if (ConditionChecker.check(ad.getConditions())) { instanceRectangle <ActiveArea>(ad); } } //###################### EXITS ###################### deleteChilds(Exits); foreach (Exit exit in rsd.getExits()) { if (exit.isHasNotEffects() || ConditionChecker.check(exit.getConditions())) { instanceRectangle <Exit>(exit); } } if (!Game.Instance.GameState.isFirstPerson()) { if (rsd.getTrajectory() == null) { break; } trajectory = new TrajectoryHandler(rsd.getTrajectory()); if (player_context == null) { //Vector2 pos = LineHandler.nodeToVector2 (lines [lines.Count-1].end); Trajectory.Node pos = trajectory.getLastNode(); player_context = new ElementReference("Player", pos.getX(), pos.getY(), rsd.getPlayerLayer()); player_context.setScale(pos.getScale()); } /*GameObject.Destroy(this.transform.FindChild ("Player"));*/ var player = GameObject.Instantiate(Player_Prefab).GetComponent <PlayerMB>(); player.transform.parent = Characters; player.Element = Game.Instance.GameState.getPlayer(); player.Context = player_context; } break; case GeneralScene.GeneralSceneSceneType.SLIDESCENE: Slidescene ssd = (Slidescene)sd; foreach (ResourcesUni r in ssd.getResources()) { if (ConditionChecker.check(r.getConditions())) { this.slides = ResourceManager.Instance.getAnimation(r.getAssetPath(Slidescene.RESOURCE_TYPE_SLIDES)); this.transform.FindChild("Background").GetComponent <Renderer>().material.mainTexture = this.slides.frames[0].Image; this.transform.position = new Vector3(40, 30, 20); break; } } break; } }
//private SlidesceneResource current_resource; public void renderScene() { ElementReference auxEleRef; switch (sd.getType()) { case GeneralScene.GeneralSceneSceneType.VIDEOSCENE: StartCoroutine(loadMovie()); this.transform.FindChild("Background").localPosition = new Vector3(40, 30, 20); break; case GeneralScene.GeneralSceneSceneType.SCENE: Scene rsd = (Scene)sd; foreach (ResourcesUni sr in rsd.getResources()) { if (ConditionChecker.check(sr.getConditions())) { Texture2DHolder th = new Texture2DHolder(sr.getAssetPath(Scene.RESOURCE_TYPE_BACKGROUND)); Texture2D tmp = th.Texture; Transform background = this.transform.FindChild("Background"); background.GetComponent <Renderer> ().material.mainTexture = tmp; float scale = (tmp.width / (tmp.height / 600f)) / 800f; this.transform.position = new Vector3(40, 30, 20); background.localPosition = new Vector3(((80 * scale) - 80) / 2f, 0, 20); background.transform.localScale = new Vector3(scale * 80, 60, 1); break; } } Transform characters = this.transform.FindChild("Characters"); foreach (Transform child in characters) { GameObject.Destroy(child.gameObject); } foreach (ElementReference cr in rsd.getCharacterReferences()) { if (ConditionChecker.check(cr.getConditions())) { GameObject ret = GameObject.Instantiate(Character_Prefab); Transform trans = ret.GetComponent <Transform> (); ret.GetComponent <CharacterMB> ().context = cr; ret.GetComponent <CharacterMB> ().charData = Game.Instance.getCharacter(cr.getTargetId()); trans.SetParent(characters); } } Transform objects = this.transform.FindChild("Objects"); foreach (Transform child in objects) { GameObject.Destroy(child.gameObject); } List <ElementReference> items = rsd.getItemReferences(); ElementReference tmpElement; foreach (ElementReference ir in rsd.getItemReferences()) { if (ConditionChecker.check(ir.getConditions())) { if (!contexts.ContainsKey(ir)) { tmpElement = new ElementReference(ir.getTargetId(), ir.getX(), ir.getY()); tmpElement.setScale(ir.getScale()); contexts.Add(ir, tmpElement); } GameObject ret = GameObject.Instantiate(Object_Prefab); Transform trans = ret.GetComponent <Transform> (); ret.GetComponent <ObjectMB> ().context = contexts[ir]; ret.GetComponent <ObjectMB> ().objData = Game.Instance.getObject(ir.getTargetId()); trans.SetParent(objects); } } Transform atrezzos = this.transform.FindChild("Atrezzos"); foreach (Transform child in atrezzos) { GameObject.Destroy(child.gameObject); } foreach (ElementReference ir in rsd.getAtrezzoReferences()) { if (ConditionChecker.check(ir.getConditions())) { GameObject ret = GameObject.Instantiate(Atrezzo_Prefab); Transform trans = ret.GetComponent <Transform> (); ret.GetComponent <AtrezzoMB> ().context = ir; ret.GetComponent <AtrezzoMB> ().atrData = Game.Instance.getAtrezzo(ir.getTargetId()); trans.SetParent(atrezzos); } } Transform activeareas = this.transform.FindChild("ActiveAreas"); foreach (Transform child in activeareas) { GameObject.Destroy(child.gameObject); } foreach (ActiveArea ad in rsd.getActiveAreas()) { if (ConditionChecker.check(ad.getConditions())) { GameObject ret = GameObject.Instantiate(ActiveArea_Prefab); Transform trans = ret.GetComponent <Transform> (); ret.GetComponent <ActiveAreaMB> ().aaData = ad; trans.localScale = new Vector3(ad.getWidth() / 10f, ad.getHeight() / 10f, 1); Vector2 tmppos = new Vector2(ad.getX(), ad.getY()) / 10 + (new Vector2(trans.localScale.x, trans.localScale.y)) / 2; trans.localPosition = new Vector2(tmppos.x, 60 - tmppos.y); trans.SetParent(activeareas); } } Transform exits = this.transform.FindChild("Exits"); foreach (Transform child in exits) { GameObject.Destroy(child.gameObject); } foreach (Exit ed in rsd.getExits()) { if (ed.isHasNotEffects() || ConditionChecker.check(ed.getConditions())) { GameObject ret = GameObject.Instantiate(Exit_Prefab); Transform trans = ret.GetComponent <Transform> (); ret.GetComponent <ExitMB> ().exitData = ed; trans.localScale = new Vector3(ed.getWidth() / 10f, ed.getHeight() / 10f, 1); Vector2 tmppos = new Vector2(ed.getX(), ed.getY()) / 10 + (new Vector2(trans.localScale.x, trans.localScale.y)) / 2; trans.localPosition = new Vector2(tmppos.x, 60 - tmppos.y); trans.SetParent(exits); } } if (!Game.Instance.isFirstPerson()) { lines = new List <LineHandler> (); foreach (Trajectory.Side side in rsd.getTrajectory().getSides()) { lines.Add(new LineHandler(rsd.getTrajectory().getNodeForId(side.getIDStart()) , rsd.getTrajectory().getNodeForId(side.getIDEnd()) , side)); } updateNeighbours(); if (player_context == null) { //Vector2 pos = LineHandler.nodeToVector2 (lines [lines.Count-1].end); Trajectory.Node pos = lines [lines.Count - 1].end; player_context = new ElementReference("Player", pos.getX(), pos.getY(), rsd.getPlayerLayer()); player_context.setScale(pos.getScale()); } /*GameObject.Destroy(this.transform.FindChild ("Player"));*/ player = GameObject.Instantiate(Player_Prefab).GetComponent <PlayerMB>(); player.transform.parent = characters; player.playerData = Game.Instance.getPlayer(); player.context = player_context; } break; case GeneralScene.GeneralSceneSceneType.SLIDESCENE: Slidescene ssd = (Slidescene)sd; foreach (ResourcesUni r in ssd.getResources()) { if (ConditionChecker.check(r.getConditions())) { this.slides = new eAnim(r.getAssetPath(Slidescene.RESOURCE_TYPE_SLIDES)); this.transform.FindChild("Background").GetComponent <Renderer> ().material.mainTexture = this.slides.frames[0].Image; this.transform.position = new Vector3(40, 30, 20); break; } } break; } }
public void RenderScene() { ready = false; this.transform.position = new Vector3(0, 0, 0); LoadParents(); switch (SceneData.getType()) { default: Debug.LogError("Wrong scene type: " + SceneData.GetType()); ready = true; break; case GeneralScene.GeneralSceneSceneType.VIDEOSCENE: InventoryManager.Instance.Show = false; movie = Game.Instance.ResourceManager.getVideo(((Videoscene)SceneData).getResources()[0].getAssetPath(Videoscene.RESOURCE_TYPE_VIDEO)); movieplayer = MovieState.LOADING; SetBackground(movie.Movie); break; case GeneralScene.GeneralSceneSceneType.SCENE: Scene scene = (Scene)SceneData; InventoryManager.Instance.Show = !SceneData.HideInventory; RefreshBackground(scene); LoadZBoundaries(); //###################### REFERENCES ###################### DeleteChilds(referencesHolder); // Characters foreach (var context in Game.Instance.GameState .GetElementReferences(scene.getId())) { InstanceElement(context); } // The references are ordered in lateupdate //###################### ACTIVEAREAS ###################### DeleteChilds(activeAreasHolder); foreach (var activeArea in scene.getActiveAreas()) { InstanceRectangle <ActiveArea>(activeArea); } OrderElementsZ(activeAreasHolder, SectionSpace); //###################### EXITS ###################### DeleteChilds(exitsHolder); foreach (var exit in scene.getExits()) { InstanceRectangle <Exit>(exit); } OrderElementsZ(exitsHolder, SectionSpace); //###################### THIRD PERSON ###################### if (!Game.Instance.GameState.IsFirstPerson && scene.isAllowPlayerLayer()) { RefreshPlayerAndTrajectory(scene); ready = true; } else { ready = true; } var playerFollower = FindObjectOfType <PlayerFollower>(); if (playerFollower) { playerFollower.SettleInstant(); } break; case GeneralScene.GeneralSceneSceneType.SLIDESCENE: InventoryManager.Instance.Show = false; Slidescene ssd = (Slidescene)SceneData; currentSlide = 0; foreach (ResourcesUni r in ssd.getResources()) { if (ConditionChecker.check(r.getConditions())) { this.slides = Game.Instance.ResourceManager.getAnimation(r.getAssetPath(Slidescene.RESOURCE_TYPE_SLIDES)); SetSlide(0); LoadBackgroundMusic(r); ready = true; break; } } break; } firstRender = false; }
public override object Clone() { Slidescene s = (Slidescene)base.Clone(); return(s); }