示例#1
0
    public override void OnUIEventHandler(EventId eventId, params object[] args)
    {
        if (eventId == EventId.OnSkillPop)
        {
            if (BattleSystem.Instance.battleData.silent)
            {
                return;
            }

            POP_TYPE type = (POP_TYPE)args [0];
            string   text = (string)args [1];
            Vector3  pos  = Vector3.zero;
            if (type != POP_TYPE.POP_NORMAL)
            {
                pos = (Vector3)args [2];

                PopItem item = new PopItem();
                item.poptext = text;
                item.poptime = 2f;
                item.type    = type;
                if (objList.Count > 0)
                {
                    item.popobj = objList.Dequeue();
                }
                else
                {
                    item.popobj = GameObject.Instantiate(popTemp);
                }
                item.popobj.transform.parent     = popTemp.transform.parent;
                item.popobj.transform.localScale = Vector3.one;
                Vector3 sceenpos = Camera.main.WorldToScreenPoint(pos);
                Vector3 finalpos = UICamera.mainCamera.ScreenToWorldPoint(sceenpos);
                finalpos.z = 0;
                //Debug.Log (string.Format ("Node pos:{0},UI pos:{1}",pos ,finalpos));
                item.popobj.transform.position = finalpos;
                item.popobj.SetActive(true);
                UILabel label = item.popobj.GetComponentInChildren <UILabel> ();
                label.text = item.poptext;
                popMap.Add(item);
            }
            else
            {
                popCenter.SetActive(true);
                popCenterText.text = text;
                centerTipTime      = 2f;
                popCenter.transform.localPosition = new Vector3(0, 362f, 0);
            }
        }
    }
示例#2
0
    public static void ShowSimpleItem(string str, POP_TYPE type = POP_TYPE.normal, float time = 1.5f)
    {
        GameObject item;
        int        cacheCount = _cacheList.Count;

        if (cacheCount > 0)
        {
            item = _cacheList[cacheCount - 1];
            _cacheList.RemoveAt(cacheCount - 1);
        }
        else
        {
            item = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/Utils/PopItem"));
            item.transform.SetParent(_parent, false);
        }
        _showingList.Add(item);

        Color color = Color.white;

        switch (type)
        {
        case POP_TYPE.normal:
            color = Color.white;
            break;

        case POP_TYPE.warning:
            color = new Color(212 / 255f, 0f, 92 / 255f, 1f);
            break;
        }

        Text txt = item.transform.FindChild("Text").GetComponent <Text>();

        txt.text  = str;
        txt.color = color;

        RectTransform rectTr = item.GetComponent <RectTransform>();

        rectTr.anchoredPosition = Vector2.zero;

        Tweener tweener = rectTr.DOAnchorPosY(100, time);

        tweener.OnComplete(HideItem);
    }
示例#3
0
 public void ChangePopType(POP_TYPE target)
 {
     PopType = target;
 }