Пример #1
0
        public void SerializeAndDeserialize_WhenCurrentAnimationIsNull()
        {
            // Arrange
            var animation        = CreateAnimation();
            var animationAssetId = AssetId.CreateUnique();

            var component = new SpriteAnimationComponent();

            component.AddAnimation("animation", animation);
            component.Position      = 0.7;
            component.PlaybackSpeed = 1.3;
            component.PlayInLoop    = true;

            AssetStore.GetAssetId(animation).Returns(animationAssetId);
            AssetStore.GetAsset <SpriteAnimation>(animationAssetId).Returns(animation);

            // Act
            var actual = SerializeAndDeserialize(component);

            // Assert
            Assert.That(actual.Animations, Has.Count.EqualTo(1));
            Assert.That(actual.Animations.Single().Key, Is.EqualTo("animation"));
            Assert.That(actual.Animations.Single().Value, Is.EqualTo(animation));
            Assert.That(actual.CurrentAnimation, Is.Null);
            Assert.That(actual.IsPlaying, Is.False);
            Assert.That(actual.Position, Is.EqualTo(component.Position));
            Assert.That(actual.PlaybackSpeed, Is.EqualTo(component.PlaybackSpeed));
            Assert.That(actual.PlayInLoop, Is.EqualTo(component.PlayInLoop));
        }
        public void PlayAnimation_ShouldChangeCurrentAnimation_WhenOtherAnimationWasSet()
        {
            // Arrange
            const string name1      = "animation 1";
            var          animation1 = CreateAnimation();

            const string name2      = "animation 2";
            var          animation2 = CreateAnimation();

            var component = new SpriteAnimationComponent();

            component.AddAnimation(name1, animation1);
            component.AddAnimation(name2, animation2);
            component.PlayAnimation(name1);

            // Assume
            Assume.That(component.CurrentAnimation.HasValue, Is.True);

            // Act
            component.PlayAnimation(name2);

            // Assert
            Assert.That(component.CurrentAnimation.HasValue, Is.True);
            Debug.Assert(component.CurrentAnimation != null, "component.CurrentAnimation != null");
            Assert.That(component.CurrentAnimation.Value.Name, Is.EqualTo(name2));
            Assert.That(component.CurrentAnimation.Value.Animation, Is.EqualTo(animation2));
        }
Пример #3
0
        protected override void Initialize()
        {
            this.IsEnabledChanged += this.FoodComponent_IsEnabledChanged;
            this._player           = this.Scene.GetAllComponentsOfType <PlayerComponent>().First();
            this._spriteAnimator   = this.GetChild <SpriteAnimationComponent>();
            this._creatures.AddRange(this.Scene.GetAllComponentsOfType <CreatureComponent>());
            this._crunchAudioPlayer            = this.AddChild <AudioPlayer>();
            this._crunchAudioPlayer.ShouldLoop = false;
            this._crunchAudioPlayer.Volume     = 1f;

            this._hitAudioPlayer            = this.AddChild <AudioPlayer>();
            this._hitAudioPlayer.ShouldLoop = false;
            this._hitAudioPlayer.Volume     = 1f;

            if (this._spriteAnimator == null)
            {
                this._spriteAnimator = this.AddChild <SpriteAnimationComponent>();
            }

            this._spriteAnimator.DrawOrder = this.DrawOrder;

            this._spriteAnimator.SnapToPixels = true;
            this._spriteAnimator.FrameRate    = 16;

            if (this._animation != null)
            {
                this._spriteAnimator.Play(this._animation, true);
            }
        }
Пример #4
0
        void Animate(ref SpriteAnimationComponent spriteAnimationComponent)
        {
            if (spriteAnimationComponent.SourceRectangle == Rectangle.Empty || spriteAnimationComponent.SourceRectangle.Value.Width == 0 || spriteAnimationComponent.SourceRectangle.Value.Height == 0)
            {
                throw new ArgumentException($"The argument {nameof(spriteAnimationComponent.SourceRectangle)} cannot be Empty or Width or Height be equals Zero!");
            }

            if (!spriteAnimationComponent.IsPlaying)
            {
                return;
            }

            spriteAnimationComponent.ElapsedTime += (Scene.GameTime?.ElapsedGameTime).GetValueOrDefault();

            if (spriteAnimationComponent.ElapsedTime >= spriteAnimationComponent.FrameTime)
            {
                switch (spriteAnimationComponent.AnimateType)
                {
                case AnimateType.All:
                    AnimateAll(ref spriteAnimationComponent);
                    break;

                case AnimateType.PerRow:
                    AnimatePerRow(ref spriteAnimationComponent);
                    break;

                case AnimateType.PerColumn:
                    AnimatePerColumn(ref spriteAnimationComponent);
                    break;
                }

                spriteAnimationComponent.ElapsedTime = TimeSpan.Zero;
            }
        }
Пример #5
0
        public Entity CreateAnimatedSprite(Scene scene, double x, double y, Random random)
        {
            var entity = new Entity();

            scene.AddEntity(entity);

            entity.AddComponent(new Transform2DComponent
            {
                Translation = new Vector2(x, y),
                Rotation    = 0,
                Scale       = Vector2.One
            });
            entity.AddComponent(new SpriteRendererComponent());

            var spriteAnimationComponent = new SpriteAnimationComponent
            {
                PlayInLoop = true
            };

            entity.AddComponent(spriteAnimationComponent);

            spriteAnimationComponent.AddAnimation("Explosion", _assetStore.GetAsset <SpriteAnimation>(AssetsIds.ExplosionAnimation));
            spriteAnimationComponent.PlayAnimation("Explosion");
            spriteAnimationComponent.Position = random.NextDouble();

            return(entity);
        }
Пример #6
0
        private void UpdateAnimationState(StateChangeEvent stateChangeEvent)
        {
            var entityId = stateChangeEvent.EntityId;

            if (!ComponentManager.ContainsAllComponents(
                    entityId,
                    typeof(SpriteAnimationBindings)
                    ))
            {
                return;
            }
            var animationBindings = ComponentManager.GetEntityComponentOrDefault <SpriteAnimationBindings>(entityId);

            var spriteAnimation = ComponentManager.GetEntityComponentOrDefault <SpriteAnimationComponent>(entityId);

            if (spriteAnimation == null)
            {
                spriteAnimation = new SpriteAnimationComponent();
                ComponentManager.AddComponentToEntity(spriteAnimation, entityId);
                spriteAnimation.AnimationStarted = stateChangeEvent.EventTime;
            }

            var binding = animationBindings.Bindings
                          .FirstOrDefault(e => BindingsMatch(e.StateConditions, stateChangeEvent.NewState));

            if (binding == null)
            {
                spriteAnimation.NextAnimatedState = null;
            }
            else
            {
                spriteAnimation.NextAnimatedState = binding;
            }
        }
Пример #7
0
            private void CreateCampfireAnimation(double x, double y)
            {
                var campfire = new Entity();

                campfire.AddComponent(new Transform2DComponent
                {
                    Translation = new Vector2(x, y),
                    Rotation    = 0,
                    Scale       = Vector2.One
                });
                campfire.AddComponent(new SpriteRendererComponent());
                var spriteAnimationComponent = new SpriteAnimationComponent();

                campfire.AddComponent(spriteAnimationComponent);

                spriteAnimationComponent.AddAnimation("main", _assetStore.GetAsset <SpriteAnimation>(AssetsIds.CampfireAnimation));
                spriteAnimationComponent.PlayAnimation("main");
                spriteAnimationComponent.PlayInLoop = true;

                var random = new Random();

                spriteAnimationComponent.Position = random.NextDouble();

                Scene.AddEntity(campfire);
            }
