亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hiscorelist.cs

?? C#開發的運行于windows mobile PDA上的游戲
?? CS
字號:
////////////////////////////////////////////////
// 
// Project: Lines.NET
// Version: 1.1
// Author:  Vladimir L.
// 
// homepage: http://www.boomsoft.org
// e-mail:   support@boomsoft.org
// 
// Copyright (c) 2003-2004, Boomsoft.org
// 

using System;
using System.Collections;
using System.Xml;
using System.IO;

namespace Lines.Core
{
	/// <summary>
	/// Represents the hi score list of the game players.
	/// </summary>
	/// <remarks>
	/// This class supports serialization to XML formatted file.
	/// </remarks>
	public class HiScoreList : IEnumerable
	{
		/// <summary>
		/// Encloses a single entry of hi score list.
		/// </summary>
		/// <remarks>
		/// Provides a set of read only properties to retrieve hi score entry information and 
		/// implements <see cref="IComparable"/> interface to simplify sorting.
		/// </remarks>
		public class PlayerScore : IComparable
		{
			/// <summary>
			/// Holds the player name.
			/// </summary>
			private string name;
			/// <summary>
			/// Holds a value of player best score.
			/// </summary>
			private int score;
			/// <summary>
			/// Holds a value of steps the player did to reach a score.
			/// </summary>
			private int steps;

			/// <summary>
			/// Creates an instance of hi score entry.
			/// </summary>
			/// <param name="name">The player name.</param>
			/// <param name="score">The game score.</param>
			/// <param name="steps">The amount of steps were used.</param>
			public PlayerScore(string name, int score, int steps)
			{
				this.name = name;
				this.score = score;
				this.steps = steps;
			}

			/// <summary>
			/// Gets the player name.
			/// </summary>
			public string Name
			{
				get {return name;}
			}

			/// <summary>
			/// Gets the game score.
			/// </summary>
			public int Score
			{
				get {return score;}
			}

			/// <summary>
			/// Gets the amount of steps were used to reach a score.
			/// </summary>
			public int Steps
			{
				get {return steps;}
			}
			#region IComparable Members

			/// <summary>
			/// Compares the current instance with another object of PlayerScore type.
			/// </summary>
			/// <param name="obj">The object of PlayerScore type to compare the current object to.</param>
			/// <returns>An integer value that indicates the relative order of the comparands. The return 
			/// value has these meanings:
			/// <list type="table">
			///		<listheader>
			///			<term>Value</term>
			///			<description>Meaning</description>
			///		</listheader>
			///		<item>
			///			<term>Less than zero</term>
			///			<description>This instance is less than <c>obj</c>.</description>
			///		</item>
			///		<item>
			///			<term>Zero</term>
			///			<description>This instance is equal to <c>obj</c>.</description>
			///		</item>
			///		<item>
			///			<term>Greater than zero</term>
			///			<description>This instance is greater than <c>obj</c>.</description>
			///		</item>
			/// </list>
			/// </returns>
			public int CompareTo(object obj)
			{
				PlayerScore playerScore = (PlayerScore)obj;
				
				if (Score > playerScore.Score)
					return 1;
				if (Score == playerScore.Score)
				{
					if (Steps < playerScore.Steps)
						return 1;
					else if (Steps == playerScore.Steps)
						return 0;
					else
						return -1;
				}
				return -1;
			}

			/// <summary>
			/// Compares if score of a first player less then score of a second player.
			/// </summary>
			/// <param name="ps1">The game score of a first player.</param>
			/// <param name="ps2">The game score of a second player.</param>
			/// <returns><c>true</c> if the score of a first player less then the score of a second player,
			/// <c>false</c> otherwise.</returns>
			public static bool operator < (PlayerScore ps1, PlayerScore ps2)
			{
				return (ps1.CompareTo(ps2) < 0);
			}
			/// <summary>
			/// Compares if score of a first player greater then score of a second player.
			/// </summary>
			/// <param name="ps1">The game score of a first player.</param>
			/// <param name="ps2">The game score of a second player.</param>
			/// <returns><c>true</c> if the score of a first player greater then the score of a second player,
			/// <c>false</c> otherwise.</returns>
			public static bool operator > (PlayerScore ps1, PlayerScore ps2)
			{
				return (ps1.CompareTo(ps2) > 0);
			}
			/// <summary>
			/// Compares if score of a first player less or equal to score of a second player.
			/// </summary>
			/// <param name="ps1">The game score of a first player.</param>
			/// <param name="ps2">The game score of a second player.</param>
			/// <returns><c>true</c> if the score of a first player less or equal to the score of a second player,
			/// <c>false</c> otherwise.</returns>
			public static bool operator <= (PlayerScore ps1, PlayerScore ps2)
			{
				return (ps1.CompareTo(ps2) <= 0);
			}
			/// <summary>
			/// Compares if score of a first player greater or equal to score of a second player.
			/// </summary>
			/// <param name="ps1">The game score of a first player.</param>
			/// <param name="ps2">The game score of a second player.</param>
			/// <returns><c>true</c> if the score of a first player greater or equal to the score of a second player,
			/// <c>false</c> otherwise.</returns>
			public static bool operator >= (PlayerScore ps1, PlayerScore ps2)
			{
				return (ps1.CompareTo(ps2) >= 0);
			}

