Example #1
0
 public void ChangeScreen(int BalloonID, Screen newScreen)
 {
     lock(m_bubbles)
     {
         ServerBalloon b = GetBubble(BalloonID);
         b.Screen = newScreen;
     }
 }
Example #2
0
 private int ScreenIndex(Screen s)
 {
     lock(m_screens) {
         int i = 0;
         foreach(Screen v in m_screens) {
             if(s.ID == v.ID) {
                 return i;
             }
             i++;
         }
         return -1;
     }
 }
Example #3
0
 private bool HandleScreenConnected(ConnectedMessage msg)
 {
     int screenID = m_nextScreenID++;
     Screen screen = new Screen("Screen-" + screenID, screenID, msg.Connection, this);
     m_screens.Add( screen);
     lock(m_bubbles)
     {
         for(int i = 0; i < ServerBalloon.NewBalloonsForScreen; i++)
         {
             // Create a new balloon for the screen
             ServerBalloon b = CreateBalloon();
             Direction dir;
             float y;
             Vector2D velocity;
             if((b.ID % 2) == 0)
             {
                 dir = Direction.Left;
                 velocity = ServerBalloon.VelocityRight;
                 y = 0.2f;
             }
             else
             {
                 dir = Direction.Right;
                 velocity = ServerBalloon.VelocityLeft;
                 y = 0.1f;
             }
             screen.EnqueueMessage(new NewBalloonMessage(b.ID, dir, y, velocity), this);
         }
     }
     return true;
 }
Example #4
0
 private Screen GetPreviousScreen(Screen s)
 {
     int screen_idx = ScreenIndex(s);
     if(screen_idx == -1)
         return null;
     screen_idx = screen_idx != 0 ? screen_idx - 1 : m_screens.Count -1;
     return m_screens[screen_idx];
 }
Example #5
0
 private Screen GetNextScreen(Screen s)
 {
     int screen_idx = ScreenIndex(s);
     if(screen_idx == -1)
         return null;
     screen_idx = screen_idx != m_screens.Count - 1 ? screen_idx + 1 : 0;
     return m_screens[screen_idx];
 }
Example #6
0
 private Screen ChooseNewScreen(Screen oldScreen, Direction direction)
 {
     lock(m_screens) {
         if(direction == Direction.Left) {
             return GetPreviousScreen(oldScreen);
         } else if(direction == Direction.Right) {
             return GetNextScreen(oldScreen);
         } else {
             return null;
         }
     }
 }
Example #7
0
 private bool HandleScreenConnected(ConnectedMessage msg)
 {
     int screenID = m_nextScreenID++;
     ScreenConnection conn = new ScreenConnection(m_queue, msg.Connection);
     Screen screen = new Screen(screenID, conn);
     conn.Sender = screen;
     conn.StartReceivingMessages();
     m_screens.Add(screen);
     Trace.WriteLine(String.Format("Screen connected: {0}", screenID));
     m_feed.Refresh();
     return true;
 }