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

📄 checkclass.cs

📁 gamecode 很不错的小游戏源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Windows.Forms;

namespace MapEditor
{
	/// <summary>
	/// CheckClass 为一静态类,不可实例化
	/// </summary>
	public class CheckClass
	{
		/// <summary>
		/// 构造函数,此处无用
		/// </summary>
		private CheckClass()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		/// <summary>
		/// 在化图之前先检查
		/// </summary>
		/// <param name="i">左上角坐标i</param>
		/// <param name="j">坐上角坐标j</param>
		/// <param name="index">图形的ID</param>
		/// <param name="recordX">标志位坐标x</param>
		/// <param name="recordY">标志位坐标y</param>
		/// <returns></returns>
		public static bool CheckForDrawing(ref int i,ref int j,int index,ref int recordX,ref int recordY)
		{
			//??????
			if(index == 30)
			{
				//左
				if(i - 1 >= 0)
				{
					if((MainEntry.theForm.Map[i - 1,j].imageIndex == 5
						|| MainEntry.theForm.Map[i - 1,j].imageIndex == 20
						|| MainEntry.theForm.Map[i - 1,j].imageIndex == 21
						|| MainEntry.theForm.Map[i - 1,j].imageIndex == FormMain.ShowNumber)
						&& !CheckClass.CheckIfHasPlayer(i - 1,j))
					{
						i = i - 1;
						recordX = i;
						recordY = j;
						return true;
					}
				}
				//右
				if(i + 1 <= 63)
				{	
					if((MainEntry.theForm.Map[i + 1,j].imageIndex == 5
						|| MainEntry.theForm.Map[i + 1,j].imageIndex == 20
						|| MainEntry.theForm.Map[i + 1,j].imageIndex == 21
						|| MainEntry.theForm.Map[i + 1,j].imageIndex == FormMain.ShowNumber)
						&& !CheckClass.CheckIfHasPlayer(i + 1,j))
					{
						i = i + 1;
						recordX = i;
						recordY = j;
						return true;
					}
				}
				//上
				if(j - 1 >= 0)
				{				
					if((MainEntry.theForm.Map[i,j - 1].imageIndex == 5
						|| MainEntry.theForm.Map[i,j - 1].imageIndex == 20
						|| MainEntry.theForm.Map[i,j - 1].imageIndex == 21
						|| MainEntry.theForm.Map[i,j - 1].imageIndex == FormMain.ShowNumber)
						&& !CheckClass.CheckIfHasPlayer(i,j - 1))
					{
						j = j - 1;
						recordX = i;
						recordY = j;
						return true;
					}
				}
				//下
				if(j + 1 <= 47)
				{				
					if((MainEntry.theForm.Map[i,j + 1].imageIndex == 5
						|| MainEntry.theForm.Map[i,j + 1].imageIndex == 20
						|| MainEntry.theForm.Map[i,j + 1].imageIndex == 21
						|| MainEntry.theForm.Map[i,j + 1].imageIndex == FormMain.ShowNumber)
						&& !CheckClass.CheckIfHasPlayer(i,j + 1))
					{
						j = j + 1;
						recordX = i;
						recordY = j;
						return true;
					}
				}
				return false;
			}
			//左
			if(i - 3 >= 0 && j - 1 >= 0 && j + 1 <= 47)
			{
				bool allRight = true;
				for(int k = 0;k < 3;k ++)
				{
					for(int t = 0;t < 3;t++)
					{
						if((MainEntry.theForm.Map[k + i - 3,t + j - 1].imageIndex != 5
							&& MainEntry.theForm.Map[k + i - 3,t + j - 1].imageIndex != 20
							&& MainEntry.theForm.Map[k + i - 3,t + j - 1].imageIndex != 21
							&& MainEntry.theForm.Map[k + i - 3,t + j - 1].imageIndex != FormMain.ShowNumber)
							|| CheckClass.CheckIfHasPlayer(k + i - 3,t + j - 1))
						{
							allRight = false;
						}
					}
				}
				if(allRight)
				{
					recordX = i - 1;
					recordY = j;
					i = i - 3;
					j = j - 1;
					return true;
				}
			}
			//右????????????
			if(i + 3 <= 63 && j - 1 >= 0 && j + 1 <= 47)
			{
				bool allRight = true;
				for(int k = 0;k < 3;k ++)
				{
					for(int t = 0;t < 3;t++)
					{
						if((MainEntry.theForm.Map[k + i + 1,t + j - 1].imageIndex != 5
							&& MainEntry.theForm.Map[k + i + 1,t + j - 1].imageIndex != 20
							&& MainEntry.theForm.Map[k + i + 1,t + j - 1].imageIndex != 21
							&& MainEntry.theForm.Map[k + i + 1,t + j - 1].imageIndex != FormMain.ShowNumber)
							|| CheckClass.CheckIfHasPlayer(k + i + 1,t + j - 1))//???
						{
							allRight = false;
						}
					}
				}
				if(allRight)
				{
					recordX = i + 1;
					recordY = j;
					i = i + 1;
					j = j - 1;
				//	MessageBox.Show(recordX.ToString() + "  " + recordY.ToString());
					return true;
				}
			}
			//上
			if(i - 1 >= 0 && i + 1 <= 63 && j - 3 >= 0)
			{		
				bool allRight = true;
				for(int k = 0;k < 3;k ++)
				{
					for(int t = 0;t < 3;t++)
					{
						if((MainEntry.theForm.Map[k + i - 1,t + j - 3].imageIndex != 5
							&& MainEntry.theForm.Map[k + i - 1,t + j - 3].imageIndex != 20
							&& MainEntry.theForm.Map[k + i - 1,t + j - 3].imageIndex != 21
							&& MainEntry.theForm.Map[k + i - 1,t + j - 3].imageIndex != FormMain.ShowNumber)
							|| CheckClass.CheckIfHasPlayer(k + i - 1,t + j - 3))
						{
							allRight = false;
						}
					}
				}
				if(allRight)
				{
					recordX = i;
					recordY = j - 1;
					i = i - 1;
					j = j - 3;
					return true;
				}
			}
			//下
			if(i - 1 >= 0 && i + 1 <= 63 && j + 3 <= 47)
			{		
				bool allRight = true;
				for(int k = 0;k < 3;k ++)
				{
					for(int t = 0;t < 3;t++)
					{
						if((MainEntry.theForm.Map[k + i - 1,t + j + 1].imageIndex != 5
							&& MainEntry.theForm.Map[k + i - 1,t + j + 1].imageIndex != 20
							&& MainEntry.theForm.Map[k + i - 1,t + j + 1].imageIndex != 21
							&& MainEntry.theForm.Map[k + i - 1,t + j + 1].imageIndex != FormMain.ShowNumber)
							|| CheckClass.CheckIfHasPlayer(k + i - 1,t + j - 1))
						{
							allRight = false;
						}
					}
				}
				if(allRight)
				{
					recordX = i;
					recordY = j + 1;
					i = i - 1;
					j = j + 1;
					return true;
				}
			}
			return false;
		}

		/// <summary>
		/// 过滤无用信息,以便保存
		/// </summary>
		public static void FilterForSave()
		{
			for(int i = 0;i < 64;i++)
			{
				for(int j = 0;j < 48;j++)
				{
					if(MainEntry.theForm.Map[i,j].fileIndex == 1)
					{
						//如果是建筑
						if((MainEntry.theForm.Map[i,j].imageIndex >= 3 &&
							MainEntry.theForm.Map[i,j].imageIndex <= 8) ||
							MainEntry.theForm.Map[i,j].imageIndex >= 36)
						{
							MainEntry.theForm.Map[i,j].imageIndex = MainEntry.theForm.RecoverMapInfo[i,j].imageIndex;
							MainEntry.theForm.Map[i,j].fileIndex = 0;
						}
					}
					else
					{
						if((MainEntry.theForm.Map[i,j].imageIndex >= 10 &&MainEntry.theForm.Map[i,j].imageIndex <= 17)
							|| (MainEntry.theForm.Map[i,j].imageIndex > 47 && MainEntry.theForm.Map[i,j].imageIndex < 49)
							|| MainEntry.theForm.Map[i,j].imageIndex == FormMain.TakeUP)

						{
							MainEntry.theForm.Map[i,j].fileIndex = 0;
							MainEntry.theForm.Map[i,j].imageIndex = MainEntry.theForm.RecoverMapInfo[i,j].imageIndex;
						}
					}
				}
			}
		}
		/// <summary>
		/// 过滤无用地图信息,以便重绘
		/// </summary>
		public static void FilterMapInfo()
		{
			for(int i = 0;i < 64;i++)
			{
				for(int j = 0;j < 48;j++)
				{
					if(MainEntry.theForm.Map[i,j].fileIndex == 1)
					{
						if((MainEntry.theForm.Map[i,j].imageIndex >= 3 &&
							MainEntry.theForm.Map[i,j].imageIndex <= 8) ||
							MainEntry.theForm.Map[i,j].imageIndex >= 36)
						{
							MainEntry.theForm.Map[i,j].imageIndex = MainEntry.theForm.RecoverMapInfo[i,j].imageIndex;
							MainEntry.theForm.Map[i,j].fileIndex = 0;
						}
					}
					else
					{
						if((MainEntry.theForm.Map[i,j].imageIndex >= 10 &&MainEntry.theForm.Map[i,j].imageIndex <= 17)
							|| (MainEntry.theForm.Map[i,j].imageIndex > 47 && MainEntry.theForm.Map[i,j].imageIndex < 49)
							|| MainEntry.theForm.Map[i,j].imageIndex == FormMain.TakeUP
							|| MainEntry.theForm.Map[i,j].imageIndex == FormMain.ShowNumber)
						{
							MainEntry.theForm.Map[i,j].fileIndex = 0;
							MainEntry.theForm.Map[i,j].imageIndex = MainEntry.theForm.RecoverMapInfo[i,j].imageIndex;
						}
					}
				}
			}
		}

		/// <summary>
		/// 恢复地图信息以便作图
		/// </summary>
		public static void RecoverMapInfoForDrawing()
		{
			for(int i = 0;i < 64;i++)
			{
				for(int j = 0;j < 48;j++)
				{
					//如果是银行或商店
					if(MainEntry.theForm.Map[i,j].fileIndex == 1
						&& (MainEntry.theForm.Map[i,j].imageIndex == 1
						|| MainEntry.theForm.Map[i,j].imageIndex == 2))
					{
						MainEntry.theForm.Map[i,j].fileIndex = 0;
						MainEntry.theForm.Map[i,j].imageIndex = MainEntry.theForm.RecoverMapInfo[i,j].imageIndex;
					}
					/*if(MainEntry.theForm.RecoverMapInfo[i,j].fileIndex == 0
						&& MainEntry.theForm.Map[i,j].imageIndex != 5
						&& MainEntry.theForm.Map[i,j].imageIndex != 20
						&& MainEntry.theForm.Map[i,j].imageIndex != 21)

⌨️ 快捷键说明

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