public AnimatedObject(string Tex, Vector2 Pos, Vector2 Scale, float rotation, float framerate, float depth, bool collidable = false) { Identifier = Tex; frameRate = frameRate; Position = Pos; scale = Scale; Rotation = rotation; Texture = Globals.Content.Load<Texture2D>(Identifier); Dictionary<string, Rectangle> spriteMap = Globals.Content.Load<Dictionary<string, Rectangle>>(Identifier + "SpriteMap"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "Idle", framerate, true); }
public override void Initialize() { Identifier = "largedebris"; Weight = 10; Texture = Globals.Content.Load<Texture2D>("WoodDebris"); Dictionary<string, Rectangle> spriteMap = Globals.Content.Load<Dictionary<string, Rectangle>>("WoodDebrisSpriteMap"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "Idle", 1.0f, true); base.Initialize(); }
public StormFront(Vector2 pos) { Identifier = "Storm Front"; SetDrawDepthRange(321, 350); SetDepth(321); Texture = Globals.Content.Load<Texture2D>("StormFront"); Dictionary<string, Rectangle> spriteMap = Globals.Content.Load<Dictionary<string, Rectangle>>("StormFrontSpriteMap"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "Idle", 0.1f, true); _color = new Color(255, 255, 255, 50); Velocity = new Vector2(1f, 0); _startingPosition = Position = pos; Collidable = false; }
public GenericDestructible(Vector2 pos, string spriteSheet, float frameRate, int health) : base() { this.ObjectType = DrawableObjectType.Destructible; Identifier = spriteSheet; Texture = Globals.Content.Load<Texture2D>(spriteSheet); Dictionary<string, Rectangle> spriteMap = Globals.Content.Load<Dictionary<string, Rectangle>>(spriteSheet + "SpriteMap"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "Good", frameRate, true); Health = health; this.LoadContent(pos, health); }
//float walkSpeed = 0.2f; public Cow(Vector2 position, bool onground = true) : base(ItemType.Debris) { Identifier = "Cow"; Position = position; Weight = 100; onGround = onground; Texture = Globals.Content.Load<Texture2D>(Identifier); Dictionary<string, Rectangle> spriteMap = Globals.Content.Load<Dictionary<string, Rectangle>>(Identifier+"SpriteMap"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "Walk", 0.3f, true); this.Initialize(); LoadContent(); }
//************************************************************** //THIS IS AN OLD CLASS, REPLACED BY GenericDestructible //************************************************************** public WalmartSizeBuilding(Vector2 pos) : base() { //textures = new List<Texture2D>(); //tex1 = Globals.Content.Load<Texture2D>("WalmartBldgGood"); //tex2 = Globals.Content.Load<Texture2D>("WalmartBldgPoor"); //tex3 = Globals.Content.Load<Texture2D>("WalmartBldgDead"); //textures.Add(tex1); //textures.Add(tex2); //textures.Add(tex3); health = 4000; Texture = Globals.Content.Load<Texture2D>("Walmart"); Dictionary<string, Rectangle> spriteMap = Globals.Content.Load<Dictionary<string, Rectangle>>("Walmart"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "Good", frameRate, true); this.LoadContent(pos, health); }
///// <summary> ///// Gets a texture origin at the bottom center of each frame. ///// </summary> //public Vector2 Origin //{ // get { return new Vector2(Animation.FrameWidth / 2.0f, Animation.FrameHeight); } //} /// <summary> /// Begins or continues playback of an animation. /// </summary> public void PlayAnimation(Animation animation, string animationName, float frameTime, bool isLooping) { // If this animation is already running, do not restart it. if (previousAnimationName == animationName) { if (Animation.Name == animation.Name) return; } animation.SetAnimation(animationName, frameTime, isLooping); oneTimeLoopComplete = false; // Start the new animation. this.animation = animation; this.frameIndex = 0; this.time = 0.0f; this.currentFrame = animation.Name + "-0"; previousAnimationName = animation.Name; }