예제 #1
0
        public void IncludesEntityGroup()
        {
            var         component    = PlayerComponent.Create();
            JsonElement deserialized = JsonSerializer.Deserialize <JsonElement>(component.Save());

            Assert.Equal(PlayerComponent.ENTITY_GROUP, deserialized.GetProperty("EntityGroup").GetString());
        }
예제 #2
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);
        }
예제 #3
0
        public void EntityWithComponent()
        {
            Entity entity = Entity.Create("some id", "some name");

            entity.AddComponent(PlayerComponent.Create(baseCuttingLaserPower: 99));

            var saved  = JsonSerializer.Serialize(entity);
            var loaded = JsonSerializer.Deserialize <Entity>(saved);

            Assert.Equal(entity._Components.Count, loaded._Components.Count);
            Assert.NotNull(loaded.GetComponent <PlayerComponent>());
            Assert.Equal(99, loaded.GetComponent <PlayerComponent>().BaseCuttingLaserPower);
        }
예제 #4
0
        public void SerializesAndDeserializesAutopilotZoneCorrectly()
        {
            var zoneId = "123854";

            var component = PlayerComponent.Create();

            component.BeginAutoexploring(zoneId);

            string saved        = component.Save();
            var    newComponent = PlayerComponent.Create(saved);

            Assert.Equal(component.ActiveAutopilotMode, newComponent.ActiveAutopilotMode);
            Assert.Null(component.AutopilotPath);
            Assert.Equal(component.AutopilotPath, newComponent.AutopilotPath);
            Assert.Equal(component.AutopilotZoneId, newComponent.AutopilotZoneId);
        }
예제 #5
0
        public void PullsStatusEffectTrackerFromEntity()
        {
            var entity = Entity.Create("", "");

            var playerComponent = PlayerComponent.Create(baseCuttingLaserPower: 5);

            entity.AddComponent(playerComponent);

            var trackerComponent = new StatusEffectTrackerComponent();

            entity.AddComponent(trackerComponent);

            Assert.Equal(5, playerComponent.CuttingLaserPower);

            trackerComponent.AddEffect(new StatusEffectTimedPowerBoost(10, 5, 5));
            Assert.Equal(15, playerComponent.CuttingLaserPower);
        }
예제 #6
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);
        }
예제 #7
0
        public void SerializesAndDeserializesCorrectly()
        {
            var path = new EncounterPath(new List <EncounterPosition>()
            {
                new EncounterPosition(15, 53)
            });

            var component = PlayerComponent.Create();

            component.LayInAutopilotPathForTravel(path);
            component.RegisterIntel(3);
            string saved = component.Save();

            var newComponent = PlayerComponent.Create(saved);

            Assert.Equal(component.KnowsIntel(0), newComponent.KnowsIntel(0));
            Assert.Equal(component.KnowsIntel(1), newComponent.KnowsIntel(1));
            Assert.Equal(component.KnowsIntel(2), newComponent.KnowsIntel(2));
            Assert.Equal(component.KnowsIntel(3), newComponent.KnowsIntel(3));
            Assert.Equal(component.CuttingLaserRange, newComponent.CuttingLaserRange);
            Assert.Equal(component.BaseCuttingLaserPower, newComponent.BaseCuttingLaserPower);
            Assert.Equal(component.ActiveAutopilotMode, newComponent.ActiveAutopilotMode);
            Assert.Equal(component.AutopilotPath.CurrentPosition, newComponent.AutopilotPath.CurrentPosition);
        }