public override void Death() { MyRigi.velocity = Vector2.zero; MyAni.SetTrigger("Revive"); hp.CurrVal = hp.MaxVal; transform.position = startPos; }
private void HandleInput() { if (Vertical == 0) { if (Input.GetButtonDown("Punch") && mp.CurrVal > 0) { MyAni.SetTrigger("Attack"); mp.CurrVal -= 5; } if (Input.GetButtonDown("Dodge")) { MyAni.SetTrigger("Roll"); } if (Input.GetButtonDown("Jump") && !IsFalling) { MyAni.SetTrigger("Jump"); Jump = true; } if (Input.GetButtonDown("Throw") && mp.CurrVal > 0) { MyAni.SetTrigger("Throw"); mp.CurrVal -= 10; } } }
public override void Death() { dropItem = true; MyAni.ResetTrigger("Die"); MyAni.SetTrigger("Idle"); hp.CurrVal = hp.MaxVal; transform.position = startPos; }
private void HandleLayers() { if (!OnGround) { MyAni.SetLayerWeight(1, 1); } else { MyAni.SetLayerWeight(1, 0); } }
public override IEnumerator TakeDamage() { hp.CurrVal -= 10; if (!IsDead) { MyAni.SetTrigger("Damage"); } else { if (dropItem) { GameObject coin = (GameObject)Instantiate(GameManager.Instance.CoinPrefab, new Vector3(transform.position.x, transform.position.y), Quaternion.identity); Physics2D.IgnoreCollision(coin.GetComponent <Collider2D> (), GetComponent <Collider2D> ()); dropItem = false; } MyAni.SetTrigger("Die"); yield return(null); } }
public void Move() { if (!Attack) { if ((GetDirection().x > 0 && transform.position.x < rightEdge.position.x) || (GetDirection().x < 0 && transform.position.x > leftEdge.position.x)) { MyAni.SetFloat("Speed", 1); transform.Translate(GetDirection() * (speed * Time.deltaTime)); } else if (currState is PatrolState) { ChangeDirection(); } else if (currState is RangedState) { Target = null; ChangeState(new IdleState()); } } }
public override IEnumerator TakeDamage() { if (!immortal) { hp.CurrVal -= 10; if (!IsDead) { MyAni.SetTrigger("Damage"); immortal = true; StartCoroutine(IndicateImmortalDamage()); yield return(new WaitForSeconds(immortalTime)); immortal = false; } else { MyAni.SetLayerWeight(1, 0); MyAni.SetTrigger("Die"); } } }
private void HandleMovement(float horiz, float verti) { //Falling from the sky if (IsFalling) { gameObject.layer = 10; MyAni.SetBool("Land", true); } //Dodge on the ground if (!Attack && !Roll && (OnGround || airControl) && verti == 0) { dodgeSpeed = 100; MyRigi.velocity = new Vector2(horiz * speed, MyRigi.velocity.y); } //Dodge in the sky if (Jump && MyRigi.velocity.y == 0) { dodgeSpeed = .0005f; MyRigi.AddForce(new Vector2(0, jumpForce)); } if (verti > 0 && OnGround) { MyAni.SetBool("LookUp", true); } else if (verti < 0 && OnGround) { MyAni.SetBool("LookDown", true); } else { MyAni.SetBool("LookUp", false); MyAni.SetFloat("Speed", Mathf.Abs(horiz)); MyAni.SetBool("LookDown", false); } }