public Creature(int startLocationX, int startLocationY) { speed = BASE_SPEED; imageToggle = 0; location = new Point(startLocationX, startLocationY); direction = Direction.Up; }
public bool CanMove(Direction d) { switch (d) { case Direction.Down: if ((Y < Game.play.Map.MapSize.Y - 1) && (Game.play.Map.Map[Y + 1, X] != '#')) return true; else return false; case Direction.Left: if ((X > 0) && (Game.play.Map.Map[Y, X - 1] != '#')) return true; else return false; case Direction.Right: if ((X < Game.play.Map.MapSize.X - 1) && ( Game.play.Map.Map[Y, X + 1] != '#')) return true; else return false; case Direction.Up: if ((Y > 0) && (Game.play.Map.Map[Y - 1, X] != '#')) return true; else return false; } return false; }
void LoadMap(int Level) { string[] tMap; tMap = System.IO.File.ReadAllLines("Maps\\"+ Level.ToString()); int i, j = 0; MapSize.Y = tMap.GetLength(0); MapSize.X = tMap[0].Length; Map = new char[MapSize.Y, MapSize.X]; for (i = 0; i < MapSize.Y; i++) { for (j = 0; j < MapSize.X; j++) { char NextSym = ' '; #region Enemy on map if (tMap[i][j] == 'S'){ Enemies.Add(new Point(j,i)); } #endregion #region Super berry else if (tMap[i][j] == 'N'){ //SpecialDots.Add(new SpecialDot(new Point(j,i))); NextSym = Convert.ToChar(164); TotalDots += 1; } #endregion #region Player else if (tMap[i][j] == '^'){ StartPoint = new Point(j,i); StartDirection = Direction.Down; } else if (tMap[i][j] == 'v'){ StartPoint = new Point(j,i); StartDirection = Direction.Up; } else if (tMap[i][j] == '<'){ StartPoint = new Point(j,i); StartDirection = Direction.Right; } else if (tMap[i][j] == '>'){ StartPoint = new Point(j, i); StartDirection = Direction.Left; } #endregion #region Wall else if (tMap[i][j] == '#'){ NextSym = '#'; } #endregion #region Berry else { TotalDots+=1; NextSym = Convert.ToChar(183); } #endregion Map[i, j] = NextSym; } } }
public void MoveCursor(Direction d) { if (d == Direction.Left) { if (Cursor > 0) Cursor--; } if (d == Direction.Right) { if (Text.Length > Cursor) { Cursor++; } } DrawText(); }
/// <summary> /// Determines the location the user is trying to move to /// </summary> /// <param name="directionToMove"></param> /// <returns></returns> public Point GetNextLocation(Direction directionToMove) { Point attemptedLocation = location_cellIndex; switch (directionToMove) { case Direction.Up: attemptedLocation.Y--; break; case Direction.Left: attemptedLocation.X--; break; case Direction.Right: attemptedLocation.X++; break; case Direction.Down: attemptedLocation.Y++; break; default: break; } return attemptedLocation; }
public Direction ReverseMove(Direction d) { switch (d) { case Direction.Left: return Direction.Right; case Direction.Down: return Direction.Up; case Direction.Up: return Direction.Down; case Direction.Right: return Direction.Left; } return Direction.Left; }
public virtual void MoveUp() { if (CanMove(Direction.Up)) { D = Direction.Up; Y -= 1; } else if ((Y == 0) && (Game.play.Map.Map[Game.play.Map.MapSize.Y - 1, X] != '#')) { D = Direction.Up; Y = Game.play.Map.MapSize.Y - 1; } }
public virtual void MoveRight() { if (CanMove(Direction.Right)) { D = Direction.Right; X +=1; } else if ((X == Game.play.Map.MapSize.X - 1) && (Game.play.Map.Map[Y, 0] != '#')) { D = Direction.Right; X = 0; } }
public virtual void MoveLeft() { if (CanMove(Direction.Left)) { D = Direction.Left; X -=1; } else if ((X == 0) && (Game.play.Map.Map[Y, Game.play.Map.MapSize.X - 1] != '#')) { D = Direction.Left; X = Game.play.Map.MapSize.X - 1; } }
public virtual void MoveDown() { if (CanMove(Direction.Down)) { D = Direction.Down; Y += 1; } else if ((Y == Game.play.Map.MapSize.Y - 1) && (Game.play.Map.Map[0, X] != '#')) { D = Direction.Right; Y = 0; } }
public virtual void Move(Direction md) { switch (md) { case Direction.Up: MoveUp(); break; case Direction.Down: MoveDown(); break; case Direction.Left: MoveLeft(); break; case Direction.Right: MoveRight(); break; } }