Beispiel #1
0
        public override void update(AICharacter character)
        {
            IGravityClient gravityClient  = character.getEntity().getGravityClient();
            KeysPressed    keysPressed    = character.getEntity().getKeysPressed();
            RayInformation rayInformation = character.getEntity().getGravityClient().getRayInformation();
            RayHitboxes    rayHitboxes    = gravityClient.getRayHitboxes();

            gravityClient.getRayInformation().checkRaysFront(gravityClient, 0.0f, character.getEntity().getTransform().eulerAngles.z + 0.0f, layermask, false);
            gravityClient.getRayInformation().checkRaysBelow(gravityClient, 0.0f, character.getEntity().getTransform().eulerAngles.z + 270.0f, layermask, false);

            float minimalSpaceBetweenTileBelow = rayInformation.MinimalSpaceBetweenTileBelow;
            float topFrontDistance             = (rayHitboxes.HitTopFront.distance * 0.9f);
            bool  turned = false;

            gravityClient.getRayInformation().checkRaysFront(gravityClient, 0.0f, character.getEntity().getTransform().eulerAngles.z + 0.0f, layermask, true);

            keysPressed = turnIfWallIsNear(gravityClient, topFrontDistance,
                                           rayInformation.MinimalSpaceBetweenTileFront, keysPressed, out turned);

            if (!turned && (rayHitboxes.HitMiddleBelow.collider.tag.CompareTo("Slope") != 0))
            {
                keysPressed = turnIfOnAnEdge(keysPressed, minimalSpaceBetweenTileBelow, character);
            }
            character.setKeysPressed(keysPressed);
        }