public Character(string textureName, Vector2 position, ContentManager content, int frameCount) { mContent = content; mTextureName = textureName; mPosition = position; mAge = age.BABY; mStates = states.SPAWNING; mSpeed = new Vector2(1.0f, 0.25f); //mSpeed = new Vector2(0, 0); mSprite = new AnimatedSprite(); //mSprite.Load(mContent, "AnimatedSprites/" + mTextureName, frameCount, 30, 149, 139, false); mSprite.Load(mContent, "AnimatedSprites/" + mTextureName, frameCount, 0.125f, 128, 128, false); bSphere = new BoundingSphere(new Vector3(position.X + mSprite.getWidth() / 2, position.Y + mSprite.getHeight() / 2, 0), mSprite.getWidth() / 2); distance = 10000; destination = Vector2.Zero; timeEating = 2.0f; timeOnFire = 0.5f; respawnRate = 3.0f; remove = false; multipleOfTwo = false; hacktex = Class1.CreateCircle((int)mSprite.getWidth() / 2, Color.Yellow); timespawning = 2.0f; }
static void Main(string[] args) { age Child = new age(); do { do { Console.WriteLine("Please type the age of the father"); }while(!int.TryParse(Console.ReadLine(), out Child.age_of_dad)); }while(Child.age_of_dad < 13); do { do { Console.WriteLine("Please type the age of the mother"); }while(!int.TryParse(Console.ReadLine(), out Child.age_of_mom)); }while(Child.age_of_mom < 13); do { do { Console.WriteLine("Please type the age of the child"); }while(!int.TryParse(Console.ReadLine(), out Child.age_of_child)); }while(Child.age_of_child > Child.age_of_mom - 13); Child.child(); Console.ReadKey(); }
public void Age_GivenUnit_HaveValuesInXml() { var age = new age(AgeUnit.month); var xAge = new YmlSerializer().ToXDocument(age).Root; xAge.Should().NotBeNull(); xAge.Should().HaveAttribute("unit", AgeUnit.month.ToString()); }
public void Age_GivenYearUnitAndValidValue_HaveValuesInXml() { var age = new age(AgeUnit.year, 12); var xAge = new YmlSerializer().ToXDocument(age).Root; xAge.Should().NotBeNull(); xAge.Should().HaveAttribute("unit", AgeUnit.year.ToString()); xAge.Should().HaveValue(12.ToString()); }
// public void setSeek(bool seek) // { // if (seek == true && mStates == states.WALKING) // mStates = states.SEEKING; // else if (seek == false) // mStates = states.WALKING; // } public void Update(GameTime gameTime, GraphicsDeviceManager graphics) { if (mStates != states.DEAD) { bSphere.Center = new Vector3(mPosition.X + mSprite.getWidth() / 2, mPosition.Y + mSprite.getHeight() / 2, 0.0f); } mSprite.Update((float)gameTime.ElapsedGameTime.TotalSeconds); if (mStates == states.SPAWNING) { if (timespawning > 0) { timespawning =- gameTime.ElapsedGameTime.Seconds; } else { mSprite.LoadEnum(mContent, spriteText.BABYJUMP, false); mStates = states.WALKING; } } else if (mStates == states.ONFIRE) { timeOnFire -= (float)gameTime.ElapsedGameTime.TotalSeconds; mPosition.X += mSpeed.X; mPosition.Y += mSpeed.Y; if (timeOnFire <= 0) { if (mAge == age.BABY) { mSprite.LoadEnum(mContent, spriteText.BABYDEATH, true); } else if (mAge == age.MEDIUM) { mSprite.LoadEnum(mContent, spriteText.MIDDEATH, true); } else { mSprite.LoadEnum(mContent, spriteText.FATTYDEATH, true); } mStates = states.DEAD; timeOnFire = 0.5f; } } else if (mStates == states.DEAD) { //changeImage("charMediumDead", Frames.CHAR_MED_DEAD_FRAMES); respawnRate -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (respawnRate <= 0) { remove = true; respawnRate = 3.0f; } } else if (mStates == states.WALKING) { mPosition.X += mSpeed.X; if (mAge != age.FAT) mPosition.Y += hopY[hopCounter]; //else //mPosition.Y += fathopY[hopCounter]; hopCounter++; if (hopCounter >= 20) { if (mAge == age.FAT) hopCounter = 0; else if (mPosition.Y > graphics.GraphicsDevice.Viewport.Height / 10) { if (HackRandom.rand.Next(0, 7) <= 4) mPosition.Y -= 10.0f; else mPosition.Y += 10.0f; } else { if (HackRandom.rand.Next(0, 6) <= 4) mPosition.Y += 10.0f; else mPosition.Y -= 10.0f; } hopCounter = 0; } } else if (mStates == states.SEEKING) { mSpeed.X = 1; mSpeed.Y = 1; int xDir = 0; int yDir = 0; float xMove = destination.X - Position.X; float yMove = destination.Y - Position.Y; /* Mmmmm, mmm! Spaghetti code! */ if (Math.Abs(mPosition.X - destination.X) < 20 && Math.Abs(mPosition.Y - destination.Y) < 20) { mStates = states.EATING; if (mAge == age.BABY) { mSprite.LoadEnum(mContent, spriteText.BABYEAT, false); } else if (mAge == age.MEDIUM) { mSprite.LoadEnum(mContent, spriteText.MIDEAT, false); } else { mSprite.LoadEnum(mContent, spriteText.FATTYEAT, false); } } if (mPosition.X != destination.X) { xDir = (int)(xMove / Math.Abs(xMove)); mPosition.X += mSpeed.X * xDir; } if (mPosition.Y != destination.Y) { yDir = (int)(yMove / Math.Abs(yMove)); mPosition.Y += mSpeed.Y * yDir; } } else if (mStates == states.EATING) { timeEating -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (timeEating < 0) { mStates = states.WALKING; if (mAge == age.BABY) { mAge = age.MEDIUM; mStates = states.WALKING; timeEating = 2.0f; mSprite.LoadEnum(mContent, spriteText.MIDJUMP, false); } else if (mAge == age.MEDIUM) { mAge = age.FAT; mSprite.LoadEnum(mContent, spriteText.FATTYJUMP, false); } } } //bSphere.Center = new Vector3(mPosition.X, mPosition.Y, 0.0f); if (mPosition.X + getWidth() > graphics.GraphicsDevice.Viewport.Width) mSpeed.X *= -1; else if (mPosition.X <= 0) mSpeed.X *= -1; if (mPosition.Y + getHeight() > graphics.GraphicsDevice.Viewport.Height) mSpeed.Y *= -1; else if (mPosition.Y <= 0) mSpeed.Y *= -1; }
public Pet(bool type, string name, uint age, bool gender, uint idNumber, bool isHere) => InitValues(type, name, age, gender, idNumber, isHere);