public void WaveComplete() { previousScore = score; previousLives = lives; endStatement.text = "WAVE COMPLETE"; endStatement.gameObject.SetActive(true); EnemyHorde.CompleteWave(); StartCoroutine(NextWave()); }
/// <summary> /// To be called by a Plant OR Pathogen object, whenever it kills a plant. /// </summary> public void KillPlant(int x, int y) { if (x < 0 || y < 0 || x >= BOARD_WIDTH || y >= BOARD_HEIGHT) { throw new System.Exception(); } plantCount--; plantHistory.Remove((Plant)gameBoard[y, x]); Destroy(((Plant)gameBoard[y, x]).gameObject); gameBoard[y, x] = new EnemyHorde(); }
public static void NewGame() { previousScore = 0; previousLives = 3; EnemyHorde.ResetWaves(); }
private void InitGame() { /* Init data structures */ gameBoard = new IEntity[BOARD_HEIGHT, BOARD_WIDTH]; tileBoard = new Tile[BOARD_HEIGHT, BOARD_WIDTH]; for (uint r = 0; r < BOARD_HEIGHT; r++) { for (uint c = 0; c < BOARD_WIDTH; c++) { /* 50% chance for plain tile, 25% chance each for other types */ int rand = Random.Range(0, 4); int tileIndex = rand >= tilePrefabs.Length ? 0 : rand; Tile tile = Instantiate(tilePrefabs[tileIndex], new Vector3(c * TILE_SIZE, r * TILE_SIZE, 0f), Quaternion.identity).GetComponent <Tile>(); tile.SetPosition(c, r); tileBoard[r, c] = tile; gameBoard[r, c] = new EnemyHorde(); } } for (int r = 0; r < BOARD_HEIGHT; r++) { for (int c = 0; c < BOARD_WIDTH; c++) { // Above if (r > 0) { tileBoard[r, c].AddAdjacentTile(tileBoard[r - 1, c]); } // Below if (r < BOARD_HEIGHT - 1) { tileBoard[r, c].AddAdjacentTile(tileBoard[r + 1, c]); } // Left if (c > 0) { tileBoard[r, c].AddAdjacentTile(tileBoard[r, c - 1]); } // Right if (c < BOARD_WIDTH - 1) { tileBoard[r, c].AddAdjacentTile(tileBoard[r, c + 1]); } } } plantHistory = new Dictionary <Plant, uint>(); activeEnemies = new List <Enemy>(); /* Initialize at dawn. */ currentPhase = Phase.Dawn; buttonLabel.text = "Finished\nPlanting"; clockFill.gameObject.SetActive(false); currentWeather = Weather.Sun; currentCycle = 1; plantCount = 0; currentEnemyCount = 0; ERPCount = 0; seedCount = 2; hydration = 10; // on a scale 0 - 20? nutrients = 4.50f; // on a scale 0 - 10? remainingTime = RESET_TIME; weapon = Weapon.Red; }