5*5格子,获得 k值的 行列 的 最大最小值(首尾值)
获得k值 相邻的 上下左右 的4个值,以k为中心的九宫格的值。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
test(24);
test(22);
test(16);
test(12);
test(6);
test(0);
test(1);
test(2);
test(3);
test(3);
test(4);
}
private void test(int k)
{
print("----------------------"+k);
int up = 0, down = 0, left = 0, right = 0;//
int neighbor_up = 0, neighbor_down = 0, neighbor_left = 0, neighbor_right = 0;//
int x1 = 0, y1 = 0;
//所属 行、列 的 首尾的值
int x2 = 0, y2 = 0;
int x3 = 0, y3 = 0;

该博客介绍了如何在Unity中处理5x5的格子系统,详细讲解了如何找到特定值k所在的行和列的最大值和最小值,同时阐述了如何获取k值周围九宫格内的所有相邻值,对于游戏开发中的地图交互和逻辑处理具有指导意义。
最低0.47元/天 解锁文章
1442





