Exemplo n.º 1
0
 private static void ProcessTimeSubLifeNoShow(Monster monster, int id)
 {
     if (monster.VLife > 0.0)
     {
         double lifeV = 0.0;
         DelayInjuredBufferItem delayInjuredBufferItem = null;
         BufferData             bufferData             = Global.GetMonsterBufferDataByID(monster, id);
         if (null != bufferData)
         {
             long nowTicks = TimeUtil.NOW();
             if (nowTicks - bufferData.StartTime < (long)bufferData.BufferSecs * 1000L)
             {
                 delayInjuredBufferItem = (monster.MyBufferExtManager.FindBufferItem(id) as DelayInjuredBufferItem);
                 if (null != delayInjuredBufferItem)
                 {
                     if (nowTicks - delayInjuredBufferItem.StartSubLifeNoShowTicks >= (long)(delayInjuredBufferItem.TimeSlotSecs * 1000))
                     {
                         delayInjuredBufferItem.StartSubLifeNoShowTicks = nowTicks;
                         lifeV = (double)delayInjuredBufferItem.SubLifeV;
                     }
                 }
             }
             else
             {
                 Global.RemoveMonsterBufferData(monster, id);
                 monster.MyBufferExtManager.RemoveBufferItem(id);
             }
         }
         if (lifeV > 0.0 && null != delayInjuredBufferItem)
         {
             GameClient enemyClient = GameManager.ClientMgr.FindClient(delayInjuredBufferItem.ObjectID);
             if (null != enemyClient)
             {
                 int nOcc = Global.CalcOriginalOccupationID(enemyClient);
                 GameManager.MonsterMgr.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, enemyClient, monster, 0, (int)lifeV, 1.0, nOcc, false, 0, 0.0, 0, 0, 0, 0.0, 0.0, false, 1.0, 0, 0, 0, 0.0);
                 if (monster.VLife <= 0.0)
                 {
                     Global.RemoveMonsterBufferData(monster, id);
                     monster.MyBufferExtManager.RemoveBufferItem(id);
                 }
             }
             else
             {
                 Global.RemoveMonsterBufferData(monster, id);
                 monster.MyBufferExtManager.RemoveBufferItem(id);
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 处理持续伤害的buffer, 定时伤害
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        private static void ProcessTimeSubLifeNoShow(Monster monster, int id)
        {
            //如果已经死亡,则不再调度
            if (monster.VLife > 0)
            {
                double lifeV = 0;
                DelayInjuredBufferItem delayInjuredBufferItem = null;

                BufferData bufferData = Global.GetMonsterBufferDataByID(monster, id);
                if (null != bufferData)
                {
                    long nowTicks = DateTime.Now.Ticks / 10000;
                    if ((nowTicks - bufferData.StartTime) < (bufferData.BufferSecs * 1000))
                    {
                        delayInjuredBufferItem = monster.MyBufferExtManager.FindBufferItem(id) as DelayInjuredBufferItem;
                        if (null != delayInjuredBufferItem)
                        {
                            if (nowTicks - delayInjuredBufferItem.StartSubLifeNoShowTicks >= (int)(delayInjuredBufferItem.TimeSlotSecs * 1000))
                            {
                                delayInjuredBufferItem.StartSubLifeNoShowTicks = nowTicks;
                                lifeV = delayInjuredBufferItem.SubLifeV;
                            }
                        }
                    }
                    else
                    {
                        ///删除,防止遗漏,占用内存资源
                        Global.RemoveMonsterBufferData(monster, id);

                        monster.MyBufferExtManager.RemoveBufferItem(id);
                    }
                }

                //如果需要加生命
                if (lifeV > 0.0 && null != delayInjuredBufferItem)
                {
                    GameClient enemyClient = GameManager.ClientMgr.FindClient(delayInjuredBufferItem.ObjectID);
                    if (null != enemyClient)
                    {
                        // 属性改造 加上一级属性公式 区分职业[8/15/2013 LiaoWei]
                        int nOcc = Global.CalcOriginalOccupationID(enemyClient);

                        //最低伤害1,使用一个外部传入的1的技巧
                        GameManager.MonsterMgr.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                             enemyClient, monster, 0, (int)lifeV, 1.0, nOcc, false, 0, 0.0, 0, 0, 0, 0.0, 0.0);

                        if (monster.VLife <= 0) //如果死亡
                        {
                            ///删除,防止遗漏,占用内存资源
                            Global.RemoveMonsterBufferData(monster, id);

                            monster.MyBufferExtManager.RemoveBufferItem(id);
                        }
                    }
                    else
                    {
                        ///删除,防止遗漏,占用内存资源
                        Global.RemoveMonsterBufferData(monster, id);

                        monster.MyBufferExtManager.RemoveBufferItem(id);
                    }
                }
            }
        }