Ejemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (relativePosition_ != null)
            {
                hash ^= RelativePosition.GetHashCode();
            }
            if (relativeVelocity_ != null)
            {
                hash ^= RelativeVelocity.GetHashCode();
            }
            if (Rcs != 0D)
            {
                hash ^= Rcs.GetHashCode();
            }
            if (Movable != false)
            {
                hash ^= Movable.GetHashCode();
            }
            if (Width != 0D)
            {
                hash ^= Width.GetHashCode();
            }
            if (Length != 0D)
            {
                hash ^= Length.GetHashCode();
            }
            if (Height != 0D)
            {
                hash ^= Height.GetHashCode();
            }
            if (Theta != 0D)
            {
                hash ^= Theta.GetHashCode();
            }
            if (absolutePosition_ != null)
            {
                hash ^= AbsolutePosition.GetHashCode();
            }
            if (absoluteVelocity_ != null)
            {
                hash ^= AbsoluteVelocity.GetHashCode();
            }
            if (Count != 0)
            {
                hash ^= Count.GetHashCode();
            }
            if (MovingFramesCount != 0)
            {
                hash ^= MovingFramesCount.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 2
0
 private void FindPlayerParts()
 {
     jump            = GetComponent <JumpControl>();
     characterSprite = GetComponentInChildren <SpriteRenderer>().gameObject;
     frogAnim        = characterSprite.GetComponent <AnimateFrog>();
     hand            = characterSprite.GetComponentInChildren <AimAtMouse>().gameObject;
     hookshotControl = hand.GetComponentInChildren <HookshotControl>();
     wallSensorRight = GameObject.Find("WallSensorR").GetComponent <WallSensor>();
     wallSensorLeft  = GameObject.Find("WallSensorL").GetComponent <WallSensor>();
     ceilingSensor   = GameObject.Find("CeilingSensor").GetComponent <CeilingSensor>();
     relative        = GameObject.Find("GroundColliders").GetComponent <RelativeVelocity>();
 }
Ejemplo n.º 3
0
        public void ResolveAtmopsherics(IMassiveBody body)
        {
            DVector2 difference = body.Position - Position;

            double distance = difference.Length() - Height * 0.5;

            difference.Normalize();

            Altitude = distance - body.SurfaceRadius;

            // The object is in the atmosphere of body B
            if (Altitude < body.AtmosphereHeight)
            {
                var surfaceNormal = new DVector2(-difference.Y, difference.X);

                double altitudeFromCenter = Altitude + body.SurfaceRadius;

                // Distance of circumference at this altitude ( c= 2r * pi )
                double pathCirumference = 2 * Math.PI * altitudeFromCenter;

                double rotationalSpeed = pathCirumference / body.RotationPeriod;

                // Simple collision detection
                if (Altitude <= 0)
                {
                    var normal = new DVector2(-difference.X, -difference.Y);

                    Position = body.Position + normal * (body.SurfaceRadius);

                    Pitch = normal.Angle();

                    AccelerationN.X = -AccelerationG.X;
                    AccelerationN.Y = -AccelerationG.Y;

                    OnGround = true;
                }
                else
                {
                    OnGround = false;
                }

                double atmosphericDensity = body.GetAtmosphericDensity(Altitude);

                RelativeVelocity = (body.Velocity + surfaceNormal * rotationalSpeed) - Velocity;

                double velocityMagnitude = RelativeVelocity.LengthSquared();

                if (velocityMagnitude > 0)
                {
                    DVector2 normalizedRelativeVelocity = RelativeVelocity.Clone();
                    normalizedRelativeVelocity.Normalize();

                    double formDragTerm     = FormDragCoefficient * FrontalArea;
                    double skinFrictionTerm = SkinFrictionCoefficient * ExposedSurfaceArea;
                    double dragTerm         = formDragTerm + skinFrictionTerm;

                    // Drag ( Fd = 0.5pv^2dA )
                    DVector2 dragForce = normalizedRelativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * dragTerm);

                    // Reject insane forces
                    if (dragForce.Length() < 50000000)
                    {
                        AccelerationD = dragForce / Mass;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void MergeFrom(RadarObstacle other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Id != 0)
     {
         Id = other.Id;
     }
     if (other.relativePosition_ != null)
     {
         if (relativePosition_ == null)
         {
             relativePosition_ = new global::Apollo.Common.Point3D();
         }
         RelativePosition.MergeFrom(other.RelativePosition);
     }
     if (other.relativeVelocity_ != null)
     {
         if (relativeVelocity_ == null)
         {
             relativeVelocity_ = new global::Apollo.Common.Point3D();
         }
         RelativeVelocity.MergeFrom(other.RelativeVelocity);
     }
     if (other.Rcs != 0D)
     {
         Rcs = other.Rcs;
     }
     if (other.Movable != false)
     {
         Movable = other.Movable;
     }
     if (other.Width != 0D)
     {
         Width = other.Width;
     }
     if (other.Length != 0D)
     {
         Length = other.Length;
     }
     if (other.Height != 0D)
     {
         Height = other.Height;
     }
     if (other.Theta != 0D)
     {
         Theta = other.Theta;
     }
     if (other.absolutePosition_ != null)
     {
         if (absolutePosition_ == null)
         {
             absolutePosition_ = new global::Apollo.Common.Point3D();
         }
         AbsolutePosition.MergeFrom(other.AbsolutePosition);
     }
     if (other.absoluteVelocity_ != null)
     {
         if (absoluteVelocity_ == null)
         {
             absoluteVelocity_ = new global::Apollo.Common.Point3D();
         }
         AbsoluteVelocity.MergeFrom(other.AbsoluteVelocity);
     }
     if (other.Count != 0)
     {
         Count = other.Count;
     }
     if (other.MovingFramesCount != 0)
     {
         MovingFramesCount = other.MovingFramesCount;
     }
 }
Ejemplo n.º 5
0
 private void FindPlayerParts()
 {
     jump = GetComponent<JumpControl>();
     characterSprite = GetComponentInChildren<SpriteRenderer>().gameObject;
     frogAnim = characterSprite.GetComponent<AnimateFrog>();
     hand = characterSprite.GetComponentInChildren<AimAtMouse>().gameObject;
     hookshotControl = hand.GetComponentInChildren<HookshotControl>();
     wallSensorRight = GameObject.Find("WallSensorR").GetComponent<WallSensor>();
     wallSensorLeft = GameObject.Find("WallSensorL").GetComponent<WallSensor>();
     ceilingSensor = GameObject.Find("CeilingSensor").GetComponent<CeilingSensor>();
     relative = GameObject.Find("GroundColliders").GetComponent<RelativeVelocity>();
 }