Example #1
0
        public void Move(string id, Vector2 position, int speed = 0, EffectHolderNode observer = null)
        {
            GameObject go = GameObject.Find(id);
            Mover      m  = go.GetComponent <Mover>();

            if (m != null)
            {
                if (speed == 0)
                {
                    m.MoveInstant(position);
                }
                else
                {
                    m.MoveFreely(position, observer, data =>
                    {
                        EffectHolderNode tmp = (EffectHolderNode)data;
                        tmp.doPulse();
                        Game.Instance.ContinueEffectExecution();
                    }, null);
                }
            }
            else
            {
                Representable r = go.GetComponent <Representable>();
                r.setPosition(position);
            }
        }
Example #2
0
 protected void Start()
 {
     representable = GetComponent <Representable>();
     if (representable)
     {
         representable.Play("stand");
     }
 }
Example #3
0
 protected void Start()
 {
     representable   = GetComponent <Representable>();
     scenePositioner = GetComponent <ScenePositioner>();
     if (scenePositioner)
     {
         representable.Play("stand");
     }
 }
Example #4
0
        private void RefreshPlayerAndTrajectory(Scene scene)
        {
            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));

            if (!ready)
            {
                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");
            }
        }
Example #5
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;
        }
Example #6
0
 protected void Start()
 {
     mover           = GetComponent <Mover>();
     representable   = GetComponent <Representable>();
     scenePositioner = GetComponent <ScenePositioner>();
 }
 protected override void Start()
 {
     base.Start();
     representable = GetComponent <Representable>();
     representable.Play("stand");
 }
Example #8
0
 protected override void Start()
 {
     base.Start();
     representable = GetComponent <Representable>();
     representable.SetTexture(Item.RESOURCE_TYPE_IMAGE);
 }
Example #9
0
 protected void Start()
 {
     mover         = GetComponent <Mover>();
     representable = GetComponent <Representable>();
 }