[游戏开发-学习笔记]菜鸟慢慢飞- 迷宫更新

Posted 虎鲨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[游戏开发-学习笔记]菜鸟慢慢飞- 迷宫更新相关的知识,希望对你有一定的参考价值。

随机迷宫,留下一个问题:

  "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));
                }
            }
        }
    }
}

 

以上是关于[游戏开发-学习笔记]菜鸟慢慢飞- 迷宫更新的主要内容,如果未能解决你的问题,请参考以下文章

[游戏开发-学习笔记]菜鸟慢慢飞- 插入排序

[游戏开发-学习笔记]菜鸟慢慢飞- 冒泡排序

[游戏开发-学习笔记]菜鸟慢慢飞

[游戏开发-学习笔记]菜鸟慢慢飞-Camera

[游戏开发-学习笔记]菜鸟慢慢飞-你怎么做笔记?

[游戏开发-学习笔记]菜鸟慢慢飞- NGUI- UIPanel(官方说明翻译)