コード例 #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
 /// <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);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Scriptopathe/codinsa2015
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            /*
             * using (Game1 game = new Game1())
             * {
             *  game.Run();
             * }*/
            string str = Console.ReadLine();

            TCPHelper.Initialize(Codinsa2015.Server.GameServer.__DEBUG_PORT, "127.0.0.1", str);
            State state = new State();

            Console.WriteLine("Client started...");

            // On récupère des données concernant la map.
            Views.GameStaticDataView data = state.GetStaticData();
            Console.WriteLine("Got static data");

            // On récupère les id de nos spells.
            List <int> mySpells = state.GetMySpells();

            Console.WriteLine("Got spells");
            int spellId = 0;

            while (true)
            {
                // On récupère les entités en vue.
                var entities = state.GetEntitiesInSight();
                Console.WriteLine("Entities in sight : " + entities.Count);
                if (entities.Count != 0)
                {
                    var entity = entities[0];
                    // Si le déplacement auto est terminé, on démarre un autre déplacement.
                    if (!state.IsAutoMoving())
                    {
                        Console.WriteLine("Moving to entity " + entity.ID + ", position = " + entity.Position);
                        state.StartMoveTo(entity.Position);
                    }

                    spellId++; spellId %= mySpells.Count;
                    // On récupère la description de notre sort : elle indique comment l'utiliser ainsi que ses
                    // caractéristiques.
                    Views.SpellLevelDescriptionView spell = state.GetMySpellCurrentLevelDescription(spellId);

                    Views.EntityBaseView e = state.GetEntityById(1);
                    var positionView       = state.GetMyPosition();

                    // Transformation des vector2 en vecteurs XNA.
                    Vector2 position       = new Vector2(positionView.X, positionView.Y);
                    Vector2 entityPosition = new Vector2(entity.Position.X, entity.Position.Y);

                    // On utilise le spell.
                    Console.WriteLine("Using spell n° " + spellId + ", targetting type = " + spell.TargetType.Type);
                    switch (spell.TargetType.Type)
                    {
                    case Views.TargettingType.Direction:
                        Vector2 dir = entityPosition - position;
                        dir.Normalize();
                        if (entityPosition == position)
                        {
                            dir = new Vector2(1, 0);
                        }

                        Views.Vector2 dirView = new Views.Vector2(dir.X, dir.Y);
                        state.UseMySpell(spellId, new Views.SpellCastTargetInfoView()
                        {
                            TargetDirection = dirView, Type = Views.TargettingType.Direction
                        });
                        break;

                    case Views.TargettingType.Position:
                        state.UseMySpell(spellId, new Views.SpellCastTargetInfoView()
                        {
                            TargetPosition = entity.Position, Type = Views.TargettingType.Position
                        });
                        break;

                    case Views.TargettingType.Targetted:
                        state.UseMySpell(spellId, new Views.SpellCastTargetInfoView()
                        {
                            TargetId = entity.ID, Type = Views.TargettingType.Targetted
                        });
                        break;
                    }
                }
            }
        }