コード例 #1
0
        public static void ProcessFakeRoleGoBack(int FakeRoleID)
        {
            FakeRoleItem fakeRoleItem = FakeRoleManager.FindFakeRoleByID(FakeRoleID);

            if (null != fakeRoleItem)
            {
                GameManager.ClientMgr.NotifyAllDelFakeRole(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, fakeRoleItem);
                int     toMapCode = fakeRoleItem.CurrentMapCode;
                GameMap gameMap   = null;
                if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                {
                    int   defaultBirthPosX   = gameMap.DefaultBirthPosX;
                    int   defaultBirthPosY   = gameMap.DefaultBirthPosY;
                    int   defaultBirthRadius = gameMap.BirthRadius;
                    Point newPos             = Global.GetMapPoint(ObjectTypes.OT_FAKEROLE, toMapCode, defaultBirthPosX, defaultBirthPosY, defaultBirthRadius);
                    int   toMapX             = (int)newPos.X;
                    int   toMapY             = (int)newPos.Y;
                    int   oldX = fakeRoleItem.MyRoleDataMini.PosX;
                    int   oldY = fakeRoleItem.MyRoleDataMini.PosY;
                    fakeRoleItem.MyRoleDataMini.PosX  = toMapX;
                    fakeRoleItem.MyRoleDataMini.PosY  = toMapY;
                    fakeRoleItem.MyRoleDataMini.LifeV = fakeRoleItem.MyRoleDataMini.MaxLifeV;
                    GameManager.MapGridMgr.DictGrids[toMapCode].MoveObject(oldX, oldY, toMapX, toMapY, fakeRoleItem);
                }
            }
        }
コード例 #2
0
        public static void ProcessDelFakeRoleByType(FakeRoleTypes fakeRoleType, bool bBroadcastDelMsg = false)
        {
            List <FakeRoleItem> fakeRoleItemList = FakeRoleManager.GetFakeRoleListByType(fakeRoleType);

            foreach (FakeRoleItem item in fakeRoleItemList)
            {
                FakeRoleManager.ProcessDelFakeRole(item.FakeRoleID, bBroadcastDelMsg);
            }
        }
コード例 #3
0
        public static void LookupEnemiesInCircleByAngle(GameClient client, int direction, int mapCode, int toX, int toY, int radius, List <int> enemiesList, double angle, bool near180)
        {
            List <object> objList = new List <object>();

            FakeRoleManager.LookupEnemiesInCircleByAngle(client, direction, mapCode, toX, toY, radius, objList, angle, near180);
            for (int i = 0; i < objList.Count; i++)
            {
                enemiesList.Add((objList[i] as FakeRoleItem).FakeRoleID);
            }
        }
コード例 #4
0
        public static void LookupAttackEnemyIDs(IObject attacker, int direction, List <int> enemiesList)
        {
            List <object> objList = new List <object>();

            FakeRoleManager.LookupAttackEnemies(attacker, direction, objList);
            for (int i = 0; i < objList.Count; i++)
            {
                enemiesList.Add((objList[i] as FakeRoleItem).FakeRoleID);
            }
        }
コード例 #5
0
        public static void ProcessDelFakeRole(int roleID, FakeRoleTypes fakeRoleType)
        {
            FakeRoleItem FakeRoleItem = FakeRoleManager.FindFakeRoleByRoleIDType(roleID, fakeRoleType);

            if (null != FakeRoleItem)
            {
                FakeRoleManager.RemoveFakeRole(FakeRoleItem.FakeRoleID);
                GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem);
            }
        }
コード例 #6
0
        public void RestorePKingNpc(int pkKingRoleID)
        {
            NPC npc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.PkKing);

            if (null != npc)
            {
                npc.ShowNpc = true;
                GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc);
                FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.DiaoXiang, false);
            }
        }
コード例 #7
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);

            FakeRoleManager.LookupEnemiesAtGridXY(attacker, (int)p.X, (int)p.Y, enemiesList);
        }
コード例 #8
0
        public static void ProcessDelFakeRole(int FakeRoleID, bool bBroadcastDelMsg = false)
        {
            FakeRoleItem FakeRoleItem = FakeRoleManager.FindFakeRoleByID(FakeRoleID);

            if (null != FakeRoleItem)
            {
                FakeRoleManager.RemoveFakeRole(FakeRoleID);
                GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem);
                if (bBroadcastDelMsg)
                {
                    GameManager.ClientMgr.NotifyAllDelFakeRole(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, FakeRoleItem);
                }
            }
        }
コード例 #9
0
        public static int NotifyInjured(SocketListener sl, TCPOutPacketPool pool, GameClient client, FakeRoleItem enemy, int burst, int injure, double injurePercent, int attackType, bool forceBurst, int addInjure, double attackPercent, int addAttackMin, int addAttackMax, double baseRate = 1.0, int addVlue = 0, int nHitFlyDistance = 0)
        {
            int ret = 0;

            if ((enemy as FakeRoleItem).CurrentLifeV > 0)
            {
                injure = 1000;
                injure = (int)((double)injure * injurePercent);
                ret    = injure;
                (enemy as FakeRoleItem).CurrentLifeV -= injure;
                (enemy as FakeRoleItem).CurrentLifeV  = Global.GMax((enemy as FakeRoleItem).CurrentLifeV, 0);
                int enemyLife = (enemy as FakeRoleItem).CurrentLifeV;
                (enemy as FakeRoleItem).AttackedRoleID = client.ClientData.RoleID;
                GameManager.ClientMgr.SpriteInjure2Blood(sl, pool, client, injure);
                (enemy as FakeRoleItem).AddAttacker(client.ClientData.RoleID, Global.GMax(0, injure));
                GameManager.SystemServerEvents.AddEvent(string.Format("假人减血, Injure={0}, Life={1}", injure, enemyLife), EventLevels.Debug);
                if ((enemy as FakeRoleItem).CurrentLifeV <= 0)
                {
                    GameManager.SystemServerEvents.AddEvent(string.Format("假人死亡, roleID={0}", (enemy as FakeRoleItem).FakeRoleID), EventLevels.Debug);
                    FakeRoleManager.ProcessFakeRoleDead(sl, pool, client, enemy as FakeRoleItem);
                }
                Point hitToGrid = new Point(-1.0, -1.0);
                if (nHitFlyDistance > 0)
                {
                    MapGrid mapGrid  = GameManager.MapGridMgr.DictGrids[client.ClientData.MapCode];
                    int     nGridNum = nHitFlyDistance * 100 / mapGrid.MapGridWidth;
                    if (nGridNum > 0)
                    {
                        hitToGrid = ChuanQiUtils.HitFly(client, enemy, nGridNum);
                    }
                }
                if ((enemy as FakeRoleItem).AttackedRoleID >= 0 && (enemy as FakeRoleItem).AttackedRoleID != client.ClientData.RoleID)
                {
                    GameClient findClient = GameManager.ClientMgr.FindClient((enemy as FakeRoleItem).AttackedRoleID);
                    if (null != findClient)
                    {
                        GameManager.ClientMgr.NotifySpriteInjured(sl, pool, findClient, findClient.ClientData.MapCode, findClient.ClientData.RoleID, (enemy as FakeRoleItem).FakeRoleID, 0, 0, (double)enemyLife, findClient.ClientData.Level, hitToGrid, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                        ClientManager.NotifySelfEnemyInjured(sl, pool, findClient, findClient.ClientData.RoleID, enemy.FakeRoleID, 0, 0, (double)enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                    }
                }
                GameManager.ClientMgr.NotifySpriteInjured(sl, pool, client, client.ClientData.MapCode, client.ClientData.RoleID, (enemy as FakeRoleItem).FakeRoleID, burst, injure, (double)enemyLife, client.ClientData.Level, hitToGrid, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                ClientManager.NotifySelfEnemyInjured(sl, pool, client, client.ClientData.RoleID, enemy.FakeRoleID, burst, injure, (double)enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                if (!client.ClientData.DisableChangeRolePurpleName)
                {
                    GameManager.ClientMgr.ForceChangeRolePurpleName2(sl, pool, client);
                }
            }
            return(ret);
        }
コード例 #10
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++)
                {
                    FakeRoleManager.LookupEnemiesAtGridXY(obj, (int)gridList[i].X, (int)gridList[i].Y, enemiesList);
                }
            }
        }
コード例 #11
0
        public void ReplacePKKingNpc(int roleId)
        {
            RoleDataEx rd = this.KingRoleData;

            this.KingRoleData = null;
            if (rd == null || rd.RoleID != roleId)
            {
                rd = Global.sendToDB <RoleDataEx, KingRoleGetData>(13230, new KingRoleGetData
                {
                    KingType = 1
                }, 0);
                if (rd == null || rd.RoleID != roleId)
                {
                    RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, roleId), 0);
                    if (dbRd == null || dbRd.RoleID <= 0)
                    {
                        return;
                    }
                    rd = dbRd;
                    if (!Global.sendToDB <bool, KingRolePutData>(13231, new KingRolePutData
                    {
                        KingType = 1,
                        RoleDataEx = rd
                    }, 0))
                    {
                    }
                }
            }
            if (rd != null && rd.RoleID > 0)
            {
                this.KingRoleData = rd;
                NPC npc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.PkKing);
                if (null != npc)
                {
                    npc.ShowNpc = false;
                    GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc);
                    FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.DiaoXiang, false);
                    FakeRoleManager.ProcessNewFakeRole(new SafeClientData
                    {
                        RoleData = rd
                    }, npc.MapCode, FakeRoleTypes.DiaoXiang, 4, (int)npc.CurrentPos.X, (int)npc.CurrentPos.Y, FakeRoleNpcId.PkKing);
                }
            }
        }
