// Start is called before the first frame update void Start() { this.enemyRunesManager = GameObject.Find("Enemy Runes").GetComponent <EnemyRunesManager>(); transform.localScale = new Vector3(0, 0, 1); Enemy.OnDeath += () => { Destroy(this.gameObject); }; Enemy.OnAttack += (target) => { float intensity = 1; var startPosition = transform.position; var targetPosition = new Vector3(target.Coordinates.x, target.Coordinates.y, startPosition.z); /// attack animation attackAnimation = StartCoroutine(AnimUtils.Animate(0.5f, (t) => { float lerp = Mathf.Pow(Mathf.Cos(Mathf.PI / 2 + Mathf.PI * Mathf.Sqrt(t)), 4) * intensity; transform.position = Vector3.Lerp(startPosition, targetPosition, lerp); if (t == 1) { attackAnimation = null; } })); }; Enemy.OnHeal += (int heal) => { AnimUtils.AddDamageOrHealNumber(heal, transform.position, false); }; Enemy.OnHit += (int damage) => { AnimUtils.AddDamageOrHealNumber(damage, transform.position, true); }; Enemy.OnRuneTriggered += (message) => AnimUtils.ShowFloatingText(message, transform.position); }
IEnumerator ChangeFloors(int newDepth) { PlayerManager.inputEnabled = false; // let player movement animation finish // yield return new WaitForSeconds(0.25f); // disable player input var pManager = GameObject.Find("Player").GetComponent <PlayerManager>(); // pManager.enabled = false; // shrink player var initialScale = pManager.transform.localScale; yield return(AnimUtils.Animate(0.5f, (t) => { var s = 1 - t; var newScale = new Vector3(s, s, 1); newScale.Scale(initialScale); pManager.transform.localScale = newScale; })); yield return(new WaitForSeconds(0.5f)); bool runePieceAcquired = false; if (newDepth % 4 == 1) { var trigger = RuneGenerator.randomTrigger(player.shards); player.AddRuneShard(trigger); runePieceAcquired = true; } else if (newDepth % 4 == 3) { var action = RuneGenerator.randomAction(player.shards); player.AddRuneShard(action); runePieceAcquired = true; } depthPanel.GetComponentInChildren <TMPro.TMP_Text>().text = "Depth " + newDepth; depthPanel.transform.Find("RunePieceAcquired").gameObject.SetActive(runePieceAcquired); depthPanel.SetActive(true); yield return(null); Destroy(currentGrid); NewGrid(newDepth); yield return(new WaitForSeconds(2)); depthPanel.SetActive(false); yield return(AnimUtils.Animate(0.5f, (t) => { var newScale = new Vector3(t, t, 1); newScale.Scale(initialScale); pManager.transform.localScale = newScale; })); PlayerManager.inputEnabled = true; // pManager.enabled = true; }
IEnumerator Pulse() { yield return(AnimUtils.Animate(0.5f, (t) => { var scale = 1 + Mathf.Sin(t * Mathf.PI) * 1.0f; transform.localScale = new Vector3(scale, scale, 1); })); transform.localScale = new Vector3(1, 1, 1); pulse = null; }
IEnumerator DoIntro() { yield return(AnimUtils.Animate(1f, t => { var s = 100 - 99 * t; text.rectTransform.localScale = new Vector3(s, s, 1); })); yield return(new WaitForSeconds(2)); yield return(AnimUtils.Animate(2, t => { var s = 1 - t; text.rectTransform.localScale = new Vector3(s, s, 1); this.GetComponent <Image>().color = new Color(0, 0, 0, s); })); Destroy(this.gameObject); }
IEnumerator GameOverScreen() { GameOverContainer.SetActive(true); GameOverText.gameObject.SetActive(false); var replay = GameOverContainer.transform.Find("Replay").gameObject; var backToMain = GameOverContainer.transform.Find("Back to Main").gameObject; replay.SetActive(false); backToMain.SetActive(false); yield return(AnimUtils.Animate(1f, (t) => { GameOverContainer.GetComponent <Image>().color = new Color(0, 0, 0, t * 0.9f); })); yield return(new WaitForSeconds(0.25f)); if (player.newHighscoreReached == null) { // hasn't been computed yet; compute it for the first time, and store it player.newHighscoreReached = player.score > Player.HIGHSCORE; Player.HIGHSCORE = player.score; } GameOverText.text = $"<b><color=red>You succumb to insanity...</color></b>\nScore: {player.score}\nHigh Score: {Player.HIGHSCORE}"; if (player.newHighscoreReached == true) { GameOverText.text += $"\nNew high score!"; } GameOverText.gameObject.SetActive(true); yield return(AnimUtils.Animate(1, (t) => { GameOverText.color = new Color(1, 1, 1, t); })); yield return(new WaitForSeconds(0.25f)); replay.SetActive(true); yield return(new WaitForSeconds(0.25f)); backToMain.SetActive(true); }