コード例 #1
0
 private CooldownID(ICooldown cooldownAsset, Type interactableComponentType, NetworkSide networkSide, CooldownType cooldownType)
 {
     this.cooldownAsset             = cooldownAsset;
     this.interactableComponentType = interactableComponentType;
     this.cooldownType = cooldownType;
     this.networkSide  = networkSide;
 }
コード例 #2
0
    private IEnumerator StartCooldown(ICooldown cd, CooldownSettings cds)
    {
        cd.OnCooldown = true;

        yield return(new WaitForSeconds(cds.cooldownTime));

        cd.OnCooldown = false;
    }
コード例 #3
0
        // TODO - Calculate delay
        private IEnumerator Cooldown(ICooldown cooldownObject)
        {
            cooldownObject.NotifyCooldownStart();

            yield return(new WaitForSeconds(cooldownObject.GetCooldown()));

            StopCooldown(cooldownObject);
        }
コード例 #4
0
        private void StopCooldown(ICooldown cooldownObject)
        {
            cooldownObject.NotifyCooldownEnd();

            StopCoroutine(_cooldowns[cooldownObject]);

            _cooldowns[cooldownObject] = null;
        }
コード例 #5
0
        public void PutOnCooldown(GameObject go, ICooldown cooldown)
        {
            var key = go.GetHashCode() + cooldown.Id.GetHashCode();

            if (!_cooldowns.ContainsKey(key))
            {
                _cooldowns.Add(key, new CooldownData(cooldown));
            }
        }
コード例 #6
0
        public void PutOnCooldown(ICooldown cooldown)
        {
            var key = cooldown.Id.GetHashCode();

            if (!_cooldowns.ContainsKey(key))
            {
                _cooldowns.Add(key, new CooldownData(cooldown));
            }
        }
コード例 #7
0
 public CommandHandler(IServiceProvider services)
 {
     _services   = services;
     _client     = services.GetRequiredService <DiscordSocketClient>();
     _commands   = services.GetRequiredService <CommandService>();
     _log        = services.GetRequiredService <ILogger>();
     _wordSearch = services.GetRequiredService <IWordSearch>();
     _cooldown   = services.GetRequiredService <ICooldown>();
 }
コード例 #8
0
 private void StartCooldown(ICooldown cooldownObject)
 {
     if (_cooldowns.ContainsKey(cooldownObject))
     {
         _cooldowns[cooldownObject] = StartCoroutine(Cooldown(cooldownObject));
     }
     else
     {
         _cooldowns.Add(cooldownObject, StartCoroutine(Cooldown(cooldownObject)));
     }
 }
コード例 #9
0
        public bool TryAbility(ICooldown cooldownObject)
        {
            // If dictionary has key, we used this tool at least once
            // so we have to check for its cooldown
            if (_cooldowns.ContainsKey(cooldownObject) && _cooldowns[cooldownObject] != null)
            {
                return(false);
            }

            StartCooldown(cooldownObject);

            return(true);
        }
コード例 #10
0
        /// <summary>
        /// Usar cooldown.
        /// </summary>
        /// <param name="cooldownSkill">Interface da habilidade que deseja implementar o cooldown</param>
        /// <returns>Retorna True se houver, False caso contrario.</returns>
        public bool Use(ICooldown cooldownSkill)
        {
            /// Caso a habilidade use o cooldown sobre o tempo.
            var cd = cooldownSkill.OverTime ? cooldownSkill.CooldownRequired * Time.deltaTime : cooldownSkill.CooldownRequired;

            if (AvailableCooldown >= cd)
            {
                AvailableCooldown -= cd;
                currentDelay       = 0f;
                return(true);
            }

            return(false);
        }
コード例 #11
0
 private void SaveCooldowns <T>(List <T> cooldowns) where T : ICooldown
 {
     for (var i = cooldowns.Count - 1; i >= 0; i--)
     {
         ICooldown cooldown = cooldowns[i];
         if (cooldown.Until < DateTime.Now.AddMilliseconds(SpellHandler.MinCooldownSaveTimeMillis))
         {
             // already expired or will expire very soon
             if (cooldown is ActiveRecordBase)
             {
                 ((ActiveRecordBase)cooldown).DeleteLater();
             }
         }
         else
         {
             var cd = cooldown.AsConsistent();
             cd.CharId = Owner.EntityId.Low;
             cd.Save();                     // update or create
             cooldowns.Add((T)cd);
         }
         cooldowns.RemoveAt(i);
     }
 }
