public GameBoardManagerObject(Level level) { ObstructedX = level.ObstructedX; ObstructedY = level.ObstructedY; Traps = new List<TrapObject>(); moves = 0; numtraps = 0; MovementInProgress = false; Pather = new PathFinder(); InitialiseBoard(); TurnManager = new TurnManager(); LoadLevel(level); for (int i = 0; i < Positions.GetLength(0); i++) { for (int j = 0; j < Positions.GetLength(1); j++) { Positions[i, j] = new Vector3F(gap * i + startPos, 0.0f, gap * j + startPos); } } }
private void LoadLevel(Level level) { for (int i = 0; i < level._boardData.GetLength(0); i++) { for (int j = 0; j < level._boardData.GetLength(1); j++) { if (!level._boardData[i, j]) { GameBoard[i, j] = SquareData.BLOCKED; } } } var gameObjectService = ServiceLocator.Current.GetInstance<IGameObjectService>(); gameObjectService.Objects.Add(new BoardObject(level._levelModel)); for (int x = 0; x < level._characters.Count; x++) { gameObjectService.Objects.Add(level._characters[x]); TurnManager.AddToList(level._characters[x]); } bool passed = false; int[,] taken = new int[10, 10]; TrapObject trap = new TrapObject(); for (int i = 0; i < level.NumberOfTraps; i++) { while (passed == false) { trap = new TrapObject(); passed = true; for (int z = 0; z < TurnManager.characterList.Count; z++) { if ((trap.PosX == TurnManager.characterList[z].PosX) && (trap.PosY == TurnManager.characterList[z].PosY)) { passed = false; } } if (taken[trap.PosX, trap.PosY] == 1) { passed = false; } } taken[trap.PosX, trap.PosY] = 1; Traps.Add(trap); numtraps++; passed = false; Console.Write("Trap added at "); Console.Write(trap.PosX); Console.Write(trap.PosY); } }