示例#1
0
 public void LockInstance(NetworkInstance instance)
 {
     this.oldNetwork         = Network.activeNetwork;
     Network.activeNetwork   = instance.network;
     this.oldDuckNetworkCore = DuckNetwork.core;
     DuckNetwork.core        = instance.duckNetworkCore;
     this.oldVirtualCore     = VirtualTransition.core;
     VirtualTransition.core  = instance.virtualCore;
     this.oldLevelCore       = Level.core;
     Level.core               = instance.levelCore;
     this.oldProfileCore      = Profiles.core;
     Profiles.core            = instance.profileCore;
     this.oldTeamCore         = Teams.core;
     Teams.core               = instance.teamsCore;
     this.oldLayerCore        = Layer.core;
     Layer.core               = instance.layerCore;
     this.oldInputCore        = InputProfile.core;
     InputProfile.core        = instance.inputProfile;
     this.oDevCore            = DevConsole.core;
     DevConsole.core          = instance.consoleCore;
     this.oldCrowdCore        = Crowd.core;
     Crowd.core               = instance.crowdCore;
     this.oldGameModeCore     = GameMode.core;
     GameMode.core            = instance.gameModeCore;
     this.oldConnectionUICore = ConnectionStatusUI.core;
     ConnectionStatusUI.core  = instance.connectionUICore;
     this.oldMonoCore         = MonoMain.core;
     MonoMain.core            = instance.monoCore;
 }
示例#2
0
 public NetworkDebugger(Level level = null, LayerCore startLayer = null)
 {
     this._startLevel = level;
     this._startLayer = startLayer;
     if (level == null)
     {
         foreach (Profile profile in Profiles.all)
         {
             profile.team = (Team)null;
         }
     }
     for (int index = 0; index < 4; ++index)
     {
         NetworkDebugger.inputProfiles.Add(new InputProfile());
     }
 }
        private static void DoPreviewRender()
        {
            MTSpriteBatch screen = DuckGame.Graphics.screen;

            DuckGame.Graphics.screen = DuckGame.Content._previewBatch;
            Viewport viewport = DuckGame.Graphics.viewport;

            DuckGame.Graphics.SetRenderTarget(DuckGame.Content._currentPreviewTarget);
            DuckGame.Graphics.viewport = new Viewport(0, 0, DuckGame.Content._currentPreviewTarget.width, DuckGame.Content._currentPreviewTarget.height);
            string str1 = Custom.data[CustomType.Block][0];

            if (Custom.previewData[CustomType.Block][0] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Block][0].GetTileData(), 0, CustomType.Block);
            }
            string str2 = Custom.data[CustomType.Block][1];

            if (Custom.previewData[CustomType.Block][1] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Block][1].GetTileData(), 1, CustomType.Block);
            }
            string str3 = Custom.data[CustomType.Block][2];

            if (Custom.previewData[CustomType.Block][2] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Block][2].GetTileData(), 2, CustomType.Block);
            }
            string str4 = Custom.data[CustomType.Background][0];

            if (Custom.previewData[CustomType.Background][0] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Background][0].GetTileData(), 0, CustomType.Background);
            }
            string str5 = Custom.data[CustomType.Background][1];

            if (Custom.previewData[CustomType.Background][1] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Background][1].GetTileData(), 1, CustomType.Background);
            }
            string str6 = Custom.data[CustomType.Background][2];

            if (Custom.previewData[CustomType.Background][2] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Background][2].GetTileData(), 2, CustomType.Background);
            }
            string str7 = Custom.data[CustomType.Platform][0];

            if (Custom.previewData[CustomType.Platform][0] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Platform][0].GetTileData(), 0, CustomType.Platform);
            }
            string str8 = Custom.data[CustomType.Platform][1];

            if (Custom.previewData[CustomType.Platform][1] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Platform][1].GetTileData(), 1, CustomType.Platform);
            }
            string str9 = Custom.data[CustomType.Platform][2];

            if (Custom.previewData[CustomType.Platform][2] != null)
            {
                Custom.ApplyCustomData(Custom.previewData[CustomType.Platform][2].GetTileData(), 2, CustomType.Platform);
            }
            if (DuckGame.Content._previewBackground)
            {
                Level     activeLevel  = Level.activeLevel;
                Level     currentLevel = Level.core.currentLevel;
                LayerCore core         = Layer.core;
                if (DuckGame.Content._previewLayerCore != null)
                {
                    Layer.core = DuckGame.Content._previewLayerCore;
                }
                Level.activeLevel       = (Level)DuckGame.Content.previewLevel;
                Level.core.currentLevel = (Level)DuckGame.Content.previewLevel;
                DuckGame.Graphics.defaultRenderTarget = DuckGame.Content._currentPreviewTarget;
                Layer.HUD.visible = false;
                DuckGame.Content.previewLevel.camera          = DuckGame.Content._previewCamera;
                DuckGame.Content.previewLevel.simulatePhysics = false;
                DuckGame.Content.previewLevel.DoUpdate();
                DuckGame.Content.previewLevel.DoUpdate();
                DuckGame.Content.previewLevel.DoDraw();
                Layer.HUD.visible = true;
                DuckGame.Graphics.defaultRenderTarget = (RenderTarget2D)null;
                Level.activeLevel       = activeLevel;
                Level.core.currentLevel = currentLevel;
                Layer.core = core;
            }
            else
            {
                DuckGame.Graphics.Clear(Color.Black);
                DuckGame.Graphics.screen.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, (MTEffect)null, DuckGame.Content._previewCamera.getMatrix());
                foreach (Thing thing in DuckGame.Content.previewLevel.things)
                {
                    if (thing.layer == Layer.Game || thing.layer == Layer.Blocks || thing.layer == null)
                    {
                        thing.Draw();
                    }
                    DuckGame.Graphics.material = (Material)null;
                }
                DuckGame.Graphics.screen.End();
            }
            DuckGame.Graphics.screen = screen;
            DuckGame.Graphics.SetRenderTarget((RenderTarget2D)null);
            Custom.data[CustomType.Block][0]      = str1;
            Custom.data[CustomType.Block][1]      = str2;
            Custom.data[CustomType.Block][2]      = str3;
            Custom.data[CustomType.Background][0] = str4;
            Custom.data[CustomType.Background][1] = str5;
            Custom.data[CustomType.Background][2] = str6;
            Custom.data[CustomType.Platform][0]   = str7;
            Custom.data[CustomType.Platform][1]   = str8;
            Custom.data[CustomType.Platform][2]   = str9;
        }
        private static void PreviewThread()
        {
            Level     activeLevel  = Level.activeLevel;
            Level     currentLevel = Level.core.currentLevel;
            LayerCore core         = Layer.core;

            try
            {
                DuckGame.Content.renderingPreview = true;
                if (!DuckGame.Content._previewBackground)
                {
                    Thing.skipLayerAdding = true;
                }
                XMLLevel xmlLevel = new XMLLevel(DuckGame.Content._previewPath);
                if (DuckGame.Content.cancelPreview)
                {
                    return;
                }
                DuckGame.Content.previewLevel = xmlLevel;
                DuckGame.Content.previewLevel.ignoreVisibility = true;
                Level.skipInitialize = !DuckGame.Content._previewBackground;
                if (!DuckGame.Content._previewBackground)
                {
                    DuckGame.Content.previewLevel.isPreview = true;
                }
                DuckGame.Content._previewLayerCore = (LayerCore)null;
                if (DuckGame.Content._previewBackground)
                {
                    Layer.core = DuckGame.Content._previewLayerCore = new LayerCore();
                    Layer.core.InitializeLayers();
                    Level.core.currentLevel = (Level)DuckGame.Content.previewLevel;
                    Level.activeLevel       = (Level)DuckGame.Content.previewLevel;
                }
                DuckGame.Content.previewLevel.Initialize();
                if (DuckGame.Content._previewBackground)
                {
                    Level.activeLevel       = activeLevel;
                    Level.core.currentLevel = currentLevel;
                }
                if (DuckGame.Content.cancelPreview)
                {
                    return;
                }
                Thing.skipLayerAdding = false;
                Level.skipInitialize  = false;
                DuckGame.Content.previewLevel.CalculateBounds();
                DuckGame.Content._previewCamera = DuckGame.Content.customPreviewWidth == 0 ? new Camera(0.0f, 0.0f, 1280f, 1280f * DuckGame.Graphics.aspect) : new Camera(0.0f, 0.0f, (float)DuckGame.Content.customPreviewWidth, (float)DuckGame.Content.customPreviewHeight);
                Vec2 vec2 = (DuckGame.Content.previewLevel.topLeft + DuckGame.Content.previewLevel.bottomRight) / 2f;
                if (DuckGame.Content.cancelPreview)
                {
                    return;
                }
                DuckGame.Content._previewCamera.width  /= 2f;
                DuckGame.Content._previewCamera.height /= 2f;
                DuckGame.Content._previewCamera.center  = !(DuckGame.Content.customPreviewCenter != Vec2.Zero) ? vec2 : DuckGame.Content.customPreviewCenter;
                DuckGame.Content.readyToRenderPreview   = true;
                if (DuckGame.Content._previewThread != null)
                {
                    while (DuckGame.Content.readyToRenderPreview)
                    {
                        if (DuckGame.Content.cancelPreview)
                        {
                            return;
                        }
                    }
                }
                DuckGame.Content.previewRendering = false;
                DuckGame.Content.renderingPreview = false;
            }
            catch (Exception ex)
            {
                Program.LogLine(ex.ToString());
                DuckGame.Content.renderingPreview = false;
                Thing.skipLayerAdding             = false;
                Level.skipInitialize = false;
            }
            if (!DuckGame.Content._previewBackground)
            {
                return;
            }
            Level.activeLevel       = activeLevel;
            Level.core.currentLevel = currentLevel;
            Layer.core = core;
        }
示例#5
0
        public void CreateInstance(int init, bool isHost)
        {
            NetworkDebugger._networkDrawingIndex = init;
            NetworkInstance networkInstance = new NetworkInstance()
            {
                network = new Network(NetworkDebugger._networkDrawingIndex)
            };

            if (this._startLevel == null)
            {
                networkInstance.teamsCore = new TeamsCore();
                networkInstance.teamsCore.Initialize();
            }
            else
            {
                networkInstance.teamsCore = Teams.core;
                List <Team> teamList = new List <Team>((IEnumerable <Team>)Teams.core.extraTeams);
                Teams.core = new TeamsCore();
                Teams.core.Initialize();
                Teams.core.extraTeams = teamList;
            }
            if (this._startLayer != null)
            {
                networkInstance.layerCore = this._startLayer;
                this._startLayer          = (LayerCore)null;
            }
            else
            {
                networkInstance.layerCore = new LayerCore();
                networkInstance.layerCore.InitializeLayers();
            }
            networkInstance.virtualCore = new VirtualTransitionCore();
            networkInstance.virtualCore.Initialize();
            if (this._startLevel == null)
            {
                networkInstance.profileCore = new ProfilesCore();
                networkInstance.profileCore.Initialize();
                networkInstance.profileCore.DefaultPlayer2.team = (Team)null;
            }
            else
            {
                networkInstance.profileCore = Profiles.core;
                Profiles.core = new ProfilesCore();
                Profiles.core.Initialize();
            }
            networkInstance.inputProfile = new InputProfileCore();
            InputProfileCore core1 = InputProfile.core;

            InputProfile.core = networkInstance.inputProfile;
            Input.InitDefaultProfiles();
            networkInstance.levelCore = new LevelCore();
            LevelCore core2 = Level.core;

            Level.core = networkInstance.levelCore;
            networkInstance.crowdCore = new CrowdCore();
            CrowdCore core3 = Crowd.core;

            Crowd.core = networkInstance.crowdCore;
            TeamsCore core4 = Teams.core;

            networkInstance.teamsCore.extraTeams = new List <Team>((IEnumerable <Team>)Teams.core.extraTeams);
            Teams.core = networkInstance.teamsCore;
            ProfilesCore core5 = Profiles.core;

            Profiles.core = networkInstance.profileCore;
            LayerCore core6 = Layer.core;

            Layer.core = networkInstance.layerCore;
            VirtualTransitionCore core7 = VirtualTransition.core;

            VirtualTransition.core = networkInstance.virtualCore;
            Network activeNetwork = Network.activeNetwork;

            Network.activeNetwork = networkInstance.network;
            networkInstance.network.DoInitialize();
            networkInstance.duckNetworkCore = new DuckNetworkCore();
            GameModeCore gameModeCore = new GameModeCore();

            networkInstance.gameModeCore = gameModeCore;
            GameModeCore core8 = GameMode.core;

            GameMode.core = gameModeCore;
            networkInstance.connectionUICore = new ConnectionStatusUICore();
            ConnectionStatusUICore core9 = ConnectionStatusUI.core;

            ConnectionStatusUI.core     = networkInstance.connectionUICore;
            networkInstance.consoleCore = new DevConsoleCore();
            DevConsoleCore core10 = DevConsole.core;

            DevConsole.core = networkInstance.consoleCore;
            DuckNetworkCore core11 = DuckNetwork.core;

            DuckNetwork.core = networkInstance.duckNetworkCore;
            DuckNetwork.Initialize();
            networkInstance.monoCore = new MonoMainCore();
            MonoMainCore core12 = MonoMain.core;

            MonoMain.core = networkInstance.monoCore;
            if (isHost)
            {
                foreach (Profile profile in Profiles.all)
                {
                    if (profile.team != null)
                    {
                        NetworkDebugger.inputProfiles[Persona.Number(profile.persona)] = InputProfile.defaultProfiles[Persona.Number(profile.persona)];
                    }
                }
                DuckNetwork.Host(4, NetworkLobbyType.Public);
                if (this._startLevel != null)
                {
                    Level.current = this._startLevel;
                    this._startLevel.NetworkDebuggerPrepare();
                    this._startLevel = (Level)null;
                }
                else
                {
                    Level.current = (Level) new TeamSelect2();
                }
            }
            else
            {
                Level.current = (Level) new JoinServer(0UL);
            }
            networkInstance.joined = true;
            if (init >= NetworkDebugger._instances.Count)
            {
                NetworkDebugger._instances.Add(networkInstance);
            }
            else
            {
                NetworkDebugger._instances[init] = networkInstance;
            }
            base.Initialize();
            InputProfile.core       = core1;
            Network.activeNetwork   = activeNetwork;
            DuckNetwork.core        = core11;
            Teams.core              = core4;
            Profiles.core           = core5;
            Layer.core              = core6;
            VirtualTransition.core  = core7;
            Level.core              = core2;
            DevConsole.core         = core10;
            Crowd.core              = core3;
            GameMode.core           = core8;
            ConnectionStatusUI.core = core9;
            MonoMain.core           = core12;
        }