示例#1
0
        public Views.EntityBaseView GetEntityById(int entityId)
        {
            if (GameServer.GetScene().Mode != SceneMode.Game)
            {
                return new Views.EntityBaseView()
                       {
                           ID = -1
                       }
            }
            ;

            Entities.EntityBase entity = GetMap().GetEntityById(entityId);
            if (entity == null)
            {
                return new Views.EntityBaseView()
                       {
                           ID = -1
                       }
            }
            ;

            if (Hero.HasSightOn(entity))
            {
                Views.EntityBaseView view = EToView(entity);

                return(view);
            }
            else
            {
                return(new Views.EntityBaseView()
                {
                    ID = -1
                });
            }
        }
示例#2
0
        public void SaveMetadata(Entities.EntityBase entity, string connectionString)
        {
            SaveModes sm = SaveModes.New;

            try
            {
                if (entity.IsNewDescription)
                {
                    sm = SaveModes.New;
                }
                else
                {
                    sm = SaveModes.Update;
                }

                if (string.IsNullOrEmpty(entity.Description))
                {
                    sm = SaveModes.Delete;
                }

                if (entity.HasChanges)
                {
                    SaveDescription(sm, connectionString, entity.Level1Type, entity.Description, entity.Schema, entity.Level1Name, entity.Level2Type, entity.Level2Name);
                    entity.IsNewDescription = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
 /// <summary>
 /// Transforme l'entité en vue.
 /// </summary>
 public Views.EntityBaseView EToView(Entities.EntityBase entity)
 {
     Views.EntityBaseView view = new Views.EntityBaseView();
     view.BaseHPRegen           = entity.BaseHPRegen;
     view.BaseAbilityPower      = entity.BaseAbilityPower;
     view.BaseArmor             = entity.BaseArmor;
     view.BaseAttackDamage      = entity.BaseAttackDamage;
     view.BaseAttackSpeed       = entity.BaseAttackSpeed;
     view.BaseCooldownReduction = entity.BaseCooldownReduction;
     view.BaseMagicResist       = entity.BaseMagicResist;
     view.BaseMaxHP             = entity.BaseMaxHP;
     view.BaseMoveSpeed         = entity.BaseMoveSpeed;
     view.Direction             = V2ToView(entity.Direction);
     view.GetAbilityPower       = entity.GetAbilityPower();
     view.GetArmor             = entity.GetArmor();
     view.GetAttackDamage      = entity.GetAttackDamage();
     view.GetCooldownReduction = entity.GetCooldownReduction();
     view.GetHP              = entity.GetHP();
     view.GetMagicResist     = entity.GetMagicResist();
     view.GetMaxHP           = entity.GetMaxHP();
     view.GetMoveSpeed       = entity.GetMoveSpeed();
     view.GetHPRegen         = entity.GetHPRegen();
     view.UniquePassive      = (Views.EntityUniquePassives)entity.UniquePassive;
     view.UniquePassiveLevel = entity.UniquePassiveLevel;
     view.HasTrueVision      = entity.HasTrueVision;
     view.HasWardVision      = entity.HasWardVision;
     view.HP              = entity.HP;
     view.ID              = entity.ID;
     view.IsDead          = entity.IsDead;
     view.IsRooted        = entity.IsRooted;
     view.IsSilenced      = entity.IsSilenced;
     view.IsStealthed     = entity.IsStealthed;
     view.IsStuned        = entity.IsStuned;
     view.IsDamageImmune  = entity.IsDamageImmune;
     view.IsControlImmune = entity.IsControlImmune;
     view.Role            = (Views.EntityHeroRole)entity.Role;
     view.Position        = V2ToView(entity.Position);
     view.ShieldPoints    = entity.ShieldPoints;
     view.Type            = (Views.EntityTypeRelative)(Entities.EntityTypeConverter.ToRelative(entity.Type, Hero.Type & Entities.EntityType.Teams));
     view.VisionRange     = entity.VisionRange;
     return(view);
 }
示例#4
0
        public Views.SpellUseResult UseMyWeapon(int entityId)
        {
            if (GameServer.GetScene().Mode != SceneMode.Game)
            {
                return(Views.SpellUseResult.InvalidOperation);
            }

            if (Hero.Weapon == null)
            {
                return(Views.SpellUseResult.InvalidOperation);
            }

            Entities.EntityBase entity = GameServer.GetMap().GetEntityById(entityId);
            if (entity == null)
            {
                return(Views.SpellUseResult.InvalidTarget);
            }

            return((Views.SpellUseResult)Hero.Weapon.Use(this.Hero, entity));
        }
示例#5
0
        /// <summary>
        /// Demande une utilisation de l'arme.
        /// Retourne true si l'utilisation a réussi, false sinon.
        /// </summary>
        /// <param name="hero"></param>
        /// <returns></returns>
        public Spells.SpellUseResult Use(Entities.EntityHero hero, Entities.EntityBase entity)
        {
            // Vérifie que le cooldown de l'arme est à 0.
            if (m_cooldownSeconds > float.Epsilon)
            {
                return(Spells.SpellUseResult.OnCooldown);
            }
            if (hero.IsBlind)
            {
                return(Spells.SpellUseResult.Blind);
            }

            m_cooldownSeconds = 1.0f / Math.Max(hero.GetAttackSpeed(), 0.2f);

            Spells.SpellLevelDescription attackSpell = GetAttackSpell();
            Spells.WeaponAttackSpell     spell       = new Spells.WeaponAttackSpell(hero, attackSpell, Enchant);
            return(spell.Use(new Spells.SpellCastTargetInfo()
            {
                Type = Spells.TargettingType.Targetted, TargetId = entity.ID
            }, true));
        }
示例#6
0
        /// <summary>
        /// Si un monstre du camp a été aggro, fait en sorte que les autres
        /// le soient aussi.
        /// </summary>
        void DispatchAgro()
        {
            // Recherche d'une aggro parmi les monstres du camp.
            Entities.EntityBase aggro = null;
            foreach (var monster in m_monsters)
            {
                if (monster.CurrentAggro != null)
                {
                    aggro = monster.CurrentAggro;
                }
            }

            // Transfert de l'aggro à tous les monstres sans aggro.
            if (aggro != null)
            {
                foreach (var monster in m_monsters)
                {
                    if (monster.CurrentAggro == null)
                    {
                        monster.CurrentAggro = aggro;
                    }
                }
            }
        }
示例#7
0
 /// <summary>
 /// Se produit lorsqu'un des monstre du camp meurt.
 /// Mémorise le tueur du camp.
 /// </summary>
 void EventCamp_OnDie(Entities.EntityBase entity, Entities.EntityHero killer)
 {
     m_lastKiller = killer;
 }
示例#8
0
        /// <summary>
        /// Mets à jour ce sort.
        /// </summary>
        public override void Update(GameTime time)
        {
            if (IsDisposing)
            {
                return;
            }

            // Supprime le spell une fois que sa durée est terminée.
            if (m_time > SourceSpell.Description.TargetType.Duration)
            {
                IsDisposing = true;
                m_canTouch  = false;
                return;
            }

            m_time += (float)time.ElapsedGameTime.TotalSeconds;
            float speed = (float)time.ElapsedGameTime.TotalSeconds * SourceSpell.Description.TargetType.Range / SourceSpell.Description.TargetType.Duration; // distance / temps

            // Mouvement du sort.
            switch (SourceSpell.Description.TargetType.Type)
            {
            // Direction : on avance dans la direction de cast.
            case Spells.TargettingType.Direction:
                m_shape.Position += m_castInfo.TargetDirection * speed;
                m_canTouch        = true;
                break;

            // Position : on reste à la position de cast :D
            case Spells.TargettingType.Position:
                m_shape.Position = m_castInfo.TargetPosition;
                m_canTouch       = true;
                break;

            // Targetted : on avance vers la cible.
            case Spells.TargettingType.Targetted:
                if (GameServer.GetMap().GetEntityById(m_castInfo.TargetId) == null)
                {
                    IsDisposing = true;
                    return;
                }

                if (SourceSpell.Description.TargetType.Duration == 0)
                {
                    // Duration 0 : sort instant.
                    Entities.EntityBase dst = GameServer.GetMap().GetEntityById(m_castInfo.TargetId);
                    m_shape.Position = dst.Position;
                    m_canTouch       = true;
                    OnCollide(dst);
                }
                else
                {
                    Vector2 dstPos = GameServer.GetMap().GetEntityById(m_castInfo.TargetId).Position;
                    Vector2 dir    = GameServer.GetMap().GetEntityById(m_castInfo.TargetId).Position - m_shape.Position;
                    dir.Normalize();
                    m_shape.Position += dir * speed;
                    if (Vector2.Distance(m_shape.Position, dstPos) <= speed)
                    {
                        m_shape.Position = dstPos;
                    }

                    m_canTouch = true;
                }

                break;
            }
        }