public override void Load(ContentManager content) { Screen.soundController.LoadGameSounds(content, this, map.CurrentMap.backgroundMusic); this.camera = new CameraController(Screen, map.Model.zoomBox); //The effects image for hits this.effectImg = new ImageController(Screen, "GameStuff/GameEffects", 110); this.effectImg.OriginDefault = new Vector2(130 / 2, 130 / 2); this.effectImg.ScaleDefault = 0.1f; this.effectImg.OnAnimationDone += OnHitAnimationDone; this.effectImg.SetFrameRectangle(200, 200); this.effectImg.FramesPerRow = 2; AddController(effectImg); //Creates the countdown before starting game countDown = new ImageController(Screen, "GameStuff/CountDown", 900, true); countDown.OriginDefault = new Vector2(150, 150); countDown.ScaleDefault = 0; countDown.SetFrameRectangle(300, 300); countDown.FramesPerRow = 2; var imgModel = countDown.SetPosition(Constants.WindowWidth / 2, Constants.WindowHeight / 2); //Set callback to determin when the game is finished imgModel.Callback = countDownNext; countDown.AnimateScale(0.7f, (countDownTime / 4) * 1000, true); AddController(countDown); gameOver = new ImageController(Screen, "GameStuff/GameOver", 150, true); gameOver.OriginDefault = new Vector2(300, 100); gameOver.ScaleDefault = 0; this.powerUps = new PowerUpController(Screen, map.Model.DropZone); AddController(powerUps); //Creates characterController, and PlayerStatsController createCharacters(content); if (!Screen.GameOptions.UseLifes) { timeLeft = new TimeSpan(0, Screen.GameOptions.Minutes, 0); timer = new TextBox(getTimeLeft(), FontDefualt, new Vector2(Constants.WindowWidth - 80, 10), Color.White); timer.Layer = 150; timer.StaticPosition = true; AddView(timer); } AddController(camera); AddController(this.map); SubscribeToGameState = true; }
public override void Load(ContentManager content) { Screen.soundController.LoadGameSounds(content, this, map.CurrentMap.backgroundMusic); this.camera = new CameraController(Screen, map.Model.zoomBox); //The effects image for hits this.effectImg = new ImageController(Screen, "GameStuff/GameEffects", 110); this.effectImg.OriginDefault = new Vector2(130 / 2, 130 / 2); this.effectImg.ScaleDefault = 0.1f; this.effectImg.OnAnimationDone += OnHitAnimationDone; this.effectImg.SetFrameRectangle(200, 200); this.effectImg.FramesPerRow = 2; AddController(effectImg); //Creates the countdown before starting game countDown = new ImageController(Screen, "GameStuff/CountDown", 900, true); countDown.OriginDefault = new Vector2(150, 150); countDown.ScaleDefault = 0; countDown.SetFrameRectangle(300, 300); countDown.FramesPerRow = 2; var imgModel = countDown.SetPosition(Constants.WindowWidth / 2, Constants.WindowHeight / 2); //Set callback to determin when the game is finished imgModel.Callback = countDownNext; countDown.AnimateScale(0.7f, (countDownTime/4) * 1000, true); AddController(countDown); gameOver = new ImageController(Screen, "GameStuff/GameOver", 150, true); gameOver.OriginDefault = new Vector2(300, 100); gameOver.ScaleDefault = 0; this.powerUps = new PowerUpController(Screen, map.Model.DropZone); AddController(powerUps); //Creates characterController, and PlayerStatsController createCharacters(content); if (!Screen.GameOptions.UseLifes) { timeLeft = new TimeSpan(0, Screen.GameOptions.Minutes, 0); timer = new TextBox(getTimeLeft(), FontDefualt, new Vector2(Constants.WindowWidth - 80, 10), Color.White); timer.Layer = 150; timer.StaticPosition = true; AddView(timer); } AddController(camera); AddController(this.map); SubscribeToGameState = true; }
private void OnPlayerHit(Vector2 pos, int damageDone, int newDamagepoints, int puncher, int reciever, string sound) { Screen.soundController.PlaySound(sound); this.players[puncher].DidHit(damageDone, reciever); this.players[reciever].GotHit(newDamagepoints, puncher); Random r = new Random(); ImageModel inf = effectImg.AddPosition(pos); inf.CurrentFrame = r.Next(0, 4); effectImg.AnimateScale(inf, 0.7f, 200); }
/// <summary> /// Adds new random powerup to the map insise the drop zone /// </summary> public void addPowerUpToMap() { ImageModel model = powerUpImg.AddPosition(randomDropPosition()); model.SetBoundBox(World, 50, 50, Vector2.Zero, Category.Cat6, Category.All); model.BoundBox.OnCollision += OnCollision; powerUpImg.AnimateScale(model, 1f, 400, false); elapsedTime = 0; generateTimeToNext(); PowerUpStatus status = new PowerUpStatus(randomPowerUp(), model); model.BoundBox.UserData = status; //model.CurrentFrame = (int)MathHelper.Clamp(status.PowerUp.imageFrame, 0f, 3f); waitingPowerUps.Add(status); }