Ejemplo n.º 1
0
        public void ConstructAnimationLibrary(string name, string currentAnimation)
        {
            AnimationLibrary = new AnimationLibrary(name, AssetManager.GetAnimationLibrary(name).Animations);

            CurrentAnimation = currentAnimation;

            AnimationManager = new AnimationManager(AnimationLibrary);
            AnimationManager.Play(CurrentAnimation);
        }
Ejemplo n.º 2
0
        private static void BuildEntityAnimationDictionaries()
        {
            Dictionary <string, Animation> _dungeonTorchAnimations = new Dictionary <string, Animation>();

            _dungeonTorchAnimations.Add("Idle", new Animation(SpriteSheets["Dungeons"], 4, 16, 16, 0.2f, new Vector2(0, 16)));

            AnimationLibrary _dungeonTorchLibrary = new AnimationLibrary("DungeonTorch", _dungeonTorchAnimations);

            AnimationLibraries.Add(_dungeonTorchLibrary);
        }
Ejemplo n.º 3
0
        public MapEntityStatic(bool isSolid, Vector2 position, int width, int height, string animationLibraryName)
        {
            IsSolid          = isSolid;
            AnimationLibrary = new AnimationLibrary(animationLibraryName);
            AnimationManager = null;

            Position = position;

            BoundingBox = new Rectangle((int)Position.X, (int)Position.Y, width, height);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates Dictionary for all Animations available to MainPlayer
        /// </summary>
        private void CreateAnimationDictionary()
        {
            Animations = new Dictionary <string, Animation>();

            Animations.Add("MoveUp", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(32, 160)));
            Animations.Add("MoveDown", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(0, 160)));
            Animations.Add("MoveLeft", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(96, 160)));
            Animations.Add("MoveRight", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(64, 160)));

            Animations.Add("SwordDown", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(0, 176)));
            Animations.Add("SwordUp", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(32, 176)));
            Animations.Add("SwordRight", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(64, 176)));
            Animations.Add("SwordLeft", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(96, 176)));

            Animations.Add("PushingDown", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(0, 192)));
            Animations.Add("PushingUp", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(32, 192)));
            Animations.Add("PushingRight", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(64, 192)));
            Animations.Add("PushingLeft", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(96, 192)));

            Animations.Add("PullingDown", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(0, 208)));
            Animations.Add("PullingUp", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(32, 208)));
            Animations.Add("PullingRight", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(64, 208)));
            Animations.Add("PullingLeft", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(96, 208)));

            Animations.Add("CarryDown", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(0, 224)));
            Animations.Add("CarryUp", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(32, 224)));
            Animations.Add("CarryRight", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(64, 224)));
            Animations.Add("CarryLeft", new Animation(AssetManager.SpriteSheets["PlayerSheet"], 2, 16, 16, 0.2f, new Vector2(96, 224)));

            CurrentAnimation = "MoveDown";

            AnimationLibrary = new AnimationLibrary("MainPlayer", Animations);

            AnimationManager = new AnimationManager(AnimationLibrary);
            AnimationManager.Play(CurrentAnimation);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads MapObjects for the Active Map, iterates through them, and instantiates objects
        /// based on the information found in the Map ObjectLayers
        /// </summary>
        private void LoadMapObjectLayers()
        {
            TiledMapObjectLayer _mapEntityObjectLayer   = MapCurrent.GetLayer <TiledMapObjectLayer>("Entity Layer");
            TiledMapObjectLayer _mapCollisionLayer      = MapCurrent.GetLayer <TiledMapObjectLayer>("Collision Layer");
            TiledMapObjectLayer _mapAreaDefinitionLayer = MapCurrent.GetLayer <TiledMapObjectLayer>("Area Definitions");

            foreach (TiledMapObject _entityObject in _mapEntityObjectLayer.Objects)
            {
                switch (_entityObject.Name)
                {
                case "mapPlayerSpawn":
                {
                    // Run Player Spawn Code Here
                    PlayerSpawnX  = Convert.ToInt32(_entityObject.Position.X);
                    PlayerSpawnY  = Convert.ToInt32(_entityObject.Position.Y);
                    IsPlayerSpawn = true;

                    break;
                }

                case "mapTransition":
                {
                    // Create Transition Objects
                    float destinationX, destinationY;

                    destinationX = Convert.ToInt32(_entityObject.Properties["mapDestinationX"]);
                    destinationY = Convert.ToInt32(_entityObject.Properties["mapDestinationY"]);

                    MapTransitionHandler mapTransition = new MapTransitionHandler(contentManager, _entityObject.Properties["mapDestination"],
                                                                                  new Vector2((float)destinationX, (float)destinationY), new Rectangle((int)_entityObject.Position.X, (int)_entityObject.Position.Y, (int)_entityObject.Size.Width, (int)_entityObject.Size.Height),
                                                                                  _entityObject.Properties["mapDestinationArea"], _entityObject.Properties["mapDestinationFacing"]);

                    MapObjects.Add(mapTransition);
                    break;
                }

                case "mapEntitySpawn":
                {
                    // Get AssetManager Data
                    AnimationLibrary _animationLibrary = AssetManager.GetAnimationLibrary(_entityObject.Properties["AnimationLibraryName"]);

                    // Spawn the Entity
                    bool isSolid = Convert.ToBoolean(_entityObject.Properties["IsSolid"]);

                    MapEntityStatic _mapEntity = new MapEntityStatic(isSolid, new Vector2(_entityObject.Position.X, _entityObject.Position.Y), (int)_entityObject.Size.Width, (int)_entityObject.Size.Height, _entityObject.Properties["AnimationLibraryName"]);
                    _mapEntity.ConstructAnimationLibrary(_animationLibrary.Name, _entityObject.Properties["CurrentAnimation"]);

                    Entities.Add(_mapEntity);
                    break;
                }
                }
            }
            foreach (TiledMapObject _collisionObject in _mapCollisionLayer.Objects)
            {
                switch (_collisionObject.Name)
                {
                case "solidStatic":
                {
                    MapCollisionSolidStatic solid = new MapCollisionSolidStatic(_collisionObject.Position, (int)_collisionObject.Size.Width, (int)_collisionObject.Size.Height);
                    CollisionObjects.Add(solid);
                    break;
                }
                }
            }
            foreach (TiledMapObject _areaDefintion in _mapAreaDefinitionLayer.Objects)
            {
                MapAreaDefinition area = new MapAreaDefinition(_areaDefintion.Name, new Vector2((int)_areaDefintion.Position.X, (int)_areaDefintion.Position.Y),
                                                               new Rectangle((int)_areaDefintion.Position.X, (int)_areaDefintion.Position.Y, (int)_areaDefintion.Size.Width, (int)_areaDefintion.Size.Height));

                Areas.Add(area);
            }
        }
Ejemplo n.º 6
0
 public AnimationManager(AnimationLibrary animationLibrary)
 {
     Libary = new AnimationLibrary(animationLibrary);
 }
Ejemplo n.º 7
0
 public AnimationLibrary(AnimationLibrary animationLibrary)
 {
     Name       = animationLibrary.Name;
     Animations = animationLibrary.Animations.ToDictionary(kv => kv.Key, kv => kv.Value.Clone() as Animation);
 }