Example #1
0
        public void ResetPlayer(EntityCommandBuffer cb, Entity player, WorldCoord worldCoord, Translation translation)
        {
            CreatureDescription descr = CreatureDescriptions[(int)ECreatureId.Player];

            Creature c = new Creature {
                id = (int)ECreatureId.Player
            };
            HealthPoints hp = new HealthPoints {
                max = descr.health, now = descr.health
            };
            AttackStat att = new AttackStat {
                range = descr.attackRange
            };
            Level lvl = new Level {
                level = 1
            };
            ExperiencePoints exp = new ExperiencePoints {
                now = 0, next = LevelSystem.GetXPRequiredForLevel(1)
            };
            GoldCount gp = new GoldCount {
                count = 0
            };
            Mobile mobile = new Mobile {
                Destination = new float3(0, 0, 0), Initial = new float3(0, 0, 0), MoveTime = 0, Moving = false
            };
            Animated animated = new Animated {
                Id = descr.spriteId, Direction = Direction.Right, Action = Action.None, AnimationTime = 0, AnimationTrigger = false
            };
            Sight sight = new Sight {
                SightRadius = 4
            };
            TurnPriorityComponent tp = new TurnPriorityComponent {
                Value = -1
            };

            // Only tint sprites if ascii
            Sprite2DRenderer s = new Sprite2DRenderer();
            LayerSorting     l = new LayerSorting {
                order = 2
            };

            s.color  = GlobalGraphicsSettings.ascii ? descr.asciiColor : Color.Default;
            s.sprite = SpriteSystem.IndexSprites[SpriteSystem.ConvertToGraphics(descr.ascii)];
            l.layer  = 2;

            cb.SetComponent(player, s);
            cb.SetComponent(player, c);
            cb.SetComponent(player, l);
            cb.SetComponent(player, hp);
            cb.SetComponent(player, att);
            cb.SetComponent(player, lvl);
            cb.SetComponent(player, exp);
            cb.SetComponent(player, gp);
            cb.SetComponent(player, mobile);
            cb.SetComponent(player, animated);
            cb.SetComponent(player, sight);
            cb.SetComponent(player, worldCoord);
            cb.SetComponent(player, translation);
            cb.SetComponent(player, tp);
        }
Example #2
0
        public Entity SpawnPlayer(EntityManager entityManager)
        {
            Entity entity             = entityManager.CreateEntity(_playerArchetype);
            CreatureDescription descr = CreatureDescriptions[(int)ECreatureId.Player];

            Creature c = new Creature {
                id = (int)ECreatureId.Player
            };
            HealthPoints hp = new HealthPoints {
                max = descr.health, now = descr.health
            };
            AttackStat att = new AttackStat {
                range = descr.attackRange
            };
            Level lvl = new Level {
                level = 1
            };
            ExperiencePoints exp = new ExperiencePoints {
                now = 0, next = LevelSystem.GetXPRequiredForLevel(1)
            };
            GoldCount gp = new GoldCount {
                count = 0
            };
            Mobile mobile = new Mobile {
                Destination = new float3(0, 0, 0), Initial = new float3(0, 0, 0), MoveTime = 0, Moving = false
            };
            Animated animated = new Animated {
                Id = descr.spriteId, Direction = Direction.Right, Action = Action.None, AnimationTime = 0, AnimationTrigger = false
            };
            Sight sight = new Sight {
                SightRadius = 4
            };
            ArmorClass ac = new ArmorClass {
                AC = descr.ac
            };
            TurnPriorityComponent tp = new TurnPriorityComponent {
                Value = -1
            };

            // Only tint sprites if ascii
            Sprite2DRenderer s = new Sprite2DRenderer();
            LayerSorting     l = new LayerSorting {
                order = 2
            };

            s.color  = GlobalGraphicsSettings.ascii ? descr.asciiColor : Color.Default;
            s.sprite = SpriteSystem.IndexSprites[SpriteSystem.ConvertToGraphics(descr.ascii)];
            l.layer  = 2;

            entityManager.SetComponentData(entity, s);
            entityManager.SetComponentData(entity, c);
            entityManager.SetComponentData(entity, l);
            entityManager.SetComponentData(entity, hp);
            entityManager.SetComponentData(entity, att);
            entityManager.SetComponentData(entity, lvl);
            entityManager.SetComponentData(entity, exp);
            entityManager.SetComponentData(entity, gp);
            entityManager.SetComponentData(entity, mobile);
            entityManager.SetComponentData(entity, animated);
            entityManager.SetComponentData(entity, sight);
            entityManager.SetComponentData(entity, ac);
            entityManager.SetComponentData(entity, tp);

            return(entity);
        }