private void LoadComboBonus() { string text = ResourceLoadManager.Instance.GetConfigText(name2); if (text == null) { Debug.LogError("LoadConfig failed: " + name2); return; } XmlDocument doc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_COMBO_BONUS, text); XmlNode root = doc.SelectSingleNode("Data"); foreach (XmlNode line in root.SelectNodes("Line")) { if (CommonFunction.IsCommented(line)) { continue; } GameMatch.Type matchType = (GameMatch.Type)(int.Parse(line.SelectSingleNode("type").InnerText)); Dictionary <uint, float> bonusConfig = null; if (!comboBonus.TryGetValue(matchType, out bonusConfig)) { bonusConfig = new Dictionary <uint, float>(); comboBonus.Add(matchType, bonusConfig); } uint combo = uint.Parse(line.SelectSingleNode("combo").InnerText); float ratio = float.Parse(line.SelectSingleNode("bonus_ratio").InnerText); bonusConfig.Add(combo, ratio); } }
public void ConnectToGS(GameMatch.Type uMatchType, string ip, int port) { if (m_gameConn != null) { CloseGameServerConn(); } if (uMatchType == GameMatch.Type.ePVP_1PLUS || uMatchType == GameMatch.Type.ePVP_3On3) { if (m_gameConn == null) { /* #if UNITY_EDITOR * int timeout = 0; #else * int timeout = 5000; #endif */ int timeout = 6; m_gameConn = new NetworkConn(m_gameMsgHandler, "Game", NetworkConn.Type.eGameServer, timeout); m_gameConn.AddEventListener(this); } } else { m_gameConn = new VirtualNetworkConnSimple(m_gameMsgHandler); m_gameConn.AddEventListener(this); VirtualGameServer.Instance = new VirtualGameServer(); } m_gameConn.Connect(ip, port); }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); GameMatch.Type o = (GameMatch.Type)arg0; LuaScriptMgr.Push(L, o); return(1); }
static int ConnectToGS(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 4); NetworkManager obj = (NetworkManager)LuaScriptMgr.GetNetObjectSelf(L, 1, "NetworkManager"); GameMatch.Type arg0 = (GameMatch.Type)LuaScriptMgr.GetNetObject(L, 2, typeof(GameMatch.Type)); string arg1 = LuaScriptMgr.GetLuaString(L, 3); int arg2 = (int)LuaScriptMgr.GetNumber(L, 4); obj.ConnectToGS(arg0, arg1, arg2); return(0); }
static int GetComboBonus(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); GameModeConfig obj = (GameModeConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "GameModeConfig"); GameMatch.Type arg0 = (GameMatch.Type)LuaScriptMgr.GetNetObject(L, 2, typeof(GameMatch.Type)); uint arg1 = (uint)LuaScriptMgr.GetNumber(L, 3); float o = obj.GetComboBonus(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); }
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); }
static int CreateNewMatch(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(Client), typeof(GameMatch.Config))) { Client obj = (Client)LuaScriptMgr.GetNetObjectSelf(L, 1, "Client"); GameMatch.Config arg0 = (GameMatch.Config)LuaScriptMgr.GetLuaObject(L, 2); bool o = obj.CreateNewMatch(arg0); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(Client), typeof(GameMatch.Type))) { Client obj = (Client)LuaScriptMgr.GetNetObjectSelf(L, 1, "Client"); GameMatch.Type arg0 = (GameMatch.Type)LuaScriptMgr.GetLuaObject(L, 2); bool o = obj.CreateNewMatch(arg0); LuaScriptMgr.Push(L, o); return(1); } else if (count == 4) { Client obj = (Client)LuaScriptMgr.GetNetObjectSelf(L, 1, "Client"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); ulong arg1 = (ulong)LuaScriptMgr.GetNumber(L, 3); GameMatch.Type arg2 = (GameMatch.Type)LuaScriptMgr.GetNetObject(L, 4, typeof(GameMatch.Type)); bool o = obj.CreateNewMatch(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else if (count == 7) { Client obj = (Client)LuaScriptMgr.GetNetObjectSelf(L, 1, "Client"); uint arg0 = (uint)LuaScriptMgr.GetNumber(L, 2); ulong arg1 = (ulong)LuaScriptMgr.GetNumber(L, 3); bool arg2 = LuaScriptMgr.GetBoolean(L, 4); GameMatch.LeagueType arg3 = (GameMatch.LeagueType)LuaScriptMgr.GetNetObject(L, 5, typeof(GameMatch.LeagueType)); List <uint> arg4 = (List <uint>)LuaScriptMgr.GetNetObject(L, 6, typeof(List <uint>)); List <uint> arg5 = (List <uint>)LuaScriptMgr.GetNetObject(L, 7, typeof(List <uint>)); obj.CreateNewMatch(arg0, arg1, arg2, arg3, arg4, arg5); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: Client.CreateNewMatch"); } return(0); }
public static void SendLoadingComplete(GameMatch.Type type) { if (GameSystem.Instance.mNetworkManager.m_gameConn == null) { return; } PVPLoadComplete obj = new PVPLoadComplete(); obj.type = MatchType.MT_PVP_1V1_PLUS; if (type == GameMatch.Type.ePVP_3On3) { obj.type = MatchType.MT_PVP_3V3; } GameSystem.Instance.mNetworkManager.m_gameConn.SendPack <PVPLoadComplete>(0, obj, MsgID.PVPLoadCompleteID); }
public float GetComboBonus(GameMatch.Type matchType, uint combo) { float bonus = 0f; Dictionary <uint, float> bonusConfig = null; if (comboBonus.TryGetValue(matchType, out bonusConfig)) { foreach (KeyValuePair <uint, float> pair in bonusConfig) { if (pair.Key > combo) { break; } bonus = pair.Value; } } return(bonus); }
public void LoadMatchConfig(ref GameMatch.Config config, GameMatch.Type matchType = GameMatch.Type.eNone) { try { if (matchType == GameMatch.Type.eNone) { config.sceneId = gameMatchData.sceneId; config.NPCs = gameMatchData.npcList; config.MainRole = gameMatchData.mainRole; config.RemotePlayers = gameMatchData.remoteList; config.MatchTime = gameMatchData.matchTime; config.OppoColorMulti = gameMatchData.oppoColorMulti; } else { GameMatchData data = null; gameMatchDatas.TryGetValue(matchType, out data); if (data != null) { config.type = data.type; config.sceneId = data.sceneId; config.NPCs = data.npcList; config.MainRole = data.mainRole; config.RemotePlayers = data.remoteList; config.MatchTime = data.matchTime; config.OppoColorMulti = data.oppoColorMulti; } else { Debug.LogError("Match Config is null!"); } } } catch (Exception exp) { Debug.Log("load match config failed: " + exp.Message); } }
public bool CreateNewMatch(GameMatch.Type gameType) { string configName; switch (gameType) { case GameMatch.Type.e1On1: configName = GlobalConst.DIR_XML_MATCH_SINGLE; break; case GameMatch.Type.ePVP_3On3: case GameMatch.Type.ePVP_1PLUS: configName = GlobalConst.DIR_XML_MATCH_PVP; break; case GameMatch.Type.eReady: configName = GlobalConst.DIR_XML_MATCH_READY; break; case GameMatch.Type.eFreePractice: configName = GlobalConst.DIR_XML_MATCH_FREE_PRACTICE; break; case GameMatch.Type.e3On3: configName = GlobalConst.DIR_XML_MATCH_MULTIPLY; break; case GameMatch.Type.eGuide: configName = GlobalConst.DIR_XML_MATCH_GUIDE; break; default: configName = GlobalConst.DIR_XML_MATCH_SINGLE; break; } return(CreateNewMatch(configName, 0ul, gameType)); }
public bool CreateNewMatch(string configName, ulong session_id = 0ul, GameMatch.Type matchType = GameMatch.Type.eNone) { if (mPlayerManager != null) { mPlayerManager.RemoveAllPlayers(); } if (mCurMatch != null) { mCurMatch = null; } GameMatch.Config config = new GameMatch.Config(); GameSystem.Instance.gameMatchConfig.LoadMatchConfig(ref config, GameMatch.Type.eNone); GameSystem.Instance.gameMatchConfig.LoadMatchConfig(ref config, matchType); config.session_id = session_id; if (config.MainRole == null) { config.MainRole = new GameMatch.Config.TeamMember(); config.MainRole.id = (MainPlayer.Instance.CaptainID).ToString(); } GameMatch match = null; switch (config.type) { case GameMatch.Type.e1On1: match = new GameMatch_1ON1(config); break; case GameMatch.Type.eReady: object o = LuaScriptMgr.Instance.GetLuaTable("_G")["TestScene"]; if (o != null) { config.sceneId = (uint)(double)o; } match = new GameMatch_Ready(config); break; case GameMatch.Type.eFreePractice: match = new GameMatch_FreePractice(config); break; case GameMatch.Type.e3On3: match = new GameMatch_3ON3(config); break; case GameMatch.Type.eGuide: GameMatch_Guide.SetConfig(ref config); match = new GameMatch_Guide(config); break; case GameMatch.Type.ePVP_1PLUS: case GameMatch.Type.ePVP_3On3: //match = new GameMatch_PVP(config); match = new GameMatch_PVP(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); }