围住神经猫
来源:互联网 发布:适合编程的笔记本电脑 编辑:程序博客网 时间:2024/05/02 01:26
/// 判断下一步可能的位置,计算猫可移动的位置
/// </summary>
/// <returns></returns>
private ArrayList FindSteps()
{
Items items = cat.GetComponent<Items>();
int rowIndex = items.rowIndex;
int columnIndex = items.columnIndex;
ArrayList steps = new ArrayList();
Vector2 nextStep = new Vector2();
#region 获得可以行走的位置 上下左右
//left
nextStep.y = rowIndex;
nextStep.x = columnIndex-1;
if (Movable(nextStep))
steps.Add(nextStep);
//right
nextStep.y = rowIndex;
nextStep.x = columnIndex + 1;
if (Movable(nextStep))
steps.Add(nextStep);
//top
nextStep.y = rowIndex + 1;
nextStep.x = columnIndex;
if (Movable(nextStep))
steps.Add(nextStep);
//bottom
nextStep.y = rowIndex - 1;
nextStep.x = columnIndex;
if (Movable(nextStep))
steps.Add(nextStep);
#endregion
//奇数行topleft,偶数行topright
nextStep.y = rowIndex + 1;
if (rowIndex % 2 == 1)
nextStep.x = columnIndex - 1;
else
nextStep.x = columnIndex + 1;
if (Movable(nextStep))
steps.Add(nextStep);
//奇数行bottomleft,偶数行bottomright
nextStep.y = rowIndex - 1;
if (rowIndex % 2 == 1)
nextStep.x = columnIndex - 1;
else
nextStep.x = columnIndex + 1;
if (Movable(nextStep))
steps.Add(nextStep);
return steps;
}
/// <summary>
/// 根据指定的位置找最大的通路
/// </summary>
/// <param name="vector"></param>
/// <returns></returns>
int FindSteps(Vector2 vector)
{
Items items = GetPot((int)vector.y, (int)vector.x);
int rowIndex = items.rowIndex;
int columnIndex = items.columnIndex;
ArrayList steps = new ArrayList();
Vector2 nextStep = new Vector2();
#region 获得可以行走的位置 上下左右
//left
nextStep.y = rowIndex;
nextStep.x = columnIndex - 1;
if (Movable(nextStep))
steps.Add(nextStep);
//right
nextStep.y = rowIndex;
nextStep.x = columnIndex + 1;
if (Movable(nextStep))
steps.Add(nextStep);
//top
nextStep.y = rowIndex + 1;
nextStep.x = columnIndex;
if (Movable(nextStep))
steps.Add(nextStep);
//bottom
nextStep.y = rowIndex - 1;
nextStep.x = columnIndex;
if (Movable(nextStep))
steps.Add(nextStep);
#endregion
//奇数行topleft,偶数行topright
nextStep.y = rowIndex + 1;
if (rowIndex % 2 == 1)
nextStep.x = columnIndex - 1;
else
nextStep.x = columnIndex + 1;
if (Movable(nextStep))
steps.Add(nextStep);
//奇数行bottomleft,偶数行bottomright
nextStep.y = rowIndex - 1;
if (rowIndex % 2 == 1)
nextStep.x = columnIndex - 1;
else
nextStep.x = columnIndex + 1;
if (Movable(nextStep))
steps.Add(nextStep);
return steps.Count;
}
private void SetAllPaths()
{
//左上角
for (int i = 0; i < rowNum ; i++)
{
for (int j = 0; j < columnNum ; j++)
{
if (Movable(new Vector2(i, j)))
ChangePath(new Vector2(i, j));
if (Movable(new Vector2(j, i)))
ChangePath(new Vector2(j, i));
}
}
//左下角
for (int i = 0; i < rowNum ; i++)
{
for (int j = 0; j < columnNum ; j++)
{
if(Movable (new Vector2 (i,rowNum -1-j)))
ChangePath (new Vector2 (i,rowNum -1-j));
if(Movable (new Vector2 (columnNum -1-j,i)))
ChangePath (new Vector2 (columnNum -1-j,i));
}
}
//右上角
for (int i = 0; i < rowNum; i++)
{
for (int j = 0; j < columnNum; j++)
{
if (Movable(new Vector2(i, rowNum - 1 - j)))
ChangePath(new Vector2(i, rowNum - 1 - j));
if (Movable(new Vector2(j, columnNum - 1 - i)))
ChangePath(new Vector2(j, columnNum - 1 - i));
}
}
//右下角
for (int i = 0; i < rowNum; i++)
{
for (int j = 0; j < columnNum; j++)
{
if (Movable(new Vector2(rowNum - 1 - i, rowNum - 1 - j)))
ChangePath(new Vector2(rowNum - 1 - i, rowNum - 1 - j));
if (Movable(new Vector2(columnNum - 1 - j, columnNum - 1 - i)))
ChangePath(new Vector2(columnNum - 1 - j, columnNum - 1 - i));
}
}
}
- Unity 围住神经猫
- 围住神经猫
- Android 围住神经猫
- 围住神经猫
- 围住神经猫
- 围住神经猫
- 围住神经猫源代码下载
- swift-游戏-围住神经猫
- 围住神经猫源码分享
- 【JS+h5】围住神经猫
- 围住神经猫判断围住的算法--简单图论
- 关于围住神经猫实现的想法
- 软件工程作业——围住神经猫
- 软件工程第二次作业 围住神经猫
- HTML5APP实战(1): 围住神经猫(一)
- HTML5APP实战(1): 围住神经猫(二)
- createjs之easeljs【游戏围住神经猫】
- 泰课在线围住神经猫
- View滑动动画的选择及其left, marginLeft, translationX参数的总结
- POJ 2479 Maximum sum(2次最大字段和)
- 如何让Window批处理文件可以支持带有空格的路径
- Defaulted 和 Deleted 函数--C++11
- Troubleshooting: 'Log file sync' Waits
- 围住神经猫
- Android Project Butter分析
- Lock与synchronized 的区别
- 小计一下
- 79.View the Exhibit and examine the structure of the CUSTOMERS table. In the CUSTOMERS table, the CU
- 入门训练 Fibonacci数列
- android superWebView ----新的 Hybrid App 解决方案(集成总结)
- Java发送内嵌图片的邮件
- Redis,Memcached