コード例 #1
0
        /// <summary>
        /// 是否可以执行选项
        /// </summary>
        /// <param name="magicHelperItem"></param>
        /// <returns></returns>
        private bool CanExecuteItemEx(GridMagicHelperItemKey key, GridMagicHelperItemEx magicHelperItem, double effectSecs, int maxNum, long nowTicks)
        {
            long ticks = magicHelperItem.StartedTicks + (long)(effectSecs * 1000);

            if (maxNum <= 0)
            {
                //判断是否超过了时间
                if (nowTicks >= ticks)
                {
                    lock (_GridMagicHelperDictEx)
                    {
                        _GridMagicHelperDictEx.Remove(key);
                    }

                    return(false);
                }
                else
                {
                    //System.Diagnostics.Debug.WriteLine("CanExecuteItem, {0}", nowTicks - ticks);
                    return(true);
                }
            }

            //判断是否超过了次数
            if (magicHelperItem.ExecutedNum >= maxNum)
            {
                lock (_GridMagicHelperDictEx)
                {
                    _GridMagicHelperDictEx.Remove(key);
                }

                return(false);
            }

            long ticksSlot = (long)((effectSecs / maxNum) * 1000);

            //判断是否超过了时间
            if (nowTicks - magicHelperItem.LastTicks < ticksSlot)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// 执行所有扩展项
        /// </summary>
        public void ExecuteAllItemsEx()
        {
            long nowTicks = TimeUtil.NOW();
            List <KeyValuePair <GridMagicHelperItemKey, GridMagicHelperItemEx> > list = null;

            lock (_GridMagicHelperDictEx)
            {
                foreach (var kv in _GridMagicHelperDictEx)
                {
                    if (CanExecuteItemEx(kv.Key, kv.Value, (int)kv.Value.MagicActionParams[0], (int)kv.Value.MagicActionParams[1], nowTicks))
                    {
                        if (null == list)
                        {
                            list = new List <KeyValuePair <GridMagicHelperItemKey, GridMagicHelperItemEx> >();
                        }
                        list.Add(kv);
                    }
                }
            }

            if (null != list)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    GridMagicHelperItemKey key = list[i].Key;
                    switch (key.MagicActionID)
                    {
                    case MagicActionIDs.MU_FIRE_WALL_X:
                        ExecuteMUFireWall_X(list[i].Key, list[i].Value, nowTicks);
                        break;

                    case MagicActionIDs.MU_FIRE_SECTOR:
                        ExecuteMUFireSector(list[i].Key, list[i].Value, nowTicks);
                        break;

                    case MagicActionIDs.MU_FIRE_STRAIGHT:
                        ExecuteMUFireStraight(list[i].Key, list[i].Value, nowTicks);
                        break;
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 添加技能辅助项(扩展)
        /// </summary>
        /// <param name="magicActionID"></param>
        /// <param name="magicActionParams"></param>
        /// <param name="mapCode"></param>
        /// <param name="centerGridXY"></param>
        /// <param name="gridWidthNum"></param>
        /// <param name="gridHeightNum"></param>
        /// <param name="copyMapID"></param>
        public void AddMagicHelperEx(MagicActionIDs magicActionID, double[] magicActionParams, int mapCode, int posX, int posY, int copyMapID = -1)
        {
            if (copyMapID < 0)
            {
                copyMapID = -1;
            }

            GameMap gameMap = GameManager.MapMgr.DictMaps[mapCode];

            ///障碍上边,不能放火墙
            if (Global.InOnlyObs(ObjectTypes.OT_CLIENT, mapCode, posX, posY))
            {
                return;
            }

            GridMagicHelperItemKey itemKey = new GridMagicHelperItemKey()
            {
                PosX          = posX,
                PosY          = posY,
                CopyMapID     = copyMapID,
                MagicActionID = magicActionID,
            };

            GridMagicHelperItemEx magicHelperItem = new GridMagicHelperItemEx()
            {
                MagicActionID     = magicActionID,
                MagicActionParams = magicActionParams,
                StartedTicks      = TimeUtil.NOW(),
                LastTicks         = TimeUtil.NOW(),
                ExecutedNum       = 0,
                MapCode           = mapCode,
            };

            lock (_GridMagicHelperDictEx)
            {
                if (_GridMagicHelperDictEx.ContainsKey(itemKey))
                {
                    return;//一个格子上边,同时只能有一个buffer
                }
                _GridMagicHelperDictEx.Add(itemKey, magicHelperItem);
            }
        }
コード例 #4
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);
                                }
                            }
                        }
                    }
                }
            }
        }