public override IEnumerator TakeDamage() { if (!immortal) { HealthStat.CurrentValue -= 10; GameManager.Instance.CollectedCoins--; if (!IsDead) { if (GameManager.Instance.CollectedCoins <= 0) { GameManager.Instance.CollectedCoins = 0; } MyAnimator.SetTrigger("damage"); immortal = true; StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); } } }
IEnumerator HurtBlinker(float hurtTime) { MyAnimator.SetLayerWeight(1, 1f); yield return(new WaitForSeconds(hurtTime)); MyAnimator.SetLayerWeight(1, 0f); }
public override IEnumerator TakeDamage() { if (!immortal) { healthStat.CurrentVal -= 10; if (!IsDead) { MyAnimator.SetTrigger("damage"); audio.PlayOneShot(damageSound); immortal = true; StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immmortalTime)); immortal = false; } else { GetComponent <Rigidbody2D>().velocity = Vector2.zero; GetComponent <Rigidbody2D>().gravityScale = 0; GetComponent <BoxCollider2D>().enabled = false; MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); audio.PlayOneShot(deadSound); } } }
public override IEnumerator TakeDamage() { if (!immortal) { healthStat.CurrentValue -= 10; if (!IsDead) { MyAnimator.SetTrigger("damage"); immortal = true; StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); for (int i = 0; i < all.Length; i++) { all [i].enabled = false; } } } }
public override IEnumerator TakeDamage() { if (!immortal) { healthStat.CurrentVal -= 10; gruntFx.Play(); if (!IsDead) { MyAnimator.SetTrigger("damage"); immortal = true; StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { playerDie.Play(); MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); } } }
public override IEnumerator TakeDamage() { if (!inmortal) { health.CurrentVal -= 10; if (!IsDead) { SoundManager.Instance.PlaySfx("12"); MyAnimator.SetTrigger("damage"); inmortal = true; StartCoroutine(IndicateInmortal()); yield return(new WaitForSeconds(inmortalTime)); inmortal = false; } else { SoundManager.Instance.PlaySfx("goblinLaught"); SoundManager.Instance.PlaySfx("death"); DeleteLife(); MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); MyAnimator.SetTrigger("tomb"); } } }
public override IEnumerator TakeDamage(string source) { if (!immortal) { if (source == "EnemySword") { healthStat.CurrentVal -= 20; } else if (source == "EnemyKnife") { healthStat.CurrentVal -= 20; } if (!IsDead) { MyAnimator.SetTrigger("damage"); immortal = true; StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); } } }
public override IEnumerator TakeDamage() { if (!immortal) { health.CurrentVal -= 10; if (!IsDead) { MyAnimator.SetTrigger("damage"); immortal = true; StartCoroutine(Immortality()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); turnOffCollisions(); MyAnimator.SetTrigger("die"); yield return(new WaitForSeconds(0.2f)); deathCount++; Debug.Log(deathCount); } } }
public override IEnumerator TakeDamage() { if (!immortal) { if (actState != ActState.Defence) { stat.Health.CurrentVal -= 10; if (!IsDead) { MyAnimator.SetTrigger("damage"); //immortal = true; //StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); } } else { MyAnimator.SetBool("defence", false); actState = ActState.Delayed; yield return(new WaitForSeconds(0.05f)); actState = ActState.StandBy; } } }
public void ActivateLayer(string layerName) { for (int i = 0; i < MyAnimator.layerCount; i++) { MyAnimator.SetLayerWeight(i, 0); } MyAnimator.SetLayerWeight(MyAnimator.GetLayerIndex(layerName), (1)); }
//Handles the animator layers private void HandleLayers() { if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); //Layer weight is set to 1 and Layer number 1 refers to AirLayer } else { MyAnimator.SetLayerWeight(1, 0); //0 refers to GroundLayer } }
void ChangeLayerWeight() { if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
// Switches the animation layers between ground and air. private void HandleLayers() { if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); // Sets layer to Air } else { MyAnimator.SetLayerWeight(1, 0); // sets layer to ground. } }
private void HandleLayer() { if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
private void HandleLayers() // Schimba layer-ul de animatii in cel de Airlayer daca playerul nu este pe pamant { if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
private void AnimationControl() // 공격상태에 따른 애니메이션 레이어 컨트롤러 { if (DataController.instance.gameData.P2_Attack_Shot) { MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
private void HandleLayers() { //When Otter is not on ground, Air Layer is played if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
private void HandleLayers() { if (!OnGround) { // sets the layer to one MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
// Layers private void HandleLayers() { // If not grounded then start using layer 1 = air layer if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); } else { MyAnimator.SetLayerWeight(1, 0); } }
public override void OnTriggerEnter2D(Collider2D other) { //calls the base on trigger enter base.OnTriggerEnter2D(other); //if player touches spike traps he dies instantly if (other.tag == "Spike") { healthStat.CurrentVal = 0; MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); } }
public void ActivateLayer(string layerName) { //this is a Looping structure. initially i is set to 0 (inactive). Then the loop runs while i is less than the number of layers // adding 1 to i in each loop for (int i = 0; i < MyAnimator.layerCount; i++) { //sets layer weight to 0 for every layer as the loop runs. this "resets" all the layers MyAnimator.SetLayerWeight(i, 0); } //sets the Layer Weight for the layer specified in layername to 1 (active) MyAnimator.SetLayerWeight(MyAnimator.GetLayerIndex(layerName), 1); }
private void HandleLayers() // sets the layers for the player state machine so they can change layers depending on actions { if (!OnGround) { MyAnimator.SetLayerWeight(1, 1); MyAnimator.SetLayerWeight(0, 0); } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetLayerWeight(0, 1); } }
public override IEnumerator Hit() { energy -= 10; if (!isDead) { MyAnimator.SetTrigger("hit"); } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("death"); } yield return(null); }
//Changes the weight of animator layers private void HandleLayers() { //If the player is in the air, AirLayer is the main layer if (!isGrounded) { MyAnimator.SetLayerWeight(1, 1); } //If the player is on the ground, the ground layer is the main layer else { MyAnimator.SetLayerWeight(1, 0); } }
public override IEnumerator TakeDamage() { Health -= 10; // we can change later if (!IsDead) { MyAnimator.SetTrigger("damage"); } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); Destroy(gameObject, 1); } yield return(null); }
private IEnumerator MovementLayers() { if (!OntheGround) { yield return(new WaitForSeconds(0.1f)); MyAnimator.SetLayerWeight(1, 1); } else { yield return(new WaitForSeconds(0.1f)); MyAnimator.SetLayerWeight(1, 0); } }
private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "coin") { SoundManager.Instance.PlaySfx("coin"); GameManager.Instance.collectedCoins++; Destroy(other.gameObject); } else if (other.gameObject.tag == "Cross") { starPos = transform.position; SoundManager.Instance.PlaySfx("live"); health.CurrentVal += 30; Destroy(other.gameObject); } else if (other.gameObject.tag == "Maraca") { SoundManager.Instance.PlaySfx("pick"); GameManager.Instance.collectedCollectibles++; MaracasCount++; Destroy(other.gameObject); } else if (other.gameObject.tag == "Cave") { GameManager.Instance.LoadLevel1(); } else if (other.gameObject.tag == "Key") { HasKey = true; GameManager.Instance.ShowKey(); Destroy(other.gameObject); } else if (other.gameObject.tag == "Spikes" && !diying) { SoundManager.Instance.PlaySfx("spikes"); SoundManager.Instance.PlaySfx("death"); diying = true; DeleteLife(); health.CurrentVal -= health.MaxVal; MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); MyAnimator.SetTrigger("tomb"); } else if (other.gameObject.tag == "Gate" && HasKey) { GameManager.Instance.ShowWinMenu(); } }
void FixedUpdate() { float horizontal = Input.GetAxis("Horizontal"); OnGround = IsGrounded() && !MyAnimator.GetCurrentAnimatorStateInfo(1).IsTag("JumpUp"); HandleMovement(horizontal); Flip(horizontal); //HandleAttacks (); HandleLayers(); //ResetValue (); if (IsDead) { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); Freeze = true; } }
public override IEnumerator TakeDamage(float _damage) { float result; if (stat.def.CurrentVal >= _damage) { result = 1; } else { result = _damage - stat.def.CurrentVal; } if (actState != ActState.Defence) { stat.Health.CurrentVal -= result; if (!IsDead) { MyAnimator.SetTrigger("damage"); //immortal = true; //StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); } } else { actState = ActState.Delayed; MyAnimator.SetBool("defence", false); yield return(new WaitForSeconds(result * 0.01f)); actState = ActState.StandBy; } }
public override IEnumerator TakeDamage(string currentDmgSrc) { if (!immortal) { if (currentDmgSrc == "erd") { currentReceiveDamage = GameManager.Instance.EnemyRangedDmg; source.PlayOneShot(takeDmgSound, 0.2F); } else if (currentDmgSrc == "emd") { currentReceiveDamage = GameManager.Instance.EnemyMeleeDmg; source.PlayOneShot(takeDmgSound, 0.2F); } healthStat.CurrentVal -= currentReceiveDamage; CombatTextManager.Instance.CreateText(transform.position, Convert.ToString(currentReceiveDamage), Color.white, false, 0f, true); if (!IsDead) { MyAnimator.SetTrigger("damage"); immortal = true; StartCoroutine(IndicateImmortal()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAnimator.SetLayerWeight(1, 0); MyAnimator.SetTrigger("die"); CombatTextManager.Instance.CreateAnnounceText(new Vector3(Camera.main.gameObject.transform.position.x, Camera.main.gameObject.transform.position.y + 1f, 0), "You Died x_x" + "\n Respawning...", Color.cyan, true, 5f, true); GameManager.Instance.DeathCount++; GameManager.Instance.CollectedCoins -= 10; GameManager.Instance.KillCount -= 10; } yield return(null); } }