Пример #1
0
    private void AnimationHandler(HitParams hp)
    {
        if (currentHitStun >= MaxHitStun)
        {
            hp.heavyHit    = true;
            currentHitStun = 0;
        }

        var hitDirection = transform.position.x > hp.AtkPositionX;

        AudioGetHit.Play();
        if (currentLife <= 0)
        {
            AudioDeath.Play();
            animator.SetBool("Death", true);
            DownAnimation(hitDirection);
        }
        else
        {
            if (hp.heavyHit || state == States.jumping)
            {
                DownAnimation(hitDirection);
            }
            else
            {
                state = States.hit;
                animator.SetTrigger("GetHit");
                spriteRenderer.flipX = hitDirection;
            }
        }
    }
Пример #2
0
 protected virtual void GetHit(HitParams hp)
 {
     Debug.Log($"{name}  {currentLife} {currentHitStun}");
     if (state != States.down)
     {
         if (hp.special ||
             (hp.SpriteLayer + layerRange >= spriteRenderer.sortingOrder &&
              hp.SpriteLayer - layerRange <= spriteRenderer.sortingOrder))
         {
             currentLife    -= hp.Damage;
             currentHitStun += hp.hitStun;
             AnimationHandler(hp);
         }
     }
 }
Пример #3
0
    public void StartAttack(string attackName)
    {
        HitParams hp = new HitParams(spriteRenderer.sortingOrder, 5, transform.position.x, 1, false, false);

        switch (attackName)
        {
        case "blaze_atk_04":
            hp.heavyHit = true;
            break;

        default:
            break;
        }

        Attack(hp);
    }
Пример #4
0
    protected IEnumerator Attack()
    {
        var stateInfo = animator.GetCurrentAnimatorStateInfo(0);

        state = States.attaking;
        yield return(new WaitForSeconds(0.1f));

        Vector2 punchPosition = spriteRenderer.flipX ? leftPunch.position : rightPunch.position;

        var hit = Physics2D.CircleCast(punchPosition, punchRadius, Vector2.up);

        if (hit.collider != null && hit.collider.CompareTag("Player"))
        {
            var hitParans = new HitParams(spriteRenderer.sortingOrder, 4, transform.position.x, 20, false, false);
            hit.collider.SendMessage("GetHit", hitParans);
        }
    }
Пример #5
0
    protected void Attack(HitParams hp)
    {
        /// HitParams hp = new HitParams(sl, dmg, at, hh);
        Vector2 punchPosition = activePunch.position;

        var hitList = Physics2D.CircleCastAll(punchPosition, punchRadius, Vector2.up);

        if (animator.GetBool("Jumping"))
        {
            AudioJumpAttack.Play();
            hp.heavyHit = true;
        }

        foreach (var hit in hitList)
        {
            if (hit.collider != null && hit.collider.CompareTag("Enemy"))
            {
                hit.collider.SendMessage("GetHit", hp);
            }
        }
    }
Пример #6
0
    void Update()
    {
        Vector3 movimento = new Vector3(10f, 0, 0.0f);

        this.transform.position = transform.position + movimento * Time.deltaTime;
        HitParams hp = new HitParams(spriteRenderer.sortingOrder, 10, transform.position.x, 0, true, true);

        var hitbox = Physics2D.BoxCastAll(new Vector2(transform.position.x + 1.3f, transform.position.y), size, 0, Vector2.up);

        foreach (var hit in hitbox)
        {
            if (hit.collider != null && hit.collider.CompareTag("Enemy"))
            {
                hit.collider.SendMessage("GetHit", hp);
            }
        }
        LayerControl();
        if (transform.position.x >= limitToDestroy)
        {
            playerScript.specialActive = false;
            Destroy(gameObject);
        }
    }