Exemple #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";
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (((PlayerController)controller).riding)
        {
            return;
        }

        if (Attacking && (InputManager.GetButtonDown(Control.Knife, InputAxis.Slash) || InputManager.GetButtonDown(Control.Skewer, InputAxis.Skewer)))
        {
            StopAllCoroutines();
            r.color       = Color.white;
            currLevel     = 0;
            inv.CanSwap   = true;
            chargedAttack = false;
            Attacking     = false;
            CanBeCanceled = false;
            return;
        }
        //conditions to throw: Must either have ingredients OR a cooked recipe
        if (!Attacking && InputManager.GetButtonDown(control, axis) && (!inv.ActiveSkewerEmpty() || inv.ActiveSkewerCooked()))
        {
            chargedAttack = true;
            center        = r.bounds.center;

            //Get the first attack from dependecies that is attacking, else null
            AttackBase activeAttack = dependecies.FirstOrDefault((at) => at.Attacking);
            if (activeAttack == null)
            {
                StartCoroutine(Charge());
            }
            else if (activeAttack.CanBeCanceled)
            {
                activeAttack.Cancel();
                StartCoroutine(Charge());
            }
        }
        if (InputManager.GetButtonUp(control, axis) && Attacking)
        {
            StopAllCoroutines();
            effectRecipeData      = inv.GetActiveEffect();
            flavorCountDictionary = new Dictionary <RecipeData.Flavors, int>(inv.GetActiveFlavorDictionary());
            ingredientArray       = inv.GetActiveSkewer().ToArray();

            r.color   = Color.white;
            currLevel = 0;
            Attack();
            inv.ClearActiveRecipe();
            inv.ClearActiveSkewer();
            inv.CanSwap   = true;
            Attacking     = false;
            chargedAttack = false;
        }
    }