public void AddEnemy() // hazi { Random rnd = new Random(); model.Enemies.Add(new Enemy(rnd.Next(0, (int)Config.Width), 0, Config.EnemySize, Config.EnemySize)); RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void MoveBall() { if (MoveShape(model.Ball)) { model.Errors++; } RefreshScreen?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Method for loading last state. /// </summary> public void LoadSave() { this.repository.LoadModelFromXml(); this.player = model.Player; this.traffic = model.Traffic; this.enemy = model.Enemy; this.lanes = model.Lanes; RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void MoveEnemies() // hazi, csak áthelyezve halálkor { for (int i = 0; i < model.Enemies.Count(); i++) { if (MoveEnemy(i)) { RelocateEnemy(model.Enemies.ElementAt(i)); } } RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void MoveEnemies2() // hazi, listabol kiszedve halálkor { for (int i = 0; i < model.Enemies.Count(); i++) { if (MoveEnemy(i)) { RemoveEnemy(model.Enemies.ElementAt(i)); } } RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void MoveStars() // Phase 2 { foreach (Star star in model.Stars) { if (MoveShape(star)) { model.Errors++; } } RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void MovePad(Direction d) { if (d == Direction.Left) { model.Pad.ChangeX(-10); } else { model.Pad.ChangeX(10); } RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void MovePad(Direction direction) { switch (direction) { case Direction.Left: model.Pad.ChangeX(-10); break; case Direction.Right: model.Pad.ChangeX(10); break; } RefreshScreen?.Invoke(this, EventArgs.Empty); }
public bool MoveShape(MyShape shape) // hazi { bool faulted = false; shape.ChangeX(shape.Dx); shape.ChangeY(shape.Dy); if (shape.Area.Left < 0 || shape.Area.Right > Config.Width) { shape.Dx = -shape.Dx; } if (shape.Area.Top < 0 || shape.Area.IntersectsWith(model.Pad.Area)) { shape.Dy = -shape.Dy; } if (shape == model.Ball && model.Enemies.Any(t => t.Area.IntersectsWith(shape.Area))) // hazi { Random rnd = new Random(); int temp = rnd.Next(1, 4); switch (temp) { case 1: model.Ball.Dx = -model.Ball.Dx; break; case 2: model.Ball.Dy = -model.Ball.Dy; break; case 3: model.Ball.Dx = -model.Ball.Dx; model.Ball.Dy = -model.Ball.Dy; break; } } if (shape.Area.Bottom > Config.Height) { shape.SetXY(shape.Area.X, Config.Height / 2); faulted = true; } RefreshScreen?.Invoke(this, EventArgs.Empty); return(faulted); }
/// <summary> /// Method for moving traffic. /// </summary> public void MoveTraffic() { foreach (var car in traffic) { if (!gameOver) { speed *= SPEED_MULTIPLIER; model.Score += speed / 100; if (!bossSequence && Math.Round(model.Score) != 0 && Math.Round(model.Score) % 500 == 0) { BossSequence?.Invoke(this, EventArgs.Empty); } if (!gameOver && car.Active) { MoveCar(car); } RefreshScreen?.Invoke(this, EventArgs.Empty); } } }
public bool MoveEnemy(int id) // hazi { bool smash = false; MyShape shape = model.Enemies.ElementAt(id); shape.ChangeX(shape.Dx); shape.ChangeY(shape.Dy); if (shape.Area.Left < 0 || shape.Area.Right > Config.Width) { shape.Dx = -shape.Dx; } if (shape.Area.Top < 0 || shape.Area.Bottom > Config.Height) { shape.Dy = -shape.Dy; } if (shape.Area.IntersectsWith(model.Ball.Area)) { smash = true; } RefreshScreen?.Invoke(this, EventArgs.Empty); return(smash); }
public void JumpPad(double x) { model.Pad.SetXY(x, model.Pad.Area.Y); RefreshScreen?.Invoke(this, EventArgs.Empty); }
public void AddStar() // Phase 2 { model.Stars.Add(new Star(Config.Width / 2, Config.Height / 2, 10, 8)); RefreshScreen?.Invoke(this, EventArgs.Empty); }