Ejemplo n.º 1
0
        private IEnumerator _bornCoroutine()
        {
            RectTransform rectTransform = this.GetComponent <RectTransform> ();

            rectTransform.localScale = Vector3.zero;

            RectTransform bgRectTransform = rectTransform.FindChild("BlockBackground") as RectTransform;
            RawImage      bg = bgRectTransform.GetComponent <RawImage> ();

            bg.color = this.MinBgColor;

            RectTransform textRectTransform = rectTransform.FindChild("BlockText") as RectTransform;
            Text          text = textRectTransform.GetComponent <Text> ();

            text.text = "" + HexagonGameBoard.getBlockNum(this.UnitNum, this.Times);


            while (this._progress < this._duration)
            {
                rectTransform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, this._progress / this._duration);
                this._progress          += Time.deltaTime;
                yield return(0);
            }
            rectTransform.localScale = Vector3.one;
        }
Ejemplo n.º 2
0
        private IEnumerator _growCoroutine()
        {
            RectTransform rectTransform     = this.GetComponent <RectTransform> ();
            RectTransform textRectTransform = rectTransform.FindChild("BlockText") as RectTransform;
            RectTransform bgRectTransform   = rectTransform.FindChild("BlockBackground") as RectTransform;

            Text     text = textRectTransform.GetComponent <Text> ();
            RawImage bg   = bgRectTransform.GetComponent <RawImage> ();

            this._times++;
            text.text = "" + HexagonGameBoard.getBlockNum(this.UnitNum, this.Times);

            rectTransform.localScale = Vector3.one;

            float   scaleFactor = 2.0f;
            Vector3 maxScale    = new Vector3(scaleFactor, scaleFactor, scaleFactor);

            while (this._progress < this._duration / 2)
            {
                textRectTransform.localScale = Vector3.Lerp(Vector3.one, maxScale, this._progress / this._duration / 2);

                float colorFactor = Mathf.Lerp(this._times - 1, this._times, this._progress / this._duration);
                bg.color = Color.Lerp(this.MinBgColor, this.MaxBgColor, colorFactor / this.MaxTimes);

                this._progress += Time.deltaTime;
                yield return(0);
            }
            while (this._progress < this._duration)
            {
                textRectTransform.localScale = Vector3.Lerp(maxScale, Vector3.one, (this._progress - this._duration / 2) / this._duration / 2);

                float colorFactor = Mathf.Lerp(this._times - 1, this._times, this._progress / this._duration);
                bg.color = Color.Lerp(this.MinBgColor, this.MaxBgColor, colorFactor / this.MaxTimes);

                this._progress += Time.deltaTime;
                yield return(0);
            }
            textRectTransform.localScale = Vector3.one;
        }