示例#1
0
    protected override IEnumerator CheckInputs()
    {
        for (; ;)
        {
            foreach (string key in keys)
            {
                if (Input.GetButtonDown(key))
                {
                    OnPressed.Invoke();
                    isUsed    = false;
                    isPressed = true;
                    if (duration > 0)
                    {
                        StartTimer();
                    }
                }

                if (Input.GetButtonUp(key))
                {
                    isPressed = false;
                    OnReleased.Invoke();
                    if (duration == 0)
                    {
                        OnUse.Invoke();
                    }
                    StopTimer();
                }
            }
            yield return(base.CheckInputs());
        }
    }
 public PluginCommand(string id, string text, OnUse use, OnCheckConditions checkConditions = null)
 {
     ID              = id;
     Text            = text;
     CheckConditions = checkConditions;
     Use             = use;
 }
示例#3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (!isEnabled)
     {
         return;
     }
     OnUse?.Invoke(type);
 }
示例#4
0
 public void Use()
 {
     if (WasUsedThisTurn)
     {
         throw new UpgradeWasAlreadyUsedThisTurnException();
     }
     OnUse?.Invoke(this, new StartAttackEventArgs(Animal));
     WasUsedThisTurn = true;
 }
示例#5
0
        public virtual void Use()
        {
            if (currentObject == null)
            {
                return;
            }

            OnUse.Invoke(currentObject.gameObject);
            currentObject.Use(this);
        }
示例#6
0
        public bool UseItem(ItemType item)
        {
            if (!inventory.TryGetValue(item, out int count) || count == 0)
            {
                return(false);
            }

            inventory[item] = count - 1;
            OnUse?.Invoke(this, item);
            return(true);
        }
示例#7
0
 protected override IEnumerator CheckInputs()
 {
     for (; ;)
     {
         foreach (string key in keys)
         {
             if (Input.GetButtonDown(key))
             {
                 OnUse.Invoke();
             }
         }
         yield return(base.CheckInputs());
     }
 }
    private IEnumerator UseCoroutine()
    {
        float currentActiveTime = 0.0f;

        //check if the ability has a period, if so use the use frequency to use the ability multiple times till the period is over
        do
        {
            modifierHandler.ApplyPreActionModifiers(CharacterBase, CharacterBase);

            OnUse?.Invoke();

            if (UseAnimator != null)
            {
                switch (ability.Ability)
                {
                case ScriptableMeleeAbility scriptableMeleeAbility:
                    UseAnimator.SetBool(AnimationUseBoolName, true);
                    break;

                case ScriptableProjectileAbility scriptableProjectileAbility:
                    UseAnimator.SetBool(AnimationRangeUseBoolName, true);
                    break;

                case ScriptableRaycastAbility scriptableRaycastAbility:
                    UseAnimator.SetBool(AnimationRangeUseBoolName, true);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            ability.Use();
            CharacterBase.LoseEnergy(ScriptableAbility.EnergyCost);

            modifierHandler.ApplyPostActionModifiers(CharacterBase, CharacterBase);

            if (ability.Ability.ActivePeriod <= 0.0f)
            {
                break;
            }

            yield return(new WaitForSeconds(ability.Ability.UseFrequency));

            currentActiveTime += ability.Ability.UseFrequency;
        }while (currentActiveTime < ability.Ability.ActivePeriod);
    }
示例#9
0
 public void UnSubscribe(OnUse _onUse)
 {
     onUse -= _onUse;
 }
示例#10
0
 public void Subscribe(OnUse _onUse)
 {
     onUse += _onUse;
 }
示例#11
0
 public void Use()
 {
     OnUse?.Invoke(this, new TailLossEventArgs(Animal));
 }
示例#12
0
 internal void InvokeOnUse(int slot)
 {
     OnUse?.Invoke(slot);
 }
示例#13
0
 public Item(ItemID item, OnUse onUse = null)
 {
     this.item = item;
     this.Use  = onUse;
 }
示例#14
0
 public static void PressUse(GameObject target)
 {
     OnUse?.Invoke(target);
 }
示例#15
0
        private void buttonUse_Click(object sender, EventArgs e)
        {
            int TagIdx = (int)Tag;

            OnUse?.Invoke(TagIdx);
        }
示例#16
0
 public void Use(VRHand hand)
 {
     OnUse.Invoke(hand.gameObject);
 }
示例#17
0
 void HandleOnFinished()
 {
     isUsed = true;
     OnUse.Invoke();
 }