public void StartNewGame() { //Load in all rleavant info if (bSinglePlayer) { ClientScene.AddPlayer(0); } else { playerCheckIn++; if (NetworkLobbyManager.singleton != null && playerCheckIn < NetworkLobbyManager.singleton.numPlayers) { return; } } Players = GameObject.FindObjectsOfType <PlayerMomController>(); if (bSinglePlayer) { Players[0].TeamColor = new Color(0.765f, 0.225f, 0.638f, 1f); } numPlayers = Players.Length + levelGen.bots; levelGen.Init(); for (int t = 0; t < numPlayers; t++) { TeamSize.Add(0); } levelGen.PassInPlayers(Players); levelGen.Generate(); hasGameStarted = true; SarlacInstance = levelGen.SarlacDude.GetComponent <SarlacController>(); StartCoroutine(Release()); }
// get the state and store the the type of game that is being dealt with void Start() { StateToLoad level = Component.FindObjectOfType(typeof(StateToLoad)) as StateToLoad; if (!level) { return; } level.FetchData(); _type = level.GetStateType(); _gameNameId = level.GetNameID(); //create the level with the data from the state GenerateLevel.Generate(level.GetByteData(), out _lowTiles, out _midTiles, out _highTiles, _lowPlane, _midPlane, _highPlane); //set up each tile foreach (Tile t in Component.FindObjectsOfType(typeof(Tile)) as Tile[]) { t.GetNeighbors(); } PlaneManager.PM.ReassociateTiles(); Destroy(level.gameObject); }
void StartGame() { if (lengthInput.text == "1" && widthInput.text == "1") { Debug.Log("Invalid width or length (values of 1)"); return; } Debug.Log("Starting game from button press..."); levelGenerator.setSize(lengthInput.text, widthInput.text); cards_left = levelGenerator.Generate(); TitleGUI_Disable(); current_card = null; }
void ManifestLevel(int index) { if (index >= Levels.Length) { currentLevel = Levels.Length - 1; index = currentLevel; } CameraTransform.localPosition = cameraRootPosition; levelState.Clear(); levelState.AddFrame(); levelState.Current.YCamera = 0; generatedLevel = GenerateLevel.Generate(ref constants, Levels[index], ref playerObject, Camera.transform, levelState.Current, levelState.Objects); levelState.SaveStates(); lastMoveResult = MoveResult.None; }
private void GenerateRandomLevel(int numberOfRooms, int roomsMaxWight, int roomsMaxHeight, int roomsMinWight, int roomsMinHeight) { var numberOfAttempts = 1; var i = 0; while (i < numberOfAttempts) { DestroyCanvasObjects(); var layout = GenerateLevel.Generate(numberOfRooms, roomsMinWight, roomsMaxWight, roomsMinHeight, roomsMaxHeight); var minX = layout.Rooms.Min(a => a.Position.X); var maxX = layout.Rooms.Max(a => a.Position.X); var minY = layout.Rooms.Min(a => a.Position.Y); var maxY = layout.Rooms.Max(a => a.Position.Y); var maxRoomSide = Mathf.Max(roomsMaxWight, roomsMaxHeight, roomsMinWight, roomsMinHeight); var sizeX = maxX - minX + maxRoomSide * 3; var sizeY = maxY - minY + maxRoomSide * 3; var Xoffset = -minX + 3 + maxRoomSide; var Yoffset = -minY + 3 + maxRoomSide; ConstractorUI.UIConstractor.GetComponent <ConstractorUI>().InstantiateLevelField(sizeX, sizeY); var levelStructure = Globals.LevelStructure; GenerateRooms(Xoffset, Yoffset, levelStructure, layout); GenerateDoors(Xoffset, Yoffset, levelStructure, layout); var isLevelPassable = GenerateItemsFromTemplate(Xoffset, Yoffset, levelStructure, layout); if (isLevelPassable) { DrawLevel(Xoffset, Yoffset, levelStructure); return; } roomsMaxWight++; roomsMaxHeight++; roomsMinWight++; roomsMinHeight++; i++; } }
Vector3[] findVisibleVertices(Vector3 lookDirection) { // Find all colliders within the fowrange // If no colliders, just direction vector is added lookDirection.Normalize(); float fii = fowAngle / density; // NOTE both arg- vertors, begin and end are calculated in visible vertices Vector3[] visibleVertices = new Vector3[density + 1]; visibleVertices[0] = Vector3.zero; // Define startposition Vector3 fowStart = rotateVector(lookDirection, -fowAngle / 2); for (int i = 1; i < density + 1; i++) { // Cast rays relative to initial vector RaycastHit2D ray = Physics2D.Raycast(parent.position, rotateVector(fowStart, fii * i), fowRadius); // There is nothing in vision range if (ray.collider == null) { visibleVertices[i] = rotateVector(fowStart, fii * i) * fowRadius; } else { // Ray hit item, that should be hidden if (ray.collider.tag == "pushAndHide") { levelgenerator.Generate(); } // Ray hit some collider visibleVertices[i] = (Vector3)ray.point - parent.position; } } return(visibleVertices); }
private void Start() { GenerateLevel.Generate(); canRestart = true; }