public override void SetUpAnimation(String xmlFile) { Animation idle = new Animation(xmlFile, IDLE); Animation laughing = new Animation(xmlFile, LAUGHING); Animation running = new Animation(xmlFile, RUNNING); Animation shooting = new Animation(xmlFile, SHOOTING); Animation shootingUp = new Animation(xmlFile, SHOOTINGUP); Animation shootingDown = new Animation(xmlFile, SHOOTINGDOWN); Animation jumpingAscent = new Animation(xmlFile, JUMPINGASCENT); Animation jumpingDescent = new Animation(xmlFile, JUMPINGDESCENT); Animation jumpingLand = new Animation(xmlFile, JUMPINGLAND); Animation dead = new Animation(xmlFile, DEAD); Animation hit = new Animation(xmlFile, HIT); this.animationMap.Add(IDLE, idle); this.animationMap.Add(LAUGHING, laughing); this.animationMap.Add(RUNNING, running); this.animationMap.Add(SHOOTING, shooting); this.animationMap.Add(SHOOTINGUP, shootingUp); this.animationMap.Add(SHOOTINGDOWN, shootingDown); this.animationMap.Add(JUMPINGASCENT, jumpingAscent); this.animationMap.Add(JUMPINGDESCENT, jumpingDescent); this.animationMap.Add(JUMPINGLAND, jumpingLand); this.animationMap.Add(DEAD, dead); this.animationMap.Add(HIT, hit); }
public Explosion(World world, SpriteBatch spriteBatch, Vector2 position) : base(world, spriteBatch, position) { World.playSound("explosion"); this.explosionAnimation = new Animation(EXPLOSION_ANIM_FILENAME, "Explosion"); this.animationPlayer = new AnimationPlayer(SpriteBatch, explosionAnimation); this.radius = INITIAL_EXPLOSION_RADIUS; }
// Constructor for an Animation Player. Sets up the initial paramters such as // this player's animation, current frame, and time displayed. // param: game - The over-arching Game object. // param: spriteBatch - The spriteBatch used to draw the Animation. // param: animation - The Animation to play. /// <summary> /// Constructor for an Animation Player. Sets up the initial parameters, including /// the player's animation, current frame, and time displayed. /// </summary> /// <param name="spriteBatch">The sprite batch used to draw this animation.</param> /// <param name="animation">The desired animation to begin playing.</param> public AnimationPlayer(SpriteBatch spriteBatch, Animation animation) { this.animation = animation; this.timeDisplayed = 0; this.currentFrame = animation.Frames[DEFAULT_START_FRAME]; playStart = DEFAULT_START_FRAME; playStop = animation.FrameCount - 1; }
// Constructor for a new Animation. // param: animationXmlFile - The XML file to load Frame information // from. public Animation(string animationXmlFile, string animationName) { this.animationName = animationName; this.spriteSheet = null; this.frames = new List<Frame>(); this.frameHeight = 0; this.frameWidth = 0; this.frameCount = 0; this.isLooping = true; parentAnimation = null; LoadAnimationXmlFile(animationXmlFile, animationName); }
public override void SetUpAnimation(String xmlFile) { Animation dead = new Animation(xmlFile, DEAD); //Animation climbing = new Animation(xmlFile, CLIMBING); //Animation diving = new Animation(xmlFile, DIVING); //Animation attacking = new Animation(xmlFile, ATTACKING); Animation flying = new Animation(xmlFile, FLYING); this.animationMap.Add(DEAD, dead); //this.animationMap.Add(CLIMBING, climbing); //this.animationMap.Add(DIVING, diving); //this.animationMap.Add(ATTACKING, attacking); this.animationMap.Add(FLYING, flying); }
public override void SetUpAnimation(String xmlFile) { Animation idle = new Animation(xmlFile, IDLE); Animation running = new Animation(xmlFile, RUNNING); Animation shooting = new Animation(xmlFile, SHOOTING); Animation dead = new Animation(xmlFile, DEAD); //Animation hit = new Animation(xmlFile, HIT); this.animationMap.Add(IDLE, idle); this.animationMap.Add(RUNNING, running); this.animationMap.Add(SHOOTING, shooting); this.animationMap.Add(DEAD, dead); //this.animationMap.Add(HIT, hit); }
/// <summary> /// /// </summary> /// <param name="xmlFile"></param> public override void SetUpAnimation(String xmlFile) { Animation idle = new Animation(xmlFile, IDLE); Animation running = new Animation(xmlFile, RUNNING); Animation jumpingAscent = new Animation(xmlFile, JUMPINGASCENT); Animation jumpingDescent = new Animation(xmlFile, JUMPINGDESCENT); Animation shooting = new Animation(xmlFile, SHOOTING); Animation runningShooting = new Animation(xmlFile, RUNNINGSHOOTING); Animation jumpingAscentShooting = new Animation(xmlFile, JUMPINGASCENTSHOOTING); Animation jumpingDescentShooting = new Animation(xmlFile, JUMPINGDESCENTSHOOTING); Animation falling = new Animation(xmlFile, FALLING); Animation fallingShooting = new Animation(xmlFile, FALLINGSHOOTING); Animation hit = new Animation(xmlFile, HIT); Animation dead = new Animation(xmlFile, DEAD); Animation deadAir = new Animation(xmlFile, DEADAIR); Animation deadAirGround = new Animation(xmlFile, DEADAIRGROUND); //Animation transforming = new Animation(xmlFile, TRANSFORMING); //Animation jumpingAscentShootingUp = new Animation(xmlFile, JUMPINGASCENTSHOOTINGUP); //Animation jumpingDescentShootingUp = new Animation(xmlFile, JUMPINGASCENTSHOOTINGUP); //Animation fallingShootingUp = new Animatin(xmlFile, FALLINGSHOOTINGUP); //Animation runningShootingUp = new Animation(xmlFile, RUNNINGSHOOTINGUP); //Animation shootingUp = new Animation(xmlFile, SHOOTINGUP); this.animationMap.Add(IDLE, idle); this.animationMap.Add(RUNNING, running); this.animationMap.Add(JUMPINGASCENT, jumpingAscent); this.animationMap.Add(JUMPINGDESCENT, jumpingDescent); this.animationMap.Add(SHOOTING, shooting); this.animationMap.Add(RUNNINGSHOOTING, runningShooting); this.animationMap.Add(JUMPINGASCENTSHOOTING, jumpingAscentShooting); this.animationMap.Add(JUMPINGDESCENTSHOOTING, jumpingDescentShooting); this.animationMap.Add(FALLING, falling); this.animationMap.Add(FALLINGSHOOTING, fallingShooting); this.animationMap.Add(HIT, hit); this.animationMap.Add(DEAD, dead); this.animationMap.Add(DEADAIR, deadAir); this.animationMap.Add(DEADAIRGROUND, deadAirGround); //this.animationMap.Add(TRANSFORMING, transforming); //this.animationMap.Add(JUMPINGASCENTSHOOTINGUP, jumpingAscentShootingUp); //this.animationMap.Add(JUMPINGDESCENTSHOOTINGUP, jumpingDescentShootingUp); //this.animationMap.Add(RUNNINGSHOOTINGUP, runningShootingUp); //this.animationMap.Add(SHOOTINGUP, shootingUp); }
/// <summary> /// Changes both the Character's state and animation to the given state. /// If the character is already in a given state, no change is to be made. /// </summary> /// <param name="newState">The new state to change to.</param> public void ChangeState(String newState) { if (!currentState.Equals(newState)) { try { currentState = newState; currentAnimation = currentRole.AnimationMap[newState]; animationPlayer.PlayAnimation(currentRole.AnimationMap[newState]); } catch(KeyNotFoundException knfe) { } } }
/// <summary> /// Sets up all of this object's animations and adds them to the animation map. public void SetUpAnimation() { Animation fall = new Animation(XMLFILENAME, FALL); Animation enter = new Animation(XMLFILENAME, ENTER); Animation extend = new Animation(XMLFILENAME, EXTEND); Animation takeOff = new Animation(XMLFILENAME, TAKEOFF); fall.parentAnimation = enter; enter.parentAnimation = extend; extend.parentAnimation = takeOff; this.animationMap.Add(FALL, fall); this.animationMap.Add(ENTER, enter); this.animationMap.Add(EXTEND, extend); this.animationMap.Add(TAKEOFF, takeOff); }
/// <summary> /// Begins or continues playback of an animation from the desired /// start and end frames. /// </summary> /// <param name="animation">The animation to play.</param> /// <param name="start">The frame index to start animating from.</param> /// <param name="end">The frame index to end animating on.</param> public void PlayAnimation(Animation newAnimation, int start, int end) { // If this animation is already running, do not restart it. if (Animation == newAnimation) return; if ((start >= 0) && (start <= newAnimation.FrameCount - 1) && (end >= 0) && (end <= newAnimation.FrameCount - 1)) { playStart = start; playStop = end; } else { playStart = DEFAULT_START_FRAME; playStop = newAnimation.FrameCount - 1; } //Reset the hasDraw values to false for each of this animation's //frames. ResetDraw(); // Start the new animation. this.animation = newAnimation; currentFrame = this.animation.Frames[playStart]; ResetTime(); }
/// <summary> /// Begins or continues playback of an animation from the beginning to /// the end of an animation. /// </summary> /// <param name="animation">The animation to play.</param> public void PlayAnimation(Animation newAnimation) { // If this animation is already running, do not restart it. if (Animation == newAnimation) return; //Reset the hasDraw values to false for each of this animation's //frames. ResetDraw(); // Start the new animation. this.animation = newAnimation; currentFrame = this.animation.Frames[0]; playStart = DEFAULT_START_FRAME; playStop = this.animation.FrameCount - 1; ResetTime(); }
/// <summary> /// Constructor for Flint's Hat. /// </summary> /// <param name="parentScreen">The screen which this object is a part of.</param> /// <param name="spriteBatch">The sprite batch which handles drawing this object.</param> /// <param name="position">The initial position of this character.</param> public FlintHat(Screen gameScreen, World world, SpriteBatch spriteBatch, Vector2 position, Character owner) : base(world, spriteBatch, position) { mass = 1.0f; //Set the Hat's owner this.owner = owner; this.gameScreen = gameScreen; //Set up the Animation Map animationMap = new Dictionary<string, Animation>(); //Set up the Hat's Animations SetUpAnimation(); //Set the current Animation currentAnimation = animationMap["Fall"]; animationPlayer = new AnimationPlayer(spriteBatch, animationMap["Fall"]); currentState = "None"; //Set the Hat's positon position = owner.Position + new Vector2(60, 0); //Set the hat's velocity velocity = new Vector2(0, 0); //Initializes the hat's hotspots. List<CollisionHotspot> hotspots = new List<CollisionHotspot>(); hotspots.Add(new CollisionHotspot(this, new Vector2(-1, -10), HOTSPOT_TYPE.top)); hotspots.Add(new CollisionHotspot(this, new Vector2(-7, 1), HOTSPOT_TYPE.left)); hotspots.Add(new CollisionHotspot(this, new Vector2(5, 1), HOTSPOT_TYPE.right)); hotspots.Add(new CollisionHotspot(this, new Vector2(-1, 12), HOTSPOT_TYPE.bottom)); Hotspots = hotspots; this.world = world; world.AddWorldObject(this); //this.ParentScreen.Components.Add(this); }
/// <summary> /// Sets up all of this object's animations and adds them to the animation map. public void SetUpAnimation() { Animation fall = new Animation(XMLFILENAME, FALL); this.animationMap.Add(FALL, fall); }
/// <summary> /// Sets the parent animation of this animation to the desired animation. /// </summary> /// <param name="parent"></param> public void setParentAnimation(Animation parent) { parentAnimation = parent; }