private bool Body_OnCollision(Fixture fixturea, Fixture fixtureb, Contact contact) { if (!Convert.ToString(fixtureb.UserData).Equals("wall") && !Convert.ToString(fixtureb.UserData).Equals("ship")) { if (fixtureb.Body.IsBullet) { String data = Convert.ToString(fixtureb.UserData); String[] splitdata = data.Split(':'); String shotType = splitdata[0]; int shotEffect = Convert.ToInt32(splitdata[1]); switch(shotType) { case("standard"): { sheilds -= shotEffect; break; } case ("emp"): { currentNegativeState = negativeState.Emped; negativeEffectTime = (shotEffect*1000); break; } case ("net"): { sheilds -= shotEffect; if(shotEffect > 0) { Console.Out.WriteLine("Damage = " + shotEffect); Console.Out.WriteLine("sheilds = " + sheilds); } break; } } //been shot return true; } else if (!Convert.ToString(fixtureb.UserData).Equals("")) { String powerupData = Convert.ToString(fixtureb.UserData); switch (powerupData) { case "shield": { sheilds = 200; break; } case "Shotgun": { currentFireState = fireState.Shotgun; break; } case "Laser": { currentFireState = fireState.Laser; break; } case "Machinegun": { currentFireState = fireState.Machinegun; break; } case "Spiral": { currentPassiveState = passiveState.SpiralFire; break; } case "Emp": { currentSecondaryFire = secondaryFire.EmpShot; altFireQuantity = 5; break; } case "Net": { currentSecondaryFire = secondaryFire.Net; altFireQuantity = 1; break; } } return false; //powerup } else { return true; } } else { float Yvel = base.mSpriteBody.LinearVelocity.Y; float Xvel = base.mSpriteBody.LinearVelocity.X; int wallDamage = (int)Math.Max(Math.Sqrt(Yvel*Yvel), Math.Sqrt(Xvel*Xvel)); sheilds -= wallDamage; return true; } }
public void updateNegativeShipState(GameTime gameTime, Matrix _view) { switch (currentNegativeState) { case (negativeState.Emped): { negativeEffectTime -= gameTime.ElapsedGameTime.Milliseconds; if (negativeEffectTime <= 0) { currentNegativeState = negativeState.Standard; negativeEffectTime = 0; } break; } } }