Esempio n. 1
0
        public void Initialize()
        {
            HealthIconAnimation = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.OwlHealthIcon);

            MoneyBagIconAnimation = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Bonbon_Gold);

            CrossAnimation = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross);

            DigitAnimations = new SpriteAnimationInstance[10];
            for (int digit = 0; digit < DigitAnimations.Length; digit++)
            {
                SpriteAnimationType animType = SpriteAnimationType.Digit0 + digit;
                DigitAnimations[digit] = SpriteAnimationFactory.CreateAnimationInstance(animType);
            }

            KeyRingAnchor.AttachTo(HealthIconAnchor);
            KeyRingAnchor.Position.Y += 64;

            KeyAnimations = new SpriteAnimationInstance[(int)KeyType.COUNT];
            for (int keyIndex = 0; keyIndex < KeyAnimations.Length; keyIndex++)
            {
                SpriteAnimationType animType = SpriteAnimationType.Key_Gold + keyIndex;
                KeyAnimations[keyIndex] = SpriteAnimationFactory.CreateAnimationInstance(animType);
            }
        }
Esempio n. 2
0
        public override void Initialize()
        {
            base.Initialize();

            foreach (SpriteAnimationType type in AnimationTypes)
            {
                SpriteAnimationInstance animation = SpriteAnimationFactory.CreateAnimationInstance(type);
                AnimationInstances.Add(type, animation);
            }

            ChangeActiveAnimation(AnimationTypes[0]);
        }
Esempio n. 3
0
        public Tankton()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Tankton_Idle_Left,
                    SpriteAnimationType.Tankton_Idle_Right,
                },
            };
            Animation.Spatial.Position.Y += Conversion.ToMeters(100);
            Animation.AttachTo(BodyComponent);

            Health = new HealthComponent(this)
            {
                MaxHealth = 20,
            };
            Health.OnHit   += OnHit;
            Health.OnDeath += OnDeath;

            HealthDisplay = new HealthDisplayComponent(this)
            {
                Health               = Health,
                HealthIcon           = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross),
                InitialDisplayOrigin = HealthDisplayComponent.DisplayOrigin.Bottom,
                NumIconsPerRow       = 5,
            };
            HealthDisplay.AttachTo(Animation);

            GameObjectFactory.CreateOnHitSquasher(this, Health, Animation).SetDefaultCurves(
                duration: HitDuration,
                extremeScale: new Vector2(0.9f, 1.1f));

            GameObjectFactory.CreateOnHitBlinkingSequence(this, Health, Animation).SetDefaultCurves(HitDuration);
        }
Esempio n. 4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Perf.Initialize((int)PerformanceSlots.COUNT, 120);

            SpriteAnimationFactory.Initialize(Content);
            GameObjectFactory.Initialize();

            World = new World(gravity: Vector2.Zero);

            PhysicsDebugView = new DebugView(World)
            {
                Flags   = (DebugViewFlags)int.MaxValue,
                Enabled = false,
            };

            base.Initialize();

#if DEBUG
            Window.AllowUserResizing = true;
#endif
        }
Esempio n. 5
0
        public Slurp()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Slurp_Idle_Left,
                    SpriteAnimationType.Slurp_Idle_Right,
                },
            };
            Animation.AttachTo(BodyComponent);

            Health = GameObjectFactory.CreateDefaultHealth(this,
                                                           maxHealth: 3,
                                                           hitDuration: HitDuration,
                                                           deathParticleTimeToLive: TimeSpan.FromSeconds(1));

            HealthDisplay = new HealthDisplayComponent(this)
            {
                Health = Health,
                InitialDisplayOrigin = HealthDisplayComponent.DisplayOrigin.Bottom,
                HealthIcon           = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross),
            };
            HealthDisplay.AttachTo(Animation);

            GameObjectFactory.CreateOnHitSquasher(this, Health, Animation).SetDefaultCurves(HitDuration);

            GameObjectFactory.CreateOnHitBlinkingSequence(this, Health, Animation).SetDefaultCurves(HitDuration);

            Homing = GameObjectFactory.CreateDefaultHomingCircle(this, BodyComponent,
                                                                 sensorRadius: 3.0f,
                                                                 homingType: HomingType.ConstantSpeed,
                                                                 homingSpeed: 0.5f);
        }
Esempio n. 6
0
        public Gate()
        {
            LeftEdgeOffset = new SpatialComponent(this);
            {
                SpriteAnimationData anim    = SpriteAnimationFactory.GetAnimation(SpriteAnimationType.Gate_Closed);
                Vector2             hotspot = anim.Config.Hotspot * anim.Config.Scale;
                float offset = Conversion.ToMeters(hotspot.X - 128);
                LeftEdgeOffset.Spatial.Position.X -= offset;
            }
            LeftEdgeOffset.AttachTo(this);

            InnerBodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            InnerBodyComponent.AttachTo(LeftEdgeOffset);

            OuterBodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            OuterBodyComponent.AttachTo(LeftEdgeOffset);

            Trigger = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            Trigger.AttachTo(this);

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Gate_Closed,
                    SpriteAnimationType.Gate_Open,
                },
            };
            Animation.AttachTo(this);
        }
Esempio n. 7
0
        public Singer()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            TargetSensor = new TargetSensorComponent(this)
            {
                SensorType                = TargetSensorType.Circle,
                CircleSensorRadius        = SensorReach,
                TargetCollisionCategories = CollisionCategory.Friendly,
            };
            TargetSensor.AttachTo(RootComponent);

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Singer_Idle_Left,
                    SpriteAnimationType.Singer_Idle_Right,
                },
            };
            Animation.AttachTo(RootComponent);

            Health = GameObjectFactory.CreateDefaultHealth(this,
                                                           maxHealth: 3,
                                                           hitDuration: HitDuration,
                                                           deathParticleTimeToLive: TimeSpan.FromSeconds(1));

            HealthDisplay = new HealthDisplayComponent(this)
            {
                Health     = Health,
                HealthIcon = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross),
            };
            HealthDisplay.AttachTo(Animation);
        }