public void Attack(IWeapon weapon, ICreature attacker, ICreature target, World world)
        {
            ITemporaryEffect e = _effect.Clone();

            e.Id = Guid.NewGuid();
            attacker.AddTemporaryEffect(e);
        }
示例#2
0
 /// <summary>
 /// adds an active monster effect
 /// </summary>
 /// <param name="effect"></param>
 public void AddMonsterEffect(ITemporaryEffect effect)
 {
     lock (effectlock) {
         monstereffects.Add(effect);
         effect.Initialize();
     }
 }
示例#3
0
 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];
 }
示例#4
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);
        }
示例#6
0
        /// <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();
            }
        }
示例#7
0
 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();
             }
         }
     }
 }
示例#8
0
        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);
                    }
                }
            }
        }
示例#9
0
 public void AddEffect(ITemporaryEffect effect)
 {
     context.GetModule <EffectModule>().AddPlayerEffect(PlayerID, effect);
 }
示例#10
0
 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;
 }
示例#13
0
        public void Attack(IWeapon weapon, ICreature attacker, ICreature target, World world)
        {
            ITemporaryEffect e = _effect.Clone();

            target.AddTemporaryEffect(_effect);
        }
示例#14
0
 public ApplyTemporaryEffectToTarget(ITemporaryEffect effect)
 {
     _effect = effect;
 }
示例#15
0
 public void RemoveEffect(ITemporaryEffect oldeffects)
 {
     lock (effectlock)
         monstereffects.RemoveAll(e => e == oldeffects);
 }
示例#16
0
 public void AddTemporaryEffect(ITemporaryEffect effect)
 {
     effect.ApplyEffect(this, _world);
     TemporaryEffects.Add(effect);
     effect.Completed += new TemporaryEffectEvent(TemporaryEffectCompleted);
 }
示例#17
0
 void TemporaryEffectCompleted(ITemporaryEffect sender)
 {
     TemporaryEffects.Remove(sender);
 }
示例#18
0
 public ApplyTemporaryEffectGetStrategy(ITemporaryEffect effect)
 {
     _effect      = effect;
     _standardGet = new StandardGetStrategy();
 }
示例#19
0
 public void AddTemporaryEffect(ITemporaryEffect effect)
 {
     TemporaryEffects.Add(effect);
     effect.Completed += new TemporaryEffectEvent(TemporaryEffectCompleted);
 }
示例#20
0
 public void AddTemporaryEffect(ITemporaryEffect effect)
 {
     TemporaryEffects.Add(effect);
     effect.Completed += new TemporaryEffectEvent(TemporaryEffectCompleted);
 }
 public ApplyTemporaryEffectToTarget(ITemporaryEffect effect)
 {
     _effect = effect;
 }
示例#22
0
 public void AddEffect(ITemporaryEffect effect)
 {
 }
示例#23
0
 void TemporaryEffectCompleted(ITemporaryEffect sender)
 {
     TemporaryEffects.Remove(sender);
 }
 public ApplyTemporaryEffectToAttacker(ITemporaryEffect effect)
 {
     _effect = effect;
 }