Esempio n. 1
0
        public virtual void AssertEqualsExpected(FeatureInfo expected)
        {
            if (!BoundingBox.Equals(expected.BoundingBox, boundingBoxTolerance))
            {
                throw new BoundingBoxException($"Bounding boxes aren't equal; expected {expected.BoundingBox}, got {BoundingBox}");
            }

            if (!MathUtil.EpsilonEqual(Extrusion, expected.Extrusion, extrusionTolerance))
            {
                throw new CumulativeExtrusionException($"Cumulative extrusion amounts aren't equal; expected {expected.Extrusion}, got {Extrusion}");
            }

            if (!MathUtil.EpsilonEqual(Duration, expected.Duration, durationTolerance))
            {
                throw new CumulativeDurationException($"Cumulative durations aren't equal; expected {expected.Duration}, got {Duration}");
            }

            if (!MathUtil.EpsilonEqual(Distance, expected.Distance, distanceTolerance))
            {
                throw new CumulativeDistanceException($"Cumulative distances aren't equal; expected {expected.Distance}, got {Distance}");
            }

            if (!CenterOfMass.EpsilonEqual(expected.CenterOfMass, centerOfMassTolerance))
            {
                throw new CenterOfMassException($"Centers of mass aren't equal; expected {expected.CenterOfMass}, got {CenterOfMass}");
            }
        }
Esempio n. 2
0
    Steering Pursue(GameObject target)
    {
        Vector3 direction   = target.transform.position - transform.position;
        float   dist        = direction.magnitude;
        float   speed       = cVel.magnitude;
        float   preditction = 0f;

        if (speed <= dist / maxPrediction)
        {
            preditction = maxPrediction;
        }
        else
        {
            maxPrediction = dist / speed;
        }
        Vector3 tVel = Vector3.zero;

        if (target.GetComponent <Movement> ())
        {
            Movement temp = target.GetComponent <Movement> ();
            tVel = temp.cVel;
        }
        else if (target.GetComponent <CenterOfMass> ())
        {
            CenterOfMass temp = target.GetComponent <CenterOfMass> ();
            tVel = temp.Avg_Vel;
        }
        //Face (target.transform.position);
        //Seek (target.transform.position + tVel * preditction);
        Debug.DrawLine(transform.position, target.transform.position + tVel * preditction, Color.red);
        return(Seek(target.transform.position + tVel * preditction));
    }
Esempio n. 3
0
    void SetCenterOfMass()
    {
        Vector3 v = CenterOfMass.getCenterOfMass(totalMass, massCenter, rb.mass, transform.position);

        totalMass += rb.mass;
        massCenter = v;

        Debug.Log("Mass: " + totalMass + " center: " + massCenter);

        Debug.DrawRay(v, Vector3.down, Color.white, 5f);
    }
Esempio n. 4
0
 public AIHelper(Robot robotEntity)
 {
     robot = robotEntity;
     com = new CenterOfMass();
     previousTrajectoryPoint = CoordinateHelper.INVALID_POINT;
 }
Esempio n. 5
0
 public AIHelper(Robot robotEntity)
 {
     robot = robotEntity;
     com   = new CenterOfMass();
     previousTrajectoryPoint = CoordinateHelper.INVALID_POINT;
 }
Esempio n. 6
0
 public Group(byte groupId)
 {
     id = groupId;
     centerOfMass = new CenterOfMass();
 }
 private void OnEnable()
 {
     centerOfMass = (CenterOfMass)target;
 }
Esempio n. 8
0
        void FixedUpdate()
        {
            HandleRigidbody();//just dealing with some rigidbody bs here

            if (!Active)
            {
                return;
            }
            if (overrides)
            {
                return;
            }
            if (joystick == null)
            {
                Debug.LogError("Unable to find joystick, has not been assigned to player");
                return;
            }


            if (canMove)
            {
                isGrounded = SetIsGrounded();
                if (isGrounded)
                {
                    parachuteMode = false;
                }

                if (pogoMode && oldIsGrounded != isGrounded)
                {
                    if (isGrounded)
                    {
                        OnPogoGrounded();
                    }
                    else
                    {
                        OnPogoLaunched();
                    }
                    oldIsGrounded = isGrounded;
                }

                if (hasJumped && !isGrounded)
                {
                    hasJumped = false;
                }

                if (isGrounded)
                {
                    if (pogoMode)
                    {
                        CheckPogoBounce();
                        doJump = false;
                    }
                    else
                    {
                        doJump = doingSwipe && input.GetUp();
                    }
                }
                else
                {
                    doJump = false;
                }


                //handle some change COM stuff
                CenterOfMass newCOM = GetCurrentCenterOfMass();
                if (newCOM != currentCenterOfMass)
                {
                    changingCOM = true;
                }
                if (isGrounded)
                {
                    changingCOM = false;
                }
                currentCenterOfMass = newCOM;


                HandleRotation();
                HandleMovement();
                HandleSubStuff();


                if (joystick.active)
                {
                    tsi = 0f;
                }
                else
                {
                    tsi += Time.fixedDeltaTime;
                }
            }


            if (prevCanMove != canMove)
            {
                joystick.ready = canMove;
            }
            prevCanMove = canMove;


            //turns off wind renderers and resets gravity strength
            if (isGrounded)
            {
                gravStrength = defaultGravityStrength;

                GameObject windTrail = transform.GetChild(4).gameObject;

                if (windTrail != null)
                {
                    for (int i = 0; i < windTrail.transform.childCount; i++)
                    {
                        GameObject wind = windTrail.transform.GetChild(i).gameObject;
                        wind.GetComponent <TrailRenderer>().emitting = false;
                    }
                }
            }
        }