Exemplo n.º 1
0
        private void SetupAnimControllerFactory()
        {
            // Each underlying prefab type defines an underlying 'animation archetype', which beatblock archetypes will map to.
            // We expect some amount of IAnimControllerConfigurationScripts to be attached to this config object, which will define the animation prefabs,
            // and thus define the animation archetypes. Each prefab will also contain data detailing which BeatBlock types use them!
            int currAnimationArchetypeId = 0;
            Dictionary <int, int> BeatBlockToAnimationTypeMapping = new Dictionary <int, int>();
            Dictionary <int, IAnimControllerConfigurationScript> AnimationArcheTypeToControllerFactoryFunctionMapping = new Dictionary <int, IAnimControllerConfigurationScript>();
            List <IObjectPool <AnimationObject> > prefabPools = new List <IObjectPool <AnimationObject> >();

            foreach (IAnimControllerConfigurationScript config in GetComponents <IAnimControllerConfigurationScript>())
            {
                foreach (AnimationObject prefab in config.GetPrefabs())
                {
                    // Each prefab type is pooled individually.
                    var newPool = MakeNewPool(prefab);

                    // Store this new subpool in the global list (which will later be passed into the categorical pool when that is constructed)
                    prefabPools.Insert(currAnimationArchetypeId, newPool);

                    // Add a mapping refence for all the BeatBlock types which will end up using this.
                    foreach (int bbType in prefab.BeatBlockTypesWhichUseThis)
                    {
                        BeatBlockToAnimationTypeMapping.Add(bbType, currAnimationArchetypeId);
                    }

                    // Add a mapping reference to the config object capable of creating the correct Controller object for this animation archetype
                    AnimationArcheTypeToControllerFactoryFunctionMapping.Add(currAnimationArchetypeId, config);

                    // Increment!
                    currAnimationArchetypeId++;
                }
            }

            // Create the shared pool of animation prefab objects
            ICategoricalObjectPool <AnimationObject> animPrefabPool = new SimpleCategoricalObjectPool <AnimationObject>(currAnimationArchetypeId, prefabPools.ToArray());

            // Create the Animation controller factory!
            animControllerFactory = new AnimationControllerFactory(BeatBlockToAnimationTypeMapping, AnimationArcheTypeToControllerFactoryFunctionMapping, animPrefabPool);
        }
Exemplo n.º 2
0
        public SimpleBeatBlockArchetypeFactory(IArchetypeFactory <IAnimationGameObjectController> animControllerFactory,
                                               IArchetypeFactory <IHitboxGameObjectController> hitboxControllerFactory,
                                               IArchetypeFactory <GameSpaceOccupationOverTimeTemplate> animOccupationFactory,
                                               IArchetypeFactory <GameSpaceOccupationOverTimeTemplate> hitboxOccupationFactory)
        {
            builder          = new BeatBlockBuilder_Recyclable();
            animCurveFactory = new AnimationCurveArchetypeFactory();

            builderFuncs = new Func <BeatBlock> [NumArchetypes];
            builderFuncs[BeatBlockArchetypes.ONE_BEAT_SMALL_BLOCK] = () => {
                int blockType = BeatBlockArchetypes.ONE_BEAT_SMALL_BLOCK;

                // Make sure we don't have carried over properties
                builder.ResetBuilder();

                // Set properties for the beat block type
                builder.TypeId(blockType)
                .Speed(1)
                .HitboxPlaybackSpeed(1)
                .Intensity(5)
                .AnimationCurve(animCurveFactory.BuildArchetype(ArchetypeMappings.AnimCurve(blockType)))
                .Comboable(false)
                .ComboFactor(1)
                .LayoutLayer(1)
                .SizeScalable(false)
                .SizeScalingFactor(1)
                .HitBoxSpaceOccupation(hitboxOccupationFactory.BuildArchetype(blockType))
                .AnimationSpaceOccupation(animOccupationFactory.BuildArchetype(blockType))
                .AnimationGameObjectController(animControllerFactory.BuildArchetype(blockType))
                .HitBoxGameObjectController(hitboxControllerFactory.BuildArchetype(blockType));

                return(builder.Build());
            };
            builderFuncs[BeatBlockArchetypes.TWO_BEAT_SMALL_BLOCK] = () => {
                int blockType = BeatBlockArchetypes.TWO_BEAT_SMALL_BLOCK;

                // Make sure we don't have carried over properties
                builder.ResetBuilder();

                // Set properties for the beat block type
                builder.TypeId(blockType)
                .Speed(2)
                .HitboxPlaybackSpeed(1)
                .Intensity(2)
                .AnimationCurve(animCurveFactory.BuildArchetype(ArchetypeMappings.AnimCurve(blockType)))
                .Comboable(false)
                .ComboFactor(1)
                .LayoutLayer(1)
                .SizeScalable(false)
                .SizeScalingFactor(1)
                .HitBoxSpaceOccupation(hitboxOccupationFactory.BuildArchetype(blockType))
                .AnimationSpaceOccupation(animOccupationFactory.BuildArchetype(blockType))
                .AnimationGameObjectController(animControllerFactory.BuildArchetype(blockType))
                .HitBoxGameObjectController(hitboxControllerFactory.BuildArchetype(blockType));

                return(builder.Build());
            };
            builderFuncs[BeatBlockArchetypes.ONE_BEAT_BIG_BLOCK] = () => {
                int blockType = BeatBlockArchetypes.ONE_BEAT_BIG_BLOCK;

                // Make sure we don't have carried over properties
                builder.ResetBuilder();

                // Set properties for the beat block type
                builder.TypeId(blockType)
                .Speed(1)
                .HitboxPlaybackSpeed(1)
                .Intensity(7)
                .AnimationCurve(animCurveFactory.BuildArchetype(ArchetypeMappings.AnimCurve(blockType)))
                .Comboable(false)
                .ComboFactor(1)
                .LayoutLayer(1)
                .SizeScalable(false)
                .SizeScalingFactor(1)
                .HitBoxSpaceOccupation(hitboxOccupationFactory.BuildArchetype(blockType))
                .AnimationSpaceOccupation(animOccupationFactory.BuildArchetype(blockType))
                .AnimationGameObjectController(animControllerFactory.BuildArchetype(blockType))
                .HitBoxGameObjectController(hitboxControllerFactory.BuildArchetype(blockType));

                return(builder.Build());
            };
            builderFuncs[BeatBlockArchetypes.TWO_BEAT_BIG_BLOCK] = () => {
                int blockType = BeatBlockArchetypes.TWO_BEAT_BIG_BLOCK;

                // Make sure we don't have carried over properties
                builder.ResetBuilder();

                // Set properties for the beat block type
                builder.TypeId(blockType)
                .Speed(2)
                .HitboxPlaybackSpeed(1)
                .Intensity(3)
                .AnimationCurve(animCurveFactory.BuildArchetype(ArchetypeMappings.AnimCurve(blockType)))
                .Comboable(false)
                .ComboFactor(1)
                .LayoutLayer(1)
                .SizeScalable(false)
                .SizeScalingFactor(1)
                .HitBoxSpaceOccupation(hitboxOccupationFactory.BuildArchetype(blockType))
                .AnimationSpaceOccupation(animOccupationFactory.BuildArchetype(blockType))
                .AnimationGameObjectController(animControllerFactory.BuildArchetype(blockType))
                .HitBoxGameObjectController(hitboxControllerFactory.BuildArchetype(blockType));

                return(builder.Build());
            };
        }