private void UpdateWavePhase() { // Not the best way to detect no enemies, but it works ok GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); if (!spawnManager.SpawningEnemies && enemies.Length == 0) { if (currentWave == maxWaves) { Phase = LevelPhase.EndPhase; } else { Phase = LevelPhase.BuildPhase; } } // If the nexus gets destroyed go to the endphase if (nexus.IsDestroyed) { lost = true; Phase = LevelPhase.EndPhase; } }
public static void SetLevelPhase(LevelPhase phase) { GameEvent_PD2.level_phase = phase; }
void Update() { switch (levelPhase) { case (LevelPhase.PHASE1): BoundsUpdate(-35.3f, -24.25f); smoothCamera.following = false; spawnManager.phase1 = true; if (enemiesKilledInPhase >= 1) { /* * spawnManager.phase1 = false; * if (EnemiesInGame.Count == 0) * { * enemiesKilledInPhase = 0; * levelPhase = LevelPhase.CONTINUE; * } * } * break; * * case (LevelPhase.PHASE2): * BoundsUpdate(-16f, -4f); * * smoothCamera.following = false; * * spawnManager.phase2 = true; * * if (enemiesKilledInPhase >= 1) * { * spawnManager.phase2 = false; * if (EnemiesInGame.Count == 0) * { * enemiesKilledInPhase = 0; * levelPhase = LevelPhase.CONTINUE; * } */ /* ****Player locked in Phase 1 for Demo!!!*** */ } break; case (LevelPhase.PHASE3): BoundsUpdate(13f, 25f); smoothCamera.following = false; spawnManager.phase3 = true; if (enemiesKilledInPhase >= 1) { spawnManager.phase3 = false; if (EnemiesInGame.Count == 0) { enemiesKilledInPhase = 0; levelPhase = LevelPhase.CONTINUE; } } break; case (LevelPhase.CONTINUE): smoothCamera.following = true; //Phase1 Cont to Phase2 if (playerObject.transform.position.x >= -10 && phaseCounter == 1 || player2Object.transform.position.x >= -10 && phaseCounter == 1) { phaseCounter++; levelPhase = LevelPhase.PHASE2; } else if (playerObject.transform.position.x < -10 && phaseCounter == 1 || player2Object.transform.position.x < -10 && phaseCounter == 1) { playerController.xMax = -9; playerTwoController.xMax = -9; } //Phase2 Cont to Phase3 else if (playerObject.transform.position.x >= 20 && phaseCounter == 2 || player2Object.transform.position.x >= 20 && phaseCounter == 2) { phaseCounter++; levelPhase = LevelPhase.PHASE3; } else if (playerObject.transform.position.x < 20 || player2Object.transform.position.x < 20 && phaseCounter == 2) { playerController.xMax = 21; playerTwoController.xMax = 21; } break; } }
public override void CharacterInteraction(CharacterController character, Interactable interactable) { if (interactable != null && character != null) { Debug.Log("INTERACTING!"); if (interactable.identifier == "apple") { if (Vector2.Distance(character.transform.position, interactable.transform.position) <= interactable.interactDistance && currentPhase == LevelPhase.FIRST) { ApplePicked(character); Destroy(interactable.gameObject, 0.1f); SetText(textApplePicked); } else { var shaker = interactable.GetComponent <ShakerEffect>(); if (shaker != null) { shaker.Shake(); } } } else if (interactable.identifier == "bucket") { if (Vector2.Distance(character.transform.position, interactable.transform.position) <= interactable.interactDistance && currentPhase == LevelPhase.SECOND_HORSE_FED_APPLE) { BucketPicked(); Destroy(interactable.gameObject, 0.1f); } else { var shaker = interactable.GetComponent <ShakerEffect>(); if (shaker != null) { shaker.Shake(); } } } else if (interactable.identifier == "horse") { if (Vector2.Distance(character.transform.position, interactable.transform.position) <= interactable.interactDistance) { if (currentPhase == LevelPhase.FIRST && applePicked) { SetText(textHorseFed); AppleItemImage.SetActive(false); currentPhase = LevelPhase.SECOND_HORSE_FED_APPLE; } else if (currentPhase == LevelPhase.SECOND_HORSE_FED_APPLE && bucketPicked) { SetText("El balde esta vacio. Debes llenarlo con agua antes de darselo a la yegua"); } else if (currentPhase == LevelPhase.SECOND_HORSE_FED_APPLE && waterBucketPicked && !bucketPicked) { SetText("¡Buen trabajo! Has alimentado a la yegua. Ahora está lista para sus actividades diarias"); Invoke("OpenMenu", 1.5f); } } } else if (interactable.identifier == "water") { if (Vector2.Distance(character.transform.position, interactable.transform.position) <= interactable.interactDistance) { if (currentPhase == LevelPhase.SECOND_HORSE_FED_APPLE && bucketPicked) { SetText("Has llenado el balde de agua. El agua de los pozos artificiales proviene del subsuelo y es naturalmente filtrada por rocas de diversos tamaños. Esta puede ser consumida sin problemas por personas y animales."); waterBucketPicked = true; bucketPicked = false; BucketItemImage.SetActive(false); BucketItemFilledImage.SetActive(true); } } } } }
public void Scored(int points, bool added = false) // total points of the level { if (points < 0) { points = 0; } if (points > 10) { points = 10; } if (!added && actualPhase == LevelPhase.SECOND_SHOT) { points -= levelScore[levelIndex()].firstScore; } else if (!added && actualPhase == LevelPhase.SECOND_SHOT) { points -= levelScore[levelIndex()].firstScore + levelScore[levelIndex()].secondScore; } switch (actualPhase) { case LevelPhase.FIRST_SHOT: // add previous bonuses if (!isFirstLevel()) { if (levelScore[levelBefore()].state == LevelScore.ScoreDisplay.WAITING_NEXT_FIRST) { levelScore[levelBefore()].state = LevelScore.ScoreDisplay.DISPLAY_SPARE; computeTotalScore(levelBefore()); } } if (points < 10) { levelScore[levelIndex()].firstScore = points; levelScore[levelIndex()].state = LevelScore.ScoreDisplay.FIRST_DISPLAY; actualPhase = LevelPhase.SECOND_SHOT; } else { if (isLastLevel()) // strike in the last level { levelScore[levelIndex()].firstScore = points; levelScore[levelIndex()].state = LevelScore.ScoreDisplay.STRIKE_WAITING_TWO; actualPhase = LevelPhase.SECOND_SHOT; } else // just a normal strike in the game { levelScore[levelIndex()].firstScore = points; levelScore[levelIndex()].state = LevelScore.ScoreDisplay.WAITING_NEXT_SECOND; actualPhase = LevelPhase.FIRST_SHOT; incrementLevel(); } } break; case LevelPhase.SECOND_SHOT: // add previous bonus if (!isFirstLevel()) { if (levelScore[levelBefore()].state == LevelScore.ScoreDisplay.WAITING_NEXT_SECOND) { levelScore[levelBefore()].state = LevelScore.ScoreDisplay.DISPLAY_STRIKE; computeTotalScore(levelBefore()); } } int firstPlusSecond = levelScore[levelIndex()].firstScore + levelScore[levelIndex()].secondScore; if (firstPlusSecond < 10) // no spare { levelScore[levelIndex()].secondScore = points; levelScore[levelIndex()].state = LevelScore.ScoreDisplay.SECOND_DISPLAY; if (isLastLevel()) { actualPhase = LevelPhase.GAME_FINISHED; } else { incrementLevel(); actualPhase = LevelPhase.FIRST_SHOT; } } else // spare ! { if (isLastLevel()) { levelScore[levelIndex()].secondScore = points; levelScore[levelIndex()].state = LevelScore.ScoreDisplay.SPARE_WAITING_THIRD; actualPhase = LevelPhase.THIRD_SHOT; } else { levelScore[levelIndex()].secondScore = points; levelScore[levelIndex()].state = LevelScore.ScoreDisplay.WAITING_NEXT_FIRST; actualPhase = LevelPhase.FIRST_SHOT; } } break; case LevelPhase.THIRD_SHOT: levelScore[levelIndex()].thirdScore = points; switch (levelScore[levelIndex()].state) { case LevelScore.ScoreDisplay.SPARE_WAITING_THIRD: if (points == 10) { levelScore[levelIndex()].state = LevelScore.ScoreDisplay.SPARE_STRIKE; } else { levelScore[levelIndex()].state = LevelScore.ScoreDisplay.DISPLAY_SPARE_THIRD; } break; case LevelScore.ScoreDisplay.STRIKE_WAITING_ONE: if (points == 10) { levelScore[levelIndex()].state = LevelScore.ScoreDisplay.STRIKE_SPARE; } else { levelScore[levelIndex()].state = LevelScore.ScoreDisplay.STRIKE_THIRD; } break; case LevelScore.ScoreDisplay.STRIKE_TWICE: if (points == 10) { levelScore[levelIndex()].state = LevelScore.ScoreDisplay.STRIKE_XXX; } else { levelScore[levelIndex()].state = LevelScore.ScoreDisplay.STRIKE_TWICE_THIRD; } break; } actualPhase = LevelPhase.GAME_FINISHED; break; } if (!isFirstLevel()) { computeTotalScore(levelBefore()); } computeTotalScore(); refreshTab(); handleSwiper(); }
private void Start() { Phase = LevelPhase.BuildPhase; player = GameObject.FindGameObjectWithTag("Player"); }
public void ReportCityBuilt() { CurrentLevelPhase = LevelPhase.MAIN; }
internal LevelNode(string JSON) : base(JSON) { LevelID = GetString("level_id"); Phase = GetEnum <LevelPhase>("phase"); NoReturnTime = (int)GetFloat("no_return_timer"); }
private void ChangePhase(LevelPhase levelPhase) { this.levelPhase.SetState(levelPhase); this.RpcSetPhase((byte)levelPhase); }