예제 #1
1
        public BaseGame(int id, int roomId, Map map, eRoomType roomType, eGameType gameType, int timeType)
            : base(id, roomType, gameType, timeType)
        {
            m_roomId = roomId;
            m_players = new Dictionary<int, Player>();
            m_turnQueue = new List<TurnedLiving>();
            m_livings = new List<Living>();

            m_random = new Random();

            m_map = map;
            m_actions = new ArrayList();
            PhysicalId = 0;
            BossWarField = "";

            m_tempBox = new List<Box>();
            m_tempPoints = new List<Point>();

            if (roomType == eRoomType.Dungeon)
            {
                Cards = new int[21];
            }
            else
            {
                Cards = new int[8];
            }

            m_gameState = eGameState.Inited;
        }
예제 #2
0
파일: BaseGame.cs 프로젝트: uvbs/DDTank-3.0
 public void OnGameOverLog(int _roomId, eRoomType _roomType, eGameType _fightType, int _changeTeam, DateTime _playBegin, DateTime _playEnd, int _userCount, int _mapId, string _teamA, string _teamB, string _playResult, int _winTeam, string BossWar)
 {
     if (GameOverLog != null)
     {
         GameOverLog(_roomId, _roomType, _fightType, _changeTeam, _playBegin, _playEnd, _userCount, _mapId, _teamA, _teamB, _playResult, _winTeam, BossWarField);
     }
 }
예제 #3
0
        public static PveInfo GetPveInfoByType(eRoomType roomType, int levelLimits)
        {
            if (roomType == eRoomType.Dungeon)
            {
                foreach (PveInfo pveInfo in m_pveInfos.Values)
                {
                    if (pveInfo.Type == (int)roomType)
                    {
                        return(pveInfo);
                    }
                }
            }

            else if (roomType == eRoomType.Freshman)
            {
                foreach (PveInfo pveInfo in m_pveInfos.Values)
                {
                    if ((pveInfo.Type == (int)roomType) && (pveInfo.LevelLimits == levelLimits))
                    {
                        return(pveInfo);
                    }
                }
            }
            return(null);
        }
예제 #4
0
        public static BaseGame StartGame(List<GamePlayer> red, List<GamePlayer> blue, int mapIndex,eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType)
        {
            try
            {
                int index = MapMgr.GetMapIndex(mapIndex,(byte)roomType);
                Map map = MapMgr.CloneMap(index);

                if (map != null)
                {
                    BaseGame game = new BaseGame(red, blue, map,roomType,teamType,gameType,timeType);

                    lock (m_games)
                    {
                        m_games.Add(game);
                    }

                    game.Prepare();
                    return game;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                log.Error("Create game error:", e);
                return null;
            }
        }
예제 #5
0
        private void HandlePlayerConsortiaFight(GSPacketIn pkg)
        {
            GamePlayer player = WorldMgr.GetPlayerById(pkg.ClientID);
            Dictionary <int, Player> players = new Dictionary <int, Player>();
            int consortiaWin  = pkg.ReadInt();
            int consortiaLose = pkg.ReadInt();
            int count         = pkg.ReadInt();
            int offer         = 0;

            for (int i = 0; i < count; i++)
            {
                GamePlayer Temp = WorldMgr.GetPlayerById(pkg.ReadInt());
                if (Temp != null)
                {
                    Player Tempplayer = new Player(Temp, 0, null, 0);
                    players.Add(i, Tempplayer);
                }
            }
            eRoomType roomtype        = (eRoomType)pkg.ReadByte();
            eGameType gametype        = (eGameType)pkg.ReadByte();
            int       totalKillHealth = pkg.ReadInt();

            if (player != null)
            {
                offer = player.ConsortiaFight(consortiaWin, consortiaLose, players, roomtype, gametype, totalKillHealth, count);
            }

            if (offer != 0)
            {
            }
        }
예제 #6
0
        private void HandlePlayerConsortiaFight(GSPacketIn pkg)
        {
            GamePlayer playerById = WorldMgr.GetPlayerById(pkg.ClientID);
            Dictionary <int, Player> dictionary = new Dictionary <int, Player>();
            int consortiaWin  = pkg.ReadInt();
            int consortiaLose = pkg.ReadInt();
            int num           = pkg.ReadInt();

            for (int i = 0; i < num; i++)
            {
                GamePlayer playerById2 = WorldMgr.GetPlayerById(pkg.ReadInt());
                if (playerById2 != null)
                {
                    Player value = new Player(playerById2, 0, null, 0, playerById2.PlayerCharacter.hp);
                    dictionary.Add(i, value);
                }
            }
            eRoomType roomType        = (eRoomType)pkg.ReadByte();
            eGameType gameClass       = (eGameType)pkg.ReadByte();
            int       totalKillHealth = pkg.ReadInt();

            if (playerById != null)
            {
                int num2 = playerById.ConsortiaFight(consortiaWin, consortiaLose, dictionary, roomType, gameClass, totalKillHealth, num);
            }
        }
예제 #7
0
        public static PveInfo GetPveInfoByType(eRoomType roomType, int levelLimits)
        {
            PveInfo result;

            if (roomType == eRoomType.Boss || roomType == eRoomType.Treasure || roomType == eRoomType.Training)
            {
                foreach (PveInfo pveInfo in PveInfoMgr.m_pveInfos.Values)
                {
                    if (pveInfo.Type == (int)roomType)
                    {
                        result = pveInfo;
                        return(result);
                    }
                }
            }
            else
            {
                if (roomType == eRoomType.Exploration)
                {
                    foreach (PveInfo pveInfo in PveInfoMgr.m_pveInfos.Values)
                    {
                        if (pveInfo.Type == (int)roomType && pveInfo.LevelLimits == levelLimits)
                        {
                            result = pveInfo;
                            return(result);
                        }
                    }
                }
            }
            result = null;
            return(result);
        }
예제 #8
0
        public static PveInfo GetPveInfoByType(eRoomType roomType, int levelLimits)
        {
            if (roomType == eRoomType.Dungeon || roomType == eRoomType.Freshman || roomType == eRoomType.Lanbyrinth || roomType == eRoomType.ConsortiaBoss || roomType == eRoomType.AcademyDungeon || roomType == eRoomType.FightLib)
            {
                using (Dictionary <int, PveInfo> .ValueCollection.Enumerator enumerator = PveInfoMgr.m_pveInfos.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        PveInfo current = enumerator.Current;
                        if (current.Type == (int)roomType)
                        {
                            PveInfo result = current;
                            return(result);
                        }
                    }
                    goto IL_AA;
                }
            }
            if (roomType == eRoomType.Exploration)
            {
                foreach (PveInfo current2 in PveInfoMgr.m_pveInfos.Values)
                {
                    if (current2.Type == (int)roomType && current2.LevelLimits == levelLimits)
                    {
                        PveInfo result = current2;
                        return(result);
                    }
                }
            }
IL_AA:
            return(null);
        }
예제 #9
0
        public static PveInfo GetPveInfoByType(eRoomType roomType, int levelLimits)
        {
            if (roomType == eRoomType.Dungeon)
            {
                foreach (PveInfo pveInfo in m_pveInfos.Values)
                {
                    if (pveInfo.Type == (int)roomType)
                    {
                        return pveInfo;
                    }
                }
            }

            else if (roomType == eRoomType.Freshman)
            {
                foreach (PveInfo pveInfo in m_pveInfos.Values)
                {
                    if ((pveInfo.Type == (int)roomType) && (pveInfo.LevelLimits == levelLimits))
                    {
                        return pveInfo;
                    }
                }
            }
            return null;
        }
예제 #10
0
파일: BaseGame.cs 프로젝트: uvbs/DDTank-3.0
        public BaseGame(int id, int roomId, Map map, eRoomType roomType, eGameType gameType, int timeType)
            : base(id, roomType, gameType, timeType)
        {
            m_roomId    = roomId;
            m_players   = new Dictionary <int, Player>();
            m_turnQueue = new List <TurnedLiving>();
            m_livings   = new List <Living>();

            m_random = new Random();

            m_map        = map;
            m_actions    = new ArrayList();
            PhysicalId   = 0;
            BossWarField = "";

            m_tempBox    = new List <Box>();
            m_tempPoints = new List <Point>();

            if (roomType == eRoomType.Treasure || roomType == eRoomType.Boss)
            {
                Cards = new int[21];
            }
            else
            {
                Cards = new int[8];
            }

            m_gameState = eGameState.Inited;
        }
예제 #11
0
        public static BaseGame StartPVEGame(List <IGamePlayer> player, int mapIndex, eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType)
        {
            try
            {
                int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId);
                index = 1072;
                Map map = MapMgr.CloneMap(index);

                if (map != null)
                {
                    PVEGame game = new PVEGame(m_gameId++, player, map, roomType, teamType, gameType, timeType);

                    lock (m_games)
                    {
                        m_games.Add(game);
                    }

                    game.Prepare();
                    return(game);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                log.Error("Create game error:", e);
                return(null);
            }
        }
예제 #12
0
 public CreateRoomAction(GamePlayer player, String name, String password, eRoomType roomType, byte timeType)
 {
     m_player = player;
     m_name = name;
     m_password = password;
     m_roomType = roomType;
     m_timeType = timeType;
 }
예제 #13
0
 public CreateRoomAction(GamePlayer player, String name, String password, eRoomType roomType, byte timeType)
 {
     m_player   = player;
     m_name     = name;
     m_password = password;
     m_roomType = roomType;
     m_timeType = timeType;
 }
예제 #14
0
        public void UpdateRoomGameType()
        {
            eRoomType roomType = this.RoomType;

            switch (roomType)
            {
            case eRoomType.Match:
            case eRoomType.Freedom:
                this.GameType = eGameType.Free;
                return;

            case eRoomType.Exploration:
            case (eRoomType)3:
                goto IL_77;

            case eRoomType.Dungeon:
                break;

            case eRoomType.FightLib:
                this.GameType = eGameType.FightLib;
                return;

            default:
                switch (roomType)
                {
                case eRoomType.Freshman:
                    this.GameType = eGameType.Freshman;
                    return;

                case eRoomType.AcademyDungeon:
                    break;

                default:
                    switch (roomType)
                    {
                    case eRoomType.Lanbyrinth:
                        break;

                    case eRoomType.Encounter:
                        goto IL_77;

                    case eRoomType.ConsortiaBoss:
                        this.GameType = eGameType.ConsortiaBoss;
                        return;

                    default:
                        goto IL_77;
                    }
                    break;
                }
                break;
            }
            this.GameType = eGameType.Dungeon;
            return;

IL_77:
            this.GameType = eGameType.ALL;
        }
예제 #15
0
        public static int ConsortiaFight(int consortiaWin, int consortiaLose, Dictionary<int, Player> players, eRoomType roomType, eGameType gameClass, int totalKillHealth, int playercount)
        {
            if (roomType != eRoomType.Match)
                return 0;

            int playerCount = playercount / 2;

            int riches = 0;
            int state = 2;
            int rate = 1;
            int value = 3;
            if (gameClass == eGameType.Guild)
            {
                value = 10;
                rate = (int)RateMgr.GetRate(eRateType.Offer_Rate);
            }

            float richesRate = RateMgr.GetRate(eRateType.Riches_Rate);
            using (ConsortiaBussiness db = new ConsortiaBussiness())
            {

                if (gameClass == eGameType.Free)
                {
                    playerCount = 0;
                }
                else
                {
                    db.ConsortiaFight(consortiaWin, consortiaLose, playerCount, out riches, state, totalKillHealth, richesRate);
                }
                //(对方公会等级-3)*50*对方玩家人数(对方玩家人数是指进入战斗时的人数,中途退出或者掉线的玩家不改变这个数值)
                //玩家增加掠夺财富
                foreach (KeyValuePair<int, Player> p in players)
                {
                    //if (p.Value.State == TankGameState.LOSE)
                    //    continue;
                    if (p.Value == null)
                        continue;

                    if (p.Value.PlayerDetail.PlayerCharacter.ConsortiaID == consortiaWin)
                    {

                        p.Value.PlayerDetail.AddOffer((playerCount + value) * rate);

                        p.Value.PlayerDetail.PlayerCharacter.RichesRob += riches;
                    }
                    else if (p.Value.PlayerDetail.PlayerCharacter.ConsortiaID == consortiaLose)
                    {
                        p.Value.PlayerDetail.AddOffer((int)Math.Round(playerCount * 0.5) * rate);
                        p.Value.PlayerDetail.RemoveOffer(value);
                    }
                }

            }

            return riches;
        }
예제 #16
0
 public RoomSetupChangeAction(BaseRoom room, GSPacketIn packet, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId)
 {
     m_room = room;
     m_roomType = roomType;
     m_timeMode = timeMode;
     m_hardLevel = hardLevel;
     m_levelLimits = levelLimits;
     m_mapId = mapId;
     m_packet = packet;
 }
예제 #17
0
 private void m_game_RoomRest(AbstractGame game)
 {
     if (this.m_game != null && this.PickUpNPC)
     {
         this.m_game.RoomRest -= new GameEventHandle(this.m_game_RoomRest);
     }
     this.RoomType  = this.OldRoomType;
     this.PickUpNPC = false;
     this.MapId     = 0;
 }
예제 #18
0
 public RoomSetupChangeAction(BaseRoom room, GSPacketIn packet, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId)
 {
     m_room        = room;
     m_roomType    = roomType;
     m_timeMode    = timeMode;
     m_hardLevel   = hardLevel;
     m_levelLimits = levelLimits;
     m_mapId       = mapId;
     m_packet      = packet;
 }
예제 #19
0
 public RoomSetupChangeAction(BaseRoom room, GSPacketIn packet, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, bool isArea)
 {
     this.m_room        = room;
     this.m_roomType    = roomType;
     this.m_timeMode    = timeMode;
     this.m_hardLevel   = hardLevel;
     this.m_levelLimits = levelLimits;
     this.m_mapId       = mapId;
     this.m_packet      = packet;
     this.m_isArea      = isArea;
 }
예제 #20
0
        public void SetRoomType(Pointer index, eRoomType type)
        {
            if ((index.x < 0 || index.x >= m_MapSize.x) || ((index.y < 0 || index.y >= m_MapSize.y)))
            {
                Debug.Log("error index : " + index.x + " : " + index.y);
                Debug.DebugBreak();
            }

            pathLoad.Add(new Pointer(index.x, index.y));
            Debug.Log(string.Format("x = {0}, y= {1}", index.x, index.y));
            m_Rooms [index.x, index.y].type = (int)type;
        }
예제 #21
0
 public RoomSetupChangeAction(BaseRoom room, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, string password, string roomname, bool isCrosszone, bool isOpenBoss)
 {
     m_room = room;
     m_roomType = roomType;
     m_timeMode = timeMode;
     m_hardLevel = hardLevel;
     m_levelLimits = levelLimits;
     m_mapId = mapId;
     m_password = password;
     m_roomName = roomname;
     m_isCrosszone = isCrosszone;
     m_isOpenBoss = isOpenBoss;
 }
예제 #22
0
 public RoomSetupChangeAction(BaseRoom room, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, string password, string roomname, bool isCrosszone, bool isOpenBoss)
 {
     this.m_room        = room;
     this.m_roomType    = roomType;
     this.m_timeMode    = timeMode;
     this.m_hardLevel   = hardLevel;
     this.m_levelLimits = levelLimits;
     this.m_mapId       = mapId;
     this.m_password    = password;
     this.m_roomName    = roomname;
     this.m_isCrosszone = isCrosszone;
     this.m_isOpenBoss  = isOpenBoss;
 }
예제 #23
0
 /// <summary>
 /// 2、宝箱掉落
 /// </summary>
 /// <returns></returns>
 public static bool BoxDrop(eRoomType e, ref  List<ItemInfo> info)
 {
     int dropId = GetDropCondiction(eDropType.Box, ((int)e).ToString(), "0");
     if (dropId > 0)
     {
         List<ItemInfo> infos = null;
         if (GetDropItems(eDropType.Box, dropId, ref infos))
         {
             info = infos != null ? infos : null;
             return true;
         }
     }
     return false;
 }
예제 #24
0
        /// <summary>
        /// 7、PVP任务掉落
        /// </summary>
        /// <param name="e"></param>
        /// <param name="playResult"></param>
        /// <param name="info"></param>
        /// <param name="gold"></param>
        /// <param name="money"></param>
        /// <param name="giftToken"></param>
        /// <returns></returns>
        public static bool PvPQuestsDrop(eRoomType e, bool playResult, ref List <ItemInfo> info)
        {
            int dropId = GetDropCondiction(eDropType.PvpQuests, ((int)e).ToString(), (Convert.ToInt16(playResult)).ToString());

            if (dropId > 0)
            {
                List <ItemInfo> infos = null;
                if (GetDropItems(eDropType.PvpQuests, dropId, ref infos))
                {
                    info = infos != null ? infos : null;
                    return(true);
                }
            }
            return(false);
        }
예제 #25
0
        /// <summary>
        /// 2、宝箱掉落
        /// </summary>
        /// <returns></returns>
        public static bool BoxDrop(eRoomType e, ref List <ItemInfo> info)
        {
            int dropId = GetDropCondiction(eDropType.Box, ((int)e).ToString(), "0");

            if (dropId > 0)
            {
                List <ItemInfo> infos = null;
                if (GetDropItems(eDropType.Box, dropId, ref infos))
                {
                    info = infos != null ? infos : null;
                    return(true);
                }
            }
            return(false);
        }
예제 #26
0
 public void UpdateRoom(string name, string pwd, eRoomType roomType, byte timeMode, int mapId)
 {
     this.Name     = name;
     this.Password = pwd;
     this.RoomType = roomType;
     this.TimeMode = timeMode;
     this.MapId    = mapId;
     this.UpdateRoomGameType();
     if (roomType == eRoomType.Freedom)
     {
         this.m_placesCount = 8;
         return;
     }
     this.m_placesCount = 4;
 }
예제 #27
0
        private void player_AfterKillingLiving(AbstractGame game, int type, int id, bool isLiving, int demage)
        {
            if (!isLiving && type == 1)
            {
                eRoomType roomType = game.RoomType;
                switch (roomType)
                {
                case eRoomType.Match:
                    if ((this.m_info.Para1 == 0 || this.m_info.Para1 == -1) && base.Value > 0)
                    {
                        base.Value--;
                    }
                    break;

                case eRoomType.Freedom:
                    if ((this.m_info.Para1 == 1 || this.m_info.Para1 == -1) && base.Value > 0)
                    {
                        base.Value--;
                    }
                    break;

                case eRoomType.Exploration:
                case (eRoomType)3:
                    break;

                case eRoomType.Dungeon:
                    if ((this.m_info.Para1 == 4 || this.m_info.Para1 == -1) && base.Value > 0)
                    {
                        base.Value--;
                    }
                    break;

                default:
                    if (roomType == eRoomType.Freshman)
                    {
                        if ((this.m_info.Para1 == 2 || this.m_info.Para1 == -1) && base.Value > 0)
                        {
                            base.Value--;
                        }
                    }
                    break;
                }
                if (base.Value < 0)
                {
                    base.Value = 0;
                }
            }
        }
예제 #28
0
        private void player_GameOver(AbstractGame game, bool isWin, int gainXp)
        {
            if (isWin)
            {
                eRoomType roomType = game.RoomType;
                switch (roomType)
                {
                case eRoomType.Match:
                    if ((this.m_info.Para1 == 0 || this.m_info.Para1 == -1) && base.Value > 0)
                    {
                        base.Value--;
                    }
                    break;

                case eRoomType.Freedom:
                    if ((this.m_info.Para1 == 1 || this.m_info.Para1 == -1) && base.Value > 0)
                    {
                        base.Value--;
                    }
                    break;

                case eRoomType.Exploration:
                case (eRoomType)3:
                    break;

                case eRoomType.Dungeon:
                    if ((this.m_info.Para1 == 4 || this.m_info.Para1 == -1) && base.Value > 0)
                    {
                        base.Value--;
                    }
                    break;

                default:
                    if (roomType == eRoomType.Freshman)
                    {
                        if ((this.m_info.Para1 == 2 || this.m_info.Para1 == -1) && base.Value > 0)
                        {
                            base.Value--;
                        }
                    }
                    break;
                }
                if (base.Value < 0)
                {
                    base.Value = 0;
                }
            }
        }
예제 #29
0
        private void HandlePlayerConsortiaFight(GSPacketIn pkg)
        {
            GamePlayer player          = WorldMgr.GetPlayerById(pkg.ClientID);
            int        consortiaWin    = pkg.ReadInt();
            int        consortiaLose   = pkg.ReadInt();
            int        count           = pkg.ReadInt();
            eRoomType  roomtype        = (eRoomType)pkg.ReadByte();
            eGameType  gametype        = (eGameType)pkg.ReadByte();
            int        totalKillHealth = pkg.ReadInt();
            int        check           = pkg.ReadInt();

            if (player != null && check == totalKillHealth)
            {
                player.ConsortiaFight(consortiaWin, consortiaLose, roomtype, gametype, totalKillHealth, count);
            }
        }
예제 #30
0
        /// <summary>
        /// 添加战斗记录
        /// </summary>
        /// <param name="logFightInfo"></param>
        public static void LogFightAdd(int roomId, eRoomType roomType, eGameType fightType, int changeTeam, DateTime playBegin, DateTime playEnd, int userCount, int mapId, string teamA,string teamB, string playResult,int winTeam,string BossWar)
        {
            try
            {
                object[] info = { _gameType, _serverId, _areaId, roomId, (int)roomType, (int)fightType, changeTeam, playBegin, playEnd, userCount, mapId, teamA, teamB, playResult, winTeam, BossWar };

                lock (m_LogFight)
                {
                    m_LogFight.Rows.Add(info);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("LogMgr Error:Fight @ " + e);
            }
        }
예제 #31
0
        public static bool BoxDrop(eRoomType e, ref List <ItemInfo> info)
        {
            eDropType arg_0F_0       = eDropType.Box;
            int       num            = (int)e;
            int       dropCondiction = DropInventory.GetDropCondiction(arg_0F_0, num.ToString(), "0");

            if (dropCondiction > 0)
            {
                List <ItemInfo> list = null;
                if (DropInventory.GetDropItems(eDropType.Box, dropCondiction, ref list))
                {
                    info = ((list != null) ? list : null);
                    return(true);
                }
            }
            return(false);
        }
예제 #32
0
        public static bool PvPQuestsDrop(eRoomType e, bool playResult, ref List <ItemInfo> info)
        {
            eDropType arg_18_0       = eDropType.PvpQuests;
            int       num            = (int)e;
            int       dropCondiction = DropInventory.GetDropCondiction(arg_18_0, num.ToString(), Convert.ToInt16(playResult).ToString());

            if (dropCondiction > 0)
            {
                List <ItemInfo> list = null;
                if (DropInventory.GetDropItems(eDropType.PvpQuests, dropCondiction, ref list))
                {
                    info = ((list != null) ? list : null);
                    return(true);
                }
            }
            return(false);
        }
예제 #33
0
        public void UpdateRoom(string name, string pwd, eRoomType roomType, byte timeMode, int mapId)
        {
            Name     = name;
            Password = pwd;
            RoomType = roomType;
            TimeMode = timeMode;
            MapId    = mapId;

            UpdateRoomGameType();
            if (roomType == eRoomType.Freedom)
            {
                m_placesCount = 8;
            }
            else
            {
                m_placesCount = 4;
            }
        }
예제 #34
0
 public override int HandlePacket(GamePlayer player, GSPacketIn packet)
 {
     if (player.CurrentRoom != null && player == player.CurrentRoom.Host && !player.CurrentRoom.IsPlaying)
     {
         int       mapId       = packet.ReadInt();
         eRoomType roomType    = (eRoomType)packet.ReadByte();
         byte      timeType    = packet.ReadByte();
         byte      hardLevel   = packet.ReadByte();
         int       levelLimits = packet.ReadInt();
         bool      IsArea      = packet.ReadBoolean();
         if (IsArea && !BattleMgr.IsOpenAreaFight)
         {
             player.SendMessage(eMessageType.ChatNormal, "尚未开放跨服战斗");
         }
         RoomMgr.UpdateRoomGameType(player.CurrentRoom, packet, roomType, timeType, (eHardLevel)hardLevel, levelLimits, mapId, IsArea);
     }
     return(0);
 }
예제 #35
0
    public void StartMatch(eRoomType gameType, int timeType)
    {
        // this.Act(new PlayerExecutable(this.EnterWaitingRoom));
        System.Threading.Thread.Sleep(100);
        switch (gameType)
        {
        case eRoomType.Match:
            EnterWaitingRoom(1);
            this.Act(new PlayerExecutable(this.CreateSoloRoom));
            break;

        default:
            Debug.Log("Starting exploration match");
            EnterWaitingRoom(2);
            this.Act(new PlayerExecutable(this.CreateExploreRoom));
            break;
        }
    }
예제 #36
0
        public PVEGame(int id, int roomId, PveInfo info, List<IGamePlayer> players, Map map, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel)
            : base(id, roomId, map, roomType, gameType, timeType)
        {
            PlayersXY = new List<Point>();

            foreach (IGamePlayer player in players)
            {
                Player fp = new Player(player, PhysicalId++, this, 1);
                //fp.Reset();
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                AddPlayer(player, fp);
            }

            m_info = info;
            BeginPlayersCount = players.Count;
            TotalKillCount = 0;
            TotalNpcGrade = 0;
            TotalNpcExperience = 0;
            TotalHurt = 0;

            m_IsBossType = "";

            WantTryAgain = 0;
            SessionId = 0;
            m_gameOverResources = new List<string>();
            Misssions = new Dictionary<int, MissionInfo>();
            m_mapHistoryIds = new List<int>();
            m_hardLevel = hardLevel;

            string script = GetScript(info, hardLevel);

            m_gameAI = ScriptMgr.CreateInstance(script) as APVEGameControl;
            if (m_gameAI == null)
            {
                log.ErrorFormat("Can't create game ai :{0}", script);
                m_gameAI = SimplePVEGameControl.Simple;
            }
            m_gameAI.Game = this;
            m_gameAI.OnCreated();

            m_missionAI = SimpleMissionControl.Simple;
            beginTime = DateTime.Now;
            m_bossCardCount = 0;
        }
예제 #37
0
        public void SendLogFight(int _roomId, eRoomType _roomType, eGameType _fightType, int _changeTeam, DateTime _playBegin, DateTime _playEnd, int _userCount, int _mapId, string _teamA, string _teamB, string _playResult, int _winTeam, string BossWar)
        {
            GSPacketIn pkg = new GSPacketIn(5);

            pkg.WriteInt(_roomId);
            pkg.WriteInt((int)_roomType);
            pkg.WriteInt((int)_fightType);
            pkg.WriteInt(_changeTeam);
            pkg.WriteDateTime(_playBegin);
            pkg.WriteDateTime(_playEnd);
            pkg.WriteInt(_userCount);
            pkg.WriteInt(_mapId);
            pkg.WriteString(_teamA);
            pkg.WriteString(_teamB);
            pkg.WriteString(_playResult);
            pkg.WriteInt(_winTeam);
            pkg.WriteString(BossWar);
            this.SendTCP(pkg);
        }
예제 #38
0
        /// <summary>
        /// 添加战斗记录
        /// </summary>
        /// <param name="logFightInfo"></param>
        public static void LogFightAdd(int roomId, eRoomType roomType, eGameType fightType, int changeTeam, DateTime playBegin, DateTime playEnd, int userCount, int mapId, string teamA, string teamB, string playResult, int winTeam, string BossWar)
        {
            try
            {
                object[] info = { _gameType, _serverId, _areaId, roomId, (int)roomType, (int)fightType, changeTeam, playBegin, playEnd, userCount, mapId, teamA, teamB, playResult, winTeam, BossWar };

                lock (m_LogFight)
                {
                    m_LogFight.Rows.Add(info);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("LogMgr Error:Fight @ " + e);
                }
            }
        }
예제 #39
0
        public PVPGame(int id, int roomId, List<IGamePlayer> red, List<IGamePlayer> blue, Map map, eRoomType roomType, eGameType gameType, int timeType)
            : base(id, roomId, map, roomType, gameType, timeType)
        {
            m_redTeam = new List<Player>();
            m_blueTeam = new List<Player>();

            StringBuilder sbTeampA = new StringBuilder();
            m_redAvgLevel = 0;
            foreach (IGamePlayer player in red)
            {
                Player fp = new Player(player, PhysicalId++, this, 1);
                sbTeampA.Append(player.PlayerCharacter.ID).Append(",");
                fp.Reset();
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;

                AddPlayer(player, fp);

                m_redTeam.Add(fp);
                m_redAvgLevel += player.PlayerCharacter.Grade;
            }
            m_redAvgLevel = m_redAvgLevel / m_redTeam.Count;
            teamAStr = sbTeampA.ToString();

            StringBuilder sbTeampB = new StringBuilder();
            m_blueAvgLevel = 0;
            foreach (IGamePlayer player in blue)
            {
                Player fp = new Player(player, PhysicalId++, this, 2);
                sbTeampB.Append(player.PlayerCharacter.ID).Append(",");
                fp.Reset();
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;

                AddPlayer(player, fp);

                m_blueTeam.Add(fp);
                m_blueAvgLevel += player.PlayerCharacter.Grade;
            }
            m_blueAvgLevel = m_blueAvgLevel / blue.Count;
            teamBStr = sbTeampB.ToString();

            BeginPlayerCount = m_redTeam.Count + m_blueTeam.Count;
            beginTime = DateTime.Now;
        }
예제 #40
0
 public static void LogFightAdd(int roomId, eRoomType roomType, eGameType fightType, int changeTeam, DateTime playBegin, DateTime playEnd, int userCount, int mapId, string teamA, string teamB, string playResult, int winTeam, string BossWar)
 {
     try
     {
         object[] values = new object[]
         {
             LogMgr._gameType,
             LogMgr._serverId,
             LogMgr._areaId,
             roomId,
             (int)roomType,
             (int)fightType,
             changeTeam,
             playBegin,
             playEnd,
             userCount,
             mapId,
             teamA,
             teamB,
             playResult,
             winTeam,
             BossWar
         };
         DataTable logFight;
         Monitor.Enter(logFight = LogMgr.m_LogFight);
         try
         {
             LogMgr.m_LogFight.Rows.Add(values);
         }
         finally
         {
             Monitor.Exit(logFight);
         }
     }
     catch (Exception arg)
     {
         if (LogMgr.log.IsErrorEnabled)
         {
             LogMgr.log.Error("LogMgr Error:Fight @ " + arg);
         }
     }
 }
예제 #41
0
        public BaseSceneGame(int id, IGameProcessor processor)
        {
            _id = id;

            _processor = processor;

            _userList = new GamePlayer[_processor.MaxPlayerCount];

            _openState = new bool[_processor.MaxPlayerCount];

            _locker = new ReaderWriterLock();

            _count = 0;

            _gameState = eGameState.FREE;

            _roomType = eRoomType.FREE;

            Revert();
        }
예제 #42
0
        public BaseSceneGame(int id, IGameProcessor processor)
        {
            _id = id;

            _processor = processor;

            _userList = new GamePlayer[_processor.MaxPlayerCount];

            _openState = new bool[_processor.MaxPlayerCount];

            _locker = new ReaderWriterLock();

            _count = 0;

            _gameState = eGameState.FREE;

            _roomType = eRoomType.FREE;

            Revert();
        }
예제 #43
0
        public static BaseGame StartPVEGame(int roomId, List<IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits)
        {
            try
            {
                PveInfo info = null;

                if (copyId == 0 || copyId == 100000)
                {
                    info = PveInfoMgr.GetPveInfoByType(roomType, levelLimits);
                }
                else
                {
                    info = PveInfoMgr.GetPveInfoById(copyId);
                }
                if (info != null)
                {
                    PVEGame game = new PVEGame(m_gameId++, roomId, info, players, null, roomType, gameType, timeType, hardLevel);
                    game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd);
                    lock (m_games)
                    {
                        m_games.Add(game);
                    }

                    game.Prepare();
                    return game;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                log.Error("Create game error:", e);
                return null;
            }
        }
예제 #44
0
 public static PveInfo GetPveInfoByType(eRoomType roomType, int levelLimits)
 {
     if (roomType == eRoomType.Boss || roomType == eRoomType.Treasure)
     {
         foreach (PveInfo pveInfo in m_pveInfos.Values)
         {
             if (pveInfo.Type == (int)roomType)
             {
                 return pveInfo;
             }
         }
     }
     else if (roomType == eRoomType.Exploration)
     {
         foreach (PveInfo pveInfo in m_pveInfos.Values)
         {
             if ((pveInfo.Type == (int)roomType) && (pveInfo.LevelLimits == levelLimits))
             {
                 return pveInfo;
             }
         }
     }
     return null;
 }
예제 #45
0
 public ProxyGame(int id,FightServerConnector fightServer,eRoomType roomType, eGameType gameType,int timeType)
     : base(id,roomType,gameType,timeType)
 {
     m_fightingServer = fightServer;
     m_fightingServer.Disconnected += new Game.Base.ClientEventHandle(m_fightingServer_Disconnected);
 }
예제 #46
0
 /// <summary>
 /// 7、PVP任务掉落
 /// </summary>
 /// <param name="e"></param>
 /// <param name="playResult"></param>
 /// <param name="info"></param>
 /// <param name="gold"></param>
 /// <param name="money"></param>
 /// <param name="giftToken"></param>
 /// <returns></returns>
 public static bool PvPQuestsDrop(eRoomType e, bool playResult, ref  List<ItemInfo> info)
 {
     int dropId = GetDropCondiction(eDropType.PvpQuests, ((int)e).ToString(), (Convert.ToInt16(playResult)).ToString());
     if (dropId > 0)
     {
         List<ItemInfo> infos = null;
         if (GetDropItems(eDropType.PvpQuests, dropId, ref infos))
         {
             info = infos != null ? infos : null;
             return true;
         }
     }
     return false;
 }
예제 #47
0
        public static BaseGame StartPVPGame(int roomId, List<IGamePlayer> red, List<IGamePlayer> blue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            try
            {
                int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId);
                Map map = MapMgr.CloneMap(index);

                if (map != null)
                {
                    PVPGame game = new PVPGame(m_gameId++, roomId, red, blue, map, roomType, gameType, timeType);
                    game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd);
                    lock (m_games)
                    {
                        m_games.Add(game);
                    }

                    game.Prepare();
                    return game;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                log.Error("Create game error:", e);
                return null;
            }

        }
예제 #48
0
        public BaseGame(List<GamePlayer> red, List<GamePlayer> blue, Map map,eRoomType roomType,eTeamType teamType, eGameType gameType, int timeType)
        {
            m_players = new Dictionary<GamePlayer, Player>();
            m_redTeam = new List<Player>();
            m_blueTeam = new List<Player>();
            m_roomType = roomType;
            m_gameType = gameType;
            m_teamType = teamType;
            m_random = new Random();

            m_redAvgLevel = 0;
            foreach (GamePlayer player in red)
            {
                Player fp = new Player(player, this, 1);
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                m_players.Add(player, fp);
                m_redTeam.Add(fp);
                player.CurrentGame = this;
                m_redAvgLevel += player.PlayerCharacter.Grade;

                fp.Died += new PlayerEventHandle(Player_Died);
            }
            m_redAvgLevel = m_redAvgLevel / m_redTeam.Count;

            m_blueAvgLevel = 0;
            foreach (GamePlayer player in blue)
            {
                Player fp = new Player(player, this, 2);
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                m_players.Add(player, fp);
                m_blueTeam.Add(fp);
                player.CurrentGame = this;
                m_blueAvgLevel += player.PlayerCharacter.Grade;

                fp.Died += new PlayerEventHandle(Player_Died);
            }
            m_blueAvgLevel = m_blueAvgLevel / blue.Count;

            m_map = map;
            m_actions = new ArrayList();
            PhysicalId = 0;

            switch (m_roomType)
            {
                case eRoomType.Freedom:
                    m_mapType = eMapType.Normal;
                    break;
                case eRoomType.Match:
                    m_mapType = eMapType.PairUp;
                    break;
                default:
                    m_mapType = eMapType.Normal;
                    break;
            }
            
           
            m_timeType = timeType;
            m_tempBox = new List<Box>();
            m_tempPoints = new List<Point>();
            Cards = new int[8];
            GameState = eGameState.Inited;
        }
예제 #49
0
        public int ConsortiaFight(int consortiaWin, int consortiaLose, Dictionary<int, Player> players, eRoomType roomType, eGameType gameClass, int totalKillHealth, int count)
        {
            m_client.SendPlayerConsortiaFight(m_character.ID, consortiaWin, consortiaLose, players, roomType, gameClass, totalKillHealth);

            return 0;
        }
예제 #50
0
 public static void CreateRoom(GamePlayer player, string name, string password, eRoomType roomType, byte timeType)
 {
     AddAction(new CreateRoomAction(player, name, password, roomType, timeType));
 }
예제 #51
0
 public static void UpdateRoomGameType(BaseRoom room, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, string password, string roomname, bool isCrosszone, bool isOpenBoss)
 {
     AddAction(new RoomSetupChangeAction(room, roomType, timeMode, hardLevel, levelLimits, mapId, password, roomname, isCrosszone, isOpenBoss));
 }
예제 #52
0
        public void SendPlayerConsortiaFight(int playerId, int consortiaWin, int consortiaLose, Dictionary<int, Player> players, eRoomType roomType, eGameType gameClass, int totalKillHealth)
        {
            GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.PLAYER_CONSORTIAFIGHT, playerId);
            pkg.WriteInt(consortiaWin);
            pkg.WriteInt(consortiaLose);
            pkg.WriteInt(players.Count);
            for (int i = 0; i < players.Count; i++)
            {
                pkg.WriteInt(players[i].PlayerDetail.PlayerCharacter.ID);
            }
            pkg.WriteByte((byte)roomType);
            pkg.WriteByte((byte)gameClass);
            pkg.WriteInt(totalKillHealth);
            SendTCP(pkg);


        }
예제 #53
0
        public int GetRandomGold(eRoomType eType)
        {
            bool flag = eType == eRoomType.PAIRUP;

            int gold = 1000;
            int rate = rand.Next(0, 100);
            if (rate < 1)
            {
                gold = flag ? 5000 : 1000;
            }
            else if (rate < 6)
            {
                gold = flag ? 2000 : 500;
            }
            else
            {
                //300 350 400 450 500 550 600 650 另外10%几率出现1000金币,5%几率出现2000金币,1%几率出现5000金币
                gold = flag ? rand.Next(6, 14) * 50 : rand.Next(5, 16) * 10;
            }

            return gold;
        }
예제 #54
0
        public void UpdateRoom(string name, string pwd, eRoomType roomType, byte timeMode, int mapId)
        {
            Name = name;
            Password = pwd;
            RoomType = roomType;
            TimeMode = timeMode;
            MapId = mapId;

            UpdateRoomGameType();
            if (roomType == eRoomType.Freedom)
            {
                m_placesCount = 8;
            }
            else
            {
                m_placesCount = 4;
            }
        }
예제 #55
0
 public AbstractGame(int id, eRoomType roomType, eGameType gameType, int timeType)
 {
     m_id = id;
     m_roomType = roomType;
     m_gameType = gameType;
     m_timeType = timeType;
     switch (m_roomType)
     {
         case eRoomType.Freedom:
             m_mapType = eMapType.Normal;
             break;
         case eRoomType.Match:
             m_mapType = eMapType.PairUp;
             break;
         default:
             m_mapType = eMapType.Normal;
             break;
     }
 }
예제 #56
0
 public BattleGame(int id, List<IGamePlayer> red, ProxyRoom roomRed, List<IGamePlayer> blue, ProxyRoom roomBlue, Map map, eRoomType roomType, eGameType gameType, int timeType)
     : base(id, roomBlue.RoomId, red, blue, map, roomType, gameType, timeType)
 {
     m_roomRed = roomRed;
     m_roomBlue = roomBlue;
 }
예제 #57
0
        public static int KillPlayer(GamePlayer win, GamePlayer lose, Dictionary<GamePlayer, Player> players, eRoomType roomType, eGameType gameClass)
        {
            if (roomType != eRoomType.Match)
                return -1;

            int state = FindConsortiaAlly(win.PlayerCharacter.ConsortiaID, lose.PlayerCharacter.ConsortiaID);

            if (state == -1)
                return state;

            int offer = GetOffer(state, gameClass);
            if (lose.PlayerCharacter.Offer < offer)
                offer = lose.PlayerCharacter.Offer;

            if (offer != 0)
            {
                players[win].GainOffer = offer;
                players[lose].GainOffer = -offer;

            }

            return state;
        }
예제 #58
0
 public int ConsortiaFight(int consortiaWin, int consortiaLose, Dictionary<int, Player> players, eRoomType roomType, eGameType gameClass, int totalKillHealth, int count)
 {
     return ConsortiaMgr.ConsortiaFight(consortiaWin, consortiaLose, players, roomType, gameClass, totalKillHealth, count);
 }
예제 #59
0
 public void OnGameOverLog(int _roomId, eRoomType _roomType, eGameType _fightType, int _changeTeam, DateTime _playBegin, DateTime _playEnd, int _userCount, int _mapId, string _teamA, string _teamB, string _playResult, int _winTeam, string BossWar)
 {
     if (GameOverLog != null)
     {
         GameOverLog(_roomId, _roomType, _fightType, _changeTeam, _playBegin, _playEnd, _userCount, _mapId, _teamA, _teamB, _playResult, _winTeam, BossWarField);
     }
 }
예제 #60
0
 public static void UpdateRoomGameType(BaseRoom room, GSPacketIn packet, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId)
 {
     AddAction(new RoomSetupChangeAction(room, packet, roomType, timeMode, hardLevel, levelLimits, mapId));
 }