Example #1
0
 public Entity(Area l, ISaveLoad saveLoad)
 {
     SaveLoad = saveLoad;
     Location = l;
     CurObjective = new objectives.Idle(this);
     CurAction = CurObjective.GetAction();
 }
Example #2
0
 public MoveMessage(Entity e, Area from, Area to)
 {
     this.ent = e.ID.ToString() ;
     this.fromx = from.X.ToString();
     this.fromy = from.Y.ToString();
     this.tox = to.X.ToString();
     this.toy = to.Y.ToString();
 }
Example #3
0
 public Entity(Area l, ILogger logger, ISaveLoad saveLoad, int id)
 {
     ID = id;
     _logger = logger;
     SaveLoad = saveLoad;
     Location = l;
     CurObjective = new objectives.Idle(this);
     CurAction = CurObjective.GetAction();
     _char = new Character(saveLoad, logger, "Ted", 20, 200, 20, 20, 20, this.ID);
 }
Example #4
0
 public void Move(Area d)
 {
     _logger.Log(new MoveMessage(this, Location, d));
     Location.RemoveEntity(this);
     Location = d;
     _logger.Log(String.Format("{0} moved to {1}", _char.Name, d.ToString()));
     d.AddEntity(this);
 }
Example #5
0
 public void Travel(Area d)
 {
     Location.RemoveEntity(this);
     Location = d;
     d.AddEntity(this);
 }
Example #6
0
 public void process( IWebSocketConnection socket, LinkedList<Entity> entList,  NormalWorld world )
 {
     switch (type)
     {
         case "entityRequest":
             foreach( Entity e in entList ) {
                 if( e.ID == int.Parse(args["Id"]))
                 {
                     StatusMessage toSend = new StatusMessage(e._char);
                     socket.Send(toSend.getJsonString());
                 }
             }
             return;
         case "moveRoute":
             Entity toMove = null;
             foreach (Entity e in entList)
             {
                 if (e.ID == int.Parse(args["Id"]))
                 {
                     toMove = e;
                 }
             }
             String[] coordsList = args["moveList"].Split(',');
             Area[] route = new Area[coordsList.Length];
             int i = 0;
             foreach (String s in coordsList)
             {
                 String[] coordsPair = s.Split(':');
                 route[i] = world.GetArea(int.Parse(coordsPair[0]), int.Parse(coordsPair[1]));
                 i++;
             }
             MoveLoop moveLoop = new MoveLoop(toMove, route, world);
             toMove.CurObjective = moveLoop;
             return;
     }
 }