Example #1
0
        public static void ProcessAllBiaoCheItems(SocketListener sl, TCPOutPacketPool pool)
        {
            List <BiaoCheItem> biaoCheItemList = new List <BiaoCheItem>();

            lock (BiaoCheManager._ID2BiaoCheDict)
            {
                foreach (BiaoCheItem val in BiaoCheManager._ID2BiaoCheDict.Values)
                {
                    biaoCheItemList.Add(val);
                }
            }
            long nowTicks = TimeUtil.NOW();

            for (int i = 0; i < biaoCheItemList.Count; i++)
            {
                BiaoCheItem biaoCheItem = biaoCheItemList[i];
                if (!BiaoCheManager.ProcessBiaoCheOverTime(sl, pool, nowTicks, biaoCheItem))
                {
                    if (!BiaoCheManager.ProcessBiaoCheDead(sl, pool, nowTicks, biaoCheItem))
                    {
                        BiaoCheManager.ProcessBiaoCheAddLife(sl, pool, nowTicks, biaoCheItem);
                    }
                }
            }
        }
Example #2
0
        public static void LookupAttackEnemyIDs(IObject attacker, int direction, List <int> enemiesList)
        {
            List <object> objList = new List <object>();

            BiaoCheManager.LookupAttackEnemies(attacker, direction, objList);
            for (int i = 0; i < objList.Count; i++)
            {
                enemiesList.Add((objList[i] as BiaoCheItem).BiaoCheID);
            }
        }
Example #3
0
        public static void ProcessDelBiaoChe(SocketListener sl, TCPOutPacketPool pool, int biaoCheID)
        {
            BiaoCheItem biaoCheItem = BiaoCheManager.FindBiaoCheByID(biaoCheID);

            if (null != biaoCheItem)
            {
                BiaoCheManager.RemoveBiaoChe(biaoCheID);
                GameManager.MapGridMgr.DictGrids[biaoCheItem.MapCode].RemoveObject(biaoCheItem);
            }
        }
Example #4
0
        public static void LookupAttackEnemies(IObject attacker, int direction, List <object> enemiesList)
        {
            int     mapCode = attacker.CurrentMapCode;
            MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];
            Point   grid    = attacker.CurrentGrid;
            int     gridX   = (int)grid.X;
            int     gridY   = (int)grid.Y;
            Point   p       = Global.GetGridPointByDirection(direction, gridX, gridY);

            BiaoCheManager.LookupEnemiesAtGridXY(attacker, (int)p.X, (int)p.Y, enemiesList);
        }
Example #5
0
        public static void ProcessNewBiaoChe(SocketListener sl, TCPOutPacketPool pool, GameClient client, int yaBiaoID)
        {
            BiaoCheItem biaoCheItem = BiaoCheManager.AddBiaoChe(client, yaBiaoID);

            if (null == biaoCheItem)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成镖车对象时失败, Client={0}, RoleID={1}, YaBiaoID={2}", Global.GetSocketRemoteEndPoint(client.ClientSocket, false), client.ClientData.RoleID, yaBiaoID), null, true);
            }
            else
            {
                GameManager.MapGridMgr.DictGrids[biaoCheItem.MapCode].MoveObject(-1, -1, biaoCheItem.PosX, biaoCheItem.PosY, biaoCheItem);
            }
        }
Example #6
0
        public static void LookupRangeAttackEnemies(IObject obj, int toX, int toY, int direction, string rangeMode, List <object> enemiesList)
        {
            MapGrid      mapGrid  = GameManager.MapGridMgr.DictGrids[obj.CurrentMapCode];
            int          gridX    = toX / mapGrid.MapGridWidth;
            int          gridY    = toY / mapGrid.MapGridHeight;
            List <Point> gridList = Global.GetGridPointByDirection(direction, gridX, gridY, rangeMode, true);

            if (gridList.Count > 0)
            {
                for (int i = 0; i < gridList.Count; i++)
                {
                    BiaoCheManager.LookupEnemiesAtGridXY(obj, (int)gridList[i].X, (int)gridList[i].Y, enemiesList);
                }
            }
        }