			#endregion
		}

		/// <summary>
		/// Holds an array of the best players' score.
		/// </summary>
		private PlayerScore[] topList = null;
		/// <summary>
		/// Defines the maximum size of his score list.
		/// </summary>
		private int maxLength;
		
		/// <summary>
		/// Creates an instance of hi score list.
		/// </summary>
		/// <remarks>
		/// The value of <see cref="maxLength"/> is set to 10 by default.
		/// </remarks>
		public HiScoreList()
			: this(10)
		{
		}

		/// <summary>
		/// Creates an instance of hi score list with predefined <see cref="maxLength"/> value.
		/// </summary>
		/// <param name="maxLength">The value of <see cref="maxLength"/> property.</param>
		public HiScoreList(int maxLength)
		{
			this.maxLength = maxLength;
			this.topList = new PlayerScore[10];
		}

		/// <summary>
		/// Loads from file a players' hi score list in XML format.
		/// <seealso cref="Save(string)"/>
		/// </summary>
		/// <param name="filename">The hi score list file name.</param>
		/// <example>
		/// <code>
		/// &lt;HiScore&gt;
		///		&lt;Player name="Vladimir" score="122" steps="40" /&gt;
		///		&lt;Player name="Vova" score="88" steps="31" /&gt;
		///		&lt;Player name="Test" score="70" steps="21" /&gt;
		///		&lt;Player name="player" score="45" steps="18" /&gt;
		///		&lt;Player name="player" score="42" steps="14" /&gt;
		///		&lt;Player name="player" score="36" steps="15" /&gt;
		///		&lt;Player name="player" score="33" steps="12" /&gt;
		///		&lt;Player name="player" score="29" steps="12" /&gt;
		///		&lt;Player name="player" score="26" steps="11" /&gt;
		///		&lt;Player name="player" score="26" steps="26" /&gt;
		///	&lt;/HiScore&gt;
		///	</code>
		/// </example>
		public void Load(string filename)
		{
			if (File.Exists(filename))
			{
				XmlDocument doc = new XmlDocument();
				doc.Load(filename);
				XmlNode root = doc.DocumentElement;
				XmlNode node = root.FirstChild;
				int count = 0;
				while ((node != null) && (count < maxLength))
				{
					topList[count] = new PlayerScore(node.Attributes["name"].Value, 
						int.Parse(node.Attributes["score"].Value), int.Parse(node.Attributes["steps"].Value));

					count++;
					node = node.NextSibling;
				}

				// Just to be sure that nobody tricked
				Array.Sort(topList);
				Array.Reverse(topList, 0, topList.Length);
			}
		}

		/// <summary>
		/// Saves to file a players' hi score list in XML format.
		/// <seealso cref="Load(string)"/>
		/// </summary>
		/// <param name="filename">The hi score list file name.</param>
		/// <remarks>
		/// See example for <see cref="Load(string)"/>.
		/// </remarks>
		public void Save(string filename)
		{
			XmlDocument doc = new XmlDocument();
			XmlNode root = doc.CreateNode(XmlNodeType.Element, "HiScore", "");
			doc.AppendChild(root);

			XmlNode node;
			XmlAttribute attribute;
			
			for (int i = 0; i < maxLength; i++)
			{
				PlayerScore playerScore = topList[i];
				if (playerScore == null)
					break;
				node = doc.CreateNode(XmlNodeType.Element, "Player", "");
				attribute = doc.CreateAttribute("name");
				attribute.Value = playerScore.Name;
				node.Attributes.Append(attribute);
				attribute = doc.CreateAttribute("score");
				attribute.Value = playerScore.Score.ToString();
				node.Attributes.Append(attribute);
				attribute = doc.CreateAttribute("steps");
				attribute.Value = playerScore.Steps.ToString();
				node.Attributes.Append(attribute);
				root.AppendChild(node);
			}

			doc.Save(filename);
		}

