public static UnitType[,] NextTower() { int rn = RD.NextInt(towers.GetLength(0)); return(RotateMatrix(towers[rn], RD.NextInt(4))); }
public static UnitType[,] NextModule() { int rn = RD.NextInt(modules.GetLength(0)); return(RotateMatrix(modules[rn], RD.NextInt(4))); }
private void FixedUpdate() { // 更新进度 float percent = curTime; if (progressStart && pieceCount > 0 && progressState == ProgressState.DAYTIME) { if (curTime < dayTime) { curTime += Time.fixedDeltaTime; } percent /= dayTime; hudManager.UpdateTimeBoard(percent); if (percent > 1) { /// do spawn monster // 数量由天数决定 // 考虑非线性 // Lazer int enemyCount = (int)((RD.NextDouble() * 0.5 + 0.5) * Mathf.Pow(dayCount, 0.7f) + 1); Debug.Log("Spawn Lazer: " + enemyCount); // enemies = new GameObject[enemyCount]; while (enemyCount-- > 0) { // random position float thita = (RD.NextFloat() * 2 * Mathf.PI); // 1-1.5倍距离生成 float actualSpawnDistance = enemySpawnDistance * (1 + RD.NextFloat() * 0.5f); Vector3 spawnpoint = new Vector3(enemySpawnDistance * Mathf.Sin(thita), 3, enemySpawnDistance * Mathf.Cos(thita)); enemies.Add(Instantiate(enemyPrefab, worldManager.playerInstance.transform.position + spawnpoint, Quaternion.identity)); } // Giant enemyCount = (int)((RD.NextDouble() * 0.5 + 0.5) * Mathf.Max(0, Mathf.Pow(dayCount - towerDestroyed[0], 0.6f))); Debug.Log("Spawn Giant: " + enemyCount); while (enemyCount-- > 0) { bool enemyposN = RD.NextInt(2) == 1; // enemies.Add(enemyposN?) enemies.Add(Instantiate(enemyGiantPrefab, GameUtils.PositionToTranform( enemyposN ? worldManager.GetUnit(worldManager.towerpos1).position : worldManager.GetUnit(worldManager.towerpos2).position ) + Vector3.up * 3, Quaternion.identity) ); } // state change SendEvent(PlayEventType.GAME_ENTER_SWITCH); SendEvent(PlayEventType.GAME_ENTER_NIGHT); progressState = ProgressState.NIGHT; curTime = 0; hudManager.UpdateTimeBoard(0); } } if (progressState == ProgressState.NIGHT) { // update UI if (curTime < nightTime) { curTime += Time.fixedDeltaTime; } percent /= nightTime; enemies.RemoveAll(g => g == null); if (/*all monster killed*/ enemies.Count == 0 || percent > 1) { SendEvent(PlayEventType.GAME_ENTER_SWITCH); SendEvent(PlayEventType.GAME_ENTER_DAY); progressState = ProgressState.DAYTIME; curTime = 0; dayCount++; } } //UI update // 补充包 if (nextPieces.Count < piecePrefabs.Length) { FillNextPiece(); } // 恒时补充资源 if (goldRefillTime > curGoldRefillTime) { curGoldRefillTime += Time.fixedDeltaTime; } else { curGoldRefillTime -= goldRefillTime; GainResource(ResourceType.GOLD); } }