Exemple #1
0
        private void TryTriggerSkills(GameClient client, long nowTicks, SkillTriggerTypes type)
        {
            //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------petSkill begin ---------- 触发类型={0}", type.ToString()));
            lock (mutex)
            {
                foreach (var data in passiveSkillList.Values)
                {
                    if (data.triggerType == (int)type)
                    {
                        //触发间隔
                        long spanTicks;
                        bool b = _spanTimeDict.TryGetValue(data.skillId, out spanTicks);
                        //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------petSkill --1-- {0} spanTime={1} nowTime={2} span={3}", data.skillId,spanTicks, nowTicks, spanTicks - nowTicks));
                        if (b && spanTicks > nowTicks)
                        {
                            continue;
                        }

                        //先判断触发概率
                        int rnd = Global.GetRandomNumber(0, 100);
                        //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------petSkill --2-- {0} 概率={1} 随机数={2} 触发={3}", data.skillId, data.triggerRate, rnd, rnd - data.triggerRate < 0));
                        if (rnd >= data.triggerRate)
                        {
                            continue;
                        }

                        //技能cd时间
                        long coolDownTicks;
                        b = coolDownDict.TryGetValue(data.skillId, out coolDownTicks);
                        //if (coolDownDict.TryGetValue(data.skillId, out coolDownTicks) && coolDownTicks > nowTicks) continue;
                        //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------petSkill --3-- {0} coolTime={1} nowTime={2} cd={3}", data.skillId, coolDownTicks, nowTicks, coolDownTicks - nowTicks));
                        if (b && coolDownTicks > nowTicks)
                        {
                            continue;
                        }


                        coolDownDict[data.skillId]  = nowTicks + data.coolDown * 1000;
                        _spanTimeDict[data.skillId] = nowTicks + data.triggerCD * 1000;

                        //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------petSkill --4-- {0} coolTime={1} spanTime={2}", data.skillId, data.coolDown, data.triggerCD));
                        int posX = client.ClientData.PosX;
                        int posY = client.ClientData.PosY;
                        SpriteAttack.AddDelayMagic(client, client.ClientData.RoleID, posX, posY, posX, posY, data.skillId);
                        EventLogManager.AddRoleSkillEvent(client, SkillLogTypes.PassiveSkillTrigger, LogRecordType.IntValue2, data.skillId, data.skillLevel, data.triggerRate, rnd, data.coolDown);
                    }
                }
            }

            //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------petSkill end ----------"));
        }
 private void TryTriggerSkills(GameClient client, long nowTicks, SkillTriggerTypes type)
 {
     lock (this.mutex)
     {
         foreach (PassiveSkillData data in this.passiveSkillList.Values)
         {
             if (data.triggerType == (int)type)
             {
                 long spanTicks;
                 bool b = this._spanTimeDict.TryGetValue(data.skillId, out spanTicks);
                 if (!b || spanTicks <= nowTicks)
                 {
                     int rnd = Global.GetRandomNumber(0, 100);
                     if (rnd < data.triggerRate)
                     {
                         long coolDownTicks;
                         b = this.coolDownDict.TryGetValue(data.skillId, out coolDownTicks);
                         if (!b || coolDownTicks <= nowTicks)
                         {
                             this.coolDownDict[data.skillId]  = nowTicks + (long)(data.coolDown * 1000);
                             this._spanTimeDict[data.skillId] = nowTicks + (long)(data.triggerCD * 1000);
                             int posX = client.ClientData.PosX;
                             int posY = client.ClientData.PosY;
                             SpriteAttack.AddDelayMagic(client, client.ClientData.RoleID, posX, posY, posX, posY, data.skillId);
                             EventLogManager.AddRoleSkillEvent(client, SkillLogTypes.PassiveSkillTrigger, LogRecordType.IntValue2, new object[]
                             {
                                 data.skillId,
                                 data.skillLevel,
                                 data.triggerRate,
                                 rnd,
                                 data.coolDown
                             });
                         }
                     }
                 }
             }
         }
     }
 }