Exemple #1
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var bombTexture       = GameResources.GameTextureResource.boomTexture.Packer.getSubtexture("bomb");
            var waitBombAnimation = GameResources.GameTextureResource.boomTexture.Packer.getSpriteAnimation("waitboom");
            var boomAnimtion      = GameResources.GameTextureResource.boomTexture.Packer.getSpriteAnimation("bombboom");

            boomAnimtion.loop = false;

            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic)
            .setFixedRotation(true);



            addComponent <FSCollisionCircle>()
            .setRadius(7);


            animation = addComponent(new Sprite <BombAnimation>(bombTexture));
            animation.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            animation.addAnimation(BombAnimation.waitBoom, waitBombAnimation);
            animation.addAnimation(BombAnimation.Boom, boomAnimtion);
            animation.currentAnimation           = BombAnimation.waitBoom;
            animation.onAnimationCompletedEvent += Animation_onAnimationCompletedEvent;
        }
Exemple #2
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var Texture = GameResources.GameTextureResource.boomTexture.Packer.getSubtexture("bomb");

            addComponent(new Sprite(Texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
            Text text = new Text();

            text.text = $"x{count}";
            addComponent(text).setLocalOffset(new Vector2(3, 3)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));


            addComponent <FSRigidBody>()
            .setBodyType(FarseerPhysics.Dynamics.BodyType.Dynamic);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(10)
            .setIsSensor(true);

            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);

            shape.onAdded += onAddedMethod;
        }
Exemple #3
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            target = Core.getGlobalManager <GameActorManager>().player;

            this.actorProperty           = addComponent <ActorPropertyComponent>();
            this.actorProperty.HP        = this.actorProperty.MaxHP = 100;
            this.actorProperty.moveSpeed = 0;

            var texture = scene.content.Load <Texture2D>("Images/Enemys/Armos");

            sprite = addComponent(new Sprite(texture));
            sprite.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            var armor = scene.content.Load <Texture2D>("Images/ItemsObjects/Shield");

            shiled = addComponent(new Sprite(armor));
            //shiled.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
            shiled.color   = new Color(255, 255, 255, 125);
            shiled.enabled = false;

            initCollision();
            addComponent(new ArmosSimpleStateMachine(this));
        }
Exemple #4
0
        public override void onAddedToScene()
        {
            var    texture = Core.content.Load <Texture2D>("Images/ItemsIcon/W_Sword001");
            Weapon weapon  = new NormalswordWeapon(texture);

            this.weapon = weapon;
            this.addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));


            this.addComponent <FSRigidBody>()
            .setBodyType(FarseerPhysics.Dynamics.BodyType.Dynamic);



            var collision = addComponent <FSCollisionCircle>()
                            .setRadius(20);

            collision.setCollisionCategories(CollisionSetting.ItemsCategory);
            collision.setCollidesWith(CollisionSetting.wallCategory);

            var sensor = addComponent <FSCollisionCircle>()
                         .setRadius(50)
                         .setIsSensor(true);

            sensor.setCollisionCategories(CollisionSetting.ItemsCategory);
            sensor.setCollidesWith(CollisionSetting.playerCategory);
        }
Exemple #5
0
        public override void onAddedToScene()
        {
            var texture = Core.content.Load <Texture2D>("Images/ItemsIcon/A_Armor04");

            armor         = new Armor(texture, "胸甲", "普通的一件胸甲", 100, "最大生命值 + 100", "护甲 + 10");
            armor.equit   = equitArmor;
            armor.tackOff = tackOffArmor;


            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(BodyType.Dynamic);

            var collision = addComponent <FSCollisionCircle>()
                            .setRadius(10);

            collision.setCollisionCategories(CollisionSetting.ItemsCategory);
            collision.setCollidesWith(CollisionSetting.wallCategory);

            var shape = addComponent <FSCollisionCircle>()
                        .setRadius(20)
                        .setIsSensor(true);

            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);

            addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            armor.equit   = equitArmor;
            armor.tackOff = tackOffArmor;
        }
