public void Start() { DifficultyStage difficulty = mDifficultyStages[GetDifficultyLevel()]; mCurrentSector = GetSectorIndex(mSerpent.transform.position); mSectors[GetLeftSectorIndex(mCurrentSector)].Generate(difficulty); mSectors[mCurrentSector].Generate(difficulty); mSectors[GetRightSectorIndex(mCurrentSector)].Generate(difficulty); if (mIslands.Length > 0) { for (int i = 0; i < mNumSectors; ++i) { float thetaStart = mSectorSize * i; float thetaEnd = mSectorSize * (i + 1); for (int island = 0; island < mNumIslandsPerSector; ++island) { SpawnIsland(Random.Range(thetaStart, thetaEnd)); } } } if (mClouds.Length > 0) { for (int i = 0; i < mNumSectors; ++i) { float thetaStart = mSectorSize * i; float thetaEnd = mSectorSize * (i + 1); for (int cloud = 0; cloud < mNumCloudsPerSector; ++cloud) { SpawnCloud(Random.Range(thetaStart, thetaEnd)); } } } }
public void Update() { //Vector2 serpentPolarPos = GetPolarCoordinate(mSerpent.transform.position); //Debug.Log(serpentPolarPos); int sector = GetSectorIndex(mSerpent.transform.position); if (sector != mCurrentSector) { int left = GetLeftSectorIndex(mCurrentSector); int right = GetRightSectorIndex(mCurrentSector); DifficultyStage difficulty = mDifficultyStages[GetDifficultyLevel()]; if (sector == left) { // we moved left mSectors[right].Destroy(); mSectors[GetLeftSectorIndex(sector)].Generate(difficulty); } else { // we moved right mSectors[left].Destroy(); mSectors[GetRightSectorIndex(sector)].Generate(difficulty); } } mCurrentSector = sector; }
public void Generate(DifficultyStage data) { int numFish = Random.Range(data.mMinSeaCreaturesToSpawn,data.mMaxSeaCreaturesToSpawn); for(int i = 0; i < numFish; ++i) { GameObject fishPrefab = data.GetRandomPrefab(data.mSeaCreaturePrefabs); if(fishPrefab == null) { continue; } float theta = Random.Range(mStart, mEnd); Vector2 fishPolarPos = new Vector2(Random.Range(mWorld.SeaBedLevel, mWorld.GetSeaLevel(theta)-2.0f), theta); SpawnEntity(fishPrefab, fishPolarPos); } int numBoats = Random.Range(data.mMinBoatToSpawn,data.mMaxBoatToSpawn); for(int i = 0; i < numBoats; ++i) { GameObject boatPrefab = data.GetRandomPrefab(data.mBoatPrefabs); if(boatPrefab == null) { continue; } float theta = Random.Range(mStart, mEnd); Vector2 boatPolarPos = new Vector2(mWorld.GetSeaLevel(theta), theta); GameObject boatObj = SpawnEntity(boatPrefab, boatPolarPos); Boat boat = boatObj.GetComponent<Boat>(); if(boat != null) { boat.SpawnPeople(this); } } }
private void UpdateDifficultLevel() { bool isDebugging = false; float ballSpawnMultiplier = isDebugging ? 2.0f : 1.0f; float numBallsSpawnedAdjusted = ballSpawnMultiplier * numBallsSpawned; if (difficultyStage == DifficultyStage.Stage1_Initial && numBallsSpawnedAdjusted > 20) { difficultyStage = DifficultyStage.Stage2_Divided; Instantiate(dividerPrefab, new Vector3(), Quaternion.identity); } else if (difficultyStage == DifficultyStage.Stage2_Divided && numBallsSpawnedAdjusted > 40) { difficultyStage = DifficultyStage.Stage3_Warped; } else if (difficultyStage == DifficultyStage.Stage3_Warped && numBallsSpawnedAdjusted > 50) { difficultyStage = DifficultyStage.Stage4_Reverse; } else if (difficultyStage == DifficultyStage.Stage4_Reverse && numBallsSpawnedAdjusted > 60) { difficultyStage = DifficultyStage.Stage5_ReverseAndCross; } else if (difficultyStage == DifficultyStage.Stage5_ReverseAndCross && numBallsSpawnedAdjusted > 70) { difficultyStage = DifficultyStage.Stage6_RedBalls; } }
public void Generate(DifficultyStage data) { int numFish = Random.Range(data.mMinSeaCreaturesToSpawn, data.mMaxSeaCreaturesToSpawn); for (int i = 0; i < numFish; ++i) { GameObject fishPrefab = data.GetRandomPrefab(data.mSeaCreaturePrefabs); if (fishPrefab == null) { continue; } float theta = Random.Range(mStart, mEnd); Vector2 fishPolarPos = new Vector2(Random.Range(mWorld.SeaBedLevel, mWorld.GetSeaLevel(theta) - 2.0f), theta); SpawnEntity(fishPrefab, fishPolarPos); } int numBoats = Random.Range(data.mMinBoatToSpawn, data.mMaxBoatToSpawn); for (int i = 0; i < numBoats; ++i) { GameObject boatPrefab = data.GetRandomPrefab(data.mBoatPrefabs); if (boatPrefab == null) { continue; } float theta = Random.Range(mStart, mEnd); Vector2 boatPolarPos = new Vector2(mWorld.GetSeaLevel(theta), theta); GameObject boatObj = SpawnEntity(boatPrefab, boatPolarPos); Boat boat = boatObj.GetComponent <Boat>(); if (boat != null) { boat.SpawnPeople(this); } } }