Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
 public override void onAddedToEntity()
 {
     base.onAddedToEntity();
     headIcon          = Core.content.Load <Texture2D>("Images/headIcons/Link_Sprite");
     redColor          = Core.content.Load <Texture2D>("Images/Color/red");
     propertyComponent = Core.getGlobalManager <GameActorManager>().player.getComponent <ActorPropertyComponent>();
 }
Ejemplo n.º 3
0
        private void initActorProperty()
        {
            actorProperty    = addComponent <ActorPropertyComponent>();
            actorProperty.HP = actorProperty.MaxHP = 30;

            actorProperty.moveSpeed = 50f;
        }
Ejemplo n.º 4
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            this.actorProperty           = addComponent <ActorPropertyComponent>();
            this.actorProperty.HP        = this.actorProperty.MaxHP = 500;
            this.actorProperty.moveSpeed = 70;

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

            sprite = addComponent(new Sprite(texture));

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

            addComponent(new DZMazeBossSimpleStateMachine(this));
            addComponent(new DZMazeBossHPBar(this)).setRenderLayer(GameLayerSetting.playerUiLayer);
        }
Ejemplo n.º 5
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            this.setScale(2f);
            this.actorProperty           = addComponent <ActorPropertyComponent>();
            this.actorProperty.HP        = this.actorProperty.MaxHP = 500;
            this.actorProperty.moveSpeed = 70;

            var texture    = scene.content.Load <Texture2D>("Images/Enemys/Slime");
            var subtexture = Subtexture.subtexturesFromAtlas(texture, 32, 32);

            initAnimation(subtexture);
            initCollision();

            this.target = Core.getGlobalManager <GameActorManager>().player;
            addComponent(new BigSlimeSimpleStateMachine(this));
            addComponent(new BigSlimeHPBar(this)).setRenderLayer(GameLayerSetting.playerUiLayer);;
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
 public DZMazeBossHPBar(DZMazeBoss boss)
 {
     actorProperty = boss.getComponent <ActorPropertyComponent>();
     nameWidth     = Graphics.instance.bitmapFont.measureString(name).X;
 }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            this.setScale(2f);

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

            var texture       = scene.content.Load <Texture2D>("Images/Enemys/Bat");
            var texturePacker = new TexturePackerAtlas(texture);
            var idleTexture   = texturePacker.createRegion("batidle", 0, 33, 16, 16);
            var flyTextur1    = texturePacker.createRegion("fly01", 0, 9, 16, 16);
            var flyTextur2    = texturePacker.createRegion("fly02", 16, 9, 16, 16);
            var flyTextur3    = texturePacker.createRegion("fly03", 32, 9, 16, 16);
            var flyTextur4    = texturePacker.createRegion("fly04", 48, 9, 16, 16);

            animation = addComponent(new Sprite <BatAnimations>(idleTexture));
            animation.setRenderLayer(GameLayerSetting.tiledActorUpLayer);
            animation.addAnimation(BatAnimations.Idle, new SpriteAnimation(idleTexture));
            animation.addAnimation(BatAnimations.Fly, new SpriteAnimation(new List <Subtexture>()
            {
                flyTextur1, flyTextur2, flyTextur3, flyTextur4
            }));
            animation.currentAnimation = BatAnimations.Idle;


            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic).
            setLinearDamping(0.8f)
            .setMass(1.5f);

            var enemtCollider = addComponent <FSCollisionCircle>()
                                .setRadius(8);

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

            var damageTriger = addComponent <DamageTrigerComponent>();

            damageTriger.setRadius(10).setIsSensor(true);
            damageTriger.setCollisionCategories(
                CollisionSetting.enemyAttackCategory);
            damageTriger.setCollidesWith(CollisionSetting.playerCategory);
            damageTriger.onAdded += () =>
            {
                damageTriger.GetFixture().onCollision += (fixtureA, fixtureB, contact) =>
                {
                    var component     = fixtureB.userData as Component;
                    var actorProperty = component.entity.getComponent <ActorPropertyComponent>();
                    actorProperty.executeDamage?.Invoke(AttackTypes.Physics, 5);
                    var rigidbody = component.entity.getComponent <FSRigidBody>();
                    var dir       = component.entity.position - this.position;
                    dir.Normalize();
                    rigidbody.body.applyLinearImpulse(dir * rigidbody.body.mass);
                    return(true);
                };
            };


            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 <RigidBodyVelocityLimited>();
            addComponent(new BatSampleStateMachine(this));
        }
Ejemplo n.º 10
0
 public BigSlimeHPBar(BigSlime bigSlime)
 {
     this.bigSlime = bigSlime;
     actorProperty = bigSlime.getComponent <ActorPropertyComponent>();
     nameWidth     = Graphics.instance.bitmapFont.measureString(name).X;
 }