//零散墙 public void CreateSingleWall() { //1.确定生成的数目 int num = this.GetRateNum(wallNum, wallNumRate); //2.确定位置 if (num == 0) { GGDebug.Log("==================零散墙==================="); } else if (num == 1) { int posIndex = Random.Range(1, 6); WallUnitController script = WallUnitController.Create(); this.AddWallUnit(script.gameObject, this.GetWallPos(fWallPosX[posIndex - 1])); GGDebug.Log("==================零散墙==================="); } else if (num == 2) { int posIndex1 = Random.Range(1, 6); int posIndex2 = this.GetDontSideNum(posIndex1); WallUnitController script = WallUnitController.Create(); this.AddWallUnit(script.gameObject, this.GetWallPos(fWallPosX[posIndex1 - 1])); script = WallUnitController.Create(); this.AddWallUnit(script.gameObject, this.GetWallPos(fWallPosX[posIndex2 - 1])); GGDebug.Log("==================零散墙==================="); } this.curCreateWallIndex++; this.loopIndexNum++; this.curHorizontalType = Global.WallHorizontalType.FRANCE; }
//满墙 public void CreateFullWall() { GGDebug.Log("==================满墙==================="); for (int i = 0; i < fWallPosX.Length; i++) { WallUnitController script = WallUnitController.Create(); this.AddWallUnit(script.gameObject, this.GetWallPos(fWallPosX[i])); } this.curCreateWallIndex++; this.curHorizontalType = Global.WallHorizontalType.FRANCE; }
public static WallUnitController Create() { GameObject go = Instantiate(Resources.Load(PREFAB_PATH)) as GameObject; ////测试随机取一个颜色 //Color randColor = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)); //go.GetComponent<Image>().color = randColor; WallUnitController script = go.GetComponent <WallUnitController>(); script.Refresh(); return(script); }
//初始一排墙:值范围是1-2 public void CreateInitHorizontalWall() { for (int i = 0; i < fWallPosX.Length; i++) { WallUnitController script = WallUnitController.Create(); this.AddWallUnit(script.gameObject, this.GetWallPos(fWallPosX[i])); } this.loopIndexNum++; //4行空墙 for (int i = 0; i < 4; i++) { this.CreateNoneWall(); this.loopIndexNum++; } this.TransformHorizontalWallType(Global.WallHorizontalType.SINGLE_WALL); }