📄 downfast.cs
字号:
using System;
using DiamondPet.UserLayer;
using System.Windows.Forms;
namespace DiamondPet.LogicLayer.GameStateRunLogic
{
/// <summary>
/// DownFast 的摘要说明。
/// 快下状态
/// </summary>
public class DownFast : RunningState
{
/// <summary>
/// 暂停命令
/// </summary>
private DownFastCommand.PauseFastCommand pauseFastCommand;
public DownFast()
{}
public DownFast(RunStateManager r) : base(r)
{
InitCommand();
}
public override void Initialize()
{
runCommandQueue.Clear();
}
#region 初始化类
/// <summary>
/// 初始化命名实例
/// </summary>
private void InitCommand()
{
pauseFastCommand = new DownFastCommand.PauseFastCommand(this);
}
#endregion
#region 贴图
protected override void DrawAll()
{
//在downfast 、downslow中并不去重新绘制
//静态的图形,只是将刚才的缓冲直接贴到
//buffer上
Draw.DrawTempToImage();
this.DrawMoveBlock();
this.DrawScore();
this.DrawPropetyBar();
this.DrawLevel();
}
#endregion
#region 游戏主循环
public override void RunStateLogic()
{
this.CheckSlowSpeed();
//时间更新
this.runStateManager.gameDate.timeControl.RenewTime(System.Environment.TickCount);
int tempDownNum = GameConstResource.eachDownNum;
DrawAll();
this.CheckCommand();
while(! runStateManager.gameDate.curGameItems.CheckCouldMove(tempDownNum,0))
{
tempDownNum--;
if(tempDownNum == 0)
break;
}
if( tempDownNum != 0 )
{
runStateManager.gameDate.curGameItems.MoveItems(tempDownNum,0);
}
else
{
CombineBlock();
//判断是否可消
if ( CheckClearBlock() == true)
{
//清连击累计变量
this.runStateManager.gameDate.gameScore.CleanNum();
runStateManager.ChangeState(RunStateManager.CLEARBLOCK);
}
else
{
runStateManager.ChangeState(RunStateManager.SELECTBLOCK);
}
}
//判断时间是否已经到了
base.JudgeTimeOver();
}
#endregion
#region 按键事件处理
/// <summary>
/// 添加命令
/// </summary>
/// <param name="key"></param>
/// <param name="isdown"></param>
public override void AddKeyCommand(System.Windows.Forms.Keys key, bool isdown)
{
if (isdown)
{
switch(key)
{
case Keys.D5:
this.runCommandQueue.AddElement(this.pauseFastCommand);
break;
case Keys.Enter:
this.runCommandQueue.AddElement(this.pauseFastCommand);
break;
}
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -