예제 #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (selector.SelectedSlot() == "Broom" && player.attacking)
     {
         Destroy(gameObject);
     }
 }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (selector.SelectedSlot() == "Duster" && player.attacking)
        {
            dirtyValue -= 0.1f;

            Debug.Log("hit");
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        //If key pressed and not attacking
        if (Input.GetKeyDown(KeyCode.Space) && !attacking)                           //original         if(Input.GetKeyDown(KeyCode.F) && !attacking)
        {
            attacking   = true;
            attackTimer = attackCoolDown;


            for (int i = 0; i < selector.itemsparent.childCount; i++)
            {
                if (selector.itemsparent.GetChild(i).childCount > 0 && selector.SelectedSlot() != "")
                {
                    FindObjectOfType <AudioManger>().Play("Cleaning", 0.1f);
                }
                //if (selector.SelectedSlot() == "")
            }

            attackTrigger.enabled = true;
            Debug.Log("attacking");
        }

        if (attacking)
        {
            if (attackTimer > 0)
            {
                attackTimer -= Time.deltaTime;
            }
            else
            {
                attacking             = false;
                attackTrigger.enabled = false;
            }
        }

        UseItem();

        //FindObjectOfType<AudioManger>().Play("Cleaning", 0.1f); //check
        //anim.SetBool("Use"+ selector.SelectedSlot(), attacking);
    }