예제 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            FindTarget();

            if (Target != null)
            {
                CheckIfDamagedTarget();

                // Rotate to target
                float angle = Trigonometry.GetAngleOfLineBetweenObjectAndTarget(this, Target.WorldPosition);
                if (Math.Abs(angle - WorldRotation) > 0.1f)
                {
                    RigidBody.AngularVelocity = 3.5f * Trigonometry.GetRotateDirectionForShortestRotation(this, Target.WorldPosition);
                }
                else
                {
                    LocalRotation = angle - Parent.WorldRotation;
                    RigidBody.FullAngularStop();
                }
            }

            FiringArc.Visible = MouseOver || IsSelected;
            FiringArc.Update(gameTime);
        }
예제 #2
0
        public override void Initialize()
        {
            base.Initialize();

            FiringArc = new FiringArc(this);
            FiringArc.Initialize();

            TargetingLine.Initialize();
            TargetingLine.Size    = new Vector2(TargetingLine.Size.X, ShipTurretData.Range);
            TargetingLine.Opacity = 0.25f;
        }