今天,我们揭秘一下Group,GameConfig,PlayersConfig这几个类。 这几个虽然是添头类,但缺少了他,游戏,嗨,真的运行不了。那,请掀起盖头来吧!
①Group——有足球知识的基础的人,都明白这是干嘛的,这是一个分组情况的类。这是中国球迷最避讳一个词,每次大赛小赛一出来,总是看到国足被分入了死亡之组,哎怎么总被分入死亡之组了,这个类在游戏中的作用如图所示:
相应源代码如下所示:
View Code
////// 当前的组别 A组 B组 C组 /// public class Group { ////// A,B,C,D............ /// public string GroupID { get; set; } }
②GameConfig——比赛的信息纯粹用这个类来存储,用这个泛型信息来储存,因此有个Game的泛型数组,对于Game这个实体类,我们以后再说。 再有将所有的信息加载的方法。他的具体信息如图所示。 当你选择巴西的时候,就用linq语句查询出来。
相应源代码如下所示:
View Code
public class GameConfig { ////// 队伍的键值对 /// DictionaryteamsDictionary = new Dictionary (); /// /// 加载比赛的列表 /// /// public void LoadGameTable(ListgameTable) { //键值对的信息 teamsDictionary = GameHelper.Instance.TeamsDictionary; /// 南非vs 墨西哥 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/11/2010"), teamsDictionary["RSA"], teamsDictionary["MEX"], "Soccer City", "JohannesBurg")); ///乌拉圭vs 法国 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/11/2010"), teamsDictionary["URU"], teamsDictionary["FRA"], "Cape Town Stadium", "Cape Town")); //南非vs乌拉圭 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/16/2010"), teamsDictionary["RSA"], teamsDictionary["URU"], "Loftus Versfeld Stadium", "Pretoria ")); //法国vs墨西哥 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/17/2010"), teamsDictionary["FRA"], teamsDictionary["MEX"], "Peter Mokaba Stadium", "Polokwane ")); //墨西哥vs乌拉圭 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/22/2010"), teamsDictionary["MEX"], teamsDictionary["URU"], "Royal Bafokeng Stadium", "RustenBurg")); //法国vs南非 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/22/2010"), teamsDictionary["FRA"], teamsDictionary["RSA"], "Free State Stadium", "Bloemfontein ")); //韩国vs希腊 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/12/2010"), teamsDictionary["KOR"], teamsDictionary["GRE"], "Nelson Mandela Bay Stadium", "Port Elizabeth")); //阿根廷vs尼日利亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/12/2010"), teamsDictionary["ARG"], teamsDictionary["NGA"], "Ellis Park Stadium", "JohannesBurg")); //阿根廷vs韩国 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/17/2010"), teamsDictionary["ARG"], teamsDictionary["KOR"], "Soccer City", "JohannesBurg")); //法国vs尼日利亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/17/2010"), teamsDictionary["GRE"], teamsDictionary["NGA"], "Free State Stadium", "Bloemfontein ")); //尼日利亚vs韩国 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/22/2010"), teamsDictionary["NGA"], teamsDictionary["KOR"], "Moses Mabhida Stadium", "Durban")); //希腊vs阿根廷 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/22/2010"), teamsDictionary["GRE"], teamsDictionary["ARG"], "Peter Mokaba Stadium", "Polokwane ")); //英格兰vs美国 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/12/2010"), teamsDictionary["ENG"], teamsDictionary["USA"], "Royal Bafokeng Stadium", "RustenBurg")); //阿尔及利亚vs斯洛文尼亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/13/2010"), teamsDictionary["ALG"], teamsDictionary["SVN"], "Peter Mokaba Stadium", "Polokwane ")); //斯洛文尼亚vs美国 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/18/2010"), teamsDictionary["SVN"], teamsDictionary["USA"], "Ellis Park Stadium", "JohannesBurg")); //英格兰vs阿尔及利亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/18/2010"), teamsDictionary["ENG"], teamsDictionary["ALG"], "Cape Town Stadium", "Cape Town")); //斯洛文尼亚vs英格兰 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/23/2010"), teamsDictionary["SVN"], teamsDictionary["ENG"], "Nelson Mandela Bay Stadium", "Port Elizabeth")); //美国vs阿尔及利亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/23/2010"), teamsDictionary["USA"], teamsDictionary["ALG"], "Loftus Versfeld Stadium", "Pretoria ")); //塞尔维亚vs加纳 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/13/2010"), teamsDictionary["SRB"], teamsDictionary["GHA"], "Loftus Versfeld Stadium", "Pretoria ")); //德国vs澳大利亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/13/2010"), teamsDictionary["GER"], teamsDictionary["AUS"], "Moses Mabhida Stadium", "Durban")); //德国vs塞尔维亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/18/2010"), teamsDictionary["GER"], teamsDictionary["SRB"], "Nelson Mandela Bay Stadium", "Port Elizabeth")); //加纳vs澳大利亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/19/2010"), teamsDictionary["GHA"], teamsDictionary["AUS"], "Royal Bafokeng Stadium", "RustenBurg")); //加纳vs德国 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/23/2010"), teamsDictionary["GHA"], teamsDictionary["GER"], "Soccer City", "JohannesBurg")); //澳大利亚vs塞尔维亚 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/23/2010"), teamsDictionary["AUS"], teamsDictionary["SRB"], "Mbombela Stadium", "Nelspruit")); //荷兰vs丹麦 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/14/2010"), teamsDictionary["NED"], teamsDictionary["DEN"], "Soccer City", "JohannesBurg")); //日本vs喀麦隆 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/14/2010"), teamsDictionary["JPN"], teamsDictionary["CMR"], "Free State Stadium", "Bloemfontein ")); //荷兰vs日本 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/19/2010"), teamsDictionary["NED"], teamsDictionary["JPN"], "Moses Mabhida Stadium", "Durban")); //喀麦隆vs丹麦 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/19/2010"), teamsDictionary["CMR"], teamsDictionary["DEN"], "Loftus Versfeld Stadium", "Pretoria ")); //丹麦vs日本 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/24/2010"), teamsDictionary["DEN"], teamsDictionary["JPN"], "Royal Bafokeng Stadium", "RustenBurg")); //喀麦隆vs荷兰 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/24/2010"), teamsDictionary["CMR"], teamsDictionary["NED"], "Cape Town Stadium", "Cape Town")); //喀麦隆vs巴拉圭 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/14/2010"), teamsDictionary["CMR"], teamsDictionary["PAR"], "Cape Town Stadium", "Cape Town")); //新西兰vs斯洛伐克 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/15/2010"), teamsDictionary["NZL"], teamsDictionary["SVK"], "Royal Bafokeng Stadium", "RustenBurg")); //巴拉圭vs斯洛伐克 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/20/2010"), teamsDictionary["SVK"], teamsDictionary["PAR"], "Free State Stadium", "Bloemfontein ")); //意大利vs新西兰 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/20/2010"), teamsDictionary["ITA"], teamsDictionary["NZL"], "Mbombela Stadium", "Nelspruit")); //斯洛伐克vs意大利 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/24/2010"), teamsDictionary["SVK"], teamsDictionary["ITA"], "Ellis Park Stadium", "JohannesBurg")); //巴拉圭vs新西兰 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/24/2010"), teamsDictionary["PAR"], teamsDictionary["NZL"], "Peter Mokaba Stadium", "Polokwane ")); //巴西vs朝鲜 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/15/2010"), teamsDictionary["BRA"], teamsDictionary["PRK"], "Ellis Park Stadium", "JohannesBurg")); //葡萄牙vs科特迪瓦 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/15/2010"), teamsDictionary["POR"], teamsDictionary["CIV"], "Soccer City", "JohannesBurg")); //巴西vs科特迪瓦 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/20/2010"), teamsDictionary["BRA"], teamsDictionary["CIV"], "Soccer City", "JohannesBurg")); //巴西vs葡萄牙 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/25/2010"), teamsDictionary["BRA"], teamsDictionary["POR"], "Nelson Mandela Bay Stadium", "Port Elizabeth")); //葡萄牙vs朝鲜 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/21/2010"), teamsDictionary["POR"], teamsDictionary["PRK"], "Cape Town Stadium", "Cape Town")); //葡萄牙vs巴西 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/25/2010"), teamsDictionary["POR"], teamsDictionary["BRA"], "Moses Mabhida Stadium", "Durban")); //朝鲜vs巴西 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/25/2010"), teamsDictionary["PRK"], teamsDictionary["BRA"], "Mbombela Stadium", "Nelspruit")); //洪都拉斯vs智利 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/16/2010"), teamsDictionary["HON"], teamsDictionary["CHI"], "Mbombela Stadium", "Nelspruit")); //西班牙vs瑞士 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/16/2010"), teamsDictionary["ESP"], teamsDictionary["SUI"], "Moses Mabhida Stadium", "Durban")); //智利vs瑞士 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/21/2010"), teamsDictionary["CHI"], teamsDictionary["SUI"], "Nelson Mandela Bay Stadium", "Port Elizabeth")); //瑞士vs洪都拉斯 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/21/2010"), teamsDictionary["ESP"], teamsDictionary["HON"], "Ellis Park Stadium", "JohannesBurg")); //智利vs西班牙 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/25/2010"), teamsDictionary["CHI"], teamsDictionary["ESP"], "Loftus Versfeld Stadium", "Pretoria ")); //瑞士vs洪都拉斯 gameTable.Add(new Game("GRP", Convert.ToDateTime("06/25/2010"), teamsDictionary["SUI"], teamsDictionary["HON"], "Free State Stadium", "Bloemfontein ")); } }
③PlayConfig——比赛运动员的信息纯粹用这个类来存储,用这个泛型信息来储存,因此有个Player的泛型数组,对于Player这个实体类,我们以后再说。 再有将所有的信息加载的方法。他的具体信息如图所示。 当你选择巴西的时候,加载相应的运动员的信息的时候,就用linq语句查询出来。
相应源代码如下所示:
View Code
这是一个头简单的方法,一般做法,应该是建立一个文件在从中读取(自动建立),这就是为什么,大多数we玩家,你有可能卸载了相应的文件,只要文件夹不删除话,球员比赛信息都存在的缘故吧!。
好了,今天内容,很简单,望大家多讨论,后面还有这个游戏的核心类的介绍。游戏的源代码地址: