private Hero MakeFakeMove(UserChoise userChoise) { LastPosX = Hero.PositionX; LastPosY = Hero.PositionY; var hero = new Hero() { PositionX = Hero.PositionX, PositionY = Hero.PositionY }; hero.OnMove(this, userChoise); return(hero); }
public void OnMove(object sender, UserChoise e) { switch (e) { case UserChoise.Down: PositionY -= 1; break; case UserChoise.Up: PositionY += 1; break; case UserChoise.Left: PositionX -= 1; break; case UserChoise.Right: PositionX += 1; break; } Moved?.Invoke(this, this); }
private void OnUserInput(object sender, UserChoise e) { if (e == UserChoise.Restart) { _boardHandler.DrawAll(); IsBombExploided = false; return; } if (IsBombExploided) { _messenger.ShowError("HIT"); return; } if (!_boardHandler.IsValidMove(e)) { return; } Move?.Invoke(this, e); _boardHandler.DrawAll(); }
public bool IsValidMove(UserChoise userChoise) { var hero = MakeFakeMove(userChoise); if (hero.PositionX == Board.SizeX) { return(false); } if (hero.PositionY == Board.SizeY) { return(false); } if (hero.PositionX == 0) { return(false); } if (hero.PositionY == 0) { return(false); } return(true); }
public void AddListener(UserChoise listener) { ChoiseEvent += listener; }