Пример #1
0
        private void StopAndRemoveBuff(Buff curentBuff)
        {
            if (curentBuff.BuffUsed)
            {
                ItemArrmor += curentBuff.MinusArmor;
                ItemArrmor -= curentBuff.Armor;


                OrijSpeed -= curentBuff.SpeedSlow;
                //Speed -= Buffs[i].SpeedSlow;

                // if (OrijAttackSpeed == AttackSpeed - Buffs[i].AttackSpeedSlow)
                ///Значит нет никаких воздействий на героя
                OrijAttackSpeed -= curentBuff.AttackSpeedSlow;
                OrijAttackSpeed += curentBuff.AttackSpeed;

                curentBuff.BuffUsed = false;
            }

            Buffs.Remove(curentBuff);    ///Время действия бафа истекло

            if (!Buffs.Any(p => p.Stun)) ///Если на юнит не воздействуют другие станы
            {
                IsUnitStun = false;
            }

            UpdateView();
        }
Пример #2
0
 public bool HasBuff(BuffType type)
 {
     lock (Buffs)
     {
         return(Buffs.Any(s => s.Card.BuffType == type));
     }
 }
Пример #3
0
    /// <summary>
    /// Method is called at the start of each turn.
    /// </summary>
    public virtual void OnTurnStart()
    {
        MovementPoints = TotalMovementPoints;
        ActionPoints   = TotalActionPoints;
        Cell.Occupent  = this;
        if (Buffs.Any())
        {
            List <Buff> dotlist = Buffs.FindAll(b => b.isDot);
            if (dotlist != null)
            {
                foreach (Buff b in dotlist)
                {
                    b.Trigger(this);
                }
            }
        }
        if (TotalHitPoints == 120)
        {
            WarriorBuff warbuff = new WarriorBuff();
            warbuff.Apply(this);
        }
        SetState(new UnitStateMarkedAsFriendly(this));
        Animator anim = GetComponentInChildren <Animator>();

        anim.SetBool("Attack", false);
        anim.SetBool("Skill", false);
        anim.SetBool("Idle", true);
    }
Пример #4
0
        public bool HasBuff(string buff)
        {
            if (Buffs == null || Buffs.Count == 0)
            {
                return(false);
            }

            return(Buffs.Any(i => i.Has(buff)));
        }
Пример #5
0
        public void AddBuff(Buff.Buff indicator)
        {
            if (indicator?.Card == null || indicator.Card.BuffType == BuffType.Bad &&
                Buffs.Any(b => b.Card.CardId == indicator.Card.CardId))
            {
                return;
            }

            Buffs.RemoveWhere(s => !s.Card.CardId.Equals(indicator.Card.CardId), out ConcurrentBag <Buff.Buff> buffs);
            Buffs = buffs;
            int randomTime = 0;

            if (Session is Character character)
            {
                randomTime = RandomTimeBuffs(indicator);

                if (!indicator.StaticBuff)
                {
                    character.Session.SendPacket(
                        $"bf 1 {character.CharacterId} {(character.ChargeValue > 7000 ? 7000 : character.ChargeValue)}.{indicator.Card.CardId}.{(indicator.Card.Duration == 0 ? randomTime : indicator.Card.Duration)} {Level}");
                    character.Session.SendPacket(character.GenerateSay(
                                                     string.Format(Language.Instance.GetMessageFromKey("UNDER_EFFECT"), indicator.Card.Name), 20));
                }
            }

            if (!indicator.StaticBuff)
            {
                indicator.RemainingTime = indicator.Card.Duration == 0 ? randomTime : indicator.Card.Duration;
                indicator.Start         = DateTime.Now;
            }

            Buffs.Add(indicator);
            indicator.Card.BCards.ForEach(c => c.ApplyBCards(Entity));

            if (indicator.Card.EffectId > 0)
            {
                //Entity.MapInstance?.Broadcast(Entity.GenerateEff(indicator.Card.EffectId));
            }

            if (ObservableBag.TryGetValue(indicator.Card.CardId, out IDisposable value))
            {
                value?.Dispose();
            }

            ObservableBag[indicator.Card.CardId] = Observable
                                                   .Timer(TimeSpan.FromMilliseconds(indicator.RemainingTime * (indicator.StaticBuff ? 1000 : 100)))
                                                   .Subscribe(o =>
            {
                RemoveBuff(indicator.Card.CardId);
                if (indicator.Card.TimeoutBuff != 0 &&
                    ServerManager.Instance.RandomNumber() < indicator.Card.TimeoutBuffChance)
                {
                    AddBuff(new Buff.Buff(indicator.Card.TimeoutBuff, Level));
                }
            });
        }
