예제 #1
0
    public void OnTimer(uint uTimerID)
    {
        for (int i = 0; i < mainRoleBuffList.Count; i++)
        {
            Client.stAddBuff st = (Client.stAddBuff)mainRoleBuffList[i];
            if (st.lTime > 0)
            {
                st.lTime           -= 500;
                mainRoleBuffList[i] = st;
                if (st.lTime <= 0)
                {
                    RemoveBuffByClient(st);
                }
            }
        }

        for (int j = 0; j < targetBuffList.Count; j++)
        {
            Client.stAddBuff st = (Client.stAddBuff)targetBuffList[j];
            if (st.lTime > 0)
            {
                st.lTime         -= 500;
                targetBuffList[j] = st;
                if (st.lTime <= 0)
                {
                    RemoveBuffByClient(st);
                }
            }
        }
    }
예제 #2
0
 void OnEventRemoveBuff(int eventID, stRemoveBuff param)
 {
     if (ClientGlobal.Instance().IsMainPlayer(param.uid))
     {
         for (int i = 0; i < mainRoleBuffList.Count; i++)
         {
             Client.stAddBuff st = (Client.stAddBuff)mainRoleBuffList[i];
             if (st.buffThisID == param.buffThisID)
             {
                 mainRoleBuffList.RemoveAt(i);
                 break;
             }
         }
         stShowBuffInfo info = new stShowBuffInfo();
         info.IsMainRole = true;
         DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info);
     }
     else
     {
         for (int i = 0; i < targetBuffList.Count; i++)
         {
             Client.stAddBuff st = (Client.stAddBuff)targetBuffList[i];
             if (st.buffThisID == param.buffThisID && st.uid == param.uid)
             {
                 targetBuffList.RemoveAt(i);
                 break;
             }
         }
         stShowBuffInfo info = new stShowBuffInfo();
         info.IsMainRole = false;
         DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info);
     }
 }
예제 #3
0
    void OnEeventAddBuff(int eventID, Client.stAddBuff state)
    {
        BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(state.buffid);

        if (db != null)
        {
            if (db.dwShield == 1)
            {//不显示的直接跳过
                return;
            }
        }
        if (ClientGlobal.Instance().IsMainPlayer(state.uid))
        {
            mainRoleBuffList.Insert(0, state);
            stShowBuffInfo info = new stShowBuffInfo();
            info.IsMainRole = true;
            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info);
        }
        else
        {
            Client.IEntity target = ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget();
            if (target != null)
            {
                if (target.GetUID() == state.uid)
                {
                    targetBuffList.Insert(0, state);
                    stShowBuffInfo info = new stShowBuffInfo();
                    info.IsMainRole = false;
                    DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info);
                }
            }
        }
    }
예제 #4
0
    void RefreshBuffIcon(Transform widget, ArrayList stateList)
    {
        if (widget == null)
        {
            return;
        }
        widget.gameObject.SetActive(true);
        for (int i = 0; i < totalBuffIconCount; i++)
        {
            int index = i + 1;
            if (m_nameDic.ContainsKey(index))
            {
                buffname = m_nameDic[index];
            }
            Transform buffTrans = widget.transform.Find(buffname.ToString());
            if (buffTrans != null)
            {
                if (i < stateList.Count)
                {
                    Client.stAddBuff st = (Client.stAddBuff)stateList[i];

                    BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid, (int)st.level);
                    if (db != null)
                    {
                        UILabel label = buffTrans.Find("Label").GetComponent <UILabel>();
                        label.text = "";
                        if (db.dwShield == 0)
                        {
                            buffTrans.gameObject.SetActive(true);
                        }
                        else
                        {
                            buffTrans.gameObject.SetActive(false);
                        }
                    }

                    BuffUICountDown bc = buffTrans.gameObject.GetComponent <BuffUICountDown>();
                    if (bc == null)
                    {
                        bc = buffTrans.gameObject.AddComponent <BuffUICountDown>();
                    }

                    bc.InitLeftTime((uint)st.lTime, db);
                }
                else
                {
                    buffTrans.gameObject.SetActive(false);
                }
            }
        }
    }
예제 #5
0
    public void ClearAllBuff()
    {
        for (int i = 0; i < mainRoleBuffList.Count; i++)
        {
            var buff            = mainRoleBuffList[i];
            Client.stAddBuff st = (Client.stAddBuff)buff;
            RemoveBuffByClient(st);
        }

        for (int i = 0; i < targetBuffList.Count; i++)
        {
            var tarbuff         = targetBuffList[i];
            Client.stAddBuff st = (Client.stAddBuff)tarbuff;
            RemoveBuffByClient(st);
        }
        CommonData.SafeClearList(mainRoleBuffList);
        CommonData.SafeClearList(targetBuffList);
    }