		/// <summary>
		/// Verifies whether a new result is a record or not.
		/// </summary>
		/// <param name="score">The player's score.</param>
		/// <param name="steps">The amount of steps player used to reach that score.</param>
		/// <returns><c>true</c> if new result is better then the worst result of hi score list, or the length
		/// of hi score list is smaller then <see cref="maxLength"/>.</returns>
		public bool IsRecord(int score, int steps)
		{
			PlayerScore playerScore = topList[maxLength - 1];
			
			if (playerScore == null)
				return true;
			if (score > playerScore.Score)
				return true;
			if ((score == playerScore.Score) && (steps < playerScore.Steps))
				return true;
			
			return false;
		}

		/// <summary>
		/// Adds a new record to hi score list.
		/// </summary>
		/// <param name="name">The player name.</param>
		/// <param name="score">The result score.</param>
		/// <param name="steps">The amount of steps were done during game.</param>
		/// <returns>A 0-based position of added record, or -1 if the result is not a record.</returns>
		public int AddRecord(string name, int score, int steps)
		{
			if (!IsRecord(score, steps))
				return -1;

			PlayerScore newPlayerScore = new PlayerScore(name, score, steps);
			PlayerScore playerScore;
			for (int i = maxLength; i > 0; i--)
			{
				playerScore = topList[i - 1];
				if (playerScore != null)
				{
					if (playerScore > newPlayerScore)
					{
						topList[i] = newPlayerScore;
						return i;
					} 
					else if (i < maxLength)
					{
						topList[i] = playerScore;
					}
				}
			}
			topList[0] = newPlayerScore;

			return 0;
		}
		#region IEnumerable Members

		/// <summary>
		/// Returns an enumerator that can iterate through a collection of player records.
		/// </summary>
		/// <returns>An <see cref="IEnumerator"/> that can be used to iterate through the collection.</returns>
		public IEnumerator GetEnumerator()
		{
			return topList.GetEnumerator();
		}