コード例 #12
0
        public static void ProcessAllFakeRoleItems(SocketListener sl, TCPOutPacketPool pool)
        {
            List <FakeRoleItem> FakeRoleItemList = new List <FakeRoleItem>();

            lock (FakeRoleManager._ID2FakeRoleDict)
            {
                foreach (FakeRoleItem val in FakeRoleManager._ID2FakeRoleDict.Values)
                {
                    FakeRoleItemList.Add(val);
                }
            }
            long nowTicks = TimeUtil.NOW();

            for (int i = 0; i < FakeRoleItemList.Count; i++)
            {
                FakeRoleItem FakeRoleItem = FakeRoleItemList[i];
                if (FakeRoleManager.ProcessFakeRoleDead(sl, pool, nowTicks, FakeRoleItem))
                {
                }
            }
        }
コード例 #13
0
        public static int ProcessNewFakeRole(RoleData4Selector clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1)
        {
            int result;

            if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("生成雕像目标地图不存在, MapCode={0}, RoleID={1}", mapCode, clientData.RoleID), null, true);
                result = -1;
            }
            else
            {
                FakeRoleManager.RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType);
                FakeRoleItem fakeRoleItem = FakeRoleManager.AddFakeRole(clientData, fakeRoleType);
                if (null == fakeRoleItem)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", mapCode, clientData.RoleID), null, true);
                    result = -1;
                }
                else
                {
                    fakeRoleItem.MyRoleDataMini.MapCode = mapCode;
                    if (toPosX >= 0 && toPosY >= 0)
                    {
                        fakeRoleItem.MyRoleDataMini.PosX = toPosX;
                        fakeRoleItem.MyRoleDataMini.PosY = toPosY;
                    }
                    if (direction >= 0)
                    {
                        fakeRoleItem.MyRoleDataMini.RoleDirection = direction;
                    }
                    if (ToExtensionID >= 0)
                    {
                        fakeRoleItem.ToExtensionID = ToExtensionID;
                    }
                    GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, fakeRoleItem.MyRoleDataMini.PosX, fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem);
                    result = fakeRoleItem.FakeRoleID;
                }
            }
            return(result);
        }
コード例 #14
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 = FakeRoleManager.FindFakeRoleByID(enemy);

            if (null != obj)
            {
                if ((obj as FakeRoleItem).CurrentLifeV > 0)
                {
                    injure = 10000;
                    (obj as FakeRoleItem).CurrentLifeV -= injure;
                    (obj as FakeRoleItem).CurrentLifeV  = Global.GMax((obj as FakeRoleItem).CurrentLifeV, 0);
                    int enemyLife = (obj as FakeRoleItem).CurrentLifeV;
                    (obj as FakeRoleItem).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 FakeRoleItem).CurrentLifeV <= 0)
                    {
                        GameManager.SystemServerEvents.AddEvent(string.Format("假人死亡, roleID={0}", (obj as FakeRoleItem).FakeRoleID), EventLevels.Debug);
                        FakeRoleManager.ProcessFakeRoleDead(sl, pool, client, obj as FakeRoleItem);
                    }
                    int ownerRoleID = (obj as FakeRoleItem).GetAttackerFromList();
                    if (ownerRoleID >= 0 && ownerRoleID != client.ClientData.RoleID)
                    {
                        GameClient findClient = GameManager.ClientMgr.FindClient(ownerRoleID);
                        if (null != findClient)
                        {
                            GameManager.ClientMgr.NotifySpriteInjured(sl, pool, findClient, findClient.ClientData.MapCode, findClient.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, 0, 0, (double)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 FakeRoleItem).FakeRoleID, 0, 0, (double)enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                        }
                    }
                    GameManager.ClientMgr.NotifySpriteInjured(sl, pool, client, client.ClientData.MapCode, client.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, burst, injure, (double)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 FakeRoleItem).FakeRoleID, burst, injure, (double)enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0);
                    if (!client.ClientData.DisableChangeRolePurpleName)
                    {
                        GameManager.ClientMgr.ForceChangeRolePurpleName2(sl, pool, client);
                    }
                }
            }
        }
コード例 #15
0
        private static bool ProcessFakeRoleDead(SocketListener sl, TCPOutPacketPool pool, long nowTicks, FakeRoleItem fakeRoleItem)
        {
            bool result;

            if (fakeRoleItem.CurrentLifeV > 0)
            {
                result = false;
            }
            else
            {
                long subTicks = nowTicks - fakeRoleItem.FakeRoleDeadTicks;
                if (subTicks < 2000L)
                {
                    result = false;
                }
                else
                {
                    FakeRoleManager.ProcessFakeRoleGoBack(fakeRoleItem.FakeRoleID);
                    result = true;
                }
            }
            return(result);
        }
コード例 #16
0
        /// </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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #17
0
        public static int ProcessNewFakeRole(SafeClientData clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1)
        {
            int result;

            if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID离线挂机时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID), null, true);
                result = -1;
            }
            else
            {
                FakeRoleManager.RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType);
                FakeRoleItem fakeRoleItem = FakeRoleManager.AddFakeRole(clientData, fakeRoleType);
                if (null == fakeRoleItem)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID), null, true);
                    result = -1;
                }
                else
                {
                    fakeRoleItem.MyRoleDataMini.MapCode = mapCode;
                    if (toPosX >= 0 && toPosY >= 0)
                    {
                        fakeRoleItem.MyRoleDataMini.PosX = toPosX;
                        fakeRoleItem.MyRoleDataMini.PosY = toPosY;
                    }
                    if (direction >= 0)
                    {
                        fakeRoleItem.MyRoleDataMini.RoleDirection = direction;
                    }
                    if (ToExtensionID >= 0)
                    {
                        fakeRoleItem.ToExtensionID = ToExtensionID;
                    }
                    if (FakeRoleTypes.LiXianGuaJi == fakeRoleType)
                    {
                        if (clientData.OfflineMarketState <= 0)
                        {
                            fakeRoleItem.MyRoleDataMini.StallName = "";
                        }
                    }
                    if (FakeRoleTypes.DiaoXiang2 == fakeRoleType)
                    {
                        if (fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams == null || fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count <= 0)
                        {
                            int fashionID = 0;
                            foreach (FashionData item in FashionManager.getInstance().RuntimeData.FashingDict.Values)
                            {
                                if (item.Type == 1)
                                {
                                    fashionID = item.ID;
                                    break;
                                }
                            }
                            if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams = new List <int>();
                            }
                            for (int i = fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count; i < 53; i++)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Add(0);
                            }
                            fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[26] = fashionID;
                        }
                    }
                    if (FakeRoleTypes.BangHuiMatchBZ == fakeRoleType || FakeRoleTypes.CompDaLingZhu_1 == fakeRoleType || FakeRoleTypes.CompDaLingZhu_2 == fakeRoleType || FakeRoleTypes.CompDaLingZhu_3 == fakeRoleType)
                    {
                        int fashionID = 0;
                        foreach (FashionData item in FashionManager.getInstance().RuntimeData.FashingDict.Values)
                        {
                            if (item.Type == 4)
                            {
                                fashionID = item.ID;
                                break;
                            }
                        }
                        if (fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams == null || fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count <= 0)
                        {
                            if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams = new List <int>();
                            }
                            for (int i = fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count; i < 53; i++)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Add(0);
                            }
                            fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[26] = fashionID;
                        }
                        else if (53 == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count)
                        {
                            fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[26] = fashionID;
                        }
                    }
                    fakeRoleItem.MyRoleDataMini.LifeV  = Math.Max(1, clientData.LifeV);
                    fakeRoleItem.MyRoleDataMini.MagicV = Math.Max(1, clientData.MagicV);
                    GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, fakeRoleItem.MyRoleDataMini.PosX, fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem);
                    result = fakeRoleItem.FakeRoleID;
                }
            }
            return(result);
        }
コード例 #18
0
        /// <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);
                                }
                            }
                        }
                    }
                }
            }
        }