// --------------------------------- Display interface methods ------------------------------- public void DisplayCountDown(bool active, float time) { if (active && time >= nextTime) { nextTime++; audioController.PlaySound("count_down"); countDownLabel.text = (int)Mathf.Abs(time) + ""; if (time >= -1) { countDownLabel.text = "Start"; } } countDownLabel.gameObject.SetActive(active); }
// ------------------------------------ Input interface methods ------------------------------------- public void OnUserFinish() { if (hasOffsetAdjusted && !isPauseGen && lastBeat != 0) { if (spaceLeft > 0) { string result = CalculateResult(songPos); Color color = GetResultColor(result); float multiplier = GetResultMultiplier(result); int damage = Mathf.FloorToInt(multiplier * comboStack * pointPerCombo); stackDamage += damage; player.PlayerAttack(); //player attack audioController.PlaySound("space_click"); canvasOutputReceiver.DisplayPlayerAttack(result, color, comboStack, damage); comboStack = 0; ResetStackList(listStackNote); ResetCurrentNoteList(listCurrentNote); isPauseGen = true; canvasOutputReceiver.SpaceResult(color); spaceLeft--; if (spaceLeft == 0) { canvasOutputReceiver.DisplayRunningOut(); isComplete = true; isPauseGen = true; StartCoroutine(DelayLose(2f)); } canvasOutputReceiver.DisplaySpaceLeft(false, spaceLeft); } } }
public void TakeDamage(int damage) { if (damage != 0) { CurrentHP -= damage; Sprite CharacterSprite = null; if (CurrentHP <= MaxHP * 0.6f) { animator.SetInteger("State", 1); CharacterSprite = HalfImage; } if (CurrentHP <= MaxHP * 0.2f) { animator.SetInteger("State", 2); CharacterSprite = FinishImage; } StartCoroutine(PlayHurtAnimation(CharacterSprite)); if (hurtSound.Length != 0) { audioController.PlaySound(hurtSound.RandomItem()); } if (CurrentHP <= 0) { CurrentHP = 0; if (gameObject.GetComponent <Enemy>() != null) { //enemy StartCoroutine(menuController.DisplayWinPanel()); } else { //player StartCoroutine(menuController.DisplayLosePanel(gameController.GetCurrentDealedDamage(), otherCharacter.GetCurrentHP())); } audioController.StopMainTheme(); } GameObject effect = null; if (gameObject.GetComponent <Enemy>() != null) { canvasOutput.ShowEnemyHealth(CurrentHP / MaxHP); effect = gameController.GetPlayerAttackEffect(damage); var newEffect = Instantiate(effect, Vector3.zero, Quaternion.identity, gameObject.transform); newEffect.transform.localPosition = Vector3.zero; gameObject.GetComponent <Enemy>().ResetManaBar(); } if (gameObject.GetComponent <Player>() != null) { canvasOutput.ShowPlayerHealth(CurrentHP / MaxHP); effect = gameController.GetEnemyAttackEffect(); var newEffect = Instantiate(effect, Vector3.zero, Quaternion.identity, gameObject.transform); newEffect.transform.localPosition = new Vector3(0, -40, 0); } } else { gameController.SetDelayGenerator(false); } }