예제 #6
0
    void RemoveBuffByClient(Client.stAddBuff st)
    {
        stRemoveBuff sb = new stRemoveBuff();

        sb.uid        = st.uid;
        sb.buffid     = st.buffid;
        sb.buffThisID = st.buffThisID;
        BuffDataBase bdb = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid);

        if (bdb != null)
        {
            if (bdb.forever == 1)
            {
                return;
            }
        }

        OnEventRemoveBuff(0, sb);
    }
예제 #7
0
    void ShowBuffInfo(Transform container, bool bMainRole)
    {
        if (container == null)
        {
            return;
        }
        int       cellHegiht  = 100;
        Transform buffMessage = container.transform.Find("BuffMessage");

        if (buffMessage == null)
        {
            return;
        }

        ArrayList buffList = BuffManager.MainRoleBuffList;

        if (!bMainRole)
        {
            buffList = BuffManager.TargetBuffList;
        }
        if (buffList.Count == 0)
        {
            buffMessage.gameObject.SetActive(false);
        }
        else
        {
            //  buffMessage.gameObject.SetActive(true);
        }
        if (!buffMessage.gameObject.activeSelf)
        {
            return;
        }
        int       count       = buffList.Count < totalBuffIconCount ? buffList.Count : totalBuffIconCount;
        Transform scrollTrans = buffMessage.Find("ScrollView");

        if (scrollTrans == null)
        {
            return;
        }
        Transform bg = buffMessage.Find("Bg");

        if (bg == null)
        {
            return;
        }
        UIScrollView sv = scrollTrans.GetComponent <UIScrollView>();

        if (sv == null)
        {
            return;
        }
        UIPanel panel   = sv.GetComponent <UIPanel>();
        Vector4 baseVec = panel.baseClipRegion;

        panel.baseClipRegion = new Vector4(baseVec.x, -cellHegiht * (count) / 2 + cellHegiht / 2, baseVec.z, cellHegiht * count);
        panel.clipOffset     = new UnityEngine.Vector2(0, 0);
        UISprite spr = bg.GetComponent <UISprite>();

        if (spr != null)
        {
            spr.height = cellHegiht * count;
        }
        spr.transform.localPosition = new Vector3(0, -cellHegiht * (count - 1) / 2, 0);
        // sv.ResetPosition();


        // Transform gridTrans = scrollTrans.Find("BuffGrid");
        Transform gridTrans = scrollTrans;

        if (gridTrans == null)
        {
            return;
        }

        int childCount = gridTrans.childCount;

        for (int j = buffList.Count; j < childCount; j++)
        {
            string    buffItemName = GetBuffItemName(j);
            Transform itemTrans    = gridTrans.Find(buffItemName);
            if (itemTrans != null)
            {
                itemTrans.gameObject.SetActive(false);
            }
        }
        for (int i = 0; i < buffList.Count; i++)
        {
            Client.stAddBuff st = (Client.stAddBuff)buffList[i];

            BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid, (int)st.level);
            if (db != null)
            {
                GameObject buffItem     = null;
                string     buffItemName = GetBuffItemName(i);
                Transform  itemTrans    = gridTrans.Find(buffItemName);
                if (itemTrans != null)
                {
                    buffItem = itemTrans.gameObject;
                }
                else
                {
                    buffItem  = GameObject.Instantiate(m_trans_BuffItemInfo.gameObject) as GameObject;
                    itemTrans = buffItem.transform;
                }

                buffItem.transform.parent = sv.transform;//gridTrans;
                itemTrans.localScale      = Vector3.one;
                itemTrans.localRotation   = Quaternion.identity;
                itemTrans.localPosition   = new Vector3(0, -cellHegiht * i, 0);
                //  UIGrid grid = gridTrans.GetComponent<UIGrid>();

                buffItem.gameObject.SetActive(true);
                // grid.repositionNow = true;
                buffItem.name = buffItemName;
                UIDragScrollView dragScroll = buffItem.GetComponent <UIDragScrollView>();
                if (dragScroll == null)
                {
                    dragScroll = buffItem.AddComponent <UIDragScrollView>();
                }
                dragScroll.scrollView = sv;
                BuffItemInfo info = buffItem.GetComponent <BuffItemInfo>();
                if (info == null)
                {
                    info = buffItem.AddComponent <BuffItemInfo>();
                }

                info.InitBuffItemInfo(db, st.lTime);
            }
        }
    }