// check situation by tutorial index private void Update() { if (increaseVolume) { soundTimer += Time.deltaTime; bgm.volume = 0.05f * deltaTime(soundTimer, 1f) + 0.05f; } if (GameManager.instance.isTutorial) { // tutorial for Koto Tower if (tutorialIdx == 1) { if (!kotoTowerGeneratorTruckButton.getShowKotoTower()) { timer += Time.deltaTime; } else { timer = 0; } if (timer >= 0.5f) { nextAndOpen(); timer = 0; } } // tutorial for generator if (tutorialIdx == 3) { if (!kotoTowerGeneratorTruckButton.getShowGenerator()) { timer += Time.deltaTime; } else { timer = 0; } if (timer >= 0.5f) { nextAndOpen(); timer = 0; } } // tutorial for char charge if (tutorialIdx == 5) { if (QuestionManager.isSendingTruck) { timer += Time.deltaTime; } if (timer >= 1f) { nextAndOpen(); timer = 0; } } // tutorial for path selection if (tutorialIdx == 7) { if (truck.getTruckStatus() == TruckStatus.WAITING) { nextAndOpen(); } } // tutorial for answer the right one if (tutorialIdx == 9) { if (GameManager.instance.totalAnsweredQuestion == 1) { timer += Time.deltaTime; } if (timer >= 0.3f) { nextAndOpen(); timer = 0; } } // tutorial for char charge power if (tutorialIdx == 11) { if (QuestionManager.isSendingTruck) { timer += Time.deltaTime; } if (timer >= 0.3f) { nextAndOpen(); timer = 0; } } // tutorial for char Tower if (tutorialIdx == 13) { if (GameManager.instance.totalAnsweredQuestion == 2) { timer += Time.deltaTime; } if (timer >= 0.2f) { nextAndOpen(); timer = 0; } } // tutorial for enemy and Koto Tower if (tutorialIdx == 15) { answer.SetActive(false); question.SetActive(false); // show this tutorial when in building mode tutorialList[tutorialIdx].activateGameObject[0].SetActive(false); tutorialList[tutorialIdx].activateGameObject[1].SetActive(false); tutorialList[tutorialIdx].activateGameObject[2].SetActive(true); // check if the player has spawned 2 towers if (tower.childCount > 1 && !forTutor) { TowerBehaviour towerBehaveOne = tower.GetChild(0).GetComponent <TowerBehaviour>(); TowerBehaviour towerBehaveTwo = tower.GetChild(1).GetComponent <TowerBehaviour>(); if (towerBehaveOne.getIsActive() && towerBehaveTwo.getIsActive()) { forTutor = true; } } if (GameManager.instance.isSelectTower) { tutorialList[tutorialIdx].activateGameObject[0].SetActive(true); tutorialList[tutorialIdx].activateGameObject[1].SetActive(true); tutorialList[tutorialIdx].activateGameObject[2].SetActive(false); } if (forTutor) { timer += Time.deltaTime; } if (timer >= 1f) { nextAndOpen(); answer.SetActive(true); question.SetActive(true); forTutor = false; timer = 0; } } // tutorial for enemy if (tutorialIdx == 17) { if (GameManager.instance.totalAnsweredQuestion == 3) { timer += Time.deltaTime; } if (timer >= 0.3f) { nextAndOpen(); timer = 0; } } // tutorial for trap if (tutorialIdx == 19) { if (changeMoney) { GameManager.instance.money += 100f; GameManager.instance.moneyChanged = true; changeMoney = false; } answer.SetActive(false); question.SetActive(false); tutorialList[tutorialIdx].activateGameObject[2].SetActive(false); tutorialList[tutorialIdx].activateGameObject[3].SetActive(false); tutorialList[tutorialIdx].activateGameObject[4].SetActive(true); // check if the player has spawned a trap if (trap.childCount > 0 && !forTutor) { TrapsBehaviour trapBehave = trap.GetChild(0).GetComponent <TrapsBehaviour>(); if (trapBehave.getIsActive()) { forTutor = true; } } if (forTutor) { timer += Time.deltaTime; } if (GameManager.instance.isSelectTrap) { tutorialList[tutorialIdx].activateGameObject[2].SetActive(true); tutorialList[tutorialIdx].activateGameObject[3].SetActive(true); tutorialList[tutorialIdx].activateGameObject[4].SetActive(false); } if (timer >= 4f) { nextAndOpen(); answer.SetActive(true); question.SetActive(true); forTutor = false; timer = 0; } } // tutorial for end tutorial if (tutorialIdx == 21) { timer += Time.deltaTime; if (timer > 4f) { nextAndWait(); } } } }
// move UI behave void behaveOnTruckStatus() { if (rect.rect.height != rectHeight && !isJustText) { rectHeight = rect.rect.height; } // if now tower or trap is selected, or there is a selected tower make the UI goes up if (GameManager.instance.isSelectTower || GameManager.instance.isSelectTrap || GameManager.instance.currentStatus == GameStatus.SELECTING_TOWER || GameManager.instance.isPaused || truck.getTruckStatus() != TruckStatus.WAITING) { currentValue = Mathf.Clamp(currentValue + (rectHeight / 10), 0f, rectHeight); } else { currentValue = anchoredPos; } rect.anchoredPosition = new Vector3(rect.anchoredPosition.x, currentValue, 0f); }