Exemplo n.º 1
0
 public MovieHolder getVideo(string uri)
 {
     if (videos.ContainsKey(uri))
     {
         return(videos[uri]);
     }
     else
     {
         MovieHolder holder = new MovieHolder(uri, type);
         if (holder.Loaded())
         {
             videos.Add(uri, holder);
             return(holder);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 2
0
        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;
        }
        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;
        }