?? frmmain.cs
字號(hào):
this.Visible = false;
frmSheJiMap SheJiMapForm = new frmSheJiMap();
SheJiMapForm.ShowDialog();
this.Visible = true;
}
private void 從新開(kāi)始當(dāng)前關(guān)RToolStripMenuItem_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
ShowMap("Level" + Level.ToString() + ".hmap");
}
private void 草地ToolStripMenuItem_Click(object sender, EventArgs e)
{
標(biāo)準(zhǔn)ToolStripMenuItem.Checked = false;
倉(cāng)庫(kù)ToolStripMenuItem.Checked = false;
草地2ToolStripMenuItem.Checked = false;
草地ToolStripMenuItem.Checked = true;
aaaToolStripMenuItem.Checked = false;
MapType = "caodi";
LoadMapType(MapType);
ChangeMapType();
}
private void 草地2ToolStripMenuItem_Click(object sender, EventArgs e)
{
標(biāo)準(zhǔn)ToolStripMenuItem.Checked = false;
倉(cāng)庫(kù)ToolStripMenuItem.Checked = false;
草地2ToolStripMenuItem.Checked = true;
草地ToolStripMenuItem.Checked = false;
aaaToolStripMenuItem.Checked = false;
MapType = "xuedi";
LoadMapType(MapType);
ChangeMapType();
}
private void 倉(cāng)庫(kù)ToolStripMenuItem_Click(object sender, EventArgs e)
{
標(biāo)準(zhǔn)ToolStripMenuItem.Checked = false;
倉(cāng)庫(kù)ToolStripMenuItem.Checked = true;
草地2ToolStripMenuItem.Checked = false;
草地ToolStripMenuItem.Checked = false;
aaaToolStripMenuItem.Checked = false;
MapType = "cangku";
LoadMapType(MapType);
ChangeMapType();
}
private void 標(biāo)準(zhǔn)ToolStripMenuItem_Click(object sender, EventArgs e)
{
標(biāo)準(zhǔn)ToolStripMenuItem.Checked = true;
倉(cāng)庫(kù)ToolStripMenuItem.Checked = false;
草地2ToolStripMenuItem.Checked = false;
草地ToolStripMenuItem.Checked = false;
草地2ToolStripMenuItem.Checked = false;
MapType = "standard";
LoadMapType(MapType);
ChangeMapType();
}
/// <summary>
/// 撤消
/// </summary>
/// <param name="activeMap"></param>
private void UndoMap(enumMap[] activeMap)
{
for (int i = 0; i < 225; i++)
{
switch (activeMap[i])
{
case enumMap.地板:
((PictureBox)MapArrayList[i]).Image = LLu.Image;
break;
case enumMap.紅箱子:
((PictureBox)MapArrayList[i]).Image = LREDBOX.Image;
break;
case enumMap.空:
((PictureBox)MapArrayList[i]).Image = null;
break;
case enumMap.墻:
((PictureBox)MapArrayList[i]).Image = LWall.Image;
break;
case enumMap.箱子:
((PictureBox)MapArrayList[i]).Image = LBox.Image;
break;
case enumMap.箱子目地的:
((PictureBox)MapArrayList[i]).Image = LAim.Image;
break;
}
}
}
private void JiLuUndo(enumMap[] activeMap, enumMap[] undoMap)
{
for (int i = 0; i < 225; i++)
{
undoMap[i] = activeMap[i];
}
}
private void 撤消ToolStripMenuItem_Click(object sender, EventArgs e)
{
JiLuUndo(Undo1MapArray,enumMapArray);
UndoMap(enumMapArray);
pbRen.Location = Ren1Locate;
撤消ToolStripMenuItem.Enabled = false;
toolStripButton5.Enabled = false;
}
private void 選關(guān)ToolStripMenuItem_Click(object sender, EventArgs e)
{
frmSelectLevel SelectLevelForm = new frmSelectLevel(Level);
SelectLevelForm.Owner = this;
if (SelectLevelForm.ShowDialog() == DialogResult.OK)
{
timer1.Enabled = false;
ShowMap("Level" + Level.ToString() + ".hmap");
}
}
private void aaaToolStripMenuItem_Click(object sender, EventArgs e)
{
aaaToolStripMenuItem.Checked = true;
標(biāo)準(zhǔn)ToolStripMenuItem.Checked = false;
倉(cāng)庫(kù)ToolStripMenuItem.Checked = false;
草地2ToolStripMenuItem.Checked = false;
草地ToolStripMenuItem.Checked = false;
MapType = "tudi";
LoadMapType(MapType);
ChangeMapType();
}
private void 開(kāi)啟ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!開(kāi)啟ToolStripMenuItem.Checked)
{
sMusic.LoopPlay();
開(kāi)啟ToolStripMenuItem.Checked = true;
關(guān)閉ToolStripMenuItem.Checked = false;
}
}
private void 關(guān)閉ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!關(guān)閉ToolStripMenuItem.Checked)
{
sMusic.Stop();
關(guān)閉ToolStripMenuItem.Checked = true;
開(kāi)啟ToolStripMenuItem.Checked = false;
}
}
private void P_Click(object sender, EventArgs e)
{
if (enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.箱子||enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] ==enumMap.紅箱子)
{
if (pbRen.Left == ((PictureBox)sender).Left && pbRen.Top + 30 == ((PictureBox)sender).Top)
{
frmMain_KeyDown(null, new KeyEventArgs(Keys.Down));
return;
}
if (pbRen.Left == ((PictureBox)sender).Left && pbRen.Top - 30 == ((PictureBox)sender).Top)
{
frmMain_KeyDown(null, new KeyEventArgs(Keys.Up));
return;
}
if (pbRen.Left + 30 == ((PictureBox)sender).Left && pbRen.Top == ((PictureBox)sender).Top)
{
frmMain_KeyDown(null, new KeyEventArgs(Keys.Right));
return;
}
if (pbRen.Left - 30 == ((PictureBox)sender).Left && pbRen.Top == ((PictureBox)sender).Top)
{
frmMain_KeyDown(null, new KeyEventArgs(Keys.Left));
return;
}
return;
}
if (enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] != enumMap.地板 && enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] != enumMap.箱子目地的) return;
for (int i = 0; i < 225; i++)
{
b[i].G = 0;
b[i].H = 0;
b[i].ParentNode = null;
if (enumMapArray[i] != enumMap.地板 && enumMapArray[i] != enumMap.箱子目地的)
{
b[i].CanMove = false;
}
else
{
b[i].CanMove = true;
}
}
Finder f = new Finder(b);
int startX = pbRen.Left / 30;
int startY = pbRen.Top / 30;
int endX=((PictureBox)sender).Left / 30;
int endY=((PictureBox)sender).Top / 30;
string NewLu = f.Find(new ObjectPoint(startX, startY), new ObjectPoint(endX,endY));
if (NewLu != "false")
{
luArray = LuShu(NewLu);
timer2.Enabled = true;
}
}
private int[] LuShu(string luStr)
{
int ArrayCount = 0;
string cluStr = luStr;
while (true)
{
int w = cluStr.IndexOf('F');
if (w > -1)
{
ArrayCount++;
cluStr = cluStr.Remove(0, w + 1);
}
else
break;
}
int[] MArray = new int[ArrayCount];
for (int i = 0; i < ArrayCount; i++)
{
MArray[i] = int.Parse(luStr.Substring(0, luStr.IndexOf('F')));
luStr = luStr.Remove(0, luStr.IndexOf('F') + 1);
}
return MArray;
}
private void P_MouseEnter(object sender, EventArgs e)
{
if (enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.地板 || enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.箱子目地的)
{
//((PictureBox)sender).Cursor = Cursors.Hand;
((PictureBox)sender).Image = pbRen.Image;
}
if (enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.箱子 || enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.紅箱子)
{
((PictureBox)sender).Cursor = Cursors.Hand;
}
}
private void P_MouseLeave(object sender, EventArgs e)
{
((PictureBox)sender).Cursor = Cursors.Default;
if (enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.地板)
{
((PictureBox)sender).Image = LLu.Image;
}
if (enumMapArray[((PictureBox)sender).Top / 30 * 15 + ((PictureBox)sender).Left / 30] == enumMap.箱子目地的)
{
((PictureBox)sender).Image = LAim.Image;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
if (RenWeiZhi < luArray.Length)
{
pbRen.Left = b[luArray[RenWeiZhi]].X * 30;
pbRen.Top = b[luArray[RenWeiZhi]].Y * 30;
RenWeiZhi++;
}
else
{
timer2.Enabled = false;
RenWeiZhi = 0;
}
}
private void 退出EToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 作者_(dá)Click(object sender, EventArgs e)
{
MessageBox.Show(" 作者: 黃亞軍\n\n 電話: 0371-62077864\n\n 郵箱: hyj19851103@163.com\n\n QQ: 372056988\n\n" +
"環(huán)境提供: 中州大學(xué)-數(shù)字夢(mèng)工廠", "關(guān)于作者", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -