// 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;
        }
    }
示例#2
0
 /// <summary>
 /// Check for and execute selected activation methods
 /// </summary>
 void SetActivation()
 {
     //Note: change to use InputManager once a proper control scheme is decided
     if (toggleActivate)
     {
         if (Input.GetKeyDown(KeyCode.F))
         {
             ToggleActive();
         }
     }
     else if (holdActivate)
     {
         if (Input.GetKey(KeyCode.F))
         {
             active     = true;
             sr.enabled = true;
         }
         else
         {
             active     = false;
             sr.enabled = false;
         }
     }
     else if (activateOnSkewer)
     {
         if (!inventory.ActiveSkewerEmpty())
         {
             active     = true;
             sr.enabled = true;
         }
         else
         {
             active     = false;
             sr.enabled = false;
         }
     }
     else if (chargeActivate)
     {
         if (attack.currLevel > 0)
         {
             active     = true;
             sr.enabled = true;
         }
         else
         {
             active     = false;
             sr.enabled = false;
         }
     }
 }