Beispiel #1
0
        public static Entity CreatePlayerEntity(int currentTick)
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "You");

            // TODO: modify PlayerAIComponent to it doesn't, you know...need these.
            e.AddComponent(new PlayerAIComponent());
            e.AddComponent(AIRotationComponent.Create(.60, true));
            e.AddComponent(AIMoraleComponent.Create(100, 100));

            var statusEffectTrackerComponent = StatusEffectTrackerComponent.Create();

            e.AddComponent(ActionTimeComponent.Create(currentTick));
            e.AddComponent(AttackerComponent.Create(e.EntityId, power: 8, meleeAttack: 55, rangedAttack: 10)); // TODO: make player not Ares
            e.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: false));
            e.AddComponent(DefenderComponent.Create(baseDefense: 0, maxHp: 70, maxFooting: 95, meleeDefense: 30, rangedDefense: 60, isInvincible: false));
            e.AddComponent(DisplayComponent.Create(_texPlayerPath, "It's you!", false, ENTITY_Z_INDEX));
            e.AddComponent(FactionComponent.Create(FactionName.PLAYER));
            e.AddComponent(OnDeathComponent.Create(new List <string>()
            {
                OnDeathEffectType.PLAYER_DEFEAT
            }));
            e.AddComponent(PlayerComponent.Create(isInFormation: true));
            e.AddComponent(SpeedComponent.Create(baseSpeed: 100));
            e.AddComponent(statusEffectTrackerComponent);
            e.AddComponent(XPTrackerComponent.Create(levelUpBase: 200, levelUpFactor: 150));

            return(e);
        }
Beispiel #2
0
        public void IncludesEntityGroup()
        {
            var         component    = CollisionComponent.Create(false, false);
            JsonElement deserialized = JsonSerializer.Deserialize <JsonElement>(component.Save());

            Assert.Equal(CollisionComponent.ENTITY_GROUP, deserialized.GetProperty("EntityGroup").GetString());
        }
Beispiel #3
0
        public static Entity Create(string saveData)
        {
            var loaded = JsonSerializer.Deserialize <SaveData>(saveData);

            var entity = new Entity().Init(entityId: loaded.EntityId, entityName: loaded.EntityName);

            foreach (var component in loaded.Components)
            {
                entity.AddComponent(component);
            }

            // TODO: Formalize this into a "template" concept
            if (entity.EntityName == "boundary sign")
            {
                entity.AddComponent(CollisionComponent.Create(true, false));
                entity.AddComponent(DefenderComponent.Create(0, 100, logDamage: false, isInvincible: true));
                entity.AddComponent(DisplayComponent.Create("res://resources/sprites/edge_blocker.png", "Trying to run away, eh? Get back to your mission!", true, 2));
            }
            else if (entity.EntityName == "satellite")
            {
                entity.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: true));
                entity.AddComponent(DefenderComponent.Create(baseDefense: int.MaxValue, maxHp: int.MaxValue, isInvincible: true, logDamage: false));
                entity.AddComponent(DisplayComponent.Create("res://resources/sprites/asteroid.png", "Space junk. Blocks movement and projectiles. Cannot be destroyed.", true, 2));
            }

            return(entity);
        }
Beispiel #4
0
        public static Entity CreateSatelliteEntity()
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "satellite");

            e.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: true));
            e.AddComponent(DefenderComponent.Create(baseDefense: int.MaxValue, maxHp: int.MaxValue, isInvincible: true, logDamage: false));
            e.AddComponent(DisplayComponent.Create(_texSatellitePath, "Space junk. Blocks movement and projectiles. Cannot be destroyed.", true, ENTITY_Z_INDEX));

            return(e);
        }
Beispiel #5
0
        public static Entity CreateEdgeBlockerEntity()
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "boundary sign");

            e.AddComponent(CollisionComponent.Create(true, false));
            e.AddComponent(DefenderComponent.Create(0, 100, logDamage: false, isInvincible: true));
            e.AddComponent(DisplayComponent.Create(_texEdgeBlockerPath, "Trying to run away, eh? Get back to your mission!", true, ENTITY_Z_INDEX));

            return(e);
        }
Beispiel #6
0
        public void SerializesAndDeserializesCorrectly()
        {
            var    component = CollisionComponent.Create(true, false, true, true);
            string saved     = component.Save();

            var newComponent = CollisionComponent.Create(saved);

            Assert.Equal(component.BlocksMovement, newComponent.BlocksMovement);
            Assert.Equal(component.BlocksVision, newComponent.BlocksVision);
            Assert.Equal(component.OnCollisionAttack, newComponent.OnCollisionAttack);
            Assert.Equal(component.OnCollisionSelfDestruct, newComponent.OnCollisionSelfDestruct);
        }
Beispiel #7
0
        public static Entity CreateProjectileEntity(Entity source, ProjectileType type, int power, EncounterPath path, int speed, int currentTick)
        {
            var displayData = projectileTypeToProjectileDisplay[type];

            var e = CreateEntity(Guid.NewGuid().ToString(), displayData.Name);

            e.AddComponent(PathAIComponent.Create(path));

            e.AddComponent(ActionTimeComponent.Create(currentTick)); // Should it go instantly or should it wait for its turn...?
            e.AddComponent(AttackerComponent.Create(source.EntityId, power));
            e.AddComponent(CollisionComponent.Create(false, false, true, true));
            e.AddComponent(DisplayComponent.Create(displayData.TexturePath, "A projectile.", false, PROJECTILE_Z_INDEX));
            e.AddComponent(SpeedComponent.Create(speed));

            return(e);
        }
Beispiel #8
0
        public static Entity CreatePlayerEntity(int currentTick)
        {
            var e = CreateEntity(Guid.NewGuid().ToString(), "player");

            var statusEffectTrackerComponent = StatusEffectTrackerComponent.Create();

            e.AddComponent(ActionTimeComponent.Create(currentTick));
            e.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: false));
            e.AddComponent(DefenderComponent.Create(baseDefense: 0, maxHp: 100, isInvincible: false));
            e.AddComponent(DisplayComponent.Create(_texPlayerPath, "It's you!", false, ENTITY_Z_INDEX));
            e.AddComponent(InventoryComponent.Create(inventorySize: 26));
            e.AddComponent(OnDeathComponent.Create(new List <string>()
            {
                OnDeathEffectType.PLAYER_DEFEAT
            }));
            e.AddComponent(PlayerComponent.Create());
            e.AddComponent(SpeedComponent.Create(baseSpeed: 100));
            e.AddComponent(statusEffectTrackerComponent);
            e.AddComponent(XPTrackerComponent.Create(levelUpBase: 200, levelUpFactor: 150));

            return(e);
        }