Exemplo n.º 1
0
 private void timelapsed(object sender, GameTimerEventArgs e)
 {
     switch (e.timeInterval)
     {
         case TimeInterval.Minute:
             DateTime start = DateTime.Now;
             GameServer.Instance.Send(this.gameId, Guid.Empty, "Hour Elapsed");
             Mobile[] mobiles = Mobiles.ToArray();
             foreach (Mobile m in mobiles)
             {
                 if (Game.Random.Next(1) > 0) break;
                 int x = (int)(m.Position.X + (Game.Random.Next(2) - 1));
                 int y = (int)(m.Position.Y + (Game.Random.Next(2) - 1));
                 if (x > 99) x = 99;
                 if (y > 99) y = 99;
                 if (x < 0) x = 0;
                 if (y < 0) y = 0;
                 Position newPosition = new Position(x, y, 0);
                 m.Move(newPosition);
             }
             Console.WriteLine((DateTime.Now - start).TotalMilliseconds);
             break;
         case TimeInterval.Day:
             GameServer.Instance.Send(this.gameId, Guid.Empty, "Day Elapsed");
             break;
     }
 }
Exemplo n.º 2
0
 public Mobile(Position p)
     : base(Game.Instance.World, p)
 {
     this.viewRadius = 5;
     InterestManager.Instance.Register(this);
 }
 public void Move(Position p, float timeToTake)
 {
     PositionedObjectChangedEventArgs args = new PositionedObjectChangedEventArgs(PositionedObjectChangedType.Position);
     args.Type = PositionedObjectChangedType.Position;
     this.Position = p;
     OnChange(args);
 }
 public void Move(Position p)
 {
     Move(p, 0);
 }
 public PositionedObject(World world, Position position)
 {
     this.position = position;
     id = Guid.NewGuid();
     //InterestManager.Instance.Register(this);
 }
Exemplo n.º 6
0
 public Terrain(Position p)
     : base(Game.Instance.World, p)
 {
     this.viewRadius = int.MinValue;
     InterestManager.Instance.Register(this);
 }