		#endregion
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情午夜影院| 久久精工是国产品牌吗| 久久亚洲精品国产精品紫薇| 欧美精品第一页| 欧美日韩精品三区| 欧美日韩精品一区二区三区 | 琪琪久久久久日韩精品| 亚洲综合成人在线视频| 亚洲一二三四区| 亚洲午夜在线视频| 日韩黄色免费电影| 看片的网站亚洲| 日本强好片久久久久久aaa| 日韩不卡在线观看日韩不卡视频| 五月婷婷激情综合网| 日韩成人精品在线| 国产在线精品一区在线观看麻豆| 国产呦萝稀缺另类资源| jlzzjlzz亚洲女人18| 欧美性猛交xxxxxx富婆| 91精品在线观看入口| 2014亚洲片线观看视频免费| 国产精品美女视频| 亚洲福利视频一区二区| 久久精品国产免费| 成人午夜视频在线| 欧美日韩免费不卡视频一区二区三区| 日韩一区二区三区观看| 国产精品久久久久久久久久久免费看 | 亚洲一线二线三线视频| 日本不卡一二三区黄网| 成人一区二区视频| 在线看不卡av| 精品第一国产综合精品aⅴ| 国产精品麻豆网站| 亚洲va欧美va天堂v国产综合| 黄网站免费久久| 在线一区二区视频| 久久久精品欧美丰满| 一区二区三区在线看| 国产麻豆视频一区二区| 欧美性大战久久久久久久蜜臀| 337p粉嫩大胆色噜噜噜噜亚洲| 亚洲日本青草视频在线怡红院| 视频一区二区国产| jizzjizzjizz欧美| 精品日本一线二线三线不卡| 一区二区三区日韩在线观看| 国模冰冰炮一区二区| 欧美日韩黄色影视| 亚洲欧美一区二区视频| 久久超级碰视频| 欧美日韩国产首页在线观看| 国产精品免费网站在线观看| 日本不卡中文字幕| 欧美亚州韩日在线看免费版国语版| 久久亚洲精精品中文字幕早川悠里| 亚洲18影院在线观看| av成人动漫在线观看| 久久久精品黄色| 久久国内精品自在自线400部| 色综合久久综合| 中文一区二区完整视频在线观看| 视频一区视频二区中文| 欧美三级日本三级少妇99| 亚洲欧洲99久久| 大尺度一区二区| 欧美国产在线观看| 国产成人一级电影| 久久夜色精品国产噜噜av| 麻豆久久久久久久| 91精品国产综合久久婷婷香蕉| 亚洲一区二区在线播放相泽| 在线看日韩精品电影| 亚洲午夜精品久久久久久久久| 色94色欧美sute亚洲线路二| 一区二区高清免费观看影视大全 | 色婷婷一区二区| 亚洲欧美偷拍三级| 色诱亚洲精品久久久久久| 亚洲黄色录像片| 欧美在线你懂得| 首页国产欧美日韩丝袜| 欧美一区二区三区免费视频| 日韩精品国产精品| 亚洲伦在线观看| 在线免费不卡电影| 婷婷中文字幕综合| 精品国产一区二区三区不卡| 国内精品在线播放| 日本一区二区在线不卡| 成人蜜臀av电影| 亚洲综合图片区| 777奇米成人网| 国产麻豆精品在线| 日韩理论片一区二区| 欧美日韩一二三区| 久久超碰97人人做人人爱| 国产欧美日韩激情| 91精品福利在线| 激情都市一区二区| 亚洲视频在线一区观看| 欧美一区二区黄| 成人国产电影网| 午夜视频久久久久久| 久久精品亚洲乱码伦伦中文 | 韩国av一区二区三区在线观看| 欧美大胆人体bbbb| 99re成人精品视频| 国产精品一区二区你懂的| 综合分类小说区另类春色亚洲小说欧美| 欧美性受极品xxxx喷水| 国产麻豆视频一区| 五月天婷婷综合| 国产精品久久久久aaaa樱花 | √…a在线天堂一区| 在线电影欧美成精品| 国产福利不卡视频| 天天操天天色综合| 国产精品久久精品日日| 欧美一级黄色片| 欧美四级电影网| 丁香桃色午夜亚洲一区二区三区| 天天综合天天综合色| 日韩美女视频19| 久久蜜桃av一区精品变态类天堂 | 青青草国产精品亚洲专区无| 综合av第一页| 日本一区二区视频在线观看| 欧美日韩在线直播| av欧美精品.com| 国产成a人无v码亚洲福利| 男人的j进女人的j一区| 亚洲h在线观看| 亚洲另类一区二区| 成人免费在线播放视频| 国产午夜久久久久| 欧美大片一区二区三区| 51精品国自产在线| 久久久久久久久久久黄色| 日韩一级完整毛片| 欧美精品在欧美一区二区少妇| 91在线你懂得| 99re6这里只有精品视频在线观看| 国产精品自拍网站| 国产又黄又大久久| 国产精品夜夜嗨| 国产激情视频一区二区在线观看| 久久se精品一区精品二区| 美国欧美日韩国产在线播放| 天天色天天爱天天射综合| 午夜国产精品一区| 婷婷中文字幕综合| 婷婷丁香激情综合| 麻豆视频观看网址久久| 国内精品嫩模私拍在线| 狠狠色狠狠色合久久伊人| 另类调教123区| 国产精品99久久久久久宅男| 国产91富婆露脸刺激对白| 成人动漫av在线| 色网综合在线观看| 欧美精品精品一区| 精品日韩99亚洲| 国产欧美一区二区精品性色 | 国产日韩欧美综合一区| 国产视频一区二区在线| 国产精品水嫩水嫩| 亚洲综合色成人| 日韩**一区毛片| 国产盗摄女厕一区二区三区| eeuss鲁片一区二区三区| 色欧美乱欧美15图片| 久久久www成人免费毛片麻豆 | 久久亚洲综合av| 国产精品久久网站| 亚洲精品免费一二三区| 日本大胆欧美人术艺术动态| 国产乱码精品一区二区三区av| 国v精品久久久网| 欧美日韩中文国产| 久久综合一区二区| 亚洲人成在线播放网站岛国| 人妖欧美一区二区| 播五月开心婷婷综合| 91精品在线麻豆| 中文字幕日韩av资源站| 青青草国产精品亚洲专区无| 风间由美性色一区二区三区| 91美女视频网站| 久久综合狠狠综合| 亚洲自拍偷拍九九九| 国产激情精品久久久第一区二区| 日本高清不卡aⅴ免费网站| 精品黑人一区二区三区久久 | 久久综合色8888| 一区二区三区四区视频精品免费 | 亚洲激情在线激情| 精品在线亚洲视频| 欧美色偷偷大香|