예제 #1
0
        private void FindPlayer(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
        private void ChaseAndAttack(ref NodeStatus status)
        {
            rotation.Enable();

            if (targetingComponent.HasTarget)
            {
                Owner.Body.Velocity = Vector2.Zero;

                steeringComponent.Disable();

                Console.WriteLine("Has target and at target...");
            }
            else
            {
                steeringComponent.Enable();

                steeringComponent.Current.TargetX = currentTarget.Position.X;
                steeringComponent.Current.TargetY = currentTarget.Position.Y;

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

            resting = elapsed > TARGET_SWAP_TIME;

            if (resting)
            {
                status = NodeStatus.Success;

                rotation.Disable();

                return;
            }

            status = NodeStatus.Running;
        }