public void PlayAnimation(Animation animation) { if (Animation == animation) { return; } this.animation = animation; this.frameIndex = 0; this.time = 0.0f; }
public void LoadContent() { string imageIdle = ""; string imageAttacked = ""; string imageDead = ""; float positionAdjustX = -30.0f; float positionAdjustY = -40.0f; int idleFrames = 1; int attackedFrames = 1; int deadFrames = 1; switch (name) { case "GREEN OGRE": imageIdle = "GreenOgreSprite/greenOgreIdle"; imageAttacked = "GreenOgreSprite/greenOgreAttacked"; imageDead = "GreenOgreSprite/greenOgreDead"; // positionAdjustX = -30.0f; // positionAdjustY = -40.0f; idleFrames = 2; attackedFrames = 2; deadFrames = 2; lifePoints = 33333; break; case "RED SLIME": imageIdle = "RedSlimeSprite/redSlimeIdle"; imageAttacked = "RedSlimeSprite/redSlimeAttacked"; imageDead = "RedSlimeSprite/redSlimeDead"; idleFrames = 2; attackedFrames = 2; deadFrames = 2; lifePoints = 1000000; break; case "BROWN DEMON": imageIdle = "BrownDemonSprite/brownDemonIdle"; imageAttacked = "BrownDemonSprite/brownDemonAttacked"; imageDead = "BrownDemonSprite/brownDemonDead"; idleFrames = 2; attackedFrames = 2; deadFrames = 2; lifePoints = 4500000; break; case "MAGIC FIEND": imageIdle = "MagicFiendSprite/magicFiendIdle"; imageAttacked = "MagicFiendSprite/magicFiendAttacked"; imageDead = "MagicFiendSprite/magicFiendDead"; idleFrames = 2; attackedFrames = 2; deadFrames = 2; lifePoints = 7654321; break; case "MINUTE MONSTER": imageIdle = "MinuteMonsterSprite/minuteMonsterIdle"; imageAttacked = "MinuteMonsterSprite/minuteMonsterAttacked"; imageDead = "MinuteMonsterSprite/minuteMonsterDead"; idleFrames = 2; attackedFrames = 2; deadFrames = 2; lifePoints = 20000000; break; default: imageIdle = "SupportSprite/support2"; imageAttacked = "SupportSprite/support"; break; } spriteIdle = content.Load<Texture2D>(imageIdle); spriteAttacked = content.Load<Texture2D>(imageAttacked); spriteDead = content.Load<Texture2D>(imageDead); idleAnimation = new Animation(spriteIdle, 1.0f, true, idleFrames); attackedAnimation = new Animation(spriteAttacked, 1.0f, false, attackedFrames); deadAnimation = new Animation(spriteDead, 1.0f, false, deadFrames); int positionX = (Level.windowWidth / 2) - (spriteIdle.Width / 12); int positionY = (Level.windowHeight / 2) - (spriteIdle.Height / 4); position = new Vector2((float)positionX + positionAdjustX, (float)positionY + positionAdjustY); spritePlayer.PlayAnimation(idleAnimation); }
public void LoadContent() { string imageIdle = ""; string imageAttack = ""; float positionAdjustX = 0.0f; float positionAdjustY = 0.0f; int idleFrames = 1; int attackFrames = 1; switch (name) { case "HERO": imageIdle = "HeroSprite/heroIdleTPR"; imageAttack = "HeroSprite/heroSheetTPR"; positionAdjustX = 0.0f; positionAdjustY = 0.0f; idleFrames = (int)frames.HERO_IDLE; attackFrames = (int)frames.HERO_ATTACK; attackPower = 200; break; case "SUPPORT": imageIdle = "SupportSprite/support"; positionAdjustX = -100.0f; positionAdjustY = 0.0f; idleFrames = (int)frames.SUPPORT_IDLE_1; attackPower = 50; break; case "SUPPORT_2": imageIdle = "SupportSprite/support2"; positionAdjustX = 100.0f; positionAdjustY = 0.0f; idleFrames = (int)frames.SUPPORT_IDLE_2; attackPower = 75; break; case "SUPPORT_3": imageIdle = "SupportSprite/support3"; positionAdjustX = -100.0f; positionAdjustY = -100.0f; idleFrames = (int)frames.SUPPORT_IDLE_3; attackPower = 125; break; case "SUPPORT_4": imageIdle = "SupportSprite/support4"; positionAdjustX = 100.0f; positionAdjustY = -100.0f; idleFrames = (int)frames.SUPPORT_IDLE_4; attackPower = 150; break; default: imageIdle = "SupportSprite/support2"; imageAttack = "SupportSprite/support"; break; } spriteIdle = content.Load<Texture2D>(imageIdle); idleAnimation = new Animation(spriteIdle, 1.0f, true, idleFrames); if (name == "HERO") { spriteAttack = content.Load<Texture2D>(imageAttack); attackAnimation = new Animation(spriteAttack, 1.0f, true, attackFrames); } int positionX = (Level.windowWidth / 2) - (spriteIdle.Width / 12); int positionY = (Level.windowHeight / 2) - (spriteIdle.Height / 4); position = new Vector2((float)positionX + positionAdjustX, (float)positionY + positionAdjustY); spritePlayer.PlayAnimation(idleAnimation); }