コード例 #1
0
 public override void PostDrawLayer(Layer layer)
 {
     if (NetworkDebugger._instances.Count == 0)
     {
         return;
     }
     if (layer == Layer.Console)
     {
         if (NetworkDebugger._interfaces[0].pin || (double)Mouse.xConsole < (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0)
         {
             DevConsoleCore core = DevConsole.core;
             DevConsole.core = NetworkDebugger._instances[0].consoleCore;
             NetworkDebugger._interfaces[0].Draw(NetworkDebugger._instances[0].network);
             DevConsole.core = core;
         }
         else
         {
             NetworkDebugger._interfaces[0].visible = false;
         }
         if (NetworkDebugger._interfaces[1].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 1)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[1].consoleCore;
                 NetworkDebugger._interfaces[1].Draw(NetworkDebugger._instances[1].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[1].visible = false;
         }
         if (NetworkDebugger._interfaces[2].pin || (double)Mouse.xConsole <(double)Layer.Console.width / 2.0 && (double)Mouse.yConsole> (double) Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 2)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[2].consoleCore;
                 NetworkDebugger._interfaces[2].Draw(NetworkDebugger._instances[2].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[2].visible = false;
         }
         if (NetworkDebugger._interfaces[3].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole > (double)Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 3)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[3].consoleCore;
                 NetworkDebugger._interfaces[3].Draw(NetworkDebugger._instances[3].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[3].visible = false;
         }
         if (this._connectionArrow == null)
         {
             this._connectionArrow = new SpriteMap("connectionArrow", 56, 13);
             this._connectionArrow.CenterOrigin();
             this._connectionX = new Sprite("connectionX");
             this._connectionX.CenterOrigin();
         }
         for (int i = 0; i < 4; ++i)
         {
             if (NetworkDebugger._instances.Count > i && NetworkDebugger._instances[i].active)
             {
                 for (int j = 0; j < 4; ++j)
                 {
                     if (i != j && NetworkDebugger._instances.Count > j && NetworkDebugger._instances[j].active)
                     {
                         NetworkConnection networkConnection1 = NetworkDebugger._instances[i].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(j)));
                         NetworkConnection networkConnection2 = NetworkDebugger._instances[j].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(i)));
                         Vec2  vec2_1 = NetworkDebugger._interfaces[i].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10));
                         Vec2  vec2_2 = NetworkDebugger._interfaces[j].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10));
                         Vec2  p2     = vec2_2 - vec2_1;
                         Vec2  vec2_3 = p2.normalized.Rotate(Maths.DegToRad(90f), Vec2.Zero);
                         float num1   = -Maths.PointDirection(Vec2.Zero, p2);
                         float num2   = 0.0f;
                         if (networkConnection1 != null)
                         {
                             float num3 = 0.0f;
                             float num4 = 0.0f;
                             if (networkConnection2 != null)
                             {
                                 num3 = NetworkDebugger.GetReceived(networkConnection1.identifier, networkConnection2.identifier);
                                 num4 = NetworkDebugger.GetSent(networkConnection1.identifier, networkConnection2.identifier);
                                 num2 = 6f;
                             }
                             this._connectionArrow.frame        = networkConnection1.status != ConnectionStatus.Connected ? 0 : 3;
                             this._connectionArrow.angleDegrees = num1;
                             this._connectionArrow.alpha        = 1f;
                             this._connectionArrow.depth        = new Depth(0.92f);
                             Vec2 vec2_4 = (vec2_1 + vec2_2) / 2f + vec2_3 * num2;
                             DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                             if (networkConnection1.status != ConnectionStatus.Disconnecting)
                             {
                                 this._connectionX.depth = new Depth(0.98f);
                                 Vec2 vec2_5 = vec2_4 - p2.normalized * 22f;
                                 if ((double)(Mouse.positionConsole - vec2_5).length < 8.0)
                                 {
                                     this._connectionX.alpha = 1f;
                                     if (this.lefpres)
                                     {
                                         networkConnection1.Disconnect();
                                         SFX.Play("quack");
                                     }
                                 }
                                 else
                                 {
                                     this._connectionX.alpha = 0.4f;
                                 }
                                 DuckGame.Graphics.Draw(this._connectionX, vec2_5.x, vec2_5.y);
                             }
                             if ((double)num4 > 0.0)
                             {
                                 ++this._connectionArrow.frame;
                                 this._connectionArrow.alpha = num4;
                                 this._connectionArrow.depth = new Depth(0.95f);
                                 DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                                 --this._connectionArrow.frame;
                             }
                             if ((double)num3 > 0.0)
                             {
                                 this._connectionArrow.frame += 2;
                                 this._connectionArrow.alpha  = num3;
                                 this._connectionArrow.depth  = new Depth(0.95f);
                                 DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                                 this._connectionArrow.frame -= 2;
                             }
                         }
                     }
                 }
             }
         }
     }
     base.PostDrawLayer(layer);
 }
コード例 #2
0
        public override void DoUpdate()
        {
            this.lefpres = Mouse.left == InputState.Pressed;
            List <DCLine> dcLineList = (List <DCLine>)null;

            lock (DevConsole.debuggerLines)
            {
                dcLineList = DevConsole.debuggerLines;
                DevConsole.debuggerLines = new List <DCLine>();
            }
            for (int index1 = 0; index1 < 4; ++index1)
            {
                if (index1 >= NetworkDebugger._instances.Count || !NetworkDebugger._instances[index1].active)
                {
                    if (index1 <= NetworkDebugger._instances.Count)
                    {
                        int          init          = -1;
                        InputProfile inputProfile1 = (InputProfile)null;
                        foreach (InputProfile defaultProfile in InputProfile.defaultProfiles)
                        {
                            if (defaultProfile.Pressed("START"))
                            {
                                foreach (InputProfile inputProfile2 in NetworkDebugger.inputProfiles)
                                {
                                    if (defaultProfile == inputProfile2)
                                    {
                                        break;
                                    }
                                }
                                for (int index2 = 0; index2 < 4; ++index2)
                                {
                                    if (NetworkDebugger.inputProfiles[index2].name == "")
                                    {
                                        bool flag = false;
                                        foreach (NetDebugInterface netDebugInterface in NetworkDebugger._interfaces)
                                        {
                                            if (netDebugInterface.visible)
                                            {
                                                flag = true;
                                                break;
                                            }
                                        }
                                        if (!flag)
                                        {
                                            init          = index1;
                                            inputProfile1 = defaultProfile;
                                        }
                                        NetworkDebugger.inputProfiles[index2] = defaultProfile;
                                        break;
                                    }
                                }
                            }
                        }
                        if (init != -1)
                        {
                            this.CreateInstance(init, false);
                            NetworkDebugger._instances[index1].ipro = inputProfile1;
                        }
                    }
                }
                else
                {
                    NetworkInstance instance = NetworkDebugger._instances[index1];
                    NetworkDebugger._networkDrawingIndex = index1;
                    this.LockInstance(instance);
                    float volume = SFX.volume;
                    if (NetworkDebugger.Mute(NetworkDebugger._networkDrawingIndex))
                    {
                        SFX.volume = 0.0f;
                    }
                    InputProfile.Update();
                    foreach (DCLine dcLine in dcLineList)
                    {
                        if (dcLine.threadIndex == index1)
                        {
                            DevConsole.core.lines.Enqueue(dcLine);
                        }
                    }
                    DevConsole.Update();
                    Network.PreUpdate();
                    FireManager.Update();
                    Level.UpdateLevelChange();
                    Level.UpdateCurrentLevel();
                    MonoMain.UpdatePauseMenu();
                    int index2 = 0;
                    foreach (NetDebugInterface netDebugInterface in NetworkDebugger._interfaces)
                    {
                        MonoMain.instance.IsMouseVisible = true;
                        if (index2 == index1 && index2 < NetworkDebugger._instances.Count)
                        {
                            netDebugInterface.Update(NetworkDebugger._instances[index2].network);
                        }
                        ++index2;
                    }
                    Network.PostUpdate();
                    if (DuckNetwork.status == DuckNetStatus.Disconnected)
                    {
                        NetworkDebugger._instances[index1].active = false;
                        foreach (Profile profile in NetworkDebugger._instances[index1].duckNetworkCore.profiles)
                        {
                            for (int index3 = 0; index3 < 4; ++index3)
                            {
                                if (NetworkDebugger.inputProfiles[index3] == profile.inputProfile || NetworkDebugger.inputProfiles[index3] == NetworkDebugger._instances[index1].ipro)
                                {
                                    NetworkDebugger.inputProfiles[index3] = new InputProfile();
                                }
                            }
                        }
                    }
                    SFX.volume = volume;
                    this.UnlockInstance();
                }
            }
            if (!Keyboard.Pressed(Keys.F11))
            {
                return;
            }
            foreach (NetworkInstance instance in NetworkDebugger._instances)
            {
                instance.network.core.ForcefulTermination();
            }
            Network.activeNetwork.core.ForcefulTermination();
            NetworkDebugger._instances.Clear();
            NetworkDebugger.inputProfiles.Clear();
            Level.current = (Level) new NetworkDebugger();
        }