Esempio n. 1
0
    public void DoUpdate(float deltaTime)
    {
        if (!IsAlive || !gameObject.activeInHierarchy)
        {
            return;
        }
        for (int i = 0, length = listBuff.Count; i < length; ++i)
        {
            if (listBuff[i].IsEnd)
            {
                listRemoveBuff.Add(listBuff[i]);
            }
            else
            {
                listBuff[i].DoUpdate(deltaTime);
            }
        }
        for (int i = 0, length = listRemoveBuff.Count; i < length; ++i)
        {
            BuffBase removeBuff = listRemoveBuff[i];
            listBuff.Remove(removeBuff);
            removeBuff.Remove(false);
        }
        listRemoveBuff.Clear();
        for (int i = 0, length = listResumeSkillEnergy.Count; i < length; ++i)
        {
            ResumeEnergy single = listResumeSkillEnergy[i];
            if (single)
            {
                single.DoUpdate(deltaTime);
            }
        }
        for (int i = 0, length = listSearchEnemy.Count; i < length; ++i)
        {
            SearchEnemyBase single = listSearchEnemy[i];
            if (single)
            {
                single.DoUpdate(deltaTime);
            }
        }
        for (int i = 0, length = listSkills.Count; i < length; ++i)
        {
            SkillBase single = listSkills[i];
            if (single)
            {
                single.DoUpdate(deltaTime);
            }
        }

        OnUpdate(deltaTime);
        UIHeadInfo.DoUpdate(deltaTime);
        for (int i = 0, length = listExtModules.Count; i < length; ++i)
        {
            InteractiveObjExt single = listExtModules[i];
            if (single)
            {
                single.DoUpdate(deltaTime);
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 玩家是否已经有此buff
    /// </summary>
    /// <param name="actor"></param>
    /// <param name="buff"></param>
    /// <returns></returns>
    private bool IsAdd(Actor actor, BuffBase buff)
    {
        // BuffData oldBuff = actor.ActorBuff.GetBuffByBaseID(buff.BuffID);
        //  =====  》角色的buff
        BuffData oldBuff = null;

        if (oldBuff != null)
        {
            switch (buff.BuffOverlap)
            {
            case BuffOverlap.ResterTime:
                oldBuff.ResterTime();
                break;

            case BuffOverlap.StackedLayer:
                oldBuff.AddLayer();
                break;

            case BuffOverlap.StackedTime:
                oldBuff.ChangePersistentTime(oldBuff.GetPersistentTime + buff.Time);
                break;

            default:
                break;
            }
            return(true);
        }
        return(false);
    }
Esempio n. 3
0
    public BuffBase GetBuff(int buffID)
    {
        BuffBase ret = null;

        m_dicBuff.TryGetValue(buffID, out ret);
        return(ret);
    }
Esempio n. 4
0
 public void AddBuff(BuffBase buff)
 {
     if (!m_BuffList.Contains(buff))
     {
         m_BuffList.Add(buff);
     }
 }
 public virtual bool Buff(BuffBase buffBase, float duration)
 {
     buffs.Add(new ActiveBuff {
         buff = buffBase, duration = Time.time + duration
     });
     return(true);
 }
Esempio n. 6
0
 /// <summary>
 /// 移除子Buff
 /// </summary>
 /// <param name="buff"></param>
 public void RemoveSubBuff(BuffBase buff)
 {
     if (m_SubBuffList != null && m_SubBuffList.Contains(buff))
     {
         m_SubBuffList.Remove(buff);
     }
 }
Esempio n. 7
0
 public void RemoveBuff(BuffBase buff)
 {
     if (m_BuffList.Contains(buff))
     {
         m_BuffList.Remove(buff);
     }
 }
    /// <summary>
    /// 玩家是否已经有此buff
    /// </summary>
    /// <param name="mActor"></param>
    /// <param name="buffBase"></param>
    /// <returns></returns>
    private bool IsAdd(Actor mActor, BuffBase buffBase)
    {
        ActorBuff oldBuff = mActor.mActorBuffManager.GetBuffByBaseID(buffBase.BuffID);

        if (oldBuff != null)
        {
            Debug.Log("IsAdd===>BuffID:" + buffBase.BuffID + ",叠加类型:" + buffBase.buffOverlapType);
            switch (buffBase.buffOverlapType)
            {
            case BuffOverlapType.ResetTime:
                oldBuff.ResetTime();
                break;

            case BuffOverlapType.AddLayer:
                oldBuff.AddLayer();
                break;

            case BuffOverlapType.AddTime:
                oldBuff.ChangeTotalFrame(oldBuff.GetTotalFrame + buffBase.TotalFrame);
                break;

            default:
                break;
            }
            return(true);
        }
        return(false);
    }
Esempio n. 9
0
    public static BuffBase GetBuff(int buffID, Entity owner, Entity caster)
    {
        HashSet <BuffBase> hash = null;

        if (!m_dicBuffPool.TryGetValue(buffID, out hash))
        {
            hash = new HashSet <BuffBase>();
            m_dicBuffPool.Add(buffID, hash);
        }

        BuffBase buff = null;
        var      e    = hash.GetEnumerator();

        if (e.MoveNext())
        {
            buff = e.Current;
            hash.Remove(buff);
            buff.Reset(buffID, owner, caster);
        }
        else
        {
            buff = CreateBuff(buffID, owner, caster);
        }
        return(buff);
    }
Esempio n. 10
0
        public static void Proc(EntModProjectile proj, NPC target, int damage)
        {
            int   statloss = 0;
            float basestat = proj.statchance;

reproc:
            float stat = statloss == 0?basestat:(basestat - (100 * statloss)) / (statloss + 1);

            if (stat >= Main.rand.NextFloat(0, 100))
            {
                int stattype = Entropy.StatTypeCalc(proj.dmgratio);

                /*if(stattype == 0){
                 *      target.AddBuff(ModContent.BuffType("SlashProc"), 600);
                 * }else if(stattype == 1){
                 *      target.AddBuff(ModContent.BuffType("SlashProc"), 600);
                 * }else if(stattype == 2){
                 *      target.AddBuff(ModContent.BuffType("SlashProc"), 600);
                 * }else{*/
                //if(Entropy.dmgtypes[stattype] == "Slash" && !target.HasBuff(ModContent.BuffType(Entropy.dmgtypes[stattype]+"Proc")))target.AddBuff(ModContent.BuffType(Entropy.dmgtypes[stattype]+"Proc"), 1);
                //Main.NewText(Entropy.dmgtypes[stattype]+"Proc");
                //target.AddBuff(ModContent.BuffType(Entropy.dmgtypes[stattype]+"Proc"), (int)(item.item.damage*0.35));
                BuffBase buff = BuffBase.GetFromIndex(target, stattype, damage, Main.player[proj.projectile.owner]);
                EntropyGlobalNPC.AddBuff(buff);
                //Main.NewText(buff);
                //Dust.NewDust(target.Center - new Vector2(0,target.height/2),0,0,mod.DustType(Entropy.dmgtypes[stattype]+"ProcDust"));
                //}
            }
            if (proj.reproc && (stat - 100) > 0)
            {
                statloss++;
                goto reproc;
            }
        }
Esempio n. 11
0
        public void AddBuff(int id)
        {
            BuffBase buffBase = BuffBaseManager.Instance.GetItem(id);

            if (buffBase == null)
            {
                UnityEngine.Debug.LogError("Buff not found in [BuffBase] table: " + id);
                return;
            }

            // remove the previous buff.
            for (int i = 0; i < mBuffList.Count; i++)
            {
                Buff buff = mBuffList[i];
                if (buff.ID == buffBase.ID)
                {
                    buff.OnDestory(true);
                    mBuffList.RemoveAt(i);
                    break;
                }
            }

            // create a new buff and attach to it.
            Buff newBuff = new Buff(this, buffBase);

            if (newBuff.OnStart())
            {
                mBuffList.Add(newBuff);
            }
        }
 /// <summary>
 /// 注册buff,给单位增加buff的时候需要先注册
 /// </summary>
 /// <param name="buff">注册对象,必须是挂载在单位上的</param>
 /// <returns>true表示成功注册</returns>
 public bool RegBuff(BuffBase buff)
 {
     lock (buffs)
         buffs.Add(buff);
     BuffEvent += buff.Update;
     Debug.Log(gameObject.name + " register buff : " + buff.data.BuffName.ToString());
     return(true);
 }
Esempio n. 13
0
 /// <summary>
 /// 附加buff
 /// </summary>
 /// <returns></returns>
 public bool AddBuff(BuffBase buff)
 {
     if (NotningBuffList != null && NotningBuffList.Contains(buff.Id))
     {
         Debug.Log(role.Name + "免疫" + buff.Name);
         return(false);
     }
     BuffMap.Add(buff.Id, buff);
     return(true);
 }
Esempio n. 14
0
 public override void Construction()
 {
     AllBuffList    = new List <BuffBase>();
     MosterBuffList = new List <BuffBase>();
     for (int i = 0; i < 15; i++)
     {
         BuffBase buff = new BuffBase();
         buff.AllList  = new List <string>();
         buff.Id       = i;
         buff.BuffType = (BuffEnum)Random.Range(0, 4);
         buff.Name     = "Name" + i;
         buff.OutLook  = i + ".prefab";
         buff.Time     = Random.Range(0.5f, 5f);
         buff.AllList.Add("测试数据1");
         buff.AllList.Add("测试数据2");
         buff.AllList.Add("测试数据3");
         buff.AllBuffList = new List <BuffTestClass>();
         int count = Random.Range(0, 5);
         for (int j = 0; j < count; j++)
         {
             BuffTestClass testClass = new BuffTestClass()
             {
                 Id   = j,
                 Name = "name" + j,
             };
             buff.AllBuffList.Add(testClass);
         }
         AllBuffList.Add(buff);
     }
     for (int i = 0; i < 2; i++)
     {
         BuffBase buff = new BuffBase();
         buff.AllList  = new List <string>();
         buff.Id       = i;
         buff.BuffType = (BuffEnum)Random.Range(0, 4);
         buff.Name     = "Name" + i;
         buff.OutLook  = i + ".prefab";
         buff.Time     = Random.Range(0.5f, 5f);
         buff.AllList.Add("测试数据1");
         buff.AllList.Add("测试数据2");
         buff.AllBuffList = new List <BuffTestClass>();
         int count = Random.Range(1, 5);
         for (int j = 0; j < count; j++)
         {
             BuffTestClass testClass = new BuffTestClass()
             {
                 Id   = j,
                 Name = "name" + j,
             };
             buff.AllBuffList.Add(testClass);
         }
         MosterBuffList.Add(buff);
     }
 }
Esempio n. 15
0
        public override bool Buff(BuffBase buffBase, float duration)
        {
            if (!base.Buff(buffBase, duration))
            {
                return(false);
            }

            StatisticsManager.Instance.AddIntValue("Player.Buffed", 1);

            return(true);
        }
Esempio n. 16
0
 /// <summary>
 /// 添加子Buff
 /// </summary>
 /// <param name="buff"></param>
 public void AddSubBuff(BuffBase buff)
 {
     if (m_SubBuffList == null)
     {
         m_SubBuffList = new List <BuffBase>();
     }
     if (!m_SubBuffList.Exists((bf) => { return(bf.BuffId == buff.BuffId); }))
     {
         m_SubBuffList.Add(buff);
     }
 }
Esempio n. 17
0
 public void Remove(BuffBase buff)
 {
     foreach (KeyValuePair <TBuffKey, Buff <TEntity, TEntityInterface, TBuffKey> > kvp in buffs)
     {
         if (buff == kvp.Value)
         {
             RemoveBuff(kvp.Key);
             break;
         }
     }
 }
Esempio n. 18
0
 private void OnComplete()
 {
     foreach (int key in buffs.Keys)
     {
         AIBehaviors pc = skillState.targets[key];
         foreach (int buffInfo in buffs[key])
         {
             pc.AddBuff(BuffBase.GetBuff((eBuffType)buffInfo, skillState.attacker, pc));
         }
     }
 }
Esempio n. 19
0
 public Buff(BuffManager manager, BuffBase buffBase)
 {
     mManager  = manager;
     mBuffBase = buffBase;
     mLeftTime = buffBase.Time * 0.001f;
     mBuffType = (EBuffType)(int)mBuffBase.Type;
     if (!string.IsNullOrEmpty(buffBase.AttribEffect))
     {
         mAttrib = (EPA)Enum.Parse(typeof(EPA), buffBase.AttribEffect);
     }
     mSpecialEffect = (EBuffSpecialEffect)(int)mBuffBase.SpecialEffect;
 }
Esempio n. 20
0
 /// <summary>
 /// 净化buff
 /// </summary>
 public void JingHua()
 {
     foreach (eBuffType buffType in keys)
     {
         BuffBase bb = list_buff[buffType];
         if (bb.blDebuff)
         {
             bb.onExit();
             list_buff.Remove(bb.buffType);
         }
     }
 }
 /// <summary>
 /// 注销buff,在buff失效时需要注销
 /// </summary>
 /// <param name="buff">注销对象</param>
 /// <returns>true表示成功注销</returns>
 public bool LogOffBuff(BuffBase buff)
 {
     lock (buffs)
         if (buffs.Contains(buff))
         {
             buffs.Remove(buff);
             BuffEvent -= buff.Update;
             Debug.Log(gameObject.name + " log off buff : " + buff.data.BuffName.ToString());
             return(true);
         }
     return(false);
 }
Esempio n. 22
0
    public override void Construction()
    {
        AllBuffList = new List <BuffBase>();
        for (int i = 0; i < 10; i++)
        {
            BuffBase buff = new BuffBase();
            buff.Id        = i + 1;
            buff.Name      = "全BUFF" + i;
            buff.OutLook   = "Assets/GameData/..." + i;
            buff.Time      = Random.Range(0.5f, 10f);
            buff.BuffType  = (BuffEnum)Random.Range(0, 4);
            buff.AllString = new List <string>();
            buff.AllString.Add("ceshi" + i);
            buff.AllString.Add("ceshiq" + i);
            buff.AllBuffList = new List <BuffTest>();
            int count = Random.Range(1, 4);
            for (int j = 0; j < count; j++)
            {
                BuffTest test = new BuffTest();
                test.Id   = j + Random.Range(0, 5);
                test.Name = "name" + j;
                buff.AllBuffList.Add(test);
            }

            AllBuffList.Add(buff);
        }

        MonsterBuffList = new List <BuffBase>();
        for (int i = 0; i < 5; i++)
        {
            BuffBase buff = new BuffBase();
            buff.Id        = i + 1;
            buff.Name      = "全BUFF" + i;
            buff.OutLook   = "Assets/GameData/..." + i;
            buff.Time      = Random.Range(0.5f, 10f);
            buff.BuffType  = (BuffEnum)Random.Range(0, 4);
            buff.AllString = new List <string>();
            buff.AllString.Add("ceshiq" + i);

            buff.AllBuffList = new List <BuffTest>();
            int count = Random.Range(1, 4);
            for (int j = 0; j < count; j++)
            {
                BuffTest test = new BuffTest();
                test.Id   = j + Random.Range(0, 5);
                test.Name = "name" + j;
                buff.AllBuffList.Add(test);
            }

            MonsterBuffList.Add(buff);
        }
    }
 //???????
 //???????
 //同类顶替????怎么弄的???
 /// <summary>
 /// 检测是否存在buff类型。
 /// </summary>
 /// <param name="type">buff类型</param>
 /// <param name="buffBase">相应的BuffBase对象</param>
 /// <returns>是否存在buff</returns>
 public bool ContainsBuffType(BuffType type, out BuffBase buffBase)
 {
     buffBase = null;
     lock (buffs)
         foreach (BuffBase item in buffs)
         {
             if (item.data.BuffType == type)
             {
                 buffBase = item;
                 return(true);
             }
         }
     return(false);
 }
Esempio n. 24
0
        public static void AddBuff(BuffBase buff)
        {
            EntropyGlobalNPC npc = buff.npc.GetGlobalNPC <EntropyGlobalNPC>();

            npc.Buffs.Add(buff);
            npc.Buffs.Sort((x, y) => x.priority != y.priority?x.priority - y.priority:x.value - y.value);
            if (buff.npc.CountBuff(buff.GetType()) > 7)
            {
                int i = npc.Buffs.FindIndex((x) => { return(buff.GetType() == x.GetType()); });
                npc.Buffs[i].PreUpdate(buff.npc, false);
                npc.Buffs[i].Update(buff.npc);
                npc.Buffs[i].isActive = false;
            }
        }
 /// <summary>
 /// 检测是否存在buff。可叠加buff返回第一个。
 /// </summary>
 /// <param name="name">buff名称</param>
 /// <param name="buffBase">相应的BuffBase对象</param>
 /// <returns>是否存在buff</returns>
 public bool ContainsBuff(BuffName name, out BuffBase buffBase)
 {
     buffBase = null;
     lock (buffs)
         foreach (BuffBase item in buffs)
         {
             if (item.data.BuffName == name)
             {
                 buffBase = item;
                 return(true);
             }
         }
     return(false);
 }
Esempio n. 26
0
 /// <summary>
 /// 添加buff
 /// </summary>
 public void AddBuff(BuffBase buff)
 {
     if (this.configuration.currentHealth <= 0)
     {
         return;
     }
     if (buff == null)
     {
         return;
     }
     if (buff.onEnert())
     {
         list_buff.Add(buff.buffType, buff);
     }
 }
Esempio n. 27
0
    public static void PushToPool(BuffBase buff)
    {
        HashSet <BuffBase> hash = null;

        if (!m_dicBuffPool.TryGetValue(buff.buffInfo.ID, out hash))
        {
            hash = new HashSet <BuffBase>();
            m_dicBuffPool.Add(buff.buffInfo.ID, hash);
        }

        if (!hash.Contains(buff))
        {
            hash.Add(buff);
        }
    }
Esempio n. 28
0
    public void Update()
    {
        if (Time.timeScale > 0)
        {
            blDelete = false;
            //处理buff
            if (list_buff != null && list_buff.Count > 0)
            {
                if (keys == null)
                {
                    keys = new eBuffType[list_buff.Count];
                    list_buff.Keys.CopyTo(keys, 0);
                }

                foreach (eBuffType buffType in keys)
                {
                    BuffBase bb = list_buff[buffType];
                    bb.onUpdate();
                    bb.durationTime -= Time.deltaTime;
                    if (bb.durationTime <= 0)
                    {
                        blDelete = true;
                        list_buff.Remove(bb.buffType);
                        bb.onExit();
                    }
                }
                if (blDelete)
                {
                    if (list_buff.Count > 0)
                    {
                        keys = new eBuffType[list_buff.Count];
                        list_buff.Keys.CopyTo(keys, 0);
                    }
                    else
                    {
                        keys = null;
                    }
                }
            }

            //技能处理
            if (list_skill != null && list_skill.Count > 0)
            {
                //new CoolDown(x.Value.recharge_skill_timer + Time.deltaTime, GameData.skills[x.Key])
                list_skill = list_skill.ToDictionary(x => x.Key, x => GetCoolDown(x.Value, Time.deltaTime));
            }
        }
    }
Esempio n. 29
0
    public void RemoveBuff(int buffID)
    {
        BuffBase buff = null;

        if (!m_dicBuff.TryGetValue(buffID, out buff))
        {
            return;
        }
        if (buff == null)
        {
            return;
        }
        buff.BuffEnd();
        m_dicBuff.Remove(buffID);
        BuffManager.PushToPool(buff);
    }
Esempio n. 30
0
        private void UpdateAfter()
        {
            if (target != null && attacker != null)
            {
                target.OnDamageTaken(this);

                //攻击完毕看看有没有buff要设置的
                for (int j = 0; j < this.damageInfo.buffInfos.Count; j++)
                {
                    target.AddBuff(BuffBase.GetBuff(damageInfo.buffInfos[j], this.attacker, target));
                }
            }

            attacker.AttackDone();
            attack_phase.SetState(AttackPhase.Done);
        }
Esempio n. 31
0
    /// <summary>
    /// 設置 Buff
    /// </summary>
    public override void SetBuff(BuffBase add)
    {
        if (image == null) {
            Vector2 postion = transform.FindChild("Buff").position;

            GameObject ob = Instantiate (
                Resources.Load<GameObject>("Prfeb/Buff"),
                postion, Quaternion.identity) as GameObject;

            ob.transform.SetParent(transform.parent.parent);
            ob.transform.localScale = Vector3.one;

            image = ob.GetComponent<Image>();
        }

        base.SetBuff(add);
    }
Esempio n. 32
0
    /// <summary>
    /// 加入 Buff
    /// </summary>
    public virtual void SetBuff(BuffBase add) {
        if (buff == null) {
            buff = new List<BuffBase>();
            buffImage = new List<Sprite>();
        } 

        buff.Add(add);  // 加入 buff
        add.Enter(control);  // 啟用 buff

        buffImage.Add(Resources.Load<Sprite>("Image/Buff/" + 
            add.GetType().ToString()));
        image.enabled = true;

        switch (add.GetType().ToString())
        {
            case "Buff.UpAttakDamgeOfBuff":
                CoverBuff("Buff.DownAttakDamgeOfBuff");
                break;

            case "Buff.UpMagicDamgeOfBuff":
                CoverBuff("Buff.DownMagicDamgeOfBuff");
                break;

            case "Buff.UpAttakDefenceOfBuff":
                CoverBuff("Buff.DownAttakDefenceOfBuff");
                break;

            case "Buff.UpMagicDefenceOfBuff":
                CoverBuff("Buff.DownMagicDefenceOfBuff");
                break;

            case "Buff.HealHP":
                GetComponent<EnemyControl>().HPImage();
                break;
        }
    }
Esempio n. 33
0
 /// <summary>
 /// 設置永久性 Buff
 /// </summary>
 public virtual void SetGlobalBuff(BuffBase global)
 {
     if (this.global == null) this.global = global;
 }
Esempio n. 34
0
 public void Set(BuffBase add, GameObject ob) {
     this.add = add;
     this.ob = ob;
 }