Ejemplo n.º 1
0
        private void initFallinMethod()
        {
            fallinAbleComponent = addComponent(new FallinAbleComponent());

            fallinAbleComponent.fallin += () =>
            {
                playerStateMachine.changeState <FallState>();
            };
        }
Ejemplo n.º 2
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));
        }