Beispiel #1
0
        public virtual void moveEntity(IGravityClient object_, float moveDistance)
        {
            Vector3 newPosition = object_.getTransform().position;

            Vector3 distance = Quaternion.Euler(
                new Vector3(object_.getTransform().eulerAngles.x,
                            object_.getTransform().eulerAngles.y,
                            object_.getTransform().eulerAngles.z)) * new Vector3(0.0f, moveDistance, 0.0f);

            distanceTravelled += distance;
            newPosition       += distance;
            object_.getTransform().position = newPosition;
        }
Beispiel #2
0
        public virtual bool checkObjectHitsFloor(IGravityClient object_)
        {
#if USE_3D_RAYS
            RayInformation3D rayInformation = object_.getRayInformation3D();
            RayHitboxes3D    rayHitboxes    = object_.getRayHitboxes3D();
#else
            RayInformation rayInformation = object_.getRayInformation();
            RayHitboxes    rayHitboxes    = object_.getRayHitboxes();
#endif
            rayInformation.checkRaysBelow(object_, 0.0f,
                                          object_.getTransform().eulerAngles.z + 270.0f,
                                          layermask);
            float correction = 0.0f;
            float minimalSpaceBetweenTileBelow = rayInformation.MinimalSpaceBetweenTileBelow;

            bool objectOnFloor = (rayHitboxes.DistanceBelow <
                                  minimalSpaceBetweenTileBelow * rayInformation.BelowTolerance) ? true :
                                 ((multiplyYVelocityDown * yFallDistance) > (rayHitboxes.DistanceBelow -
                                                                             minimalSpaceBetweenTileBelow)) ? true : false;

            if (objectOnFloor)
            {
                correction = -(rayHitboxes.DistanceBelow -
                               rayInformation.MinimalSpaceBetweenTileBelow);
                moveEntity(object_, correction);
            }

            return(objectOnFloor);
        }
Beispiel #3
0
        public virtual bool checkObjectHitsPlatform(float yModifier, IGravityClient object_)
        {
#if USE_3D_RAYS
            RayInformation3D rayInformation = object_.getRayInformation3D();
            RayHitboxes3D    rayHitboxes    = object_.getRayHitboxes3D();
#else
            RayInformation rayInformation = object_.getRayInformation();
            RayHitboxes    rayHitboxes    = object_.getRayHitboxes();
#endif
            rayInformation.checkRaysTop(object_, 0.0f, object_.getTransform().eulerAngles.z + 90.0f, layermask);
            bool objectHitTop = (rayHitboxes.DistanceTop <
                                 rayInformation.MinimalSpaceBetweenTileTop) ? true :
                                (yModifier > (rayHitboxes.DistanceTop -
                                              rayInformation.MinimalSpaceBetweenTileTop)) ? true : false;

            if (objectHitTop)
            {
                float correction = -(rayHitboxes.DistanceTop -
                                     rayInformation.MinimalSpaceBetweenTileTop);
                moveEntity(object_, correction);
                checkObjectHitsFloor(object_);
            }
            return(objectHitTop);
        }