public bool GetSkillFromId(uint id, Class c, CooldownType t, out Skill sk) { sk = new Skill(0, Class.None, "", ""); switch (t) { case CooldownType.Skill: if (!Game.DB.SkillsDatabase.TryGetSkill(id, c, out sk)) { return(false); } break; case CooldownType.Item: if (!Game.DB.ItemsDatabase.TryGetItemSkill(id, out sk)) { return(false); } break; case CooldownType.Passive: if (!Game.DB.AbnormalityDatabase.TryGetPassiveSkill(id, out sk)) { return(false); } break; } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="AttackMessage"/> class. /// </summary> /// <param name="sender">施法者</param> /// <param name="targets">攻击目标</param> /// <param name="spellId">技能</param> public AttackMessage(BattleAgent sender, List<BattleAgent> targets, int skillId, CooldownType type) { this.Sender = sender; this.Targets = targets; this.SkillId = skillId; this.CooldownType = type; }
public MabiCooldown(CooldownType type, uint id, DateTime expires, string error) { this.Type = type; this.Id = id; this.Expires = expires; this.ErrorMessage = error; }
private void AddTimer(CooldownType type, float second, TimerEventHandler action) { CooldownTimer t = TimerManager.SharedInstance.CreateTimer(second, action); timerDict.Add(type, t); String name = this.gameObject.name; Type tt = this.baseSoldier.GetType(); // if (tt == typeof(ODSoldier) || // tt == typeof(HMSoldier) || // tt == typeof(LESoldier) || // tt == typeof(MXSoldier)) { // t.Start(); // } // // if (name=="hf1"||name=="hf2"||name=="hf3"||name=="hf1") { // // } // // // if (this.gameObject.name == "hf2") { // t.Start (); // } // if (this.gameObject.name == "hf3") { // t.Start (); // } // if (this.gameObject.name == "hf1") { // t.Start (); // } t.Start(); }
private CooldownID(ICooldown cooldownAsset, Type interactableComponentType, NetworkSide networkSide, CooldownType cooldownType) { this.cooldownAsset = cooldownAsset; this.interactableComponentType = interactableComponentType; this.cooldownType = cooldownType; this.networkSide = networkSide; }
public void StartCooldown(CooldownType type, float seconds) { switch (type) { case CooldownType.CAST_SPELL: spellCastTimer = seconds; spellCastCurTimer = seconds; spellCastCD = true; spellCastCooldownImg.enabled = true; break; case CooldownType.POWERFUL_ATTACK: pwrAtkTimer = seconds; pwrAtkCurTimer = seconds; pwrAtkCD = true; powerfullAtkCooldownImg.enabled = true; break; case CooldownType.SHIELD: shieldTimer = seconds; shieldCurTimer = seconds; shieldCD = true; shieldCooldownImg.enabled = true; break; default: break; } }
public void StartCooldown(CooldownType type, Action cb) { var temp = _coolDowns.Find(x => x.Type == type); temp.IsCoolingDown = true; if (_flashCoroutine != null) { //theres already a flasher going so we need to check which one will stop first if (_currentlyFlashingCooldown.TimeLeft < temp.CooldownTime) { characterSelect.ResetToCurrentMaterial(); StopCoroutine(_flashCoroutine); StartFlasher(temp); } } else { //no current flasher so we can just start StartFlasher(temp); } var coolDown = new CooldownCoroutineCallbackPair(); coolDown.Callback = cb; _coolDownTimers[type] = coolDown; coolDown.CooldownTimer = StartCoroutine(CooldownInternal(type, temp.CooldownTime, cb)); }
public Cooldown GetCooldown(CooldownType type, uint id) { string key = type.ToString() + id; Cooldown cool; cooldownDict.TryGetValue(key, out cool); return(cool); }
public bool TryStartCooldown(CooldownType type, Action cb) { if (IsCoolingDown(type)) { return(false); } StartCooldown(type, cb); return(true); }
public void DeleteCooldown(CooldownType type, uint id) { string key = type.ToString() + id; Cooldown cool; cooldownDict.TryGetValue(key, out cool); if (cool != null) { cool.Dispose(); } cooldownDict.Remove(key); }
/// <summary> /// Sets or updates a cooldown for a user. /// </summary> public void SetCooldown(CooldownType type, string name, TimeSpan duration) { DateTime expiresOn = DateTime.UtcNow.Add(duration); string id = $"{type.ToString().ToLower()}:{name}"; if (type.EqualsAny(CooldownType.Command, CooldownType.Global, CooldownType.Notify)) { if (!InternalCooldowns.TryAdd(id, expiresOn)) { InternalCooldowns[id] = expiresOn; } } if (type == CooldownType.Claimable) { Claimable info = Engine.GetClaimable(name); if (Cooldowns.ContainsKey(id)) { // if you can set a claimable cooldown. bool canUpdate = (Cooldowns[id] - DateTime.UtcNow) <= TimeSpan.Zero; if (canUpdate) { // Set up/update the streak stats if ((DateTime.UtcNow - Cooldowns[id]) >= info.Preservation) // if the streak will reset. { SetStat(info.StreakId, 1); } else { UpdateStat(info.StreakId, 1); } Cooldowns[id] = DateTime.UtcNow.Add(info.Cooldown); // set new expiration. } } else { SetStat(info.StreakId, 1); Cooldowns[id] = DateTime.UtcNow.Add(info.Cooldown); } } if (type == CooldownType.Item) { if (!Cooldowns.TryAdd(id, expiresOn)) { Cooldowns[id] = expiresOn; } } }
public static Cooldown Create(CooldownType type, uint id, float cdTime) { GameObject go = new GameObject("Cooldown"); go.hideFlags = HideFlags.HideAndDontSave; Cooldown cooldown = go.AddComponent <Cooldown>(); cooldown.type = type; cooldown.id = id; cooldown.cdTime = cdTime; cooldown.startTime = Time.realtimeSinceStartup; return(cooldown); }
public PlayerData(DateTime next, CooldownType type) { switch (type) { case CooldownType.ReportCooldown: ReportCooldown = next; break; case CooldownType.MessageCooldown: MessageCooldown = next; break; } }
public void StopCooldown(CooldownType type) { var temp = _coolDowns.Find(x => x.Type == type); if (_coolDownTimers[type] != null) { StopCoroutine(_coolDownTimers[type].CooldownTimer); _coolDownTimers[type].Callback(); _coolDownTimers[type] = null; } temp.IsCoolingDown = false; }
public static string GetFriendlyName(this CooldownType type) { return(type switch { CooldownType.Server => "This server", CooldownType.Channel => "This channel", CooldownType.User => "You", CooldownType.Global => "Everybody", _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) });
public SkillCooldownOld(uint id, uint cd, CooldownType t) { Id = id; Cooldown = cd; if (t == CooldownType.Item) { Cooldown = Cooldown * 1000; } Type = t; if (cd != 0) { Timer = new Timer(Cooldown); } }
public SkillCooldown(Skill sk, int cd, CooldownType t) { Skill = sk; Cooldown = cd; if (t == CooldownType.Item) { Cooldown = Cooldown * 1000; } if (cd != 0) { Timer = new System.Timers.Timer(Cooldown); } }
public TimeSpan CalculateRemainingCooldownTime(CooldownType type, DateTime currentTime) { TimeSpan timeDiff = TimeSpan.Zero; try { timeDiff = Cooldowns[type].Item1 + Cooldowns[type].Item2 - currentTime; } catch { Console.WriteLine($"WARN: cooldown type {type} not found in {Name}'s cooldowns."); } return(timeDiff > TimeSpan.Zero ? timeDiff : TimeSpan.Zero); }
public void AddCooldown(CooldownType type, uint id, float cdTime) { Cooldown cool = GetCooldown(type, id); if (cool != null) { cool.Dispose(); } cool = Cooldown.Create(type, id, cdTime); string key = type.ToString() + id; cooldownDict[key] = cool; if (OnCooldownChange != null) { OnCooldownChange(cool); } }
IEnumerator ButtonCooldown(CooldownType type, int index, ButtonEvent buttonEvent, float duration) { if (type == CooldownType.MainAction) { Player.players[playerIndex].canPlayMain = false; } else if (type == CooldownType.Event) { Player.players[playerIndex].canPlayEvent[index] = false; } yield return(StartCoroutine(buttonEvent.StartCooldown(duration))); if (type == CooldownType.MainAction) { Player.players[playerIndex].canPlayMain = true; } }
private IEnumerator CooldownInternal(CooldownType type, float time, Action cb) { var temp = _coolDowns.Find(x => x.Type == type); var timeRemaining = time; while (timeRemaining > 0) { yield return(new WaitForEndOfFrame()); timeRemaining -= Time.deltaTime * GameManager.Instance.TimeScale; temp.TimeLeft = timeRemaining; } _coolDownTimers[type] = null; temp.IsCoolingDown = false; cb(); }
public static void SetCooldownType(PlayerItem item, CooldownType cooldownType, float value) { item.damageCooldown = -1f; item.roomCooldown = -1; item.timeCooldown = -1f; switch (cooldownType) { case CooldownType.Timed: item.timeCooldown = value; break; case CooldownType.Damage: item.damageCooldown = value; break; case CooldownType.PerRoom: item.roomCooldown = (int)value; break; } }
public static string GetFriendlyName(this CooldownType type) { switch (type) { case CooldownType.Server: return("This server"); case CooldownType.Channel: return("This channel"); case CooldownType.User: return("You"); case CooldownType.Global: return("Everybody"); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static string GetPerName(this CooldownType type) { switch (type) { case CooldownType.Server: return("Per server"); case CooldownType.Channel: return("Per channel"); case CooldownType.User: return("Per user"); case CooldownType.Global: return("Global"); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public Ability(string _name, float _cooldown_time, float _cast_time, Action _onActivate, CooldownType _type) { if (_onActivate == null) { Debug.LogError("Tried to create ability without callback" + name); return; } if (_cooldown_time <= 0f) { Debug.LogError("Resulting cooldown for " + _name + " is less or equal to zero, which is incorrect."); Debug.Break(); } //we treat ability as immutable object, so we only accept the callback in constructor onCast = _onActivate; //use for error reports and other things name = _name; //do we have a cast time? has_cast_time = _cast_time > 0f ? true : false; //if yes, create cast timer if (has_cast_time && cast_timer == null) { cast_timer = Timer.Countdown(_cast_time, actual_cast).Pause(); } cooldown_time = _cooldown_time; //switch (_type) //{ // case CooldownType.fromStart: // cooldown_time = _cooldown_time + _cast_time; // break; // case CooldownType.fromCastPoint: // cooldown_time = _cooldown_time; // break; // default: // break; //} castTime = _cast_time; cooldowntype = _type; firstUse = true; }
public SkillCooldown(Skill sk, ulong cd, CooldownType t, Dispatcher d, bool autostart = true, bool pre = false) { base.Dispatcher = d; Pre = pre; var cooldown = cd > int.MaxValue ? int.MaxValue : cd; Skill = sk; Cooldown = t == CooldownType.Skill ? cooldown : cooldown * 1000; Type = t; OriginalCooldown = Cooldown; if (cooldown == 0) { return; } _timer = new Timer(Cooldown); _timer.Elapsed += _timer_Elapsed; if (autostart) { Start(); } }
public AbyssCooldownAttribute(int amount, double per, CooldownMeasure cooldownMeasure, CooldownType bucketType) : base(amount, per, cooldownMeasure, bucketType) { }
public CooldownData(uint id, CooldownType type) { Id = id; Type = type; }
/// <summary> /// /// </summary> /// <param name="coolType">冷却类型</param> /// <param name="millisecondSpans">毫秒冷却时间间隔</param> public CooldownTime(CooldownType cooldownType, params long[] millisecondSpans) { _cooldownType = cooldownType; _millisecondSpans = millisecondSpans; }
public Rectangle GetCooldownRectangle(CooldownType type) { return(SpriteAtlas.Cooldowns[type.ToString()].Rectangle); }
/// <summary> /// 普通攻击技能 /// 攻击距离 /// </summary> /// <param name="type">Type.</param> /// <param name="data">Data.</param> public void AddSkillDemo(CooldownType type, SkillData data) { skillDict.Add(type, data); }
/// <summary> /// Adds a cooldown to the creature. If one already exists, the Expiry and Error messages are updated. /// If the expiry has already passed, the cooldown is not added and removed if needed. /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <param name="expires"></param> /// <param name="error">The error message to be shown. Use {0} to insert the time left.</param> /// <returns></returns> public void AddCooldown(CooldownType type, uint id, DateTime expires, string error) { var cooldown = Cooldowns.FirstOrDefault(c => c.Type == type && c.Id == id); if (cooldown != null) { cooldown.Expires = expires; cooldown.ErrorMessage = error; if (cooldown.Expires < DateTime.Now) Cooldowns.Remove(cooldown); return; } if (expires < DateTime.Now) return; cooldown = new MabiCooldown(type, id, expires, error); Cooldowns.Add(cooldown); }
public Rectangle GetCooldownRectangle(CooldownType type) { return SpriteAtlas.Cooldowns[type.ToString()].Rectangle; }
/// <summary> /// Checks for a valid cooldown of the specified type and id. Optionally sends the error message to the client. /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <param name="sendError"></param> /// <returns>True if a valid cooldown is found, false otherwise</returns> public bool CheckForCooldown(CooldownType type, uint id, bool sendError = true) { var cooldown = Cooldowns.FirstOrDefault(c => c.Type == type && c.Id == id); if (cooldown == null) return false; if (cooldown.Expires < DateTime.Now) { Cooldowns.Remove(cooldown); return false; } if (sendError) cooldown.SendErrorMessage(this); return true; }
/// <summary> /// Initializes a new instance of the <see cref="AttackMessage"/> class. /// </summary> /// <param name="sender">施法者</param> /// <param name="targets">攻击目标</param> /// <param name="spellId">技能</param> public AttackMessage(BattleAgent sender, List <BattleAgent> targets, int skillId, CooldownType type) { this.Sender = sender; this.Targets = targets; this.SkillId = skillId; this.CooldownType = type; }
/// <summary> /// 普通攻击技能 /// 攻击距离 /// </summary> /// <param name="type">Type.</param> /// <param name="data">Data.</param> public void AddSkillDemo(CooldownType type, SkillData data) { skillDict.Add (type, data); }
private void AddTimer(CooldownType type, float second, TimerEventHandler action) { CooldownTimer t = TimerManager.SharedInstance.CreateTimer (second, action); timerDict.Add (type, t); String name = this.gameObject.name; Type tt = this.baseSoldier.GetType (); // if (tt == typeof(ODSoldier) || // tt == typeof(HMSoldier) || // tt == typeof(LESoldier) || // tt == typeof(MXSoldier)) { // t.Start(); // } // // if (name=="hf1"||name=="hf2"||name=="hf3"||name=="hf1") { // // } // // // if (this.gameObject.name == "hf2") { // t.Start (); // } // if (this.gameObject.name == "hf3") { // t.Start (); // } // if (this.gameObject.name == "hf1") { // t.Start (); // } t.Start (); }