コード例 #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Enemy"))
     {
         other.gameObject.GetComponent <Enmity>().HitByPlayer();
         ds.damageSword(ds.damagePerHit);
     }
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (!defending && (Input.GetKeyDown(KeyCode.X) || Input.GetButtonDown("Hero B")) && itemDurability.canUseShield() && !attacking)
        {
            defending = true;
            // Durability stuff here
            StartCoroutine(BraceShield());
            if (ct.hasSword)
            {
                playerAnimator.Play("HeroGuardSword");
            }
            else
            {
                playerAnimator.Play("HeroGuard");
            }
            //print("Blocking");
        }
        else if (Input.GetKeyUp(KeyCode.X) || Input.GetButtonUp("Hero B"))
        {
            defending = false;
            if (ct.hasSword)
            {
                if (ct.hasShield)
                {
                    playerAnimator.Play("HeroIdleSwsh");
                }
                else
                {
                    playerAnimator.Play("HeroIdleSword");
                }
            }
            else
            {
                if (ct.hasShield)
                {
                    playerAnimator.Play("HeroIdleShield");
                }
                else
                {
                    playerAnimator.Play("HeroIdle");
                }
            }
            StartCoroutine(LowerShield());
        }

        else if ((Input.GetKeyDown(KeyCode.Z) || Input.GetButtonDown("Hero A")) && itemDurability.canUseSword() && !attacking)
        {
            attacking = true;
            itemDurability.damageSword(itemDurability.damagePerSwing);
            StartCoroutine(SwordAttack());
        }
    }