void Swipe(string direction) { if (animationManager.heroAnimator.GetCurrentAnimatorStateInfo(0).IsName("IdleHero")) { switch (direction) { case "right": dodgeCommand = PeikkoState.RIGHT; animationManager.PlayAnimation(AnimatorScript.HeroAnimation.DODGE_RIGHT); audioManager.PlaySound(AudioManagerScript.SoundClip.HERO_SWIPE); break; case "left": dodgeCommand = PeikkoState.LEFT; animationManager.PlayAnimation(AnimatorScript.HeroAnimation.DODGE_LEFT); audioManager.PlaySound(AudioManagerScript.SoundClip.HERO_SWIPE); break; case "Attack": dodgeCommand = PeikkoState.ATTACK; animationManager.PlayAnimation(AnimatorScript.HeroAnimation.ATTACK); audioManager.PlaySound(AudioManagerScript.SoundClip.HERO_SWIPE); break; } StartCoroutine("SetHeroDefault"); } }
void ChangePeikkoState() { peikkoActionCount++; if (peikkoActionCount.Equals(5)) { peikkoActionCount = 0; PlayAnimation(AnimatorScript.BossAnimation.VULNERABLE); peikkoState = PeikkoState.VULNERABLE; Color color = attackButton.color; color.a = 1; attackButton.color = color; attackButton.transform.GetComponent <Button>().interactable = true; return; } switch (Random.Range(0, 3)) { case 0: PlayAnimation(AnimatorScript.BossAnimation.ATTACK); peikkoState = PeikkoState.ATTACK; break; case 1: PlayAnimation(AnimatorScript.BossAnimation.HIT_LEFT); peikkoState = PeikkoState.LEFT; break; case 2: PlayAnimation(AnimatorScript.BossAnimation.HIT_RIGHT); peikkoState = PeikkoState.RIGHT; break; } }
void Update() { if (state == PeikkoState.Moving && enemyHealth.playDeathAnim == false) { transform.position = transform.position + new Vector3(moveDirection, 0, 0) * speed * Time.deltaTime; animator.SetBool("Running", true); } else { if (PlayerDetect()) { //Debug.Log("or"); animator.SetTrigger("Hyppy"); //StartCoroutine("BushJump"); } } if (enemyHealth.playDeathAnim == true) { state = PeikkoState.Hiding; AudioSrc.Play(); Destroy(this.GetComponent <CapsuleCollider2D>()); Destroy(this.GetComponent <Rigidbody2D>()); Destroy(this.gameObject, 0.2f); animator.SetTrigger("Death"); } }
public IEnumerator BushJump() { state = PeikkoState.Moving; activePeikko = true; prb.AddForce(new Vector2(0, 150), ForceMode2D.Impulse); //activePeikko = true; yield return(new WaitForSeconds(0.1f)); spriteRenderer.sortingOrder = bushSpriteRenderer.sortingOrder + 1; yield return(new WaitForSeconds(1f)); }
private void Start() { peikkoDamage = 0; audioManager = GetComponent <AudioManagerScript>(); animationManager = GetComponent <AnimatorScript>(); music = Camera.main.GetComponent <AudioSource>(); instance = this; peikkoState = PeikkoState.DEFAULT; dodgeCommand = PeikkoState.DEFAULT; peikkoActionCount = 0; Color color = attackButton.color; color.a = 0; attackButton.color = color; attackButton.transform.GetComponent <Button>().interactable = false; }
void ResolveCommand() { if (peikkoActionCount.Equals(0)) { Color color = attackButton.color; color.a = 0; attackButton.color = color; attackButton.transform.GetComponent <Button>().interactable = false; } switch (peikkoState) { case PeikkoState.ATTACK: audioManager.PlaySound(AudioManagerScript.SoundClip.PEIKKO_SMASH); if (!dodgeCommand.Equals(PeikkoState.LEFT) && !dodgeCommand.Equals(PeikkoState.RIGHT)) { TakeDamage(); } return; case PeikkoState.RIGHT: audioManager.PlaySound(AudioManagerScript.SoundClip.PEIKKO_SWING); if (!dodgeCommand.Equals(PeikkoState.RIGHT)) { TakeDamage(); } return; case PeikkoState.LEFT: audioManager.PlaySound(AudioManagerScript.SoundClip.PEIKKO_SWING); if (!dodgeCommand.Equals(PeikkoState.LEFT)) { TakeDamage(); } return; case PeikkoState.VULNERABLE: if (dodgeCommand.Equals(PeikkoState.ATTACK)) { DoDamage(); } return; } peikkoState = PeikkoState.DEFAULT; }
private void Start() { prb = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponentInChildren <SpriteRenderer>(); animator = GetComponentInChildren <Animator>(); enemyHealth = GetComponent <EnemyHealth>(); AudioSrc = GetComponent <AudioSource>(); if (useBush == true) { activePeikko = false; state = PeikkoState.Hiding; } else { activePeikko = true; FlipEnemy(); state = PeikkoState.Moving; } }
IEnumerator SetHeroDefault() { yield return(new WaitForSeconds(waitTime)); dodgeCommand = PeikkoState.DEFAULT; }