X hits on this document

400 views

0 shares

0 downloads

0 comments

79 / 102

else

   projectileStartPosition = new Vector2(175, 340);

projectile = new Projectile(curGame, spriteBatch,

   "Textures/Ammo/rock_ammo", projectileStartPosition,

   animations["Fire"].frameSize.Y, isAI, gravity);

projectile.Initialize();

AnimationRunning = false;

stallUpdateCycles = 0;

...

175.

Further modify the Initialize method by adding the following code at the top of the method:

C#

...

{

// Load multiple animations form XML definition

XDocument doc = XDocument.Load("Content/Textures/Catapults/AnimationsDef.xml");

XName name = XName.Get("Definition");

var definitions = doc.Document.Descendants(name);

// Loop over all definitions in XML

foreach (var animationDefinition in definitions)

{

   bool? toLoad = null;

   bool val;

if (bool.TryParse(animationDefinition.Attribute("IsAI").Value, out val))

       toLoad = val;

   // Check if the animation definition need to be loaded for current

   // catapult

   if (toLoad == isAI || null == toLoad)

   {

       // Get a name of the animation

string animatonAlias = animationDefinition.Attribute("Alias").Value;

       Texture2D texture =

           curGame.Content.Load<Texture2D>(

           animationDefinition.Attribute("SheetName").Value);

       // Get the frame size (width & height)

       Point frameSize = new Point();

       frameSize.X = int.Parse(

Page | 79

Document info
Document views400
Page views400
Page last viewedTue Jan 24 22:11:56 UTC 2017
Pages102
Paragraphs3115
Words17333

Comments