コード例 #1
0
    // PICK UP OBJECTS
    private void OnTriggerStay2D(Collider2D collision)
    {
        // PICK UP USABLE
        if (collision.gameObject.tag == "Usable")
        {
            int id = -1;
            for (int i = 0; i < ItemsManager.Instance.UsablesList.Capacity; i++)
            {
                if (collision.gameObject.GetComponent <Usable>().itemName == ItemsManager.Instance.UsablesList[i].itemName)
                {
                    id = i;
                    break;
                }
            }
            PlayerManager.Instance.addUsableById(id, 1);
            SoundManager.Instance.PlaySound(SoundManager.Sounds.ItemPickup);
            Destroy(collision.gameObject);
        }
        // PICK UP KEY
        if (collision.gameObject.tag == "Key_Object")
        {
            PlayerManager.Instance.keys++;
            SoundManager.Instance.PlaySound(SoundManager.Sounds.KeyPickup);
            Destroy(collision.gameObject);
        }
        // PICK UP SOUL
        if (collision.gameObject.tag == "Soul" && PickSoul == true)
        {
            // INSTANTIATE PARTICLES
            Instantiate(soulParticles, collision.transform.position, collision.transform.rotation);

            PlaySoulPickup();
            Destroy(collision.gameObject);
            PlayerManager.Instance.addSouls(1);
        }

        //USE PRIORITY SETTING
        if (collision.gameObject.tag == "SoulsExchange" || collision.gameObject.tag == "UsablesShop" || collision.gameObject.tag == "WeaponsShop" || collision.gameObject.tag == "Person")
        {
            PlayerManager.Instance.usePriority = true;
        }

        // SOULS EXCHANGE
        if (collision.gameObject.tag == "SoulsExchange" && Input.GetKey(KeyCode.E) && PlayerManager.Instance.usePriority == true)
        {
            feetAnimator.SetBool(walkingParamID, false);
            animator.SetBool(walkingParamID, false);
            InteractionManager.Instance.SoulsShop(collision.gameObject);
            //InteractionManager.Instance.SoulsExchange(PlayerManager.Instance.souls);
        }

        // USABLES SHOP
        if (collision.gameObject.tag == "UsablesShop" && Input.GetKey(KeyCode.E) && PlayerManager.Instance.usePriority == true)
        {
            feetAnimator.SetBool(walkingParamID, false);
            animator.SetBool(walkingParamID, false);
            InteractionManager.Instance.UsablesShop(collision.gameObject);
        }

        // WEAPONS SHOP
        if (collision.gameObject.tag == "WeaponsShop" && Input.GetKey(KeyCode.E) && PlayerManager.Instance.usePriority == true)
        {
            feetAnimator.SetBool(walkingParamID, false);
            animator.SetBool(walkingParamID, false);
            InteractionManager.Instance.WeaponsShop(collision.gameObject);
        }

        // PERSON
        if (collision.gameObject.tag == "Person" && Input.GetKey(KeyCode.E) && PlayerManager.Instance.usePriority == true)
        {
            feetAnimator.SetBool(walkingParamID, false);
            animator.SetBool(walkingParamID, false);
            dialoguescript = collision.gameObject.GetComponent <DialogueScript>();
            dialoguescript.playDialogue();
        }

        if (collision.gameObject.tag == "Inside")
        {
            EnviromentManager.Instance.openRoof();
            insideHouse = true;
        }
    }