void LayoutWallObject(ref List <Vector2Int> emptyCells) { var cell = VExt.NextFromList(emptyCells); var go = VExt.LayoutAnimationObject( ObjData.r_PrefabPhysicsAnimation, cell.x, cell.y, "wall", ObjData.t_GameObjectsRoot, SortingLayer.Object.ToString(), VExt.NextFromArray(ObjData.p_WallsPresets.Animation)); var e = _world.NewEntityWith(out GameObjectComponent goComponent, out WallComponent _); goComponent.Transform = go.transform; goComponent.GO = go.GetComponent <PrefabComponentsShortcut>(); goComponent.GO.NPCNameText.text = e.GetInternalId().ToString(); var dataComponent = e.Set <NPCDataSheetComponent>(); dataComponent.Stats.MaxHealthPoint = UnityEngine.Random.Range(minWallHP, maxWallHP + 1); dataComponent.Stats.HealthPoint = dataComponent.Stats.MaxHealthPoint; emptyCells.Remove(cell); }
public void LevelCreate() { var rooms = new Rooms(); var roomsArray = VExt.NextFromArray(rooms.RoomsArray); Array.Reverse(roomsArray); int width = roomsArray[0].Length; int height = roomsArray.Length;; List <Vector2Int> emptyCells = new List <Vector2Int>(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (roomsArray[i][j] != ' ') { NewLevelTile(rooms.GetNameID('.'), new Vector2(j, i)); } switch (roomsArray[i][j]) { case '.': emptyCells.Add(new Vector2Int(j, i)); break; case '#': NewLevelTile(rooms.GetNameID('#'), new Vector2(j, i)); break; case 'X': NewLevelTile(rooms.GetNameID('X'), new Vector2(j, i)); break; case '@': NewPlayer(j, i); break; case 'A': NewLevelTile(rooms.GetNameID('A'), new Vector2(j, i)); break; default: break; } } } for (int i = 0; i < boostHPCount; i++) { //LayoutBoostHPObject(ref emptyCells); } for (int i = 0; i < healCount; i++) { NewFruitHeal(ref emptyCells); } for (int i = 0; i < wallCount; i++) { LayoutWallObject(ref emptyCells); } for (int i = 0; i < enemy01Count; i++) { LayoutEnemyObject(ref emptyCells, ObjData.p_Enemy01Preset); } for (int i = 0; i < enemy02Count; i++) { LayoutEnemyObject(ref emptyCells, ObjData.p_Enemy02Preset); } }