⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectstate.cs

📁 嵌入式程序
💻 CS
字号:
using System;
using System.Windows.Forms;
using System.Drawing;
using DiamondPet.UserLayer;


namespace DiamondPet.LogicLayer.GameStateStartLogic
{
	/// <summary>
	/// SelectState 的摘要说明。
	/// 选择状态
	/// </summary>
	public class SelectState : StartState
	{
		private int selectIndex;

		#region 初始化
		public int SelectIndex
		{
			get
			{
				return selectIndex;
			}
			set
			{
				selectIndex = value;
			}
		}

		public SelectState(UserLayerStateManager u)
		{
			userLayerStateManager = u;

			//实例化命令类
			this.downCommand = new StartCommand.DownCommand(this);
			this.enterCommand = new StartCommand.EnterCommand(this);
			this.upCommand = new StartCommand.UpCommand(this);

			selectIndex = 0;
		}
		#endregion

		#region 按键事件
		/// <summary>
		/// 加入命令队列
		/// </summary>
		/// <param name="key"></param>
		public override void AddCommand(Keys key)
		{
			switch(key)
			{
				case Keys.Down:
					this.downCommand.ExecuteCommand();
					break;
				case Keys.Up:
					this.upCommand.ExecuteCommand();
					break;
				case Keys.Enter:
					this.enterCommand.ExecuteCommand();
					break;
			}
		}
		#endregion

		#region 游戏主循环
		/// <summary>
		/// 逻辑处理
		/// </summary>
		public override void StartStateLogic()
		{
			//绘制背景
			DrawBackGround();

			//绘制按钮
            DrawButton();

    	}
		#endregion

		#region 画图
		/// <summary>
		/// 绘制按钮
		/// </summary>
		private void DrawButton()
		{
			for(int i= 0;i < GameConstResource.btNumbers;++i)
			{
				Draw.DrawImage(Pictures.picturesImage[GameConstResource.btstart + i],
					GameConstResource.startleftupperX,
					GameConstResource.startleftupperY + GameConstResource.dY * i,
					Pictures.picturesImage[GameConstResource.btstart + i].Width,
					Pictures.picturesImage[GameConstResource.btstart + i].Height,
					0,0,Pictures.picturesImage[GameConstResource.btstart + i].Width,
					Pictures.picturesImage[GameConstResource.btstart + i].Height);
			}

			//画选中项
			Draw.DrawImage(Pictures.picturesImage[GameConstResource.btstarton + selectIndex],
				GameConstResource.startleftupperX,
				GameConstResource.startleftupperY + GameConstResource.dY * selectIndex,
				Pictures.picturesImage[GameConstResource.btstarton + selectIndex].Width,
				Pictures.picturesImage[GameConstResource.btstarton + selectIndex].Height,
				0,0,Pictures.picturesImage[GameConstResource.btstarton + selectIndex].Width,
				Pictures.picturesImage[GameConstResource.btstarton + selectIndex].Height);

		}

		/// <summary>
		/// 背景绘制
		/// </summary>
		private void DrawBackGround()
		{
			Draw.DrawImage(Pictures.picturesImage[GameConstResource.startbg],0,0);
		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -