コード例 #1
0
        private void CastSpell()
        {
            if (!Monster.CanCast)
            {
                return;
            }

            if (Monster != null && Monster.Target != null && SpellScripts.Count > 0)
            {
                if (_random.Next(1, 101) < ServerContext.Config.MonsterSpellSuccessRate)
                {
                    var spellidx = _random.Next(SpellScripts.Count);

                    if (SpellScripts[spellidx] != null)
                    {
                        SpellScripts[spellidx].OnUse(Monster, Target);
                    }
                }
            }

            if (Monster != null && Monster.Target != null && Monster.Target.CurrentHp > 0)
            {
                if (DefaultSpell != null)
                {
                    DefaultSpell.OnUse(Monster, Monster.Target);
                }
            }
        }
コード例 #2
0
        public RangeHero(HeroTable hero)
        {
            Talents.Add("L1", hero.TalentL1);
            Talents.Add("L2", hero.TalentL2);
            Talents.Add("L3", hero.TalentL3);
            Talents.Add("L4", hero.TalentL4);
            Talents.Add("R1", hero.TalentR1);
            Talents.Add("R2", hero.TalentR2);
            Talents.Add("R3", hero.TalentR3);
            Talents.Add("R4", hero.TalentR4);
            Name            = hero.Name;
            Hp              = hero.Hp;
            Mana            = hero.Mana;
            IncHp           = hero.IncHp;
            IncMana         = hero.IncMana;
            MainAttribute   = hero.MainAttribute;
            Strength        = hero.Strength;
            Agility         = hero.Agility;
            Intelligence    = hero.Intelligence;
            IncStrength     = hero.IncStrength;
            IncAgility      = hero.IncAgility;
            IncIntelligence = hero.IncIntelligence;
            Damage          = hero.Damage;
            Armor           = hero.Armor;
            AttackSpeed     = hero.AttackSpeed;
            Speed           = hero.Speed;
            Description     = hero.Description;
            AttackRange     = (int)hero.AttackRange;
            ProjectileSpeed = (int)hero.ProjectileSpeed;

            using (DotaBaseContext context = new DotaBaseContext())
            {
                List <AbilityTable> abilities = context.AbilityTable.ToList();
                DefaultSpell        First     = new DefaultSpell(abilities.First(x => x.Name == hero.FirstSpell));
                FirstSpell = First;

                DefaultSpell Second = new DefaultSpell(abilities.First(x => x.Name == hero.SecondSpell));
                SecondSpell = Second;

                DefaultSpell Third = new DefaultSpell(abilities.First(x => x.Name == hero.ThirdSpell));
                ThirdSpell = Third;

                Ultimate Ulti = new Ultimate(abilities.First(x => x.Name == hero.Ultimate));
                Ultimate = Ulti;
            }
        }