Exemple #1
0
        public Vector2 ComputeForce()
        {
            Vector2 desired = TargetPosition - Agent.Position;

            float distance = desired.Length();

            desired.Normalize();

            Vector2 steeringVec;

            if (distance < SlowingRadius)
            {
                float mag = OrionMath.Map(distance, 0, 100, 0, Agent.MaxSpeed);
                desired *= mag;

                steeringVec = desired - Agent.Velocity;
                steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxDeceleration);
            }
            else
            {
                desired *= Agent.MaxSpeed;

                steeringVec = desired - Agent.Velocity;
                steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxAcceleration);
            }

            return(steeringVec);
        }
Exemple #2
0
        public Vector2 ComputeForce()
        {
            Vector2 desiredVelocity = OrionMath.VectorNormalize(TargetPosition - Agent.Position) * Agent.MaxSpeed;

            Vector2 steeringVec = desiredVelocity - Agent.Velocity;

            steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxAcceleration);

            return(steeringVec);
        }
        private Vector2 Seek(Vector2 target)
        {
            Vector2 desiredVelocity = OrionMath.VectorNormalize(target - Agent.Position) * Agent.MaxSpeed;

            Vector2 steeringVec = desiredVelocity - Agent.Velocity;

            steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxAcceleration);

            return(steeringVec);
        }
        public virtual void Update(GameTime gameTime)
        {
            PreviousScene.Update(gameTime);

            _fadeTime = OrionMath.LinearInterpolate(0.0f, 1.0f, _elapsed);

            if (_elapsed <= 1.0f)
            {
                _elapsed += gameTime.ElapsedGameTime.Milliseconds / FadeDuration;
            }
            else
            {
                if (Elapsed != null)
                {
                    Elapsed(this, new EventArgs());
                }
            }
        }
Exemple #5
0
        public override void Update(GameTime gameTime, IUpdatable parent)
        {
            Vector2 mousePos  = new Vector2(Mouse.GetState().Position.X, Mouse.GetState().Position.Y);
            Vector2 playerPos = Vector2.Transform(Position, OrionEngine.Instance.GetComponent <Camera2D>().Transform);

            float armRotation = OrionMath.AngleBetween(mousePos, playerPos);

            if (armRotation >= 180 && armRotation < 360)
            {
                armRotation -= 180;
            }

            armRotation -= 90;
            if (_isInverted)
            {
                armRotation *= -1;
            }

            if (armRotation >= 360)
            {
                armRotation -= 360;
            }
            else if (armRotation < 0)
            {
                armRotation += 360;
            }

            LogManager.Instance.LogMessage(this, _ArmFrontSprite, "Rotation=" + armRotation);

            _ArmBackSprite.Rotation  = armRotation;
            _ArmFrontSprite.Rotation = armRotation;
            _GunSprite.Rotation      = armRotation;

            ICollider collider = GetAttachable <ICollider>();

            if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                collider.ApplyLinearImpulse(new Vector2(-0.5f, 0.0f));
            }

            base.Update(gameTime, parent);
        }