コード例 #1
0
ファイル: Motor.cs プロジェクト: aahriman/RobotBattlefield
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = MAX_SPEED.GetHashCode();
         hashCode = (hashCode * 397) ^ ROTATE_IN.GetHashCode();
         hashCode = (hashCode * 397) ^ ACCELERATION.GetHashCode();
         hashCode = (hashCode * 397) ^ DECELERATION.GetHashCode();
         hashCode = (hashCode * 397) ^ MAX_INITIAL_POWER.GetHashCode();
         hashCode = (hashCode * 397) ^ COST;
         hashCode = (hashCode * 397) ^ ID;
         return(hashCode);
     }
 }
コード例 #2
0
        public Vector3 Arrive(Vector3 targetPosition, DECELERATION deceleration)
        {
            Vector3 toTarget = targetPosition - m_Agent.Position;

            float distance = toTarget.Length();

            if (distance > 0)
            {
                const float decelTweaker = 0.3f;

                float speed = distance / ((float)deceleration * decelTweaker);

                speed = Math.Min(speed, Agent.MAX_SPEED);

                Vector3 desiredVelocity = toTarget * speed / distance;

                return desiredVelocity - m_Agent.Position;
            }

            return Vector3.Zero;
        }