public void Attack(IWeapon weapon, ICreature attacker, ICreature target, World world) { ITemporaryEffect e = _effect.Clone(); e.Id = Guid.NewGuid(); attacker.AddTemporaryEffect(e); }
/// <summary> /// adds an active monster effect /// </summary> /// <param name="effect"></param> public void AddMonsterEffect(ITemporaryEffect effect) { lock (effectlock) { monstereffects.Add(effect); effect.Initialize(); } }
public PlayerBattleEntity(Context context, long playerid, Adventure adventure, MonsterBattleLogic battlelogic) { this.context = context; PlayerID = playerid; Adventure = adventure; BattleLogic = battlelogic; user = context.GetModule <UserModule>().GetUser(playerid); Name = context.Database.Load <User>(u => u.Name).Where(u => u.ID == playerid).ExecuteScalar <string>(); Image = context.Database.Load <User>(u => u.Avatar).Where(u => u.ID == playerid).ExecuteScalar <string>(); Effects = new ITemporaryEffect[0]; }
void RemovePlayerEffect(Player player, ITemporaryEffect activeeffect) { ITemporaryEffect effect = playereffects[player.UserID].FirstOrDefault(e => e == activeeffect); if (effect == null) { return; } effect.WearOff(); playereffects[player.UserID].Remove(effect); }
public void AddEffect(ITemporaryEffect effect) { ITemporaryEffect oldeffects = effects.FirstOrDefault(e => e.GetType() == effect.GetType()); if (oldeffects != null) { context.GetModule <EffectModule>().RemoveEffect(oldeffects); } context.GetModule <EffectModule>().AddMonsterEffect(effect); effects.Add(effect); }
/// <summary> /// adds an active player effect /// </summary> /// <param name="playerid">id of player</param> /// <param name="effect">effect to add</param> public void AddPlayerEffect(long playerid, ITemporaryEffect effect) { lock (effectlock) { List <ITemporaryEffect> effects; if (!playereffects.TryGetValue(playerid, out effects)) { playereffects[playerid] = effects = new List <ITemporaryEffect>(); } effects.RemoveAll(e => e.GetType() == effect.GetType()); effects.Add(effect); effect.Initialize(); } }
void ReduceEffect(User user, Player player, string effect, int level) { lock (effectlock) { ITemporaryEffect activeeffect = GetActivePlayerEffects(player.UserID).FirstOrDefault(e => e.Name.ToLower() == effect); if (activeeffect != null) { if (level >= activeeffect.Level) { RemovePlayerEffect(player, activeeffect); } else { activeeffect.Level -= level; context.GetModule <RPGMessageModule>().Create().Text("The effect level of ").User(user).Text("'s ").Text(activeeffect.Name).Text(" was reduced to ").Text(activeeffect.Level.ToString()).Text(".").Send(); } } } }
void ITimerService.Process(double time) { lock (effectlock) { for (int i = monstereffects.Count - 1; i >= 0; --i) { ITemporaryEffect effect = monstereffects[i]; effect.Time -= time; if (effect.Time <= 0.0) { effect.WearOff(); monstereffects.RemoveAt(i); } else { (effect as IStatusEffect)?.ProcessStatusEffect(time); } } foreach (long player in playereffects.Keys.ToArray()) { List <ITemporaryEffect> effects = playereffects[player]; for (int i = effects.Count - 1; i >= 0; --i) { ITemporaryEffect effect = effects[i]; effect.Time -= time; if (effect.Time <= 0.0) { effect.WearOff(); effects.RemoveAt(i); } else { (effect as IStatusEffect)?.ProcessStatusEffect(time); } } if (effects.Count == 0) { playereffects.Remove(player); } } } }
public void AddEffect(ITemporaryEffect effect) { context.GetModule <EffectModule>().AddPlayerEffect(PlayerID, effect); }
public void AddTemporaryEffect(ITemporaryEffect effect) { effect.ApplyEffect(this, _world); TemporaryEffects.Add(effect); effect.Completed += new TemporaryEffectEvent(TemporaryEffectCompleted); }
public ApplyTemporaryEffectGetStrategy(ITemporaryEffect effect) { _effect = effect; _standardGet = new StandardGetStrategy(); }
public ApplyTemporaryEffectToAttacker(ITemporaryEffect effect) { _effect = effect; }
public void Attack(IWeapon weapon, ICreature attacker, ICreature target, World world) { ITemporaryEffect e = _effect.Clone(); target.AddTemporaryEffect(_effect); }
public ApplyTemporaryEffectToTarget(ITemporaryEffect effect) { _effect = effect; }
public void RemoveEffect(ITemporaryEffect oldeffects) { lock (effectlock) monstereffects.RemoveAll(e => e == oldeffects); }
void TemporaryEffectCompleted(ITemporaryEffect sender) { TemporaryEffects.Remove(sender); }
public void AddTemporaryEffect(ITemporaryEffect effect) { TemporaryEffects.Add(effect); effect.Completed += new TemporaryEffectEvent(TemporaryEffectCompleted); }
public void AddEffect(ITemporaryEffect effect) { }