public ParticleAnimation NewInstance(int XPos, int YPos, bool randomized) { ParticleAnimation clonedParticle = new ParticleAnimation( Texture, RectInitialFrame.X, RectInitialFrame.Y, RectInitialFrame.Width, RectInitialFrame.Height, FrameCount, Columns, FrameLength ); clonedParticle.Position = new Vector2(XPos, YPos); if (randomized) { double mantissa = (random.NextDouble() * 2.0) - 1.0; double exponent = Math.Pow(2.0, random.Next(0, 6)); float RotationAngle = (float)(mantissa * exponent); float circle = MathHelper.Pi * 2; clonedParticle.Rotation = RotationAngle % circle; } else { clonedParticle.Rotation = 0; } clonedParticle.effects = SpriteEffects.FlipHorizontally; return(clonedParticle); }
public ParticleAnimation NewInstance(int XPos, int YPos, bool randomized, Direction direction) { ParticleAnimation clonedParticle = NewInstance(XPos, YPos, randomized); if (direction == Direction.Left) { clonedParticle.effects = SpriteEffects.FlipHorizontally; } else { clonedParticle.effects = SpriteEffects.None; } return(clonedParticle); }
public ProjectileManager(ContentManager content) { player1Projectiles = new List <Projectile>(); player2Projectiles = new List <Projectile>(); particles = new List <ParticleAnimation>(); // Load some universal things // Dictionary <String, Object> moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/impact.txt"); Texture2D punchTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); punchEffect = new ParticleAnimation( punchTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/spikySlash.txt"); Texture2D spikySlashTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); spikySlashEffect = new ParticleAnimation( spikySlashTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/spikyImpact.txt"); Texture2D spikyImpactTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); spikyImpactEffect = new ParticleAnimation( spikyImpactTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/impactSlash.txt"); Texture2D impactSlashTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); impactSlashEffect = new ParticleAnimation( impactSlashTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/slash.txt"); Texture2D slashTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); slashEffect = new ParticleAnimation( slashTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/block.txt"); Texture2D blockTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); blockEffect = new ParticleAnimation( blockTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/portraits/LongSword.txt"); Texture2D portraitTexture = content.Load <Texture2D>("LongSword/" + (String)moveInfo["sprite"]); portrait = new ParticleAnimation( portraitTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/jumpDust.txt"); Texture2D jumpTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); jumpEffect = new ParticleAnimation( jumpTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine moveInfo = PlayerFactory.parseMoveInfo("Config/Base/effect/dashDust.txt"); Texture2D dashTexture = content.Load <Texture2D>((String)moveInfo["sprite"]); dashEffect = new ParticleAnimation( dashTexture, int.Parse((String)moveInfo["XImageStart"]), int.Parse((String)moveInfo["YImageStart"]), int.Parse((String)moveInfo["Width"]), int.Parse((String)moveInfo["Height"]), int.Parse((String)moveInfo["FrameCount"]), int.Parse((String)moveInfo["Columns"]), float.Parse((String)moveInfo["FrameLength"]) ); // As a default this is prob fine }