zoukankan      html  css  js  c++  java
  • [游戏开发-学习笔记]菜鸟慢慢飞(七)- 迷宫更新

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

      "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));
                    }
                }
            }
        }
    }
  • 相关阅读:
    RN常用布局和CSS
    RN常用组件
    海屯天地技术服务支持
    微前端应用解决方案
    React组件复用方式
    Webpack-CodeSplit(按需加载)
    Webpack-CodeSplit(静态文件篇)
    Webpack抽离第三方类库以及common解决方案
    Javascript十六种常用设计模式
    React hooks详解
  • 原文地址:https://www.cnblogs.com/workhai/p/6230374.html
Copyright © 2011-2022 走看看