Exemple #6
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture = GameResources.GameTextureResource.xObjectPacker.Packer.getSubtexture(390);

            addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic)
            .setMass(2f);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(7)
            .setIsSensor(true);
            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);

            shape.onAdded += () =>
            {
                shape.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var picker = ((Component)fixtureB.userData).entity as Player.Player;

                    if (picker != null)
                    {
                        picker.pickUp(new RockItem(), this.count);
                        this.destroy();
                    }
                    return(true);
                };
            };
        }
Exemple #7
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture1 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(450);
            var texture2 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(451);
            var texture3 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(452);
            var texture4 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(453);
            var texture5 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(454);
            var texture6 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(455);
            var texture7 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(456);
            var texture8 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(457);
            var texture9 = GameResources.GameTextureResource.xAnimationsTexturePacker.Packer.getSubtexture(458);

            animations = addComponent(new Sprite <DeathAnimations>(texture1));
            animations.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            animations.addAnimation(DeathAnimations.Death, new SpriteAnimation(new List <Subtexture>()
            {
                texture1,
                texture2,
                texture3,
                texture4,
                texture5,
                texture6,
                texture7,
                texture8,
                texture9
            })
            {
                loop = false
            });
            animations.currentAnimation           = DeathAnimations.Death;
            animations.onAnimationCompletedEvent += Animations_onAnimationCompletedEvent;
        }
Exemple #8
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture      = GameResources.GameTextureResource.xObjectPacker.Packer.getSubtexture(rockIndex);
            var brokeTexture = GameResources.GameTextureResource.xObjectPacker.Packer.getSubtexture(rockIndex + 1);

            animations = addComponent(new Sprite <xRockAniamtion>(texture));
            animations.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            animations.addAnimation(xRockAniamtion.Idle, new SpriteAnimation(texture));
            animations.addAnimation(xRockAniamtion.Broke, new SpriteAnimation(brokeTexture));
            animations.currentAnimation = xRockAniamtion.Idle;


            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(BodyType.Dynamic)
                            .setIsSleepingAllowed(false);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(5);

            shape.setCollisionCategories(CollisionSetting.tiledObjectCategory);
            shape.setCollidesWith(CollisionSetting.expositionCategory);

            shape.onAdded += () =>
            {
                shape.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    this.destoryByExposition();
                    triggerEvent?.Invoke();
                    return(true);
                };
            };

            colliderEntity = scene.createEntity("collision");
            colliderEntity.setPosition(this.position);
            colliderEntity.addComponent <FSRigidBody>()
            .setBodyType(BodyType.Static);

            var colliderShape = colliderEntity.addComponent <FSCollisionCircle>();

            colliderShape.setRadius(6);
            colliderShape.setCollisionCategories(CollisionSetting.wallCategory);


            triggerEvent = () =>
            {
                if (!colliderEntity.isDestroyed)
                {
                    colliderEntity.destroy();
                }
            };
        }
Exemple #9
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            var texture = scene.content.Load <Texture2D>("Images/Actors/DongZhuangVillageMayor");

            animation = addComponent(new Sprite(texture));
            animation.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            initCollision();
            initTalkTrigger();
        }
Exemple #10
0
 public override void update()
 {
     if (couldPause && GameSetting.isGamePause)
     {
         return;
     }
     base.update();
     animation.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
     if (actorProperty.HP <= 0)
     {
         scene.addEntity(new Deatheffects02()).setPosition(this.position).setScale(2f);
         onDeathed?.Invoke();
         this.destroy();
     }
 }
Exemple #11
0
 public override void update()
 {
     if (couldPause && GameSetting.isGamePause)
     {
         return;
     }
     base.update();
     if (switchButton.isPressed)
     {
         switchWeapon();
     }
     preDirection = currentDirection;
     playerStateMachine.update(Time.deltaTime);
     animation.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
 }
