Example #1
0
    private void Start()
    {
        Definitions.DefinitionStart();

        //Some rendering initialization
        drawLine = GetComponent <LineRenderer>();

        startCircle  = GetChild(this.gameObject, "StartCircle");
        endCircle    = GetChild(this.gameObject, "EndCircle");
        circleBounds = GetChild(this.gameObject, "CircleBounds");

        startRend        = startCircle.GetComponent <SpriteRenderer>();
        startLineRend    = startCircle.GetComponent <LineRenderer>();
        endRend          = endCircle.GetComponent <SpriteRenderer>();
        circleBoundsRend = circleBounds.GetComponent <LineRenderer>();

        Color drawLineColor  = drawLine.startColor;
        Color startLineColor = startLineRend.startColor;

        //Color circleBoundsColor = circleBoundsRend.startColor;

        drawLineColor.a  = drawLineAlpha;
        startLineColor.a = startLineAlpha;
        //circleBoundsColor.a = circleBoundsAlpha;

        circleBoundsGradient = new Gradient();

        cb_colorKey          = new GradientColorKey[2];
        cb_colorKey[0].color = cb_colorKey[1].color = Color.white;
        cb_colorKey[0].time  = 0;
        cb_colorKey[1].time  = 1;

        cb_alphaKey          = new GradientAlphaKey[5];
        cb_alphaKey[0].alpha = cb_alphaKey[1].alpha = cb_alphaKey[3].alpha = cb_alphaKey[4].alpha = 0;
        cb_alphaKey[2].alpha = circleBoundsMaxAlpha;
        cb_alphaKey[0].time  = 0;
        cb_alphaKey[1].time  = .43f;
        cb_alphaKey[2].time  = .5f;
        cb_alphaKey[3].time  = .57f;
        cb_alphaKey[4].time  = 1;

        circleBoundsGradient.SetKeys(cb_colorKey, cb_alphaKey);
        circleBoundsRend.colorGradient = circleBoundsGradient;

        drawLine.startColor      = drawLine.endColor = drawLineColor;
        startLineRend.startColor = startLineRend.endColor = startLineColor;

        parentCanvas = transform.parent.GetComponent <Canvas>();

        minRadius = Definitions.mainCamera.pixelHeight * minRatio;
        maxRadius = Definitions.mainCamera.pixelHeight * maxRatio;

        startCircleRend    = startCircle.GetComponent <CircleRenderer>();
        circleBoundsCircle = circleBounds.GetComponent <CircleRenderer>();

        //get the size to for rendering the touch min and max radiuses for the player
        startCircleRend._horizRadius    = startCircleRend._vertRadius = (minRadius / Definitions.visiblePixelsPerUnitRatio) * (1 / startCircle.transform.localScale.x) * (1 / transform.localScale.x) * (1 / parentCanvas.transform.localScale.x);
        circleBoundsCircle._horizRadius = circleBoundsCircle._vertRadius = (maxRadius / Definitions.visiblePixelsPerUnitRatio) * (1 / circleBounds.transform.localScale.x) * (1 / transform.localScale.x) * (1 / parentCanvas.transform.localScale.x);
        startCircleRend.CreatePoints();
        circleBoundsCircle.CreatePoints();

        circleBoundsRenderThresholdRadius = maxRadius * circleBoundsRenderThreshold;
    }