コード例 #1
0
ファイル: EntityFactory.cs プロジェクト: klutch/Loderpit
        // Shield of thorns spell entity
        public static int createShieldOfThornsSpell(int targetEntityId, string damageDie, float radius, List<Faction> factionsToAffect)
        {
            int entityId = EntityManager.createEntity();
            TrackEntityPositionComponent trackEntityPositionComponent = new TrackEntityPositionComponent(entityId, targetEntityId);
            AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId, factionsToAffect);
            DamageShieldComponent damageShieldComponent = new DamageShieldComponent(entityId, damageDie);
            AreaOfEffectComponent areaOfEffectComponent;
            Body sensor = BodyFactory.CreateCircle(SystemManager.physicsSystem.world, radius, 1f);

            sensor.UserData = entityId;
            sensor.CollidesWith = (ushort)CollisionCategory.None;
            sensor.BodyType = BodyType.Static;
            areaOfEffectComponent = new AreaOfEffectComponent(entityId, sensor);

            EntityManager.addComponent(entityId, trackEntityPositionComponent);
            EntityManager.addComponent(entityId, affectedEntitiesComponent);
            EntityManager.addComponent(entityId, damageShieldComponent);
            EntityManager.addComponent(entityId, areaOfEffectComponent);
            EntityManager.addComponent(entityId, new IgnoreBridgeRaycastComponent(entityId));
            EntityManager.addComponent(entityId, new IgnoreRopeRaycastComponent(entityId));

            return entityId;
        }
コード例 #2
0
ファイル: EntityFactory.cs プロジェクト: klutch/Loderpit
        // Create flame aura spell
        public static int createFlameAuraSpell(int targetId, float radius, string chanceToProc, string damageDie, int tickDelay, int tickCount, List<Faction> factionsToAffect)
        {
            int entityId = EntityManager.createEntity();
            PositionComponent positionComponent = EntityManager.getPositionComponent(targetId);
            TrackEntityPositionComponent trackEntityPositionComponent = new TrackEntityPositionComponent(entityId, targetId);
            AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId, factionsToAffect);
            AreaOfEffectComponent areaOfEffectComponent;
            Body sensor = BodyFactory.CreateCircle(SystemManager.physicsSystem.world, radius, 1f, positionComponent.position);
            Action<Skill, int, int> onHitOther;

            sensor.UserData = entityId;
            sensor.BodyType = BodyType.Static;
            sensor.CollidesWith = (ushort)CollisionCategory.None;
            areaOfEffectComponent = new AreaOfEffectComponent(entityId, sensor);

            onHitOther = (skill, attackerId, defenderId) =>
                {
                    // Skip if defender doesn't exist
                    if (!EntityManager.doesEntityExist(defenderId))
                    {
                        return;
                    }

                    if (Roller.roll(chanceToProc) == 1)
                    {
                        createDoTSpell(defenderId, DamageType.Fire, damageDie, tickDelay, tickCount);
                    }
                };

            EntityManager.addComponent(entityId, trackEntityPositionComponent);
            EntityManager.addComponent(entityId, affectedEntitiesComponent);
            EntityManager.addComponent(entityId, areaOfEffectComponent);
            EntityManager.addComponent(entityId, new ProcComponent(entityId, onHitOther, null));
            EntityManager.addComponent(entityId, new IgnoreBridgeRaycastComponent(entityId));
            EntityManager.addComponent(entityId, new IgnoreRopeRaycastComponent(entityId));

            return entityId;
        }