Ejemplo n.º 1
0
    public void Walk(float axis)
    {
        velocity.x = speed.x * axis;

        lastPosition = currPosition;
        currPosition = CharacterCont.GetCharacterPosition();

        if (axis < 0)
        {
            scale     = new Vector2(-1f, 1f);
            direction = Direction.Left;
        }
        else if (axis > 0)
        {
            scale     = new Vector2(1f, 1f);
            direction = Direction.Right;
        }

        world.checkpointManager.Check();

        if (cbOnWalk != null)
        {
            cbOnWalk(this);
        }
    }
Ejemplo n.º 2
0
    public bool IsCharacterAtEdge()
    {
        Vector3 characterPos    = CharacterCont.GetCharacterPosition();
        Vector3 leftCameraEdge  = CameraController.GetLeftEdgePosition();
        Vector3 rightCameraEdge = CameraController.GetRightEdgePosition();

        // FIXME: Make constant offsets.
        if (characterPos.x <= leftCameraEdge.x + 2f && direction == Direction.Left ||
            characterPos.x >= rightCameraEdge.x - 2f && direction == Direction.Right
            )
        {
            return(true);
        }

        return(false);
    }