Ejemplo n.º 1
0
 protected void FixedUpdate()
 {
     if (movieplayer == MovieState.LOADING)
     {
         if (movie.isError())
         {
             movieplayer = MovieState.NOT_MOVIE;
             Debug.Log(movie.Error);
         }
         else if (movie.Loaded())
         {
             Debug.Log("Seted movie, ready to play.");
             movie.Play();
             interactuable = true;
             movieplayer   = MovieState.PLAYING;
         }
     }
     else if (movieplayer == MovieState.PLAYING)
     {
         ready = true;
         if (!movie.isPlaying())
         {
             movie.Stop();
             Interacted();
         }
     }
 }
Ejemplo n.º 2
0
        public InteractuableResult Interacted(PointerEventData pointerData)
        {
            InteractuableResult res = InteractuableResult.IGNORES;

            switch (SceneData.getType())
            {
            case GeneralScene.GeneralSceneSceneType.SCENE:
                var scene = SceneData as Scene;
                if (!Game.Instance.GameState.IsFirstPerson && scene.isAllowPlayerLayer())
                {
                    RaycastHit hitInfo;
                    background.GetComponent <Collider>().Raycast(Camera.main.ScreenPointToRay(pointerData.position), out hitInfo, float.MaxValue);
                    var texPos   = PixelsSize;
                    var texCoord = hitInfo.textureCoord;
                    texCoord.y = 1 - texCoord.y;
                    texPos.Scale(texCoord);
                    var positioner = PlayerMB.Instance.GetComponent <ScenePositioner>();
                    var accesible  = TrajectoryHandler.GetAccessibleTrajectory(positioner.Position, trajectoryHandler);
                    PlayerMB.Instance.GetComponent <Mover>().Move(accesible.closestPoint(texPos));
                }
                break;

            case GeneralScene.GeneralSceneSceneType.SLIDESCENE:
                if (ProgressSlide())
                {
                    res = InteractuableResult.REQUIRES_MORE_INTERACTION;
                }
                else
                {
                    res = FinishCutscene((Cutscene)SceneData);
                }
                break;

            case GeneralScene.GeneralSceneSceneType.VIDEOSCENE:
                var videoscene = (Videoscene)SceneData;
                if (movieplayer == MovieState.NOT_MOVIE ||
                    movieplayer == MovieState.STOPPED ||
                    (movieplayer == MovieState.PLAYING && !movie.isPlaying()) ||
                    videoscene.isCanSkip())
                {
                    movie.Stop();
                    movieplayer = MovieState.STOPPED;
                    if (movieplayer == MovieState.PLAYING)
                    {
                        TrackerAsset.Instance.Accessible.Skipped(SceneData.getId(), AccessibleTracker.Accessible.Cutscene);
                    }
                    res = FinishCutscene(videoscene);
                }
                break;
            }

            return(res);
        }
Ejemplo n.º 3
0
    private void Movie(List <Vector2Int> chessList, int index, Game2048Chess chess)
    {
        for (int i = index - 1; i >= 0; i--)
        {
            Vector2Int current = chessList[i + 1];
            Vector2Int target  = chessList[i];

            MovieState movieState = Movie(chess, current, target);

            if (movieState != MovieState.Movie)
            {
                break;
            }
        }
    }
Ejemplo n.º 4
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;
        }