Пример #6
0
 public bool HasBuff(CardType type, byte subtype, bool removeWeaponEffects = false)
 {
     if (removeWeaponEffects)
     {
         return(Buffs.Any(buff => buff.Card.BCards.Any(b =>
                                                       b.Type == (byte)type && b.SubType == subtype &&
                                                       (b.CastType != 1 ||
                                                        b.CastType == 1 && buff.Start.AddMilliseconds(buff.Card.Delay * 100) < DateTime.Now))));
     }
     return(Buffs.Any(buff => buff.Card.BCards.Any(b => b.Type == (byte)type && b.SubType == subtype && (b.CastType != 1 || b.CastType == 1 && buff.Start.AddMilliseconds(buff.Card.Delay * 100) < DateTime.Now))) ||
            StaticBcards.Any(s => s.Type.Equals((byte)type) && s.SubType.Equals(subtype)));
 }
Пример #7
0
        public bool Tick()
        {
            Auras = GetAuras();

            if (Auras == null || Auras.Length == 0)
            {
                return(false);
            }

            if (Buffs != null)
            {
                if (BuffsToKeepActive?.Count > 0)
                {
                    foreach (KeyValuePair <string, CastFunction> keyValuePair in BuffsToKeepActive)
                    {
                        if (!Buffs.Any(e => e.SpellId != 0 && e.Name.Equals(keyValuePair.Key, StringComparison.OrdinalIgnoreCase)) &&
                            keyValuePair.Value())
                        {
                            return(true);
                        }
                    }
                }

                if (Buffs.Length > 0 && DispellBuffs != null)
                {
                    DispellBuffs();
                }
            }

            if (Debuffs != null)
            {
                if (DebuffsToKeepActive?.Count > 0)
                {
                    foreach (KeyValuePair <string, CastFunction> keyValuePair in DebuffsToKeepActive)
                    {
                        if (!Debuffs.Any(e => e.SpellId != 0 && e.Name.Equals(keyValuePair.Key, StringComparison.OrdinalIgnoreCase)) &&
                            keyValuePair.Value())
                        {
                            return(true);
                        }
                    }
                }

                if (Debuffs.Length > 0 && DispellDebuffs != null)
                {
                    // DispellDebuffs();
                }
            }

            return(false);
        }
Пример #8
0
        public bool Tick(bool forceUpdate = false)
        {
            if (DateTime.Now - LastBuffUpdate > MinUpdateTime ||
                forceUpdate)
            {
                Buffs          = GetBuffs();
                Debuffs        = GetDebuffs();
                LastBuffUpdate = DateTime.Now;
            }

            if (BuffsToKeepActive?.Count > 0 && Buffs != null)
            {
                foreach (KeyValuePair <string, CastFunction> keyValuePair in BuffsToKeepActive)
                {
                    if (!Buffs.Any(e => e.Equals(keyValuePair.Key, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (keyValuePair.Value.Invoke())
                        {
                            return(true);
                        }
                    }
                }
            }

            if (Buffs?.Count > 0 && DispellBuffs != null)
            {
                DispellBuffs.Invoke();
            }

            if (DebuffsToKeepActive?.Count > 0 && Debuffs != null)
            {
                foreach (KeyValuePair <string, CastFunction> keyValuePair in DebuffsToKeepActive)
                {
                    if (!Debuffs.Any(e => e.Equals(keyValuePair.Key, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (keyValuePair.Value.Invoke())
                        {
                            return(true);
                        }
                    }
                }
            }

            if (Debuffs?.Count > 0 && DispellDebuffs != null)
            {
                DispellDebuffs.Invoke();
            }

            return(false);
        }
Пример #9
0
        public override void StartDay(GameDate thisDate)
        {
            PriceHistory.Add(Price);

            if (Buffs.Any(buff => buff is RedBuff))
            {
                //Todo:ChangeToUseAnotherController
            }
            PriceController.StartDay(thisDate);
            TodayAnticipate = PriceController.GetPrice( );
            Price           = new StockPrice(TodayAnticipate.OpenPrice,
                                             TodayAnticipate.OpenPrice,
                                             TodayAnticipate.OpenPrice,
                                             TodayAnticipate.OpenPrice,
                                             0,
                                             0);
        }
Пример #10
0
        private void StopAndRemoveBuff(Buff currentBuff)
        {
            if (currentBuff.BuffUsed)
            {
                Arrmor += currentBuff.MinusArmor;
                Arrmor -= currentBuff.Armor;
                currentBuff.BuffUsed = false;
                OrijAttackSpeed     -= currentBuff.AttackSpeedSlow;
                OrijAttackSpeed     += currentBuff.AttackSpeed;
                Speed = Speed - currentBuff.SpeedSlow;
            }
            Buffs.Remove(currentBuff);   ///Время действия бафа истекло

            if (!Buffs.Any(p => p.Stun)) ///Если на юнит не воздействуют другие станы
            {
                IsUnitStun = false;
            }
        }
Пример #11
0
 public bool IsSlept(BattleSkill skill = null)
 {
     return(Buffs.Any(b => b.IsFinish == false && b.ActionInfo.actionType == eActionType.sleep && b.Skill != skill));
 }
Пример #12
0
 public bool IsStunned(BattleSkill skill = null)
 {
     return(Buffs.Any(b => b.IsFinish == false && (b.ActionInfo.actionType == eActionType.stun || b.ActionInfo.actionType == eActionType.hidden) && b.Skill != skill));
 }
Пример #13
0
 public bool IsHidden()
 {
     return(Buffs.Any(b => b.IsFinish == false && b.ActionInfo.actionType == eActionType.hidden));
 }
Пример #14
0
        public override void Update(GameTime gameTime)
        {
            var origX = X;
            var origY = Y;

            if (!IsAlive)
            {
                Velocity  = Vector2.Zero;
                Speed     = 0;
                Knockback = null;
            }
            else
            {
                Speed = BaseSpeed;

                if (this is Zerd)
                {
                    Speed *= this.SkillValue(SkillType.Swiftness, true);
                }

                Buffs.ForEach(b =>
                {
                    Speed     += b.MovementSpeedFactor;
                    var damage = b.DamagePerSecond * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                    if (damage > 0)
                    {
                        new DamageInstance(null, damage, b.DamageType, b.Applier, b.AbilityType, false).DamageBeing(this);
                    }
                    b.TimeRemaining = b.TimeRemaining.SubtractWithGameSpeed(gameTime.ElapsedGameTime);
                    if (b is DashBuff && this is Zerd && ((Zerd)this).SkillPoints(SkillType.ColdWinds) > 0)
                    {
                        foreach (var e in this.Enemies().Where(e => e.Buffs.All(b2 => !(b2 is FrozenBuff)) && e.Hitbox().Any(h => Hitbox().Any(h.Intersects))))
                        {
                            e.AddBuff(new FrozenBuff(e, TimeSpan.FromSeconds(((Zerd)this).SkillValue(SkillType.ColdWinds, false))));
                        }
                    }
                });

                if (Buffs.Any(b => b is SprintBuff) && this is Zerd)
                {
                    Speed *= 1 + ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.SprintSpeed] / 100;
                }
                else if (this is Zerd)
                {
                    Speed *= 1 + ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.MovementSpeed] / 100;
                }

                Speed = MathHelper.Clamp(Speed, GameplayConstants.MinSpeed, GameplayConstants.MaxSpeed);

                Buffs.ForEach(b => Speed = b.Frozen ? 0 : Speed);

                Buffs = Buffs.Where(b => b.TimeRemaining > TimeSpan.Zero).ToList();

                Health += HealthRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                if (this is Zerd)
                {
                    Health += HealthRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed *
                              ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.HealthRegen] / 100;
                }
                Mana += ManaRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                if (this is Zerd)
                {
                    Mana += ManaRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed *
                            ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.ManaRegen] / 100;
                }

                if (Knockback == null)
                {
                    var angle = Velocity.AngleBetween(Facing);
                    Speed *= angle < GameplayConstants.ZerdFrontFacingAngle ? 1 : angle > 180 - GameplayConstants.ZerdFrontFacingAngle ? GameplayConstants.BackpedalFactor : GameplayConstants.SideStepFactor;
                    if (Velocity.Length() > 0.01)
                    {
                        X += Velocity.X * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                        Y -= Velocity.Y * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                    }
                }
                else
                {
                    if (Knockback.Speed > 0 && Knockback.MaxDuration > TimeSpan.Zero)
                    {
                        X += (int)(Knockback.Direction.X * Knockback.Speed * gameTime.ElapsedGameTime.TotalSeconds *
                                   (float)Math.Pow(Knockback.Duration.TotalMilliseconds / Knockback.MaxDuration.TotalMilliseconds, GameplayConstants.KnockbackDecay)) *
                             Globals.GameState.GameSpeed;
                        Y += (int)(Knockback.Direction.Y * Knockback.Speed * gameTime.ElapsedGameTime.TotalSeconds *
                                   (float)Math.Pow(Knockback.Duration.TotalMilliseconds / Knockback.MaxDuration.TotalMilliseconds, GameplayConstants.KnockbackDecay)) *
                             Globals.GameState.GameSpeed;
                    }
                    Knockback.Duration = Knockback.Duration.SubtractWithGameSpeed(gameTime.ElapsedGameTime);
                    if (Knockback.Duration < TimeSpan.Zero)
                    {
                        Knockback = null;
                    }
                }

                Health = MathHelper.Clamp(Health, 0, MaxHealth);
                Mana   = MathHelper.Clamp(Mana, 0, MaxMana);
            }

            // If we tried to move make sure we aren't hitting anything, else reject the move (only reject one dimension if needed)
            if (X != origX || Y != origY)
            {
                if (Globals.Map.CollidesWithWall(this))
                {
                    var newX = X;
                    var newY = Y;
                    X = origX;
                    // Try just moving the Y
                    if (Globals.Map.CollidesWithWall(this))
                    {
                        X = newX;
                        Y = origY;
                        // Try just moving the X
                        if (Globals.Map.CollidesWithWall(this))
                        {
                            // Can't move either axis
                            X = origX;
                        }
                    }
                }
            }

            GetCurrentAnimation().Update(gameTime);
            Buffs.ForEach(b => b.Update(gameTime));
        }
Пример #15
0
 public override List <Rectangle> Hitbox()
 {
     return(Buffs.Any(b => b.GrantsInvulnerability) ? new List <Rectangle>() : new List <Rectangle> {
         this.BasicHitbox()
     });
 }
Пример #16
0
        public override bool IsCritical(DamageTypes type, AbilityTypes ability)
        {
            var chance = CriticalChance;

            if (type == DamageTypes.Fire)
            {
                chance += this.SkillValue(SkillType.Devastation, false) / 100;
            }
            if (ability == AbilityTypes.Iceball)
            {
                chance += this.AbilityValue(AbilityUpgradeType.IceballCrit) / 100;
            }
            if ((ability == AbilityTypes.Iceball || ability == AbilityTypes.Fireball || ability == AbilityTypes.Wand) && Buffs.Any(b => b is RageBuff))
            {
                var buff = Buffs.First(b => b is RageBuff);
                Buffs.Remove(buff);
                chance += buff.CritChanceFactor;
            }
            return(Globals.Random.NextDouble() < chance);
        }