Example #7
0
        private static bool ProcessBiaoCheOverTime(SocketListener sl, TCPOutPacketPool pool, long nowTicks, BiaoCheItem biaoCheItem)
        {
            bool result;

            if (nowTicks - biaoCheItem.StartTime < (long)Global.MaxYaBiaoTicks)
            {
                result = false;
            }
            else
            {
                BiaoCheManager.ProcessDelBiaoChe(sl, pool, biaoCheItem.BiaoCheID);
                result = true;
            }
            return(result);
        }
Example #8
0
        public static void NotifyInjured(SocketListener sl, TCPOutPacketPool pool, GameClient client, int roleID, int enemy, int enemyX, int enemyY, int burst, int injure, double attackPercent, int addAttack, double baseRate = 1.0, int addVlue = 0, int nHitFlyDistance = 0)
        {
            object obj = BiaoCheManager.FindBiaoCheByID(enemy);

            if (null != obj)
            {
                if ((obj as BiaoCheItem).CurrentLifeV > 0)
                {
                    injure = (obj as BiaoCheItem).CutLifeV;
                    injure = (int)((double)injure * baseRate + (double)addVlue);
                    (obj as BiaoCheItem).CurrentLifeV -= injure;
                    (obj as BiaoCheItem).CurrentLifeV  = Global.GMax((obj as BiaoCheItem).CurrentLifeV, 0);
                    double enemyLife = (double)(obj as BiaoCheItem).CurrentLifeV;
                    (obj as BiaoCheItem).AttackedRoleID = client.ClientData.RoleID;
                    GameManager.ClientMgr.SpriteInjure2Blood(sl, pool, client, injure);
                    GameManager.SystemServerEvents.AddEvent(string.Format("镖车减血, Injure={0}, Life={1}", injure, enemyLife), EventLevels.Debug);
                    if ((obj as BiaoCheItem).CurrentLifeV <= 0)
                    {
                        GameManager.SystemServerEvents.AddEvent(string.Format("镖车死亡, roleID={0}", (obj as BiaoCheItem).BiaoCheID), EventLevels.Debug);
                        BiaoCheManager.ProcessBiaoCheDead(sl, pool, client, obj as BiaoCheItem);
                    }
                    if ((obj as BiaoCheItem).AttackedRoleID >= 0 && (obj as BiaoCheItem).AttackedRoleID != client.ClientData.RoleID)
                    {
                        GameClient findClient = GameManager.ClientMgr.FindClient((obj as BiaoCheItem).AttackedRoleID);
                        if (null != findClient)
                        {
                            GameManager.ClientMgr.NotifySpriteInjured(sl, pool, findClient, findClient.ClientData.MapCode, findClient.ClientData.RoleID, (obj as BiaoCheItem).BiaoCheID, 0, 0, enemyLife, findClient.ClientData.Level, new Point(-1.0, -1.0), 0, EMerlinSecretAttrType.EMSAT_None, 0);
                            ClientManager.NotifySelfEnemyInjured(sl, pool, findClient, findClient.ClientData.RoleID, (obj as BiaoCheItem).BiaoCheID, 0, 0, enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                        }
                    }
                    GameManager.ClientMgr.NotifySpriteInjured(sl, pool, client, client.ClientData.MapCode, client.ClientData.RoleID, (obj as BiaoCheItem).BiaoCheID, burst, injure, enemyLife, client.ClientData.Level, new Point(-1.0, -1.0), 0, EMerlinSecretAttrType.EMSAT_None, 0);
                    ClientManager.NotifySelfEnemyInjured(sl, pool, client, client.ClientData.RoleID, (obj as BiaoCheItem).BiaoCheID, burst, injure, enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                    if (!client.ClientData.DisableChangeRolePurpleName)
                    {
                        GameManager.ClientMgr.ForceChangeRolePurpleName2(sl, pool, client);
                    }
                }
            }
        }
Example #9
0
        private static bool ProcessBiaoCheDead(SocketListener sl, TCPOutPacketPool pool, long nowTicks, BiaoCheItem biaoCheItem)
        {
            bool result;

            if (biaoCheItem.CurrentLifeV > 0)
            {
                result = false;
            }
            else
            {
                long subTicks = nowTicks - biaoCheItem.BiaoCheDeadTicks;
                if (subTicks < 2000L)
                {
                    result = false;
                }
                else
                {
                    BiaoCheManager.ProcessDelBiaoChe(sl, pool, biaoCheItem.BiaoCheID);
                    result = true;
                }
            }
            return(result);
        }
        /// <summary>
        /// 扇形范围的圆形区域伤害
        /// </summary>
        /// <param name="key"></param>
        /// <param name="magicHelperItem"></param>
        /// <param name="nowTicks"></param>
        public void ExecuteMUFireSector(GridMagicHelperItemKey key, GridMagicHelperItemEx magicHelperItem, long nowTicks)
        {
            int id    = (int)key.MagicActionID;
            int gridX = key.PosX;
            int gridY = key.PosY;

            magicHelperItem.ExecutedNum++;
            magicHelperItem.LastTicks = nowTicks;

            //执行伤害
            //根据敌人ID判断对方是系统爆的怪还是其他玩家
            int    addValue     = (int)magicHelperItem.MagicActionParams[2];
            int    attacker     = (int)magicHelperItem.MagicActionParams[3];
            double baseRate     = magicHelperItem.MagicActionParams[4];
            int    radio        = (int)(magicHelperItem.MagicActionParams[5]); //服务器坐标单位
            int    angel        = (int)(magicHelperItem.MagicActionParams[6]); //角度
            int    direction    = (int)(magicHelperItem.MagicActionParams[7]); //释放时的方向
            int    mapGridWidth = (int)(magicHelperItem.MagicActionParams[9]); //格子宽度

            gridX *= mapGridWidth;
            gridY *= mapGridWidth;
            if (-1 != attacker)
            {
                GameClient client = GameManager.ClientMgr.FindClient(attacker);
                if (null != client)
                {
                    List <Object> enemiesList = new List <object>();
                    GameManager.ClientMgr.LookupEnemiesInCircleByAngle(direction, magicHelperItem.MapCode, client.ClientData.CopyMapID, gridX, gridY, radio, enemiesList, angel, false);
                    GameManager.MonsterMgr.LookupEnemiesInCircleByAngle(direction, magicHelperItem.MapCode, client.ClientData.CopyMapID, gridX, gridY, radio, enemiesList, angel, false);
                    for (int x = 0; x < enemiesList.Count; x++)
                    {
                        IObject obj = enemiesList[x] as IObject;
                        if (obj.CurrentCopyMapID != client.CurrentCopyMapID)
                        {
                            continue;
                        }

                        if (obj is GameClient) //被攻击者是角色
                        {
                            if ((obj as GameClient).ClientData.RoleID != attacker && Global.IsOpposition(client, (obj as GameClient)))
                            {
                                GameManager.ClientMgr.NotifyOtherInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                         client, obj as GameClient, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, false, baseRate, addValue);
                            }
                        }
                        else if (obj is Monster) //被攻击者是怪物
                        {
                            if (Global.IsOpposition(client, (obj as Monster)))
                            {
                                GameManager.MonsterMgr.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                     client, obj as Monster, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, baseRate, addValue);
                            }
                        }
                        else if (obj is BiaoCheItem) //被攻击者是镖车
                        {
                            if (Global.IsOpposition(client, (obj as BiaoCheItem)))
                            {
                                BiaoCheManager.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                             client, obj as BiaoCheItem, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, baseRate, addValue);
                            }
                        }
                        else if (obj is JunQiItem) //被攻击者是帮旗
                        {
                            if (Global.IsOpposition(client, (obj as JunQiItem)))
                            {
                                JunQiManager.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                           client, obj as JunQiItem, 0, 0, 1.0, 1, false, 0, 0, 0, 0, baseRate, addValue);
                            }
                        }
                        else if (obj is FakeRoleItem) //被攻击者是假人
                        {
                            if (Global.IsOpposition(client, (obj as FakeRoleItem)))
                            {
                                FakeRoleManager.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                              client, obj as FakeRoleItem, 0, 0, 1.0, 1, false, 0, baseRate, addValue, 0);
                            }
                        }
                    }
                }
                else
                {
                    Monster monster = GameManager.MonsterMgr.FindMonster(magicHelperItem.MapCode, attacker);
                    if (null != monster)
                    {
                        List <Object> enemiesList = new List <object>();
                        GameManager.ClientMgr.LookupEnemiesInCircleByAngle(direction, magicHelperItem.MapCode, monster.CopyMapID, gridX, gridY, radio, enemiesList, angel, false);
                        GameManager.MonsterMgr.LookupEnemiesInCircleByAngle(direction, magicHelperItem.MapCode, monster.CopyMapID, gridX, gridY, radio, enemiesList, angel, false);
                        for (int x = 0; x < enemiesList.Count; x++)
                        {
                            IObject obj = enemiesList[x] as IObject;
                            if (obj.CurrentCopyMapID != monster.CurrentCopyMapID)
                            {
                                continue;
                            }

                            if (obj is GameClient) //被攻击者是角色
                            {
                                if ((obj as GameClient).ClientData.RoleID != attacker && Global.IsOpposition(monster, (obj as GameClient)))
                                {
                                    GameManager.ClientMgr.NotifyOtherInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                             monster, obj as GameClient, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, baseRate, addValue);
                                }
                            }
                            else if (obj is Monster) //被攻击者是怪物
                            {
                                if (Global.IsOpposition(monster, (obj as Monster)))
                                {
                                    GameManager.MonsterMgr.Monster_NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                                 monster, obj as Monster, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, baseRate, addValue);
                                }
                            }
                        }
                    }
                }
            }
        }
        /// </summary>
        public void ExecuteMUFireWall(int id, string gridXY, Dictionary <MagicActionIDs, GridMagicHelperItem> dict)
        {
            string[] fields = gridXY.Split('_');
            int      gridX  = Global.SafeConvertToInt32(fields[0]);
            int      gridY  = Global.SafeConvertToInt32(fields[1]);

            GridMagicHelperItem magicHelperItem = null;

            lock (dict)
            {
                dict.TryGetValue((MagicActionIDs)id, out magicHelperItem);
            }

            if (null == magicHelperItem)
            {
                return;
            }
            if (!CanExecuteItem(dict, magicHelperItem, (int)magicHelperItem.MagicActionParams[0], (int)magicHelperItem.MagicActionParams[1]))
            {
                return;
            }

            magicHelperItem.ExecutedNum++;
            magicHelperItem.LastTicks = TimeUtil.NOW();

            //执行伤害
            //根据敌人ID判断对方是系统爆的怪还是其他玩家
            int    addValue = (int)magicHelperItem.MagicActionParams[2];
            int    attacker = (int)magicHelperItem.MagicActionParams[3];
            double baseRate = magicHelperItem.MagicActionParams[4];

            if (-1 != attacker)
            {
                GameClient client = GameManager.ClientMgr.FindClient(attacker);
                if (null != client)
                {
                    List <Object> enemiesList = new List <object>();
                    GameManager.ClientMgr.LookupEnemiesAtGridXY(client, gridX, gridY, enemiesList);
                    GameManager.MonsterMgr.LookupEnemiesAtGridXY(client, gridX, gridY, enemiesList);
                    BiaoCheManager.LookupEnemiesAtGridXY(client, gridX, gridY, enemiesList);
                    JunQiManager.LookupEnemiesAtGridXY(client, gridX, gridY, enemiesList);
                    for (int x = 0; x < enemiesList.Count; x++)
                    {
                        IObject obj = enemiesList[x] as IObject;
                        if (obj.CurrentCopyMapID != client.CurrentCopyMapID)
                        {
                            continue;
                        }

                        if (obj is GameClient) //被攻击者是角色
                        {
                            if ((obj as GameClient).ClientData.RoleID != attacker && Global.IsOpposition(client, (obj as GameClient)))
                            {
                                GameManager.ClientMgr.NotifyOtherInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                         client, obj as GameClient, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, false, baseRate, addValue);
                            }
                        }
                        else if (obj is Monster) //被攻击者是怪物
                        {
                            if (Global.IsOpposition(client, (obj as Monster)))
                            {
                                GameManager.MonsterMgr.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                     client, obj as Monster, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, baseRate, addValue);
                            }
                        }
                        else if (obj is BiaoCheItem) //被攻击者是镖车
                        {
                            if (Global.IsOpposition(client, (obj as BiaoCheItem)))
                            {
                                BiaoCheManager.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                             client, obj as BiaoCheItem, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, baseRate, addValue);
                            }
                        }
                        else if (obj is JunQiItem) //被攻击者是帮旗
                        {
                            if (Global.IsOpposition(client, (obj as JunQiItem)))
                            {
                                JunQiManager.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                           client, obj as JunQiItem, 0, 0, 1.0, 1, false, 0, 0, 0, 0, baseRate, addValue);
                            }
                        }
                        else if (obj is FakeRoleItem) //被攻击者是假人
                        {
                            if (Global.IsOpposition(client, (obj as FakeRoleItem)))
                            {
                                FakeRoleManager.NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                              client, obj as FakeRoleItem, 0, 0, 1.0, 1, false, 0, baseRate, addValue, 0);
                            }
                        }
                    }
                }
                else
                {
                    Monster monster = GameManager.MonsterMgr.FindMonster(magicHelperItem.MapCode, attacker);
                    if (null != monster)
                    {
                        List <Object> enemiesList = new List <object>();
                        GameManager.ClientMgr.LookupEnemiesAtGridXY(monster, gridX, gridY, enemiesList);
                        GameManager.MonsterMgr.LookupEnemiesAtGridXY(monster, gridX, gridY, enemiesList);
                        BiaoCheManager.LookupEnemiesAtGridXY(monster, gridX, gridY, enemiesList);
                        JunQiManager.LookupEnemiesAtGridXY(monster, gridX, gridY, enemiesList);
                        for (int x = 0; x < enemiesList.Count; x++)
                        {
                            IObject obj = enemiesList[x] as IObject;
                            if (obj.CurrentCopyMapID != monster.CurrentCopyMapID)
                            {
                                continue;
                            }

                            if (obj is GameClient) //被攻击者是角色
                            {
                                if ((obj as GameClient).ClientData.RoleID != attacker && Global.IsOpposition(monster, (obj as GameClient)))
                                {
                                    GameManager.ClientMgr.NotifyOtherInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                             monster, obj as GameClient, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, baseRate, addValue);
                                }
                            }
                            else if (obj is Monster) //被攻击者是怪物
                            {
                                if (Global.IsOpposition(monster, (obj as Monster)))
                                {
                                    GameManager.MonsterMgr.Monster_NotifyInjured(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                                                                                 monster, obj as Monster, 0, 0, 1.0, 1, false, 0, 1.0, 0, 0, 0, 0.0, 0.0, false, baseRate, addValue);
                                }
                            }
                        }
                    }
                }
            }
        }