码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-12-28 20:30:16      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:清单   笔记   vector   dex   color   continue   pre   sum   tle   

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

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

 

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

标签:清单   笔记   vector   dex   color   continue   pre   sum   tle   

原文地址:http://www.cnblogs.com/workhai/p/6230374.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!