public override void Update(GameTime gameTime) { HandleStun(gameTime, mAnimationPlayer, lightningCowAnimation, mPainAnimation); //mHealth -= 10; if (mHealth <= 0) { for (int i = 0; i < 10; i++) { Particle smoke = new Particle(mHackSmoke, mFixture.Body.Position, 1.0f); smoke.mScale = new Vector2(1f); float precision = 100f; float maxSmokeSpeed = 1f; float maxRotSpeed = 1.0f; float maxScaleSpeed = 1.0f; smoke.mVelocity = new Vector2( Particle.Random(-maxSmokeSpeed / 2, +maxSmokeSpeed / 2), Particle.Random(-maxSmokeSpeed / 2, +maxSmokeSpeed / 2)); smoke.mRotVel = Particle.Random(-maxRotSpeed / 2, +maxRotSpeed / 2); smoke.mScaleVel = -new Vector2( Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2), Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2)); GetGameWorld().AddGameObject(smoke); //Console.Out.WriteLine("Okay Cows are like smoke"); } } // mFixture.Body.LinearDamping = .01f; mFixture.Body.Rotation = 0f; timeElapsed += gameTime.ElapsedGameTime.TotalMilliseconds; if (timeElapsed > 1000) { timeElapsed = 0; getNextDirection(mPlayer); } Vector2 multiply = new Vector2(0, 0); switch (cowDirection) { case DIRECTION.UP: multiply.Y = 1f; break; case DIRECTION.RIGHT: multiply.X = 1f; break; case DIRECTION.DOWN: multiply.Y = -1f; break; case DIRECTION.LEFT: multiply.X = -1f; break; default: break; } mFixture.Body.ApplyLinearImpulse(multiply * cowMaxSpeed * .03f); if (!mAnimationPlayer.IsPlaying()) { mAnimationPlayer.Play(); } mAnimationPlayer.Update(gameTime); base.Update(gameTime); if (justSpawned) { if (cowRand.Next() % 2 == 0) mThunderSnd.Play(mThunderVolume, 0f, 0f); else mMooSnd.Play(mMooVolume, 0, 0); justSpawned = false; } /*Could be used for intermittent monster calls * mTimeSinceCall += gameTime.ElapsedGameTime.TotalMilliseconds; if (mTimeSinceCall > mCallFrequency) { mTimeSinceCall = 0; else if (cowRand.Next() % 19 == 0) { mMooSnd.Play(mMooVolume, 0f, 0f); } }*/ float speedParticle = 10f; if (mFixture.Body.LinearVelocity.Length() > speedParticle) { Particle smoke = new Particle(mHackSmoke, mFixture.Body.Position, 1.0f); smoke.mScale = new Vector2(0.5f); float precision = 100f; float maxSmokeSpeed = 2.0f; float maxRotSpeed = 1.0f; float maxScaleSpeed = 2.0f; smoke.mVelocity = new Vector2( Particle.Random(-maxSmokeSpeed / 2, +maxSmokeSpeed / 2), Particle.Random(-maxSmokeSpeed / 2, +maxSmokeSpeed / 2)); smoke.mRotVel = Particle.Random(-maxRotSpeed / 2, +maxRotSpeed / 2); smoke.mScaleVel = -new Vector2( Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2), Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2)); GetGameWorld().AddGameObject(smoke); mHealth -= 30; } //base.Update(gameTime); }
public bool playerOnCollision(Fixture one, Fixture two, FarseerPhysics.Dynamics.Contacts.Contact contact) { if (two.UserData.ToString() == "Sword" || two.Body.UserData.ToString() == "Sword") { //tempColor = Color.Red; return false; } else if (two.UserData.ToString() == "Monster" || two.Body.UserData.ToString() == "Monster") { // kill the player mPlayerDamageSnd.Play(mPlayerDamageVolume, 0, 0); // decrease health --mHealth; mPlayerDamageSnd.Play(mPlayerDamageVolume, -.3f, 0); if (this is AlivePlayer) { Particle ouch = new Particle(mOuch, mFixture.Body.Position + (new Vector2(30, 30) * Camera.kPixelsToUnits), 0.5f); ouch.mScale = new Vector2(1f, -1f); GetGameWorld().AddGameObject(ouch); } } else if (two.UserData.ToString() == "Soul" || two.Body.UserData.ToString() == "Soul") { mCollectSoulSnd.Play(mCollectSoulVolume, 0, 0); } //tempColor = Color.Red; return true; }
protected void Fart() { /*Particle smoke = new Particle(mHackSmoke, mPosition, 1.0f); float precision = 100f; float maxSmokeSpeed = 2.0f; float maxRotSpeed = 1.0f; float maxScaleSpeed = 1.0f; smoke.mVelocity = new Vector2( Particle.Random(-maxSmokeSpeed/2, +maxSmokeSpeed/2), Particle.Random(-maxSmokeSpeed/2, +maxSmokeSpeed/2)); smoke.mRotVel = Particle.Random(-maxRotSpeed/2, +maxRotSpeed/2); smoke.mScaleVel = -new Vector2( Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2), Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2)); GetGameWorld().AddGameObject(smoke);*/ Particle smoke = new Particle(mHackSmoke, new Vector2(mPosition.X, mPosition.Y - (20.0f * Camera.kPixelsToUnits)), .75f); smoke.mScale = new Vector2(0.1f); float precision = 100f; float maxSmokeSpeed = 0f; float maxRotSpeed = 1.0f; float maxScaleSpeed = 1.0f; smoke.mVelocity = new Vector2( Particle.Random(-maxSmokeSpeed/2, +maxSmokeSpeed/2), Particle.Random(-maxSmokeSpeed/2, +maxSmokeSpeed/2)); smoke.mRotVel = Particle.Random(-maxRotSpeed/2, +maxRotSpeed/2); smoke.mScaleVel = -new Vector2( Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2), Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2)); GetGameWorld().AddGameObject(smoke); }
public virtual bool monsterOnCollision(Fixture one, Fixture two, FarseerPhysics.Dynamics.Contacts.Contact contact) { tempColor = Color.Red; if ((String)two.Body.UserData == "Sword") { // --mHealth; //mFixture.Body.ApplyLinearImpulse(new Vector2(5f, 5f)); Vector2 forceOfHit = getKnockBack(one, two); //one.Body.LinearDamping = .01f; mFixture.Body.ApplyForce(forceOfHit * 3); //two.Body.ResetDynamics(); mFixture.Body.Mass *= 0.8f; //mFixture.Body. isHit = true; //this.mHealth -= 100; //Should play the bat collision sound but the Snd is too touchy, and the SEI isn't interruptable... //mHitMonsterSnd.Play(mHitMonsterSndVolume, -.5f, 0); //mHitMonsterSEI.Play(); Random rand = new Random(); // Particle smoke; switch(rand.Next(0,3)) { case 0: smoke = new Particle(critical, one.Body.Position, 1.0f); break; case 1: smoke = new Particle(pow, one.Body.Position, 1.0f); break; case 2: smoke = new Particle(hit, one.Body.Position, 1.0f); break; //case 3: // smoke = new Particle(hit, one.Body.Position, 1.0f); } smoke.mScale = new Vector2(1f, -1f); float precision = 100f; float maxSmokeSpeed = 2.0f; float maxRotSpeed = 1.0f; float maxScaleSpeed = 2.0f; smoke.mVelocity = new Vector2( Particle.Random(-maxSmokeSpeed / 2, +maxSmokeSpeed / 2), Particle.Random(-maxSmokeSpeed / 2, +maxSmokeSpeed / 2)); smoke.mRotVel = Particle.Random(-maxRotSpeed / 2, +maxRotSpeed / 2); smoke.mScaleVel = -new Vector2( Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2), Particle.Random(-maxScaleSpeed / 2, +maxScaleSpeed / 2)); if(GetGameWorld() != null) GetGameWorld().AddGameObject(smoke); mStunTimeout += 0.5f; } else mMonMonCollSnd.Play(mMonMonCollVolume, -.5f, 0); return true; }