Пример #8
0
 protected override void Initialize()
 {
     this._playTextRenderer   = this.FindComponentInChildren("PlayText") as TextRenderComponent;
     this._exitTextRenderer   = this.FindComponentInChildren("ExitText") as TextRenderComponent;
     this._selectionRenderer  = this.GetChild <SpriteAnimationComponent>();
     this._gameStateComponent = this.Scene.GetAllComponentsOfType <GameStateComponent>().First();
     this._inputManager       = this.Scene.GetModule <InputManager>();
 }
 protected override void Initialize()
 {
     this._startingPosition         = this.LocalPosition;
     this._spriteAnimationComponent = this.GetChild <SpriteAnimationComponent>();
     this._timer    = this.Scene.GetAllComponentsOfType <TimerComponent>().First();
     this.DrawOrder = 11;
     this.Reset();
 }
        public void Position_ShouldThrow_WhenValueIsOutOfRangeBetweenZeroAndOne(double position)
        {
            // Arrange
            var component = new SpriteAnimationComponent();

            // Act
            // Assert
            Assert.That(() => { component.Position = position; }, Throws.TypeOf <ArgumentOutOfRangeException>());
        }
        public override void OnStart()
        {
            Debug.Assert(Entity != null, nameof(Entity) + " != null");

            _transformComponent       = Entity.GetComponent <Transform2DComponent>();
            _spriteAnimationComponent = Entity.GetComponent <SpriteAnimationComponent>();

            _spriteAnimationComponent.PlayAnimation(FlapAnimation);
            _spriteAnimationComponent.Stop();
        }
Пример #12
0
        public Entity CreateBird()
        {
            var entity = new Entity {
                Name = "Bird"
            };

            entity.AddComponent(new Transform2DComponent
            {
                Translation = Vector2.Zero,
                Rotation    = 0,
                Scale       = new Vector2(2, 2)
            });
            entity.AddComponent(new SpriteRendererComponent {
                SortingLayerName = "Bird"
            });
            entity.AddComponent(new InputComponent
            {
                InputMapping = new InputMapping
                {
                    ActionMappings =
                    {
                        new ActionMapping
                        {
                            ActionName      = "Flap",
                            HardwareActions =
                            {
                                new HardwareAction
                                {
                                    HardwareInputVariant = HardwareInputVariant.CreateKeyboardVariant(Key.Space)
                                }
                            }
                        }
                    }
                }
            });
            entity.AddComponent(new BirdIdleFlyingComponent());
            var spriteAnimationComponent = new SpriteAnimationComponent {
                PlayInLoop = true
            };

            spriteAnimationComponent.AddAnimation("Flap", _assetStore.GetAsset <SpriteAnimation>(new AssetId(new Guid("FD8C8E61-A4B0-43C9-A89D-B22554B8A3F7"))));
            entity.AddComponent(spriteAnimationComponent);
            entity.AddComponent(new BirdFlapAnimationComponent());
            entity.AddComponent(new RectangleColliderComponent
            {
                Dimension = new Vector2(32 - 2, 24 - 2)
            });
            entity.AddComponent(new BirdSoundComponent(
                                    audioPlayer: _audioPlayer,
                                    wingSound: _assetStore.GetAsset <ISound>(new AssetId(new Guid("4ee1890b-3b92-45bb-9bee-a81e270f61d6"))),
                                    hitSound: _assetStore.GetAsset <ISound>(new AssetId(new Guid("7224f1b5-1471-4741-b720-0a10fc99ea53"))),
                                    dieSound: _assetStore.GetAsset <ISound>(new AssetId(new Guid("d1235819-13d0-419f-a50d-71478c1ad9bd")))
                                    ));
            return(entity);
        }
        public void Position_ShouldBeSet_WhenValueIsBetweenZeroAndOne(double position)
        {
            // Arrange
            var component = new SpriteAnimationComponent();

            // Act
            component.Position = position;

            // Assert
            Assert.That(component.Position, Is.EqualTo(position));
        }
Пример #14
0
            public SpriteAnimationComponent AddSpriteAnimationComponent()
            {
                var component = new SpriteAnimationComponent();

                var entity = new Entity();

                entity.AddComponent(component);
                _scene.AddEntity(entity);

                return(component);
            }
Пример #15
0
        private bool timeEnoughToFlipFrame(GameTime gameTime, SpriteAnimationComponent spriteAnimationComponent,
                                           SpriteAnimationBinding binding)
        {
            var elapsedTimeForFrame = gameTime.TotalGameTime.TotalMilliseconds -
                                      spriteAnimationComponent.AnimationStarted;

            if (elapsedTimeForFrame >= binding.FrameLength)
            {
                return(true);
            }
            return(false);
        }
        public void Stop_ShouldThrow_WhenThereIsNoCurrentAnimation()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            component.AddAnimation(name, animation);

            // Act
            // Assert
            Assert.That(() => component.Stop(), Throws.InvalidOperationException);
        }
Пример #17
0
            public (SpriteAnimationComponent, SpriteRendererComponent) AddSpriteAnimationAndRendererComponents()
            {
                var spriteAnimationComponent = new SpriteAnimationComponent();
                var spriteRendererComponent  = new SpriteRendererComponent();

                var entity = new Entity();

                entity.AddComponent(spriteAnimationComponent);
                entity.AddComponent(spriteRendererComponent);
                _scene.AddEntity(entity);

                return(spriteAnimationComponent, spriteRendererComponent);
            }
Пример #18
0
        private void ProcessAnimation(GameTime gameTime, int entityId, SpriteAnimationComponent spriteAnimation)
        {
            if (!ComponentManager.ContainsAllComponents(
                    entityId,
                    typeof(SpriteComponent)
                    ))
            {
                return;
            }
            var spriteComponent = ComponentManager.GetEntityComponentOrDefault <SpriteComponent>(entityId);

            if (spriteAnimation.CurrentAnimatedState == null && spriteAnimation.NextAnimatedState != null)
            {
                spriteAnimation.CurrentAnimatedState = spriteAnimation.NextAnimatedState;
            }
            else if (spriteAnimation.CurrentAnimatedState == null)
            {
                return;
            }

            var binding = spriteAnimation.CurrentAnimatedState;

            if (!timeEnoughToFlipFrame(gameTime, spriteAnimation, binding))
            {
                return;
            }

            //Incremenet the x position by one tile width.
            var newX = spriteComponent.Position.X + spriteComponent.TileWidth;
            var newY = spriteComponent.Position.Y;

            //Check if the new positions exceeds the end position of the animation loop
            if (newY > binding.EndPosition.Y || newY == binding.EndPosition.Y && newX >= binding.EndPosition.X)
            {
                newX = binding.StartPosition.X;
                newY = binding.StartPosition.Y;
                spriteAnimation.CurrentAnimatedState = spriteAnimation.NextAnimatedState;
            }
            //Check if new sprite crop bounds exceeds the sprites actual bounds
            else if (newX + spriteComponent.TileWidth > spriteComponent.Sprite.Width)
            {
                newX = binding.StartPosition.X;
                newY = spriteComponent.Position.Y + spriteComponent.TileHeight;
                if (newY + spriteComponent.TileHeight > spriteComponent.Sprite.Height)
                {
                    newY = binding.StartPosition.Y;
                }
            }
            spriteComponent.Position         = new Point(newX, newY);
            spriteAnimation.AnimationStarted = gameTime.TotalGameTime.TotalMilliseconds;
        }
        public void RemoveAnimation_ShouldThrow_WhenAnimationToRemoveIsCurrentAnimation()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            component.AddAnimation(name, animation);
            component.PlayAnimation(name);

            // Act
            // Assert
            Assert.That(() => { component.RemoveAnimation(name); }, Throws.InvalidOperationException);
        }
