Esempio n. 1
0
    public override void OnTriggerEnter2D(Collider2D collision)
    {
        sfxPlayer = GetComponent <PlaySFX>();

        // skewer roots
        if (collision.gameObject.tag == "ThrowThrough")
        {
            var environment = collision.gameObject.GetComponent <DestructableEnvironment>();
            if (environment != null)
            {
                if (environment.skewerable)
                {
                    environment.health -= 1;
                    environment.Destroy();
                }
            }
        }

        // pickup  drops
        if (collision.gameObject.tag == "SkewerableObject")
        {
            if (!inventory.ActiveSkewerFull() && !inventory.ActiveSkewerCooked())
            {
                //Debug.Log("Hit skewerable object");
                SkewerableObject targetObject = collision.gameObject.GetComponent <SkewerableObject>();

                sfxPlayer.Play(pickUpSFX);

                inventory.AddToSkewer(targetObject.data);
                MGSTextSpawner.instance?.SpawnText(targetObject.data, transform.position);
                Destroy(collision.gameObject);
            }
            else
            {
                sfxPlayer.Play(cantPickUpSFX);
            }
        }

        //do knockback effects
        if (collision.gameObject.tag == "Predator" || collision.gameObject.tag == "Prey")
        {
            DoKnockBack(collision.gameObject.GetComponent <Rigidbody2D>(), bunceForce);
        }
    }
 /// <summary>
 /// Update the text prompt to display the current skewer action
 /// </summary>
 private void UpdateSkewerPrompt()
 {
     conTextPrompt.text = "";
     if (skewerInventory.GetActiveSkewer().GetCount() > 0)
     {
         conTextPrompt.text = "[C] : COOK";
     }
     if (skewerInventory.ActiveSkewerCooked())
     {
         conTextPrompt.text = "[SPACE] : THROW";
         cookedText.text    = "!SKEWER COOKED!";
     }
     else
     {
         cookedText.text = "";
         if (skewerInventory.ActiveSkewerFull())
         {
             cookedText.text = "FULL CAPACITY";
         }
     }
 }