예제 #1
0
        /// <summary>
        /// 添加BUFF
        /// </summary>
        /// <param name="self"></param>
        /// <param name="id"></param>
        /// <param name="timestamp"></param>
        /// <returns></returns>
        public static Buff AddBuff(this BuffComponent self, int id, long timestamp)
        {
            BuffConfig conf = BuffConfigCategory.Instance.Get(id);

            if (self.Groups.ContainsKey(conf.Group))
            {
                var old = self.Groups[conf.Group];
                if (old.Config.Priority > conf.Priority)
                {
                    Log.Info("添加BUFF失败,优先级" + old.Config.Id + " > " + conf.Id);
                    return(null); //优先级低
                }
                Log.Info("优先级高或相同,替换旧的");
                self.Remove(self.Groups[conf.Group].Id);
            }

            Buff buff = self.AddChild <Buff, int, long>(id, timestamp, true);

            self.Groups[conf.Group] = buff;
            EventSystem.Instance.Publish(new EventType.AfterAddBuff()
            {
                Buff = buff
            });
            return(buff);
        }
예제 #2
0
        /// <summary>
        /// 初始化(第一次创建Unit走这里,因为服务端穿的属性是加了BUFF后的属性,所以这里创建BUFF时不叠加属性)
        /// </summary>
        /// <param name="self"></param>
        /// <param name="buffIds"></param>
        /// <param name="buffTimestamps"></param>
        public static void Init(this BuffComponent self, List <int> buffIds, List <long> buffTimestamps)
        {
            self.Groups = DictionaryComponent <int, Buff> .Create();

            self.ActionControls = DictionaryComponent <int, int> .Create();

            for (int i = 0; i < buffIds.Count; i++)
            {
                var        id        = buffIds[i];
                var        timestamp = buffTimestamps[i];
                BuffConfig conf      = BuffConfigCategory.Instance.Get(id);
                if (self.Groups.ContainsKey(conf.Group))
                {
                    var old = self.Groups[conf.Group];
                    if (old.Config.Priority > conf.Priority)
                    {
                        Log.Info("添加BUFF失败,优先级" + old.Config.Id + " > " + conf.Id);
                        continue; //优先级低
                    }
                    Log.Info("优先级高或相同,替换旧的");
                    self.Remove(self.Groups[conf.Group].Id);
                }

                Buff buff = self.AddChild <Buff, int, long, bool>(id, timestamp, true);//走这里不叠加属性
                self.Groups[conf.Group] = buff;
                EventSystem.Instance.Publish(new EventType.AfterAddBuff()
                {
                    Buff = buff
                });
            }
        }
예제 #3
0
파일: BuffConfig.cs 프로젝트: 526077247/ET
 public override void EndInit()
 {
     for (int i = 0; i < list.Count; i++)
     {
         BuffConfig config = list[i];
         config.EndInit();
         this.dict.Add(config.Id, config);
     }
     this.AfterEndInit();
 }
예제 #4
0
        /// <summary>
        /// 通过Buff配置表的id移除buff
        /// </summary>
        /// <param name="self"></param>
        /// <param name="id"></param>
        public static void RemoveByConfigId(this BuffComponent self, int id)
        {
            BuffConfig config = BuffConfigCategory.Instance.Get(id);

            if (self.Groups.ContainsKey(config.Group))
            {
                Buff buff = self.GetChild <Buff>(self.Groups[config.Group].Id);
                if (buff.ConfigId == id)
                {
                    self.Groups.Remove(buff.Config.Group);
                    buff?.Dispose();
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 通过Buff配置表的id取
        /// </summary>
        /// <param name="self"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Buff GetByConfigId(this BuffComponent self, int id)
        {
            BuffConfig config = BuffConfigCategory.Instance.Get(id);

            if (self.Groups.ContainsKey(config.Group))
            {
                Buff buff = self.GetChild <Buff>(self.Groups[config.Group].Id);
                if (buff.ConfigId == id)
                {
                    return(buff);
                }
            }

            return(null);
        }