コード例 #12
0
        private void SaveCooldowns <T>(List <T> cooldowns) where T : ICooldown
        {
            for (int index = cooldowns.Count - 1; index >= 0; --index)
            {
                ICooldown cooldown = (ICooldown)cooldowns[index];
                if (cooldown.Until < DateTime.Now.AddMilliseconds((double)SpellHandler.MinCooldownSaveTimeMillis))
                {
                    if (cooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)cooldown).DeleteLater();
                    }
                }
                else
                {
                    IConsistentCooldown consistentCooldown = cooldown.AsConsistent();
                    consistentCooldown.CharId = this.Owner.EntityId.Low;
                    consistentCooldown.Save();
                    cooldowns.Add((T)consistentCooldown);
                }

                cooldowns.RemoveAt(index);
            }
        }
コード例 #13
0
 // Update is called once per frame
 private void Update()
 {
     for (int i = 0; i < NUMBEROFSKILLS; i++)
     {
         if (cooldowns[i] == null)
         {
             continue;
         }
         // Updates sprite icons for combos
         spriteIcons[i].sprite = cooldowns[i].GetIcon();
         ICooldown cooldown          = cooldowns[i];
         float     nextAvailableTime = cooldown.GetNextAvailableTime();
         float     cooldownDuration  = cooldown.GetCooldownDuration();
         if (nextAvailableTime < Time.time) // Skill is available and ready to use
         {
             darkMasks[i].fillAmount = 0;
         }
         else
         {
             darkMasks[i].fillAmount = Mathf.Lerp(0f, 1f, (nextAvailableTime - Time.time) / cooldownDuration);
         }
     }
 }
コード例 #14
0
        /// <summary>Provides the observer with new data.</summary>
        /// <param name="value">The current notification information.</param>
        public void OnNext(ICooldown value)
        {
            if (this.Skill.Level.Current == 0)
            {
                this.BorderColor = this.NotLearnedColor;
                return;
            }

            if (value.Current > 0)
            {
                // this.CooldownText.Text = (Math.Min(value.Current, 99)).ToString(CultureInfo.CurrentCulture);
                // this.CooldownText.CenterOnRectangle(this.blackOverlay);
                this.cooldownNumber.Value = (int)Math.Min(value.Current, 99);
                this.cooldownNumber.CenterOnRectangle(this.blackOverlay);

                ///this.CooldownText.CenterOnRectangle(this.blackOverlay);
                if (this.Skill.CastData.EnoughMana)
                {
                    this.BorderColor = this.NotReadyColor;
                }
                else
                {
                    this.BorderColor = this.NotEnoughManaColor;
                }
            }
            else
            {
                if (this.Skill.CastData.EnoughMana)
                {
                    this.BorderColor = this.ReadyColor;
                }
                else
                {
                    this.BorderColor = this.NotEnoughManaColor;
                }
            }
        }
コード例 #15
0
 /// <summary>
 /// Same as IsOn for for indicated serverside Cooldown
 /// </summary>
 public static bool IsOnServer(Interaction interaction, ICooldown cooldown)
 {
     return(IsOnServer(interaction.PerformerPlayerScript, cooldown));
 }
コード例 #16
0
 public float GetRemainingDuration(GameObject go, ICooldown cooldown)
 {
     return(_cooldowns.ContainsKey(go.GetHashCode() + cooldown.Id.GetHashCode()) ? _cooldowns[cooldown.Id.GetHashCode()].RemainingTime : 0f);
 }
コード例 #17
0
 public bool IsOnCooldown(ICooldown cooldown)
 {
     return(_cooldowns.ContainsKey(cooldown.Id.GetHashCode()));
 }
コード例 #18
0
 public bool IsOnCooldown(GameObject go, ICooldown cooldown)
 {
     return(_cooldowns.ContainsKey(go.GetHashCode() + cooldown.Id.GetHashCode()));
 }
コード例 #19
0
 /// <summary>
 /// Cooldown identified by a particular cooldown asset.
 /// </summary>
 /// <param name="cooldownAsset"></param>
 /// <param name="side">network side this cooldown is for</param>
 /// <returns></returns>
 public static CooldownID Asset(ICooldown cooldownAsset, NetworkSide side)
 {
     return(new CooldownID(cooldownAsset, null, side, CooldownType.Asset));
 }
コード例 #20
0
 public void Init(ICooldown itemCooldown, CooldownSettings CDS)
 {
     pCDS          = CDS;
     pItemCooldown = itemCooldown;
     StartCoroutine(StartCooldown(itemCooldown, CDS));
 }
コード例 #21
0
 public float GetRemainingDuration(ICooldown cooldown)
 {
     return(_cooldowns.ContainsKey(cooldown.Id.GetHashCode()) ? _cooldowns[cooldown.Id.GetHashCode()].RemainingTime : 0f);
 }
コード例 #22
0
 /// <summary>
 /// Same as TryStart with NetworkSide.Server
 /// </summary>
 public static bool TryStartServer(Interaction interaction, ICooldown cooldown, float secondsOverride = float.NaN)
 {
     return(TryStartServer(interaction.PerformerPlayerScript, cooldown, secondsOverride));
 }
コード例 #23
0
 /// <summary>
 /// Cooldown Data constructor.
 /// Initializes the cooldown properties.
 /// </summary>
 /// <param name="cooldown">ICooldown class to init values for cooldown data</param>
 public CooldownData(ICooldown cooldown)
 {
     Id            = cooldown.Id;
     RemainingTime = cooldown.CooldownDuration;
 }
コード例 #24
0
 /// <summary>
 /// Same as IsOn for for indicated clientside Cooldown
 /// </summary>
 public static bool IsOnClient(PlayerScript player, ICooldown cooldown)
 {
     return(IsOn(player, CooldownID.Asset(cooldown, NetworkSide.Client)));
 }
コード例 #25
0
 /// <summary>
 /// Same as IsOn for for indicated serverside Cooldown
 /// </summary>
 public static bool IsOnServer(PlayerScript player, ICooldown cooldown)
 {
     return(IsOn(player, CooldownID.Asset(cooldown, NetworkSide.Server)));
 }
コード例 #26
0
 /// <summary>
 /// Starts the cooldown for the player if it's not currently on.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="cooldown">cooldown to try starting</param>
 /// <param name="side">indicates which side's cooldown should be started</param>
 /// <param name="secondsOverride">custom cooldown time in seconds</param>
 /// <returns>true if cooldown was successfully started, false if cooldown was already on.</returns>
 public static bool TryStart(PlayerScript player, ICooldown cooldown, NetworkSide side, float secondsOverride = float.NaN)
 {
     return(player.Cooldowns.TryStart(cooldown, side, secondsOverride));
 }
コード例 #27
0
 /// <summary>
 /// This function adds new cooldown to the cooldowns list.
 /// </summary>
 /// <param name="cooldown">New cooldown to add</param>
 public void AddCooldown(ICooldown cooldown)
 {
     cooldowns.Add(new CooldownData(cooldown));
 }
コード例 #28
0
 /// <summary>
 /// Starts the cooldown for the interaction's performer if it's not currently on.
 /// </summary>
 /// <param name="interaction">interaction whose performer's cooldown should be started</param>
 /// <param name="cooldown">cooldown to try starting</param>
 /// <param name="side">indicates which side's cooldown should be started</param>
 /// <returns>true if cooldown was successfully started, false if cooldown was already on.</returns>
 public static bool TryStart(Interaction interaction, ICooldown cooldown, NetworkSide side)
 {
     return(TryStart(interaction.PerformerPlayerScript, cooldown, side));
 }
コード例 #29
0
 public void StartDashCooldown()
 {
     dashCooldown = new SimpleTimer(settings.dashSettings.dashCooldown);
 }
コード例 #30
0
 /// <summary>
 /// Same as TryStart with NetworkSide.Server
 /// </summary>
 public static bool TryStartServer(PlayerScript player, ICooldown cooldown, float secondsOverride = float.NaN)
 {
     return(TryStart(player, cooldown, NetworkSide.Server, secondsOverride));
 }