首页 > 代码库 > [游戏开发-学习笔记]菜鸟慢慢飞(七)- 迷宫更新
[游戏开发-学习笔记]菜鸟慢慢飞(七)- 迷宫更新
随机迷宫,留下一个问题:
"Quaternion这个API看不懂,先放到学习清单中,如果会这个,应该就可以横墙,竖墙只用一个."
查看了下官方API。
只用一面墙,效果是一样的。
更新一下代码:
using UnityEngine; /// <summary> /// 初始化迷宫 /// </summary> public class InitializeMazerev1 : MonoBehaviour { public GameObject WallHS; public GameObject pillars; public int sumber = 100; // Use this for initialization void Awake() { int sidexy = sumber * 11; for (int i = 0; i < (sumber + 1); i++) { for (int j = 0; j < (sumber + 1); j++) { int pillarx = i * 110; int wallHx = 55 + 110 * i; int pillarz = j * 110; int wallVz = 55 + 110 * j; if (i == sumber && j == sumber) { Instantiate(pillars, new Vector3(pillarx, 50, pillarz), Quaternion.identity); continue; } if (i == sumber) { Instantiate(pillars, new Vector3(pillarx, 50, pillarz), Quaternion.identity); //Instantiate(WallV, new Vector3(pillarx, 50, wallVz), Quaternion.identity); Instantiate(WallHS, new Vector3(pillarx, 50, wallVz), Quaternion.Euler(0, 90, 0)); continue; } if (j == sumber) { Instantiate(pillars, new Vector3(pillarx, 50, pillarz), Quaternion.identity); Instantiate(WallHS, new Vector3(wallHx, 50, pillarz), Quaternion.identity); } else { Instantiate(pillars, new Vector3(pillarx, 50, pillarz), Quaternion.identity); Instantiate(WallHS, new Vector3(wallHx, 50, pillarz), Quaternion.identity); // Instantiate(WallV, new Vector3(pillarx, 50, wallVz), Quaternion.identity) Instantiate(WallHS, new Vector3(pillarx, 50, wallVz), Quaternion.Euler(0, 90, 0)); } } } } }
[游戏开发-学习笔记]菜鸟慢慢飞(七)- 迷宫更新
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。