Beispiel #1
0
 public static ElementContainer GetInstance()
 {
     if (instance == null)
     {
         instance = new ElementContainer();
     }
     return(instance);
 }
Beispiel #2
0
 /// <summary>
 /// 根据数据设置资源实体
 /// </summary>
 /// <param name="resEntity"></param>
 public void Set(ResEntity resEntity, GameObject followGo)
 {
     if (resEntity != null)
     {
         resEntitySelf   = resEntity;
         elementTypeSelf = (ElementType)resEntitySelf.type;
         first.GetComponent <Image>().sprite = tuo[resEntity.type];
         first.transform.Find("Icon").GetComponent <Image>().sprite = icon[resEntity.type];
         text1.text = resEntitySelf.data.Count > 0 ? resEntitySelf.data[0].key + ":" + resEntitySelf.data[0].value : "";
         text2.text = resEntitySelf.data.Count > 1 ? resEntitySelf.data[1].key + ":" + resEntitySelf.data[1].value : "";
         text3.text = resEntitySelf.data.Count > 2 ? resEntitySelf.data[2].key + ":" + resEntitySelf.data[2].value : "";
         if (!string.IsNullOrEmpty(resEntitySelf.icon))
         {
             StartCoroutine(LoadPhoto(resEntitySelf.icon));
         }
         if (resEntitySelf.type == 1)
         {
             photo.sprite = personSpriteTemp;
         }
         else if (resEntitySelf.type == 5)
         {
             photo.sprite = sbSpriteTemp;
         }
         if (!string.IsNullOrEmpty(resEntitySelf.lineId))
         {
             try
             {
                 resPointTrans = followGo.transform;
                 resPointTrans.gameObject.AddComponent <ElementPoint>().elementItem = this;
             }
             catch
             {
                 Debug.LogError(resEntitySelf.id);
             }
         }
         else if (!string.IsNullOrEmpty(resEntitySelf.apId))
         {
             try
             {
                 resApTrans = ElementContainer.GetInstance().transform.Find(resEntitySelf.apId).GetComponent <ElementItem>().resPointTrans;
             }
             catch
             {
                 Debug.LogError("请先添加基站的数据");
             }
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 根据当前层级显示UI
        /// </summary>
        /// <param name="level">0-第一层级(默认层级),1-第二层级</param>
        public void SetUIByLevel(int level)
        {
            switch (level)
            {
            case 0:
                Debug.Log("显示第一层级");
                secondPanel.SetActive(false);
                secondLine.GetComponent <Image>().DOFillAmount(0, 0.3f).OnComplete(delegate() {
                    first.SetActive(level == 0 ? true : false);
                    second.SetActive(level == 1 ? true : false);
                }).SetEase(Ease.Linear);
                break;

            case 1:
                Debug.Log("显示第二层级");
                if (ElementContainer.GetInstance().nowElement != null)
                {
                    if (ElementContainer.GetInstance().nowElement != this)
                    {
                        ElementContainer.GetInstance().nowElement.SetUIByLevel(0);
                    }
                }
                first.SetActive(level == 0 ? true : false);
                second.SetActive(level == 1 ? true : false);
                secondLine.GetComponent <Image>().DOFillAmount(1, 0.3f).OnComplete(delegate()
                {
                    secondPanel.SetActive(true);
                }).SetEase(Ease.Linear);
                ElementContainer.GetInstance().nowElement = this;
                if (resEntitySelf.type != 1 && resEntitySelf.type != 2)
                {
                    Camera.main.GetComponent <BLCameraControl>().LookAtResAutoDis(GameObject.Find("Follow_" + resEntitySelf.lineId + "_" + resEntitySelf.id).transform);
                }
                else
                {
                    Camera.main.GetComponent <BLCameraControl>().LookAtPosition(targetPos);
                }
                break;

            default:
                break;
            }
        }
Beispiel #4
0
 // Start is called before the first frame update
 private void Awake()
 {
     instance = this;
 }