示例#1
0
        private void initSceneChangeTrigger()
        {
            var objectLayer     = tiledMap.getObjectGroup("Object");
            var dzTriggerObject = objectLayer.objectWithName("DongZhuangVillageTrigger");
            var mazeObject      = objectLayer.objectWithName("DongZhuangMazeTrigger");

            var dzvillageEntity = createSceneTrigger(dzTriggerObject);

            dzvillageEntity.getComponent <SceneChangeTriggerComponent>().onAdded += () =>
            {
                dzvillageEntity.getComponent <SceneChangeTriggerComponent>().GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var village    = new DongZhuangVillage();
                    var transition = new FadeTransition(() =>
                    {
                        player.detachFromScene();
                        player.attachToScene(village);
                        player.setPosition(447, 35);
                        return(village);
                    });
                    transition.onTransitionCompleted += () =>
                    {
                        GameSetting.isGamePause = false;
                    };
                    Core.startSceneTransition(transition);

                    GameSetting.isGamePause = true;
                    return(true);
                };
            };

            var mazeEntity = createSceneTrigger(mazeObject);

            mazeEntity.getComponent <SceneChangeTriggerComponent>().onAdded += () =>
            {
                mazeEntity.getComponent <SceneChangeTriggerComponent>().GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var maze0      = new Maze0();
                    var transition = new FadeTransition(() =>
                    {
                        player.detachFromScene();
                        player.attachToScene(maze0);
                        player.setPosition(152, 280);
                        return(maze0);
                    });
                    transition.onTransitionCompleted += () =>
                    {
                        GameSetting.isGamePause = false;
                    };
                    Core.startSceneTransition(transition);

                    GameSetting.isGamePause = true;
                    return(true);
                };
            };
        }
示例#2
0
        private void initVillageTrigger()
        {
            var entity = createEntity("dongzhuangvillage");

            entity.setPosition(villageTrigger.position + new Vector2(villageTrigger.width / 2f, villageTrigger.height / 2f));
            entity.addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic);

            var trigger = entity.addComponent <SceneChangeTriggerComponent>();

            trigger.setSize(villageTrigger.width, villageTrigger.height);
            trigger.setIsSensor(true);
            trigger.setCollisionCategories(CollisionSetting.tiledObjectCategory);
            trigger.setCollidesWith(CollisionSetting.playerCategory);

            trigger.onAdded += () =>
            {
                trigger.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var area       = new DongZhuangVillage();
                    var transition = new FadeTransition(() =>
                    {
                        player.detachFromScene();
                        player.attachToScene(area);
                        player.setPosition(120, 915);
                        return(area);
                    });
                    transition.onTransitionCompleted += () =>
                    {
                        GameSetting.isGamePause = false;
                    };
                    Core.startSceneTransition(transition);

                    GameSetting.isGamePause = true;

                    return(true);
                };
            };
        }