예제 #1
0
        //添加buff
        public void AddBuff(BaseBuff buff)
        {
            int buffID = buff.attributes.BuffID;

            Debug.Log("BuffID=" + buffID);
            //没有这个buff组,创建一个
            if (buffMap.ContainsKey(buffID) == false)
            {
                buffMap [buffID] = new List <BaseBuff> ();
            }
            //判断是否允许叠加, 必须最大层数
            if (buff.attributes.allowOverlay == true && buffMap[buffID].Count < buff.attributes.count)
            {
                buffMap[buffID].Add(buff);
                buff.OnAddBuff();
                AddBuffEvtArg arg = new AddBuffEvtArg();
                arg.buffID   = buffID;
                arg.casterID = buff.caster.GetInstanceID();
                arg.ownerID  = buff.Owner.GetInstanceID();
                FireEvent(this, EventType.EVT_ADD_BUFF, arg);
            }
            else
            {
                buffMap [buffID].Clear();
                buffMap [buffID].Add(buff);
                buff.OnAddBuff();
                AddBuffEvtArg arg = new AddBuffEvtArg();
                arg.buffID   = buffID;
                arg.casterID = buff.caster.GetInstanceID();
                arg.ownerID  = buff.Owner.GetInstanceID();
                FireEvent(this, EventType.EVT_ADD_BUFF, arg);
            }
        }
예제 #2
0
        void OnAddBuff(object sender, EventArgs arg)
        {
            AddBuffEvtArg _arg   = arg as AddBuffEvtArg;
            int           buffID = _arg.buffID;

            if (Global.BuffData.ContainsKey(buffID))
            {
                BuffItem buff = Global.BuffData [buffID] as BuffItem;
                Debug.Log("buff icon = " + buff.iconName);
                if (buffIconMap.ContainsKey(buff.BuffID))
                {
                    return;
                }
                GameObject obj = Global.GetPrefab(buff.iconName);
                if (obj == null)
                {
                    Debug.LogWarning("未能读取到" + buff.iconName);
                    return;
                }

                Debug.Log(obj.name);
                GameObject imgObj = (GameObject)Instantiate(obj);
                Image      img    = obj.GetComponent <Image> ();
                img.enabled = false;
                buffIconMap.Add(buffID, imgObj);
                isDirty = true;
            }
            else
            {
                Debug.Log("OnAddBuff失败!没找到Buff");
            }
        }