예제 #1
0
파일: Crawler.cs 프로젝트: siquel/BeatEmUp
        private void MoveToPlayer(ref NodeStatus status)
        {
            TargetingComponent targetingComponent = Owner.FirstComponentOfType <TargetingComponent>();

            if (targetingComponent.HasTarget && targetingComponent.Target.Name.Contains("Player"))
            {
                Owner.Body.Velocity = Vector2.Zero;

                steeringComponent.Disable();

                status = NodeStatus.Success;
            }
            else
            {
                GameObject player = Owner.Game.FindGameObject(o => o.Name.Contains("Player"));

                if (player == null)
                {
                    return;
                }

                steeringComponent.Enable();

                steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior));
                steeringComponent.Current.TargetX = player.Position.X;
                steeringComponent.Current.TargetY = player.Position.Y;

                spriterComponent.FlipX = Owner.Body.Velocity.X > 0f;

                status = NodeStatus.Running;
            }
        }
예제 #2
0
파일: Blob.cs 프로젝트: siquel/BeatEmUp
        protected override void OnInitialize()
        {
            MonsterBuilder builder = new BlobBuilder();

            builder.Build(Owner);

            Tree tree = CreateTree();

            tree.Initialize();

            Owner.AddComponent(tree);

            spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Boss\Boss");
            spriterComponent.Initialize();
            spriterComponent.ChangeAnimation("Walk");
            spriterComponent.Scale = 0.75f;

            Owner.AddComponent(spriterComponent);

            steeringComponent = Owner.FirstComponentOfType <SteeringComponent>();

            SteeringBehavior seek = new SeekBehavior()
            {
                DesiredVelocity = new Vector2(1.25f),
                MaxSpeed        = 1.25f
            };

            steeringComponent.AddBehavior(seek);

            steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior));

            rotation           = Owner.FirstComponentOfType <SkillRotation>();
            targetingComponent = Owner.FirstComponentOfType <TargetingComponent>();

            BossHealthComponent c = new BossHealthComponent(Owner);

            c.Initialize();
            Owner.AddComponent(c);

            rotation.Enable();
        }
예제 #3
0
        // TODO: duplicated code. Crawlerilla melkein sama init logic.
        protected override void OnInitialize()
        {
            MonsterBuilder builder = new ZombieBuilder();

            builder.Build(Owner);

            Tree tree = CreateTree();

            tree.Initialize();

            Owner.AddComponent(tree);

            // Idle, Walk, Attack
            spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\GenericZombie\GenericZombie");
            spriterComponent.Initialize();
            spriterComponent.ChangeAnimation("Walk");
            spriterComponent.Scale = 0.5f;

            Owner.AddComponent(spriterComponent);

            steeringComponent = Owner.FirstComponentOfType <SteeringComponent>();

            SteeringBehavior flee = new FleeBehavior()
            {
                DesiredVelocity = new Vector2(4.25f),
                MaxSpeed        = 3.25f
            };

            SteeringBehavior seek = new SeekBehavior()
            {
                DesiredVelocity = new Vector2(4.25f),
                MaxSpeed        = 3.25f
            };

            steeringComponent.AddBehavior(flee);
            steeringComponent.AddBehavior(seek);

            steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior));
        }
예제 #4
0
파일: Crawler.cs 프로젝트: siquel/BeatEmUp
        protected override void OnInitialize()
        {
            MonsterBuilder builder = new CrawlerBuilder();

            builder.Build(Owner);

            Tree tree = CreateTree();

            tree.Initialize();

            Owner.AddComponent(tree);

            spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Crawler\crawler");
            spriterComponent.Initialize();
            spriterComponent.ChangeAnimation("NewAnimation");
            spriterComponent.Scale = 0.3f;

            Owner.AddComponent(spriterComponent);

            steeringComponent = Owner.FirstComponentOfType <SteeringComponent>();

            SteeringBehavior flee = new FleeBehavior()
            {
                DesiredVelocity = new Vector2(2.25f),
                MaxSpeed        = 1.25f
            };

            SteeringBehavior seek = new SeekBehavior()
            {
                DesiredVelocity = new Vector2(2.25f),
                MaxSpeed        = 1.25f
            };

            steeringComponent.AddBehavior(flee);
            steeringComponent.AddBehavior(seek);

            steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior));
        }