public void Disable()
    {
        IsOn = false;
        GlobalCallbacks.RemoveUpdateListener(OnDebugElementUpdate);
        GlobalCallbacks.RemoveRenderObjectListener(OnDebugElementRenderObject);

        OnDebugElementDisable();
    }
        public IEnumerator CannotReloadPastMaxAmmoLimit()
        {
            Ability ability = GetAbility();

            GlobalCallbacks.AddUpdateListener(() => ability.UpdateState(ReloadInput));

            yield return(new WaitForSeconds(1));

            Assert.AreEqual(ability.Behaviour.AmmoCapacity, ability.CurrentAmmo);
        }
        public IEnumerator ShouldFullyReloadWithinTimeframe()
        {
            Ability ability = GetAbility();

            ability.CurrentAmmo = 0;

            GlobalCallbacks.AddUpdateListener(() => ability.UpdateState(ReloadInput));

            yield return(new WaitForSeconds(ability.Behaviour.ReloadTime));

            Assert.AreEqual(ability.Behaviour.AmmoCapacity, ability.CurrentAmmo);
        }
    public override void Enable()
    {
        if (IsOn)
        {
            Disable();
        }

        IsOn = true;
        GlobalCallbacks.AddUpdateListener(OnDebugElementUpdate);
        GlobalCallbacks.AddRenderObjectListener(OnDebugElementRenderObject);

        OnDebugElementEnable();
    }
        public IEnumerator CannotHaveNegativeAmmo()
        {
            int startAmmo = 0;

            Ability ability = GetAbility();
            // Ensure ability isn't charged
            AbilityPart nonChargedBehaviour = AbilityLoader.Behaviour.Where(x => !(x is ChargedBehaviour)).Random();

            ability.EquipPart(nonChargedBehaviour);

            // We do this after equipping since changing behaviour will reset ammo count to max
            ability.CurrentAmmo = startAmmo;

            GlobalCallbacks.AddUpdateListener(() => ability.UpdateState(FireInput));

            // First we wait for the cooldown to expire
            yield return(new WaitForSeconds(ability.Behaviour.CooldownDuration));

            // Then we wait a single frame for the actual shooting to occur
            yield return(0);

            Assert.AreEqual(startAmmo, ability.CurrentAmmo);
        }
Example #6
0
 public static void On(Action <object> callback)
 {
     GlobalCallbacks.Add(callback);
 }