void ReadTeamMember(XmlNode node, Team.Side team, GameMatchData matchData) { foreach (XmlNode child in node.ChildNodes) { XmlElement element = child as XmlElement; GameMatch.Config.TeamMember tm = new GameMatch.Config.TeamMember(); tm.pos = XmlUtils.XmlGetAttr_Int(element, "pos"); tm.id = XmlUtils.XmlGetAttr_String(element, "id"); tm.team = team; if (element.Name == "NPC") { matchData.npcList.Add(tm); } else if (child.Name == "MainRole") { matchData.mainRole = tm; } else if (child.Name == "RemotePlayer") { matchData.remoteList.Add(tm); } else { Debug.Log(ToString() + ": Invalid config."); return; } } }
public void CreateBullFightMatch(ulong sessionID, uint roleId, uint npcId) { GameMatch.Config config = new GameMatch.Config(); config.leagueType = GameMatch.LeagueType.eBullFight; config.type = GameMatch.Type.eBullFight; List <uint> sceneIDs = new List <uint>(GameSystem.Instance.SceneConfig.configs.Keys); config.sceneId = sceneIDs[UnityEngine.Random.Range(0, sceneIDs.Count)]; config.MatchTime = new IM.Number(120); config.session_id = sessionID; var member = new GameMatch.Config.TeamMember(); member.id = roleId.ToString(); member.pos = (int)fogs.proto.msg.FightStatus.FS_MAIN; member.team = Team.Side.eHome; member.team_name = MainPlayer.Instance.Name; member.roleInfo = MainPlayer.Instance.GetRole(roleId).m_roleInfo; config.MainRole = member; var enemy = new GameMatch.Config.TeamMember(); enemy.id = npcId.ToString(); enemy.pos = 4; enemy.team = Team.Side.eAway; enemy.roleInfo = null; config.NPCs.Add(enemy); CreateNewMatch(config); }
protected override void _OnLoadingCompleteImp() { base._OnLoadingCompleteImp(); GameMatch.Config.TeamMember member = m_config.NPCs[1]; _GeneratePlayerData(member, member.team != m_config.MainRole.team); if (m_config == null) { Debug.LogError("Match config file loading failed."); return; } //TODO 针对PVP修改 //main role PlayerManager pm = GameSystem.Instance.mClient.mPlayerManager; mainRole = pm.GetPlayerById(uint.Parse(m_config.MainRole.id)); mainRole.m_StateMachine.ReplaceState(new PlayerState_Stand_Simple(mainRole.m_StateMachine, this)); //mainRole.m_inputDispatcher = new InputDispatcher(mainRole); //mainRole.m_inputDispatcher.m_enable = false; mainRole.m_catchHelper = new CatchHelper(mainRole); mainRole.m_catchHelper.ExtractBallLocomotion(); mainRole.m_StateMachine.SetState(PlayerState.State.eStand, true); mainRole.m_team.m_role = GameMatch.MatchRole.eDefense; mainRole.m_alwaysForbiddenPickup = true; //npc Team oppoTeam = mainRole.m_team.m_side == Team.Side.eAway ? m_homeTeam : m_awayTeam; npc = oppoTeam.GetMember(0); npc.m_StateMachine.ReplaceState(new PlayerState_Knocked_NoHold(npc.m_StateMachine, this)); if (npc.model != null) { npc.model.EnableGrey(); } npc.m_team.m_role = GameMatch.MatchRole.eOffense; npc.operMode = Player.OperMode.AI; npc.m_alwaysForbiddenPickup = true; //shooter shooter = oppoTeam.GetMember(1); if (shooter.model != null) { shooter.model.EnableGrey(); } m_auxiliaries.Add(shooter.m_id); shooter.m_team.m_role = GameMatch.MatchRole.eOffense; shooter.operMode = Player.OperMode.AI; shooter.m_alwaysForbiddenPickup = true; _UpdateCamera(mainRole); }
public void CreateNewQualifyingMatch(ulong sessionID, List <FightRole> fightList, RivalInfo rivalInfo) { GameMatch.Config config = new GameMatch.Config(); config.leagueType = GameMatch.LeagueType.eQualifying; config.type = GameMatch.Type.e3AIOn3AI; List <uint> sceneIDs = new List <uint>(GameSystem.Instance.SceneConfig.configs.Keys); config.sceneId = sceneIDs[UnityEngine.Random.Range(0, sceneIDs.Count)]; config.MatchTime = new IM.Number(120); config.session_id = sessionID; //object obj = LuaScriptMgr.Instance.GetLuaTable("_G")["CurLoadingImage"]; string str = "Texture/LoadShow"; object obj = (object)str; LuaScriptMgr.Instance.GetLuaTable("_G").Set("CurLoadingImage", obj); foreach (FightRole info in fightList) { var member = new GameMatch.Config.TeamMember(); member.id = info.role_id.ToString(); member.pos = (int)info.status; member.team = Team.Side.eHome; member.team_name = MainPlayer.Instance.Name; member.roleInfo = MainPlayer.Instance.GetRole(info.role_id).m_roleInfo; if (info.status == FightStatus.FS_MAIN) { config.MainRole = member; } else { config.NPCs.Add(member); } } int pos = 4; foreach (RoleInfo info in rivalInfo.role_info) { var member = new GameMatch.Config.TeamMember(); member.id = info.id.ToString(); member.pos = pos++; member.team = Team.Side.eAway; member.team_name = rivalInfo.name; member.roleInfo = info; member.isRobot = rivalInfo.player_type == CharacterType.ROBOT ? true : false; if (member.isRobot == false) { member.equipInfo = rivalInfo.equipments; member.squadInfo = rivalInfo.squad; } config.NPCs.Add(member); } CreateNewMatch(config); }
public void CreateMatch(PractiseData practise, ulong session_id) { if (practise.ID == 10001) { GameSystem.Instance.mClient.CreateNewMatch(GlobalConst.DIR_XML_MATCH_GUIDE, session_id, GameMatch.Type.eGuide); return; } GameMatch.Type type = GameMatch.Type.ePractise; GameMatch.Config config = new GameMatch.Config(); config.leagueType = GameMatch.LeagueType.ePractise; config.type = type; config.needPlayPlot = false; config.MatchTime = IM.Number.zero; config.sceneId = uint.Parse(practise.scene); config.extra_info = practise.ID; config.session_id = session_id; if (GameSystem.Instance.PractiseConfig.GetConfig(practise.ID).is_activity == 1) { GameMatch.Config.TeamMember mem = new GameMatch.Config.TeamMember(); List <uint> list = MainPlayer.Instance.GetRoleIDList(); int max = list.Count; int index = UnityEngine.Random.Range(0, max - 1); mem.id = list[index].ToString(); mem.team = Team.Side.eHome; mem.pos = 1; config.MainRole = mem; } else { if (practise.self_id != 0) { GameMatch.Config.TeamMember mem = new GameMatch.Config.TeamMember(); mem.id = practise.self_id.ToString(); mem.team = Team.Side.eHome; mem.pos = 1; config.MainRole = mem; } } if (practise.npc_id != 0) { GameMatch.Config.TeamMember npc = new GameMatch.Config.TeamMember(); npc.id = practise.npc_id.ToString(); npc.team = Team.Side.eAway; npc.pos = 2; config.NPCs.Add(npc); } GameSystem.Instance.mClient.CreateNewMatch(config); }
public void CreateShootMatch(ulong sessionID, fogs.proto.msg.GameMode gameMode, uint roleId, uint npcId, uint gameModeId, uint mode_type_id) { GameMatch.Config config = new GameMatch.Config(); config.gameModeID = gameModeId; config.leagueType = GameMatch.LeagueType.eShoot; if (gameMode == fogs.proto.msg.GameMode.GM_GrabZone) { config.type = GameMatch.Type.eGrabZone; } else if (gameMode == fogs.proto.msg.GameMode.GM_MassBall) { config.type = GameMatch.Type.eMassBall; } else if (gameMode == fogs.proto.msg.GameMode.GM_GrabPoint) { config.type = GameMatch.Type.eGrabPoint; } List <uint> sceneIDs = new List <uint>(GameSystem.Instance.SceneConfig.configs.Keys); GameMode confGameMode = GameSystem.Instance.GameModeConfig.GetGameMode(gameModeId); config.sceneId = uint.Parse(confGameMode.scene); config.MatchTime = new IM.Number((int)confGameMode.time); config.session_id = sessionID; var member = new GameMatch.Config.TeamMember(); member.id = roleId.ToString(); member.pos = (int)fogs.proto.msg.FightStatus.FS_MAIN; member.team = Team.Side.eHome; member.team_name = MainPlayer.Instance.Name; member.roleInfo = MainPlayer.Instance.GetRole(roleId).m_roleInfo; config.MainRole = member; var enemy = new GameMatch.Config.TeamMember(); enemy.id = npcId.ToString(); enemy.pos = 4; enemy.team = Team.Side.eAway; enemy.mode_type_id = mode_type_id; enemy.roleInfo = null; config.NPCs.Add(enemy); CreateNewMatch(config); }
protected override void _CreatePlayersData() { _GeneratePlayerData(m_config.MainRole, m_config.MainRole.id.Length > 4); GameMatch.Config.TeamMember member = m_config.NPCs[0]; _GeneratePlayerData(member, member.team != m_config.MainRole.team); }
public void CreatePracticeVsMatch(List <uint> roleIds) { GameMatch.Config config = new GameMatch.Config(); config.type = GameMatch.Type.ePracticeVs; config.leagueType = GameMatch.LeagueType.ePracticeLocal; string[] scences = GameSystem.Instance.CommonConfig.GetString("gPracticeVsScene").Split('&'); int index = UnityEngine.Random.Range(0, scences.Length); config.sceneId = uint.Parse(scences[index]); config.MatchTime = new IM.Number(3 * 60); //config.MatchTime = 7; int pos = 1; config.MainRole = new GameMatch.Config.TeamMember(); config.MainRole.id = roleIds[0].ToString(); config.MainRole.pos = pos++; config.MainRole.team = Team.Side.eHome; foreach (uint id in roleIds) { if (id.ToString() != config.MainRole.id) { GameMatch.Config.TeamMember npc = new GameMatch.Config.TeamMember(); npc.id = id.ToString(); npc.pos = pos++; npc.team = Team.Side.eHome; config.NPCs.Add(npc); } } List <uint> rdList = new List <uint>(); foreach (var kv in BaseDataConfig2.roleBaseDatas) { if (kv.Value.display == 1) { rdList.Add(kv.Key); } } List <uint> npcList = new List <uint>(); for (var i = 0; i < 3; i++) { int r = UnityEngine.Random.Range(0, rdList.Count); npcList.Add(rdList[r]); rdList.RemoveAt(r); } foreach (var id in npcList) { GameMatch.Config.TeamMember npc = new GameMatch.Config.TeamMember(); npc.id = id.ToString(); npc.pos = pos++; npc.team = Team.Side.eAway; RoleInfo r = new RoleInfo(); r.id = id; r.acc_id = MainPlayer.Instance.AccountID; RoleBaseData2 rd = GameSystem.Instance.RoleBaseConfigData2.GetConfigData(id); r.star = (uint)rd.init_star; r.level = 1; r.quality = 1; npc.roleInfo = r; config.NPCs.Add(npc); } CreateNewMatch(config); }
public void CreateNewMatch(uint gameModeID, ulong sessionID, bool needPlayPlot, GameMatch.LeagueType leagueType, List <uint> teammates = null, List <uint> npcList = null) { GameMode gameMode = GameSystem.Instance.GameModeConfig.GetGameMode(gameModeID); if (teammates.Count < 1 && (gameMode.matchType == GameMatch.Type.e3On3 || gameMode.matchType == GameMatch.Type.eAsynPVP3On3 || gameMode.matchType == GameMatch.Type.ePractice1V1)) { return; } GameMatch.Config config = new GameMatch.Config(); config.leagueType = leagueType; config.type = gameMode.matchType; //config.type = GameMatch.Type.e3AIOn3AI; config.sceneId = uint.Parse(gameMode.scene); config.MatchTime = new IM.Number((int)gameMode.time); config.session_id = sessionID; config.gameModeID = gameModeID; config.needPlayPlot = needPlayPlot; config.level = gameMode.level; int pos = 1; config.MainRole = new GameMatch.Config.TeamMember(); config.MainRole.id = teammates[0].ToString(); config.MainRole.pos = pos++; config.MainRole.team = Team.Side.eHome; if (teammates != null) { foreach (uint id in teammates) { if (id.ToString() != config.MainRole.id) { GameMatch.Config.TeamMember mem_npc = new GameMatch.Config.TeamMember(); mem_npc.id = id.ToString(); mem_npc.pos = pos++; mem_npc.team = Team.Side.eHome; config.NPCs.Add(mem_npc); } } } List <uint> npcs = new List <uint>(); if (npcList != null) { npcs = npcList; } else { if (gameMode.mappedNPC.ContainsKey(MainPlayer.Instance.Captain.m_position)) { npcs.Add(gameMode.mappedNPC[MainPlayer.Instance.Captain.m_position]); } foreach (List <uint> candidates in gameMode.unmappedNPC) { if (candidates != null && candidates.Count > 0) { uint id = 0; do { id = candidates[UnityEngine.Random.Range(0, candidates.Count - 1)]; } while (npcs.Contains(id)); npcs.Add(id); } } } foreach (uint ID in npcs) { GameMatch.Config.TeamMember mem_npc = new GameMatch.Config.TeamMember(); mem_npc.id = ID.ToString(); mem_npc.pos = pos++; mem_npc.team = Team.Side.eAway; config.NPCs.Add(mem_npc); } CreateNewMatch(config); }
public bool CreateNewMatch(GameMatch.Config config) { if (mPlayerManager != null) { mPlayerManager.RemoveAllPlayers(); } if (mCurMatch != null) { mCurMatch = null; } //涂鸦数据 GameMatch.Config.TeamMember mainRole = config.MainRole; if (mainRole != null) { RoleInfo role = MainPlayer.Instance.GetRole2(uint.Parse(mainRole.id)); if (role != null && role.badge_book_id != 0) { BadgeBook book = MainPlayer.Instance.badgeSystemInfo.GetBadgeBookByBookId(role.badge_book_id); mainRole.badgeBook = book; } for (int i = 0; i < config.NPCs.Count; ++i) { GameMatch.Config.TeamMember teamMate = config.NPCs [i]; if (teamMate != null) { RoleInfo roleTeammate = MainPlayer.Instance.GetRole2(uint.Parse(teamMate.id)); if (roleTeammate != null && roleTeammate.badge_book_id != 0) { BadgeBook book = MainPlayer.Instance.badgeSystemInfo.GetBadgeBookByBookId(roleTeammate.badge_book_id); teamMate.badgeBook = book; } } } } GameMatch match = null; switch (config.type) { case GameMatch.Type.ePVP_1PLUS: case GameMatch.Type.ePVP_3On3: match = new GameMatch_PVP(config); break; case GameMatch.Type.e1On1: case GameMatch.Type.eCareer1On1: match = new GameMatch_1ON1(config); break; case GameMatch.Type.ePractise: match = new GameMatch_Practise(config); break; case GameMatch.Type.eReady: match = new GameMatch_Ready(config); break; case GameMatch.Type.eFreePractice: match = new GameMatch_FreePractice(config); break; case GameMatch.Type.ePracticeVs: match = new GameMatch_PracticeVs(config); break; case GameMatch.Type.e3On3: case GameMatch.Type.eCareer3On3: match = new GameMatch_3ON3(config); break; case GameMatch.Type.eAsynPVP3On3: match = new GameMatch_AsynPVP3ON3(config); break; case GameMatch.Type.e3AIOn3AI: match = new GameMatch_3AION3AI(config); break; case GameMatch.Type.eReboundStorm: match = new GameMatch_ReboundStorm(config); break; case GameMatch.Type.eBlockStorm: match = new GameMatch_BlockStorm(config); break; case GameMatch.Type.eUltimate21: match = new GameMatch_Ultimate21(config); break; case GameMatch.Type.eMassBall: match = new GameMatch_MassBall(config); break; case GameMatch.Type.eGrabZone: match = new GameMatch_GrabZone(config); break; case GameMatch.Type.eGrabPoint: match = new GameMatch_GrabPoint(config); break; case GameMatch.Type.eBullFight: match = new GameMatch_BullFight(config); break; case GameMatch.Type.ePractice1V1: match = new GameMatch_Practice1V1(config); break; case GameMatch.Type.eQualifyingNewerAI: match = new GameMatch_QualifyingNewerAI(config); break; case GameMatch.Type.eLadderAI: match = new GameMatch_LadderAI(config); break; } if (match == null) { Debug.LogError("Unsupported match type is detected when creating a new match."); return(false); } mCurMatch = match; mCurMatch.Build(); return(true); }