public void SelectCard(Card card) { if (null == selectedCard) { selectedCard = card; return; } eventSystem.enabled = false; StartCoroutine(ActionAfterDelay.DoAfterDelay(0.5f, () => { CompareCards(card); })); }
public void AffectPlayer(string potionType) //changes the characters attributes with potion drinking and shows UI specific to each potion { switch (potionType) //determine potion type { // Health increments by 20 case "HealthPotion": FindObjectOfType <HealthManager>().IncrementCurrentHealth(20); HealthDrank.SetActive(true); Animation.SetActive(true); //play animation while drinking the potion ActionAfterDelay.Create(2.0f, () => { //UI and animation last 2 after the potion drinking is called HealthDrank.SetActive(false); Animation.SetActive(false); }); break; // Increases stength by 20 case "StrengthPotion": FindObjectOfType <EnemyHit>().IncrementStrength(10); StrengthDrank.SetActive(true); Animation.SetActive(true); //play animation while drinking the potion ActionAfterDelay.Create(2.0f, () => { //UI and animation last 2 after the potion drinking is called StrengthDrank.SetActive(false); Animation.SetActive(false); }); break; // Increases speed by 2 case "SpeedPotion": FindObjectOfType <ThirdPersonMovement>().IncrementSpeed(2); SpeedDrank.SetActive(true); Animation.SetActive(true); //play animation while drinking the potion ActionAfterDelay.Create(2.0f, () => { //UI and animation last 2 after the potion drinking is called SpeedDrank.SetActive(false); Animation.SetActive(false); }); break; case "QuickRevive": //extra life if the player dies FindObjectOfType <HealthManager>().quickRevive = true; QuickReviveDrank.SetActive(true); Animation.SetActive(true); //play animation while drinking the potion ActionAfterDelay.Create(2.0f, () => { //UI and animation last 2 after the potion drinking is called QuickReviveDrank.SetActive(false); Animation.SetActive(true); }); break; } }
// Method to take damage public void TakeDamage(float damage) { // Takeaway provided damage, update UI _currentHealth -= damage; UpdateHealthBar(); // If the health of the player reaches below 0, it is respawned to the beginning of the day sequence (game restart) if (_currentHealth <= 0) { _anim.SetBool("Dead", true); foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy")) { Destroy(enemy); } SpawnEnemy._spawnEnabled = false; _currentHealth = _startingHealth; ActionAfterDelay.Create(3.0f, () => { DeathCanvas.SetActive(true); Screen.lockCursor = false; }); ActionAfterDelay.Create(8.0f, () => { Screen.lockCursor = true; DeathCanvas.SetActive(false); // An alternate scenario occurs if the player drank a quick revive potion prior to dying if (quickRevive) { _anim.SetBool("Revive", true); QuickReviveUsed.SetActive(true); ActionAfterDelay.Create(3.0f, () => { _anim.SetBool("Revive", false); QuickReviveUsed.SetActive(false); }); SpawnEnemy._spawnEnabled = true; } else { // If player has not consumed a quick revive potion, then game restarts to initital settings _gameController.GetComponent <ManageLevels>().BackToStart(); ScoreCounter._score = 0; } _anim.SetBool("Dead", false); }); } }