Exemple #12
0
        public override void onAddedToScene()
        {
            var texture    = scene.content.Load <Texture2D>("Images/ItemsObjects/treasureBox_small");
            var subtexture = Subtexture.subtexturesFromAtlas(texture, 14, 14);

            animation = addComponent(new Sprite <TreasureBoxStates>(subtexture[0]));
            animation.setRenderLayer(GameLayerSetting.actorMoverLayer)
            .setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));


            animation.addAnimation(TreasureBoxStates.Close, new SpriteAnimation(subtexture[0]));
            animation.addAnimation(TreasureBoxStates.Open, new SpriteAnimation(subtexture[1]));

            if (hasOpened)
            {
                animation.currentAnimation = TreasureBoxStates.Open;
            }
            else
            {
                animation.currentAnimation = TreasureBoxStates.Close;
            }
            animation.play(animation.currentAnimation);

            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(FarseerPhysics.Dynamics.BodyType.Dynamic);

            trigger = addComponent <SceneObjectTriggerComponent>();
            trigger.setRadius(10)
            .setIsSensor(true);

            trigger.setCollisionCategories(CollisionSetting.ItemsCategory);
            trigger.setCollidesWith(CollisionSetting.playerCategory);

            trigger.onAdded += onAddedMethod;


            var eButtontexture = scene.content.Load <Texture2D>("Images/ItemsObjects/EButton");

            eButtonSprite = addComponent(new Sprite(eButtontexture));
            eButtonSprite.setLocalOffset(new Vector2(-14, -14 - eButtonSprite.height));
            eButtonSprite.enabled = false;

            var openTexture = scene.content.Load <Texture2D>("Images/ItemsObjects/openFont");

            openSprite = addComponent(new Sprite(openTexture));
            openSprite.setLocalOffset(new Vector2(-14 + eButtonSprite.width * 2, -14 - eButtonSprite.height));
            openSprite.enabled = false;
        }
Exemple #13
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var eButtontexture = scene.content.Load <Texture2D>("Images/ItemsObjects/EButton");

            eButtonSprite = addComponent(new Sprite(eButtontexture));
            eButtonSprite.setLocalOffset(new Vector2(-14, -14 - eButtonSprite.height));
            eButtonSprite.enabled = false;

            var searchTexture = scene.content.Load <Texture2D>("Images/ItemsObjects/searchFont");

            searchSprite = addComponent(new Sprite(searchTexture));
            searchSprite.setLocalOffset(new Vector2(-14 + eButtonSprite.width * 2, -14 - eButtonSprite.height));
            searchSprite.enabled = false;

            var tiledMap          = scene.content.Load <TiledMap>("TileMaps/MapObjects/Sign01");
            var tiledMapComponent = addComponent(new TiledMapComponent(tiledMap));

            tiledMapComponent.setLayersToRender(new string[] { "object" });
            tiledMapComponent.setRenderLayer(GameLayerSetting.actorMoverLayer)
            .setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y + 8));


            var colliderObject = tiledMap.getObjectGroup("Collision");
            var collision      = colliderObject.objectWithName("collision");

            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(FarseerPhysics.Dynamics.BodyType.Kinematic)
            ;

            Vertices vertices = new Vertices(collision.polyPoints);
            var      collider = addComponent(new FSCollisionPolygon(vertices));

            collider.setCollisionCategories(CollisionSetting.wallCategory);


            trigger = addComponent <SceneObjectTriggerComponent>();
            trigger.setRadius(10)
            .setIsSensor(true);
            trigger.setCollisionCategories(CollisionSetting.ItemsCategory);
            trigger.setCollidesWith(CollisionSetting.playerCategory);

            trigger.onAdded += onAddedMethod;
        }
Exemple #14
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture    = Core.content.Load <Texture2D>("Images/Players/Allplayer");
            var subtexture = new Nez.Textures.Subtexture(texture, new Rectangle(306, 2630 - 1191 - 16, 5, 16));

            addComponent(new Sprite(subtexture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(7).setIsSensor(true);
            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);
            shape.onAdded = () =>
            {
                shape.GetFixture().onCollision += Body_onCollision;
            };
        }
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture = Core.content.Load <Texture2D>("Images/ItemsIcon/P_Red04");

            addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic)
            ;

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(10).setIsSensor(true);

            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);


            shape.onAdded += onAddedMethod;
        }
Exemple #16
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture    = scene.content.Load <Texture2D>("TileMaps/MapTextures/Overworld");
            var subtexture = new Subtexture(texture, new Rectangle(384, 0, 16, 48));

            addComponent(new Sprite(subtexture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(BodyType.Kinematic);

            var shape = addComponent <SceneObjectTriggerComponentBox>();

            shape.setSize(18, 48);

            shape.setCollisionCategories(CollisionSetting.tiledObjectCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);

            shape.onAdded += () =>
            {
                shape.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    collisioned = true;
                    return(true);
                };

                shape.GetFixture().onSeparation += (fixtureA, fixtureB) =>
                {
                    collisioned = false;
                };
            };


            colliderEntity = scene.createEntity("collision").setPosition(this.position);
            colliderEntity.addComponent <FSRigidBody>()
            .setBodyType(BodyType.Static);

            colliderEntity.addComponent <FSCollisionBox>()
            .setSize(16, 48);
        }
Exemple #17
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture = GameTextureResource.xObjectPacker.Packer.getSubtexture(153);

            addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(7)
            .setIsSensor(true);
            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);

            shape.onAdded = () =>
            {
                shape.GetFixture().onCollision += Body_onCollision;
            };
        }
Exemple #18
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var    texture = Core.content.Load <Texture2D>("Images/ItemsIcon/W_Bow03");
            Weapon weapon  = new NormalBowWeapon();

            addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
            this.addComponent <FSRigidBody>()
            .setBodyType(FarseerPhysics.Dynamics.BodyType.Dynamic);

            var collision = addComponent <FSCollisionCircle>()
                            .setRadius(20);

            collision.setCollisionCategories(CollisionSetting.ItemsCategory);
            collision.setCollidesWith(CollisionSetting.wallCategory);

            var sensor = addComponent <SceneObjectTriggerComponent>();

            sensor.setRadius(40)
            .setIsSensor(true);

            sensor.setCollisionCategories(CollisionSetting.ItemsCategory);
            sensor.setCollidesWith(CollisionSetting.playerCategory);

            sensor.onAdded += () =>
            {
                sensor.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var picker = ((Component)fixtureB.userData).entity as Player.Player;

                    if (picker != null)
                    {
                        picker.pickUp(weapon, 1);
                        this.destroy();
                    }
                    return(true);
                };
            };
        }
Exemple #19
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture    = scene.content.Load <Texture2D>("TileMaps/MapTextures/Overworld");
            var subtexture = new Subtexture(texture, new Rectangle(48, 80, 48, 16));
            var sprite     = addComponent(new Sprite(subtexture));

            //sprite.setLocalOffset(new Vector2(24, 8));
            sprite.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(FarseerPhysics.Dynamics.BodyType.Kinematic);


            var collider = addComponent(new SceneObjectTriggerComponentBox());

            collider.setSize(48, 16);
            collider.setCollisionCategories(CollisionSetting.ItemsCategory);
            collider.setCollidesWith(CollisionSetting.expositionCategory);

            collider.onAdded += onAddedMethod;
        }
Exemple #20
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            this.actorProperty           = addComponent <ActorPropertyComponent>();
            this.actorProperty.HP        = this.actorProperty.MaxHP = 80;
            this.actorProperty.moveSpeed = 70;

            fallinAbleComponent         = addComponent(new FallinAbleComponent());
            fallinAbleComponent.fallin += () =>
            {
                Death();
            };

            var texture = scene.content.Load <Texture2D>("Images/Enemys/Archer");

            addComponent(new Sprite(texture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            initCollision();

            var viewFieldTrigger = addComponent <EnemyViewComponent>();

            viewFieldTrigger.setRadius(fieldOfView);
            viewFieldTrigger.setIsSensor(true);
            viewFieldTrigger.setCollisionCategories(CollisionSetting.enemyCategory);
            viewFieldTrigger.setCollidesWith(CollisionSetting.playerCategory);

            viewFieldTrigger.onAdded += () =>
            {
                viewFieldTrigger.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    target       = ((Component)(fixtureB.userData)).entity;
                    isFindTarget = true;
                    return(true);
                };
            };

            addComponent(new ArcherSimpleStateMachine(this));
        }
Exemple #21
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var tiledMap          = scene.content.Load <TiledMap>("TileMaps/MapObjects/Rock01");
            var tiledMapComponent = addComponent(new TiledMapComponent(tiledMap));

            tiledMapComponent.setLayersToRender(new string[] { "object" });
            tiledMapComponent.setRenderLayer(GameLayerSetting.actorMoverLayer)
            .setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y))
            ;

            var colliderObject = tiledMap.getObjectGroup("Collision");
            var collision      = colliderObject.objectWithName("collision");


            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(FarseerPhysics.Dynamics.BodyType.Static);

            Vertices vertices = new Vertices(collision.polyPoints);
            var      collider = addComponent(new FSCollisionPolygon(vertices));

            collider.setCollisionCategories(CollisionSetting.wallCategory);
        }
Exemple #22
0
        public override void update()
        {
            base.update();
            animation.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
            if (!startBoom)
            {
                timer += Time.deltaTime;
                if (timer > waitTime)
                {
                    timer     = 0f;
                    startBoom = true;
                    animation.currentAnimation = BombAnimation.Boom;
                    var shape = getComponent <FSCollisionCircle>();

                    var entity = createAttackEntity();


                    FSWorld         fSWorld         = scene.getSceneComponent <FSWorld>();
                    SimpleExplosion simpleExplosion = new SimpleExplosion(fSWorld.world);
                    simpleExplosion.enabledOnCategories = CollisionSetting.playerCategory | CollisionSetting.enemyCategory;
                    simpleExplosion.activate(shape.GetFixture().body.position, 0.5f, 0.02f, 0.035f);

                    shape.removeComponent();
                    Core.schedule(0.2f, timer => { entity.destroy(); });
                }
                if (changeColor)
                {
                    changeColor = false;
                    var time   = (waitTime - timer) / 5f;
                    var sprite = getComponent <Sprite>();
                    sprite.color = Color.Red;
                    Core.schedule(0.1f, timer => { sprite.color = Color.White; });
                    Core.schedule(time, timer => { changeColor = true; });
                }
            }
        }
Exemple #23
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            this.actorProperty               = addComponent <ActorPropertyComponent>();
            this.actorProperty.HP            = this.actorProperty.MaxHP = 30;
            this.actorProperty.moveSpeed     = 70;
            this.actorProperty.executeDamage = executeDamageMethod;

            var texture1 = scene.content.Load <Texture2D>("Images/Enemys/BlackOctor1");
            var texture2 = scene.content.Load <Texture2D>("Images/Enemys/BlackOctor2");
            var texture3 = GameResources.GameTextureResource.xObjectPacker.Packer.getSubtexture(750);

            animations = addComponent(new Sprite <OctorAnimations>(new Subtexture(texture1)));
            animations.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));
            animations.addAnimation(OctorAnimations.Attack, new SpriteAnimation(new Subtexture(texture2)));
            animations.addAnimation(OctorAnimations.Appera, new SpriteAnimation(new Subtexture(texture1)));
            animations.addAnimation(OctorAnimations.Hide, new SpriteAnimation(texture3));

            animations.currentAnimation = OctorAnimations.Hide;

            rigidBody = addComponent <FSRigidBody>()
                        .setBodyType(BodyType.Dynamic)
                        .setLinearDamping(int.MaxValue)
                        .setMass(2f);

            var collider = addComponent <FSCollisionCircle>()
                           .setRadius(5);

            collider.setCollisionCategories(CollisionSetting.enemyCategory);
            collider.setCollidesWith(CollisionSetting.allAttackTypeCategory
                                     | CollisionSetting.playerAttackCategory);


            ViewTrigger = scene.createEntity("OctorViewTrigger").setPosition(this.position);
            ViewTrigger.addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic);
            var view = ViewTrigger.addComponent <EnemyViewComponent>();

            view.setRadius(fieldOfView)
            .setIsSensor(true);

            view.setCollisionCategories(CollisionSetting.enemyCategory);
            view.setCollidesWith(CollisionSetting.playerCategory);

            view.onAdded += () =>
            {
                view.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var compoent = fixtureB.userData as Component;
                    target       = compoent.entity;
                    isFindTarget = true;
                    return(true);
                };

                view.GetFixture().onSeparation += (fixtureA, fixtureB) => {
                    target       = null;
                    isFindTarget = false;
                };
            };

            colliderEntity = scene.createEntity("collision").setPosition(this.position);
            colliderEntity.addComponent <FSRigidBody>()
            .setBodyType(BodyType.Static);

            colliderShape = colliderEntity.addComponent <FSCollisionCircle>()
                            .setRadius(7);
            colliderShape.setCollisionCategories(CollisionSetting.wallCategory);


            stateMachine = addComponent(new OctorSimpleStateMachine(this));
        }
Exemple #24
0
 public void update()
 {
     sprite.setLayerDepth(LayerDepthExt.caluelateLayerDepth(entity.position.Y));
 }
Exemple #25
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            var texture       = scene.content.Load <Texture2D>("TileMaps/MapTextures/objects");
            var texturePacker = TexturePackerAtlas.create(texture, 32, 32);

            animationTexture[0] = texturePacker.createRegion("1", 64, 96, 32, 32);
            animationTexture[1] = texturePacker.createRegion("2", 96, 96, 32, 32);
            animationTexture[2] = texturePacker.createRegion("3", 128, 96, 32, 32);
            animationTexture[3] = texturePacker.createRegion("4", 160, 96, 32, 32);

            animation = addComponent(new Sprite <BottleAnimation>(animationTexture[0]));
            animation.setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            animation.addAnimation(BottleAnimation.Idle, new SpriteAnimation(animationTexture[0]));
            var spriteAnimation = new SpriteAnimation(new List <Subtexture>()
            {
                animationTexture[0],
                animationTexture[1],
                animationTexture[2],
                animationTexture[3],
            });

            spriteAnimation.loop = false;
            animation.addAnimation(BottleAnimation.Broke, spriteAnimation);
            animation.onAnimationCompletedEvent += Animation_onAnimationCompletedEvent;

            animation.currentAnimation = BottleAnimation.Idle;
            animation.play(BottleAnimation.Idle);

            var rigidBody = addComponent <FSRigidBody>()
                            .setBodyType(FarseerPhysics.Dynamics.BodyType.Dynamic);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(5)
            ;

            shape.setCollisionCategories(CollisionSetting.tiledObjectCategory);
            shape.setCollidesWith(CollisionSetting.allAttackCategory | CollisionSetting.allAttackTypeCategory);

            shape.onAdded = onAddedMethod;

            colliderEntity = scene.createEntity("collision");
            colliderEntity.setPosition(this.position);
            colliderEntity.addComponent <FSRigidBody>()
            .setBodyType(BodyType.Static);

            var colliderShape = colliderEntity.addComponent <FSCollisionCircle>();

            colliderShape.setRadius(4);
            colliderShape.setCollisionCategories(CollisionSetting.wallCategory);

            triggerEvent = () =>
            {
                if (!colliderEntity.isDestroyed)
                {
                    colliderEntity.destroy();
                }
            };
        }
Exemple #26
0
        private void initTiledMap()
        {
            var tiledEntity = createEntity("tiledMap");

            tiledMap = content.Load <TiledMap>("TileMaps/Maps/DongZhuang/cave2");
            var tiledMapComponent = tiledEntity.addComponent(new TiledMapComponent(tiledMap));

            tiledMapComponent.setLayersToRender(new string[] { "Tiled", "Wall" });
            tiledMapComponent.setRenderLayer(GameLayerSetting.tiledLayer);

            var tileMapUpPlayerComponent = tiledEntity.addComponent(new TiledMapComponent(tiledMap));

            tileMapUpPlayerComponent.setLayersToRender(new string[] { "UpPlayer" });
            tileMapUpPlayerComponent.setRenderLayer(GameLayerSetting.tiledActorUpLayer).setLayerDepth(LayerDepthExt.caluelateLayerDepth(210));

            createMapCollision(tiledMap, "Collision");
        }