Example #1
0
        private void Start()
        {
            Instance = this;
            NavLibrary.InitMap(MaxRow, MaxCol, GeneratePointStatus);

            GameObject objPrefab = Resources.Load <GameObject>("Prefabs/Brick");
            GameObject objBrick  = Instantiate(objPrefab, transform);

            objBrick.name = "Ground";
            objBrick.transform.GetChild(0).gameObject.layer = LayerMask.NameToLayer("Brick");
            objBrick.transform.localScale = new Vector3(MaxCol, 1, MaxRow);
            objBrick.transform.position   = new Vector3(MaxCol / 2 - 0.5f, 0, MaxRow / 2 - 0.5f);
            objBrick.GetComponentInChildren <Renderer>().material.mainTextureScale = new Vector2(MaxCol, MaxRow);

            GameObject objWallsRoot = new GameObject("WallsRoot");

            objWallsRoot.transform.SetParent(transform);
            for (int i = 0, lenRow = Mathf.CeilToInt(MaxRow / RectMeshCreater.MaxRow); i < lenRow; ++i)
            {
                for (int j = 0, lenCol = Mathf.CeilToInt(MaxCol / RectMeshCreater.MaxCol); j < lenCol; ++j)
                {
                    RectMeshCreater.GenerateParams param = new RectMeshCreater.GenerateParams()
                    {
                        row              = RectMeshCreater.MaxRow,
                        col              = RectMeshCreater.MaxCol,
                        startRow         = i * RectMeshCreater.MaxRow,
                        startCol         = j * RectMeshCreater.MaxCol,
                        materialPath     = "Assets/Resources/Materials/WallMat.mat",
                        objName          = "Wall_" + i + "_" + j,
                        parent           = objWallsRoot.transform,
                        mfOperate        = mfCoins,
                        cbIsGenerateCell = (cellRow, cellCol) =>
                        {
                            return(NavLibrary.GetPointStatus(cellRow, cellCol) == 0);
                        }
                    };
                    mfCoins = RectMeshCreater.GenerateRectObj(new Vector3(j * RectMeshCreater.MaxCol, 0.01f, i * RectMeshCreater.MaxRow), param);
                }
            }

            GameObject objPlayer = Instantiate(Resources.Load <GameObject>("Prefabs/Myself"));

            objPlayer.name = "Myself";
            objPlayer.transform.position = Vector3.zero;
        }
Example #2
0
 void InitNative()
 {
     NavLibrary.InitMap(MaxRow, MaxCol, GeneratePointStatus);
 }