public void Animation(GameTime gameTime, Enemy enemy, SpriteBatch spriteBatch) { if (enemy.invincibilityFrames) { if ((int)(enemy.invincibilityTimer / 0.40) % 2 == 1) { color = Color.Blue; } else if ((int)(enemy.invincibilityTimer / 0.40) % 2 == 1) { color = Color.Red; } else { color = Color.White; } } else { color = Color.White; } if (currentAnimation == Enums.EnemyAnimations.LADYBUG_FLY_LEFT || currentAnimation == Enums.EnemyAnimations.LADYBUG_FLY_RIGHT || currentAnimation == Enums.EnemyAnimations.ANT_MOVE_LEFT || currentAnimation == Enums.EnemyAnimations.ANT_MOVE_RIGHT || currentAnimation == Enums.EnemyAnimations.HAWK_FLY_LEFT || currentAnimation == Enums.EnemyAnimations.HAWK_FLY_RIGHT || currentAnimation == Enums.EnemyAnimations.SPIDER_MOVE_LEFT || currentAnimation == Enums.EnemyAnimations.SPIDER_MOVE_RIGHT || currentAnimation == Enums.EnemyAnimations.SNAIL_MOVE_LEFT || currentAnimation == Enums.EnemyAnimations.SNAIL_MOVE_RIGHT || currentAnimation == Enums.EnemyAnimations.SNAIL_AGGRO_LEFT || currentAnimation == Enums.EnemyAnimations.SNAIL_AGGRO_RIGHT) { currentAnimation = nextAnimation; } if (currentAnimation == Enums.EnemyAnimations.LADYBUG_ATTACK_LEFT || currentAnimation == Enums.EnemyAnimations.LADYBUG_ATTACK_RIGHT || currentAnimation == Enums.EnemyAnimations.ANT_ATTACK_LEFT || currentAnimation == Enums.EnemyAnimations.ANT_ATTACK_RIGHT || currentAnimation == Enums.EnemyAnimations.HAWK_ATTACK_LEFT || currentAnimation == Enums.EnemyAnimations.HAWK_ATTACK_RIGHT || currentAnimation == Enums.EnemyAnimations.SPIDER_ATTACK_LEFT || currentAnimation == Enums.EnemyAnimations.SPIDER_ATTACK_RIGHT || currentAnimation == Enums.EnemyAnimations.SNAIL_TRANSF_LEFT || currentAnimation == Enums.EnemyAnimations.SNAIL_TRANSF_RIGHT || currentAnimation == Enums.EnemyAnimations.SNAIL_ATTACK_LEFT || currentAnimation == Enums.EnemyAnimations.SNAIL_ATTACK_RIGHT) { if (ladybug_Attack_Left.getPlayedOnce() || ladybug_Attack_Right.getPlayedOnce() || ant_Attack_Left.getPlayedOnce() || ant_Attack_Right.getPlayedOnce() || hawk_Attack_Left.getPlayedOnce() || hawk_Attack_Right.getPlayedOnce() || spider_Attack_Left.getPlayedOnce() || spider_Attack_Right.getPlayedOnce() || snail_Transf_Left.getPlayedOnce() || snail_Transf_Right.getPlayedOnce() || snail_Attack_Left.getPlayedOnce() || snail_Attack_Right.getPlayedOnce()) { if (nextAnimation == Enums.EnemyAnimations.LADYBUG_ATTACK_LEFT || nextAnimation == Enums.EnemyAnimations.LADYBUG_ATTACK_RIGHT) { nextAnimation = previousAnimation; } currentAnimation = nextAnimation; ladybug_Attack_Left.resetPlayedOnce(); ladybug_Attack_Right.resetPlayedOnce(); ant_Attack_Left.resetPlayedOnce(); ant_Attack_Right.resetPlayedOnce(); hawk_Attack_Left.resetPlayedOnce(); hawk_Attack_Right.resetPlayedOnce(); spider_Attack_Left.resetPlayedOnce(); spider_Attack_Right.resetPlayedOnce(); snail_Transf_Left.resetPlayedOnce(); snail_Transf_Right.resetPlayedOnce(); snail_Attack_Left.resetPlayedOnce(); snail_Attack_Right.resetPlayedOnce(); } } Rectangle tempRec; switch (currentAnimation) { case Enums.EnemyAnimations.LADYBUG_FLY_LEFT: enemy.changeTexture(ladybug_Fly_Left.texture); tempRec = divAnimationDestRectanglesDic["Ladybug_Fly_Left"].Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, ladybug_Fly_Left.getSpriteEffects(), new Vector2(0, -30), color, scale); previousAnimation = Enums.EnemyAnimations.LADYBUG_FLY_LEFT; break; case Enums.EnemyAnimations.LADYBUG_FLY_RIGHT: enemy.changeTexture(ladybug_Fly_Right.texture); tempRec = divAnimationDestRectanglesDic["Ladybug_Fly_Right"].Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, ladybug_Fly_Right.getSpriteEffects(), new Vector2(0, -30), color, scale); previousAnimation = Enums.EnemyAnimations.LADYBUG_FLY_RIGHT; break; case Enums.EnemyAnimations.LADYBUG_ATTACK_LEFT: enemy.changeTexture(ladybug_Attack_Left.texture); tempRec = ladybug_Attack_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, ladybug_Attack_Left.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.LADYBUG_ATTACK_RIGHT: enemy.changeTexture(ladybug_Attack_Right.texture); tempRec = ladybug_Attack_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, ladybug_Attack_Right.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.SNAIL_ATTACK_RIGHT: enemy.changeTexture(snail_Attack_Right.texture); tempRec = snail_Attack_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, snail_Attack_Right.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.SNAIL_ATTACK_LEFT: enemy.changeTexture(snail_Attack_Left.texture); tempRec = snail_Attack_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, snail_Attack_Left.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.SNAIL_MOVE_LEFT: enemy.changeTexture(snail_Move_Left.texture); tempRec = snail_Move_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, snail_Move_Left.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.SNAIL_MOVE_RIGHT: enemy.changeTexture(snail_Move_Right.texture); tempRec = snail_Move_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, snail_Move_Right.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.SPIDER_ATTACK_RIGHT: enemy.changeTexture(spider_Attack_Right.texture); tempRec = spider_Attack_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, spider_Attack_Right.getSpriteEffects(), new Vector2(0, -30), color, scale); break; case Enums.EnemyAnimations.SPIDER_ATTACK_LEFT: enemy.changeTexture(spider_Attack_Left.texture); tempRec = spider_Attack_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, spider_Attack_Left.getSpriteEffects(), new Vector2(0, -30), color, scale); break; case Enums.EnemyAnimations.SPIDER_MOVE_LEFT: enemy.changeTexture(spider_Move_Left.texture); tempRec = spider_Move_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, spider_Move_Left.getSpriteEffects(), new Vector2(0, -0), color, scale); break; case Enums.EnemyAnimations.SPIDER_MOVE_RIGHT: enemy.changeTexture(spider_Move_Right.texture); tempRec = spider_Move_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, spider_Move_Right.getSpriteEffects(), new Vector2(0, -0), color, scale); break; case Enums.EnemyAnimations.HAWK_FLY_LEFT: enemy.changeTexture(hawk_Fly_Left.texture); tempRec = hawk_Fly_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, hawk_Fly_Left.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.HAWK_FLY_RIGHT: enemy.changeTexture(hawk_Fly_Right.texture); tempRec = hawk_Fly_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, hawk_Fly_Right.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.HAWK_ATTACK_LEFT: enemy.changeTexture(hawk_Attack_Left.texture); tempRec = hawk_Attack_Left.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, hawk_Attack_Left.getSpriteEffects(), new Vector2(0, -15), color, scale); break; case Enums.EnemyAnimations.HAWK_ATTACK_RIGHT: enemy.changeTexture(hawk_Fly_Right.texture); tempRec = hawk_Fly_Right.Update(gameTime); enemy.DrawSpriteBatch(spriteBatch, tempRec, hawk_Fly_Right.getSpriteEffects(), new Vector2(0, -15), color, scale); break; } }
public void NextAnimation(Enums.EnemyAnimations nextAnimation) { this.nextAnimation = nextAnimation; }