Пример #20
0
        void AnimatePerRow(ref SpriteAnimationComponent spriteAnimationComponent)
        {
            spriteAnimationComponent.CurrentFrameColumn++;

            if (spriteAnimationComponent.CurrentFrameColumn == spriteAnimationComponent.FrameColumnsCount)
            {
                spriteAnimationComponent.CurrentFrameColumn = 0;
                spriteAnimationComponent.IsPlaying          = spriteAnimationComponent.IsLooping;
            }

            spriteAnimationComponent.SourceRectangle = new Rectangle(
                spriteAnimationComponent.CurrentFrameColumn * spriteAnimationComponent.FrameWidth,
                spriteAnimationComponent.SourceRectangle.Value.Y,
                spriteAnimationComponent.FrameWidth,
                spriteAnimationComponent.SourceRectangle.Value.Height);
        }
Пример #21
0
        void AnimatePerColumn(ref SpriteAnimationComponent spriteAnimationComponent)
        {
            spriteAnimationComponent.CurrentFrameRow++;

            if (spriteAnimationComponent.CurrentFrameRow == spriteAnimationComponent.FrameRowsCount)
            {
                spriteAnimationComponent.CurrentFrameRow = 0;
                spriteAnimationComponent.IsPlaying       = spriteAnimationComponent.IsLooping;
            }

            spriteAnimationComponent.SourceRectangle = new Rectangle(
                spriteAnimationComponent.SourceRectangle.Value.X,
                spriteAnimationComponent.CurrentFrameRow * spriteAnimationComponent.FrameHeight,
                spriteAnimationComponent.SourceRectangle.Value.Width,
                spriteAnimationComponent.FrameHeight);
        }
Пример #22
0
        protected override void Initialize()
        {
            this.State              = new PlayerState(this._currentStance.Stance, this.WorldTransform.Position, Vector2.Zero);
            this._startState        = this.State;
            this._physicsModule     = this.Scene.GetModule <SimplePhysicsModule>();
            this._inputManager      = this.Scene.GetModule <InputManager>();
            this._spriteAnimator    = this.GetChild <SpriteAnimationComponent>();
            this._jumpAudioPlayer   = this.FindComponentInChildren("JumpPlayer") as AudioPlayer;
            this._crunchAudioPlayer = this.FindComponentInChildren("CrunchPlayer") as AudioPlayer;
            this._creatures.AddRange(this.Scene.GetAllComponentsOfType <CreatureComponent>());

            if (this._physicsModule == null && this.Scene.AddModule(new SimplePhysicsModule()))
            {
                this._physicsModule = this.Scene.GetModule <SimplePhysicsModule>();
            }
        }
        public void RemoveAnimation_ShouldRemoveAnimationFromAnimations()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            component.AddAnimation(name, animation);

            // Assume
            Assume.That(component.Animations, Has.Count.EqualTo(1));

            // Act
            component.RemoveAnimation(name);

            // Assert
            Assert.That(component.Animations, Has.Count.Zero);
        }
        public void AddAnimation_ShouldAddAnimationToAnimations()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            // Assume
            Assume.That(component.Animations, Has.Count.Zero);

            // Act
            component.AddAnimation(name, animation);

            // Assert
            Assert.That(component.Animations, Has.Count.EqualTo(1));
            Assert.That(component.Animations, Contains.Key(name));
            Assert.That(component.Animations[name], Is.EqualTo(animation));
        }
        public void PlayAnimation_ShouldSetIsPlayingToTrueAndPositionToZero()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            component.AddAnimation(name, animation);
            component.Position = 0.5;

            // Assume
            Assume.That(component.IsPlaying, Is.False);

            // Act
            component.PlayAnimation(name);

            // Assert
            Assert.That(component.IsPlaying, Is.True);
            Assert.That(component.Position, Is.Zero);
        }
        public void Pause_ShouldSetIsPlayingToFalseAndKeepCurrentPosition()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            component.AddAnimation(name, animation);
            component.PlayAnimation(name);
            component.Position = 0.5;

            // Assume
            Assume.That(component.IsPlaying, Is.True);

            // Act
            component.Pause();

            // Assert
            Assert.That(component.IsPlaying, Is.False);
            Assert.That(component.Position, Is.EqualTo(0.5));
        }
        public void PlayAnimation_ShouldSetCurrentAnimation_WhenItIsNotSet()
        {
            // Arrange
            const string name      = "animation";
            var          animation = CreateAnimation();
            var          component = new SpriteAnimationComponent();

            component.AddAnimation(name, animation);

            // Assume
            Assume.That(component.CurrentAnimation.HasValue, Is.False);

            // Act
            component.PlayAnimation(name);

            // Assert
            Assert.That(component.CurrentAnimation.HasValue, Is.True);
            Debug.Assert(component.CurrentAnimation != null, "component.CurrentAnimation != null");
            Assert.That(component.CurrentAnimation.Value.Name, Is.EqualTo(name));
            Assert.That(component.CurrentAnimation.Value.Animation, Is.EqualTo(animation));
        }
        public void SaveAndLoad_ShouldSaveSceneToFileAndThenLoadItFromFile_GivenSceneWithEntityWithSpriteAnimationComponent()
        {
            // Arrange
            var scene = SystemUnderTest.SceneFactory.Create();

            var entityWithSpriteAnimation = CreateNewEntityWithRandomName();
            var spriteAnimationComponent  = new SpriteAnimationComponent();

            entityWithSpriteAnimation.AddComponent(spriteAnimationComponent);
            scene.AddEntity(entityWithSpriteAnimation);

            spriteAnimationComponent.AddAnimation("animation", SystemUnderTest.AssetStore.GetAsset <SpriteAnimation>(AssetsIds.TestSpriteAnimation));
            spriteAnimationComponent.PlayAnimation("animation");
            spriteAnimationComponent.Position      = 0.7;
            spriteAnimationComponent.PlaybackSpeed = 1.3;
            spriteAnimationComponent.PlayInLoop    = true;

            // Act
            SystemUnderTest.SceneLoader.Save(scene, _sceneFilePath);
            var loadedScene = SystemUnderTest.SceneLoader.Load(_sceneFilePath);

            // Assert
            AssertScenesAreEqual(loadedScene, scene);
            AssertEntitiesAreEqual(loadedScene.RootEntities.Single(), entityWithSpriteAnimation);
            var loadedSpriteAnimationComponent = loadedScene.RootEntities.Single().GetComponent <SpriteAnimationComponent>();

            Assert.That(loadedSpriteAnimationComponent.Animations, Has.Count.EqualTo(1));
            Assert.That(loadedSpriteAnimationComponent.Animations.Single().Key, Is.EqualTo("animation"));
            Assert.That(SystemUnderTest.AssetStore.GetAssetId(loadedSpriteAnimationComponent.Animations.Single().Value),
                        Is.EqualTo(AssetsIds.TestSpriteAnimation));
            Assert.That(loadedSpriteAnimationComponent.CurrentAnimation, Is.Not.Null);
            Debug.Assert(loadedSpriteAnimationComponent.CurrentAnimation != null, "loadedSpriteAnimationComponent.CurrentAnimation != null");
            Assert.That(loadedSpriteAnimationComponent.CurrentAnimation.Value.Name, Is.EqualTo("animation"));
            Assert.That(SystemUnderTest.AssetStore.GetAssetId(loadedSpriteAnimationComponent.CurrentAnimation.Value.Animation),
                        Is.EqualTo(AssetsIds.TestSpriteAnimation));
            Assert.That(loadedSpriteAnimationComponent.IsPlaying, Is.True);
            Assert.That(loadedSpriteAnimationComponent.Position, Is.EqualTo(spriteAnimationComponent.Position));
            Assert.That(loadedSpriteAnimationComponent.PlaybackSpeed, Is.EqualTo(spriteAnimationComponent.PlaybackSpeed));
            Assert.That(loadedSpriteAnimationComponent.PlayInLoop, Is.EqualTo(spriteAnimationComponent.PlayInLoop));
        }
Пример #29
0
        void AnimateAll(ref SpriteAnimationComponent spriteAnimationComponent)
        {
            spriteAnimationComponent.CurrentFrameColumn++;

            if (spriteAnimationComponent.CurrentFrameColumn == spriteAnimationComponent.FrameColumnsCount)
            {
                spriteAnimationComponent.CurrentFrameColumn = 0;
                spriteAnimationComponent.CurrentFrameRow++;

                if (spriteAnimationComponent.CurrentFrameRow == spriteAnimationComponent.FrameRowsCount)
                {
                    spriteAnimationComponent.CurrentFrameRow = 0;
                    spriteAnimationComponent.IsPlaying       = spriteAnimationComponent.IsLooping;
                }
            }

            spriteAnimationComponent.SourceRectangle = new Rectangle(
                spriteAnimationComponent.CurrentFrameColumn * spriteAnimationComponent.FrameWidth,
                spriteAnimationComponent.CurrentFrameRow * spriteAnimationComponent.FrameHeight,
                spriteAnimationComponent.FrameWidth,
                spriteAnimationComponent.FrameHeight);
        }
Пример #30
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()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();

            //TurretComponent = new TurretComponent();
            //TrapComponent = new TrapComponent();
            //PortableShopComponent = new PortableShopComponent();
            //PortableShieldComponent = new PortableShieldComponent();
            //MotivateComponent =  new MotivateComponent();
            //FallbackComponent = new FallbackComponent();
            //ChargeComponent = new ChargeComponent();
            //HealingStationComponent = new HealingStationComponent();
            //ExplodingDroidComponent = new ExplodingDroidComponent();

            base.Initialize();
        }
Пример #31
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()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory = new NPCFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            NpcAIComponent = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            NPCComponent = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent = new SoundComponent();
            ActorTextComponent = new ActorTextComponent();
            TurretComponent = new TurretComponent();
            TrapComponent = new TrapComponent();
            ExplodingDroidComponent = new ExplodingDroidComponent();
            HealingStationComponent = new HealingStationComponent();
            PortableShieldComponent = new PortableShieldComponent();
            PortableStoreComponent = new PortableStoreComponent();
            ActiveSkillComponent = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();

            Quests = new List<Quest>();

            #region Initialize Effect Components
            AgroDropComponent = new AgroDropComponent();
            AgroGainComponent = new AgroGainComponent();
            BuffComponent = new BuffComponent();
            ChanceToSucceedComponent = new ChanceToSucceedComponent();
            ChangeVisibilityComponent = new ChangeVisibilityComponent();
            CoolDownComponent = new CoolDownComponent();
            DamageOverTimeComponent = new DamageOverTimeComponent();
            DirectDamageComponent = new DirectDamageComponent();
            DirectHealComponent = new DirectHealComponent();
            FearComponent = new FearComponent();
            HealOverTimeComponent = new HealOverTimeComponent();
            InstantEffectComponent = new InstantEffectComponent();
            KnockBackComponent = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent = new ReduceAgroRangeComponent();
            ResurrectComponent = new ResurrectComponent();
            StunComponent = new StunComponent();
            TimedEffectComponent = new TimedEffectComponent();
            EnslaveComponent = new EnslaveComponent();
            CloakComponent = new CloakComponent();
            #endregion

            base.Initialize();
        }
        /// <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()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();
            pI = new PlayerInfo();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }