コード例 #1
0
        public void SetData(VirusData v)
        {
            this.v     = v;
            title.text = v.name;

            if (v.prefabPath != mLastPrefabPath)
            {
                if (mVirus != null)
                {
                    DestroyImmediate(mVirus.gameObject);
                }

                var prefab = ResourceUtil.Load <VirusBase>(v.prefabPath);
                if (mVirus == null && prefab != null)
                {
                    mVirus = Instantiate(prefab);
                    if (mVirus != null)
                    {
                        mVirus.rectTransform.SetParent(modelRoot, false);
                        mVirus.GetComponent <Collider2D>().enabled = false;
                        mVirus.stunEffect.gameObject.SetActive(false);
                        mVirus.cureEffect.gameObject.SetActive(false);
                        mColorIndex = UnityEngine.Random.Range(0, 6);
                        mVirus.SetColor(mColorIndex);
                    }
                }

                mLastPrefabPath = v.prefabPath;
            }

            if (mVirus != null)
            {
                mVirus.stunEffect.Stop(true);
            }
            if (v.isMax)
            {
                fill.value = 1f;
            }
            else
            {
                fill.value = v.progress;
            }
            if (v.isUnlock)
            {
                if (v.isReceivable)
                {
                    radioState.Radio(2);
                }
                else
                {
                    radioState.Radio(1);
                }
            }
            else
            {
                radioState.Radio(0);
            }
        }
コード例 #2
0
        private void Refresh()
        {
            if (v.prefabPath != mLastPrefabPath)
            {
                if (mVirus != null)
                {
                    DestroyImmediate(mVirus.gameObject);
                }

                var prefab = ResourceUtil.Load <VirusBase>(v.prefabPath);
                if (mVirus == null && prefab != null)
                {
                    mVirus = Instantiate(prefab);
                    if (mVirus != null)
                    {
                        mVirus.rectTransform.SetParent(modelRoot, false);
                        mVirus.SetColor(ColorIndex);
                    }
                }
                mLastPrefabPath = v.prefabPath;
            }

            if (mVirus != null)
            {
                mVirus.stunEffect.Stop(true);
            }
            if (v.isMax)
            {
                fill.value    = 1f;
                fillText.text = "";
                receiveBtn.SetData(LTKey.COLLECT_FINISH.LT(), true, false);
            }
            else
            {
                fill.value    = v.progress;
                fillText.text = $"{v.collectCount - v.startCount}/{v.endCount - v.startCount}";
                receiveBtn.SetData(LTKey.RECEIVE.LT(), !v.isReceivable, false);
            }
            diamondCount.text = "x" + D.I.GetBookDiamond(v.id);
            title.text        = v.name;
            tips.text         = v.tips;
            description.text  = v.description;
            adReceiveRadio.Radio(!D.I.noAd && v.needPlayAd);
        }