示例#1
0
 public MainController(Control Control, MessageFilter MessageFilter, Boolean EnableStepping, Boolean EnableDrawing, Boolean Online) : base(Control, MessageFilter, EnableStepping, EnableDrawing, Online)
 {
     // Simplest Controller
     Processing = new Thread(Run)
     {
         Name = "Controller"
     };
     //
     if (Online)
     {
         Connection = new DiepConnection();
         Connection.MessageReceived += Client_MessageReceived;
         Connection.Start();
         var connectMessage = new ConnectMessage()
         {
             Id   = -1,
             Name = DiepConnection.GetUsername(),
         };
         Connection.Enqueue(connectMessage);
     }
     // Starting Controller Dictionaries
     Tanks  = new Dictionary <long, Tank>();
     Shoots = new Dictionary <long, Shoot>();
     Shapes = new Dictionary <long, Shape>();
 }
示例#2
0
 private void SendOtherTanks(DiepConnection Connection)
 {
     foreach (var connection in Connections.ToArray().Where(a => a.Id != Connection.Id && a.Tank != null))
     {
         var tank         = connection.Tank;
         var bounds       = tank.Bounds;
         var spawnMessage = new TankSpawnMessage()
         {
             Id           = connection.Id,
             ServerTankId = tank.Id,
             Name         = connection.Tank.Name,
             Height       = bounds.Height,
             Width        = bounds.Width,
             TeamColor    = tank.TeamColor,
             Weight       = tank.Weight,
             X            = bounds.X,
             Y            = bounds.Y
         };
         Connection.Enqueue(spawnMessage);
     }
 }