public void ArtificialIntelligence(BARRIER barrier) { while (true) { try { this.rnd = new Random(); this.Move(this.rnd.Next(-1, 1), this.rnd.Next(-1, 1), barrier); } catch { Console.WriteLine("there can not move"); } break; } }
public void Move(int x, int y, BARRIER barrier) { if (!(barrier.X == this.X + x) & !(barrier.Y == this.Y + y)) { if (x >= base.X & x <= 0) { throw new Exception("object can not be located abroad, error x"); } if (y >= base.Y & y <= 0) { throw new Exception("object can not be located abroad, error y"); } this.X = x; this.Y = y; } }
public void Move(int x, int y, BARRIER barrier, BONUS bonus) { if (!(barrier.X == this.X + x) & !(barrier.Y == this.Y + y)) { if (x >= base.X & x <= 0) { throw new Exception("player can not be located abroad, error x"); } if (y >= base.Y & y <= 0) { throw new Exception("player can not be located abroad, error y"); } this.X = x; this.Y = y; } if (bonus.X == this.X + x & bonus.Y == this.Y + y) { this.Speed += bonus.Speedincrease; this.Effecttime += bonus.Effecttime; } }