Exemplo n.º 1
0
    public void HuidigPlusTrap(Vector2 van, Vector2 tot)
    {
        SpriteRenderer[] spriteRenderers = SpriteRenderers();
        float            xMostLeft       = spriteRenderers.Min(x => x.transform.position.x);
        float            xMostRight      = spriteRenderers.Max(x => x.transform.position.x);
        float            yLowest         = spriteRenderers.Min(x => x.transform.position.y);
        float            yHighest        = spriteRenderers.Max(x => x.transform.position.y);

        foreach (SpriteRenderer spriteRenderer in spriteRenderers)
        {
            float procentueleLocatieX = MathS.ProcentueleLocatie_VoorFloats(xMostLeft, xMostRight, spriteRenderer.transform.position.x);
            float x = MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(van.x, tot.x, procentueleLocatieX);

            float procentueleLocatieY = MathS.ProcentueleLocatie_VoorFloats(yLowest, yHighest, spriteRenderer.transform.position.y);
            float y = MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(van.y, tot.y, procentueleLocatieX);

            RestorePoint_Position restorePoint_Position = spriteRenderer.GetComponent <RestorePoint_Position>();
            x = x + restorePoint_Position.Stored.x;
            y = y + restorePoint_Position.Stored.y;

            float z = 1;

            spriteRenderer.transform.position = new Vector3(x, y, z);
        }
    }
    public void SetOplopendeScaleHorizontaal(Vector2 van, Vector2 tot, bool isPlusHuidige)
    {
        SpriteRenderer[] spriteRenderers = SpriteRenderers();
        float            xLeft           = spriteRenderers.Min(x => x.transform.position.x);
        float            xRight          = spriteRenderers.Max(x => x.transform.position.x);

        float yLeft  = spriteRenderers.Min(x => x.transform.position.y);
        float yRight = spriteRenderers.Max(x => x.transform.position.y);

        foreach (SpriteRenderer spriteRenderer in spriteRenderers)
        {
            float procentueleLocatieX = MathS.ProcentueleLocatie_VoorFloats(xLeft, xRight, spriteRenderer.transform.position.x);
            float x = MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(van.x, tot.x, procentueleLocatieX);

            float procentueleLocatieY = MathS.ProcentueleLocatie_VoorFloats(yLeft, yRight, spriteRenderer.transform.position.y);
            float y = MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(van.y, tot.y, procentueleLocatieX);

            if (isPlusHuidige)
            {
                RestorePoint_Scale restorePoint_Scale = spriteRenderer.GetComponent <RestorePoint_Scale>();
                x = x + restorePoint_Scale.Stored.x;
                y = y + restorePoint_Scale.Stored.y;
            }

            float z = 1;

            spriteRenderer.transform.localScale = new Vector3(x, y, z);
        }
    }
Exemplo n.º 3
0
    public void HuidigPlusStretch(Vector2 van, Vector2 tot)
    {
        Vector2[] positieRange     = new Vector2[] { van, tot };
        float     erbijMeestLinks  = positieRange.Min(x => x.x);
        float     erbijMeestRechts = positieRange.Max(x => x.x);
        float     erbijMeestOnder  = positieRange.Min(x => x.y);
        float     erbijMeestBoven  = positieRange.Max(x => x.y);

        SpriteRenderer[] spriteRenderers = SpriteRenderers();
        float            xMostLeft       = spriteRenderers.Min(x => x.transform.position.x);
        float            xMostRight      = spriteRenderers.Max(x => x.transform.position.x);
        float            xMostDown       = spriteRenderers.Min(x => x.transform.position.y);
        float            xMostUp         = spriteRenderers.Max(x => x.transform.position.y);

        foreach (SpriteRenderer spriteRenderer in spriteRenderers)
        {
            float procentueleLocatie_Horizontaal = MathS.ProcentueleLocatie_VoorFloats(xMostLeft, xMostRight, spriteRenderer.transform.position.x);
            float plusX = MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(erbijMeestLinks, erbijMeestRechts, procentueleLocatie_Horizontaal);

            float procentueleLocatie_Verticaal = MathS.ProcentueleLocatie_VoorFloats(xMostDown, xMostUp, spriteRenderer.transform.position.y);
            float plusY = MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(erbijMeestOnder, erbijMeestBoven, procentueleLocatie_Verticaal);

            RestorePoint_Position restorePoint_Position = spriteRenderer.GetComponent <RestorePoint_Position>();

            spriteRenderer.transform.position = new Vector3(
                restorePoint_Position.Stored.x + plusX,
                restorePoint_Position.Stored.y + plusY,
                restorePoint_Position.Stored.z);
        }

        MathS.Getal_OpBasisVan_ProcentueleLocatie_VoorFloats(0, 0, 0);
        MathS.ProcentueleLocatie_VoorFloats(0, 0, 0);

        float yLowest  = spriteRenderers.Min(x => x.transform.position.y);
        float yHighest = spriteRenderers.Max(x => x.transform.position.y);
    }