Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private IEnumerator<KeyboardState> GetBehaviour()
- {
- KeyboardState state = null;
- // random moves
- while (true)
- {
- var avalibleList = GetPath();
- var randomMove = _random.Next(avalibleList.Count);
- BombSet = false;
- if (avalibleList[randomMove] == Keys.SPACE)
- BombSet = true;
- state = GetDownKeyboardState(avalibleList[randomMove]);
- //if (num <= 24)
- //{
- // state = GetDownKeyboardState(Keys.LEFT);
- //}
- //if (num > 24 && num <= 48)
- //{
- // state = GetDownKeyboardState(Keys.UP);
- //}
- //if (num > 48 && num <= 72)
- //{
- // state = GetDownKeyboardState(Keys.RIGHT);
- //}
- //if (num > 72 && num <= 98)
- //{
- // state = GetDownKeyboardState(Keys.DOWN);
- //}
- //if (num > 98 && num <= 100)
- //{
- // state = GetDownKeyboardState(Keys.SPACE);
- // BombSet = true;
- //}
- for (int i = 0; i < ConstantValues.CountToMoveOnActualPosition; i++)
- {
- yield return state;
- }
- }
- }
- /// <summary>
- /// Check if can make next step to avoid walls and bricks
- /// </summary>
- /// <returns></returns>
- private List<Keys> GetPath()
- {
- var avalibleMoves = new List<Keys>();
- var num = _random.Next(100);
- if (this.Movable(this.X - 1, this.Y))
- {
- avalibleMoves.Add(Keys.LEFT);
- }
- if (this.Movable(this.X, this.Y - 1))
- {
- avalibleMoves.Add(Keys.UP);
- }
- if (this.Movable(this.X + 1, this.Y))
- {
- avalibleMoves.Add(Keys.RIGHT);
- }
- if (this.Movable(this.X, this.Y + 1))
- {
- avalibleMoves.Add(Keys.DOWN);
- }
- if (num > 70 && num <= 100)
- avalibleMoves.Add(Keys.SPACE);
- return avalibleMoves;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement