Beispiel #1
0
        private bool Body_onCollision(FarseerPhysics.Dynamics.Fixture fixtureA, FarseerPhysics.Dynamics.Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            if (player.weapon == null)
            {
                var uiManager = Core.getGlobalManager <GameUIManager>();
                if ((GameEvent.homeEvent & GameHomeEvent.initWeaponBoxOpened) == 0)
                {
                    IList <Conmunication> conmunications = new List <Conmunication>();
                    conmunications.Add(new Conmunication("Images/headIcons/Link_Sprite", "宝箱里有武器,还是把武器带上吧"));
                    uiManager.createConmunication(conmunications);
                }
                else
                {
                    IList <Conmunication> conmunications = new List <Conmunication>();
                    conmunications.Add(new Conmunication("Images/headIcons/Link_Sprite", "江湖险恶还是把武器先装备上吧,摁Q选择装备进行装备"));
                    uiManager.createConmunication(conmunications);
                }


                player.position += new Vector2(0, -5);
            }
            else
            {
                var shuchengArea = new ShuChengArea();


                var transition = new FadeTransition(() =>
                {
                    player.detachFromScene();
                    player.attachToScene(shuchengArea);
                    player.setPosition(345, 110);
                    return(shuchengArea);
                });

                transition.onTransitionCompleted = () =>
                {
                    GameSetting.isGamePause = false;
                };

                Core.startSceneTransition(transition);

                GameSetting.isGamePause = true;
            }
            return(true);
        }
Beispiel #2
0
        private void leaveTriggerEvent()
        {
            var shuchengArea = new ShuChengArea();
            var transition   = new FadeTransition(() =>
            {
                player.detachFromScene();
                player.attachToScene(shuchengArea);
                player.setPosition(430, 80);
                return(shuchengArea);
            });

            transition.onTransitionCompleted += () =>
            {
                GameSetting.isGamePause = false;
            };
            Core.startSceneTransition(transition);

            GameSetting.isGamePause = true;
        }
Beispiel #3
0
        private void initShuChengAreaChangeTrigger(TiledObject tiledObject)
        {
            var entity = createEntity("shuchengArea");

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

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

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

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

                    GameSetting.isGamePause = true;

                    return(true);
                };
            };
        }