public override void Initialize() { Vote.ClearVotes(); if (this.level == "RANDOM") { this._randomLevel = LevelGenerator.MakeLevel(seed: this.seed); this.seed = this._randomLevel.seed; } base.Initialize(); if (Network.isActive) { Level.core.gameInProgress = true; } if (this._randomLevel != null) { this._randomLevel.LoadParts(0.0f, 0.0f, (Level)this, this.seed); List <SpawnPoint> source1 = new List <SpawnPoint>(); foreach (SpawnPoint spawnPoint in this.things[typeof(SpawnPoint)]) { source1.Add(spawnPoint); } if (source1.Count == 0) { Level.current = (Level) new GameLevel("RANDOM"); return; } List <SpawnPoint> chosenSpawns = new List <SpawnPoint>(); for (int index = 0; index < 4; ++index) { if (chosenSpawns.Count == 0) { chosenSpawns.Add(source1.ElementAt <SpawnPoint>(Rando.Int(source1.Count - 1))); } else { IOrderedEnumerable <SpawnPoint> source2 = source1.OrderByDescending <SpawnPoint, int>((Func <SpawnPoint, int>)(x => { int num = 9999999; foreach (Transform transform in chosenSpawns) { num = (int)Math.Min((transform.position - x.position).length, (float)num); } return(num); })); chosenSpawns.Add(source2.First <SpawnPoint>()); } } foreach (SpawnPoint spawnPoint in source1) { if (!chosenSpawns.Contains(spawnPoint)) { Level.Remove((Thing)spawnPoint); } } foreach (Thing thing in this.things) { if (Network.isActive && thing.isStateObject) { GhostManager.context.MakeGhost(thing, initLevel: true); thing.ghostType = Editor.IDToType[thing.GetType()]; } } PyramidBackground pyramidBackground = new PyramidBackground(0.0f, 0.0f); pyramidBackground.visible = false; Level.Add((Thing)pyramidBackground); base.Initialize(); } this.things.RefreshState(); if (this._mode == null) { this._mode = (GameMode) new DM(this._validityTest, this._editorTestMode); } this._mode.DoInitialize(); if (!Network.isServer) { return; } foreach (Duck prepareSpawn in this._mode.PrepareSpawns()) { prepareSpawn.localSpawnVisible = false; prepareSpawn.immobilized = true; Level.Add((Thing)prepareSpawn); } }
public override void Initialize() { this._pauseGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f); this._pauseMenu = new UIMenu("@LWING@PAUSE@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@DPAD@MOVE @SELECT@SELECT"); this._confirmMenu = new UIMenu("REALLY QUIT?", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@SELECT@SELECT"); this._testMode = new UIMenu("TEST MODE", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@SELECT@SELECT"); UIDivider uiDivider = new UIDivider(true, 0.8f); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("RESTART", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._restart), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("RESUME", (UIMenuAction) new UIMenuActionCloseMenu(this._pauseGroup), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("OPTIONS", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._pauseMenu, (UIComponent)Options.optionsMenu), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("TEST MODE", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._pauseMenu, (UIComponent)this._testMode), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIText("", Color.White), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("QUIT", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._quit), UIAlign.Left), true); uiDivider.rightSection.Add((UIComponent) new UIImage("pauseIcons", UIAlign.Right), true); this._pauseMenu.Add((UIComponent)uiDivider, true); this._pauseMenu.Close(); this._pauseGroup.Add((UIComponent)this._pauseMenu, false); this._pauseGroup.Add((UIComponent)Options.optionsMenu, false); Options.openOnClose = this._pauseMenu; this._confirmMenu.Add((UIComponent) new UIMenuItem("NO!", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._confirmMenu, (UIComponent)this._pauseMenu)), true); this._confirmMenu.Add((UIComponent) new UIMenuItem("YES!", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._quit)), true); this._confirmMenu.Close(); this._pauseGroup.Add((UIComponent)this._confirmMenu, false); this._testMode.Add((UIComponent) new UIMenuItemNumber("PLAYERS", field: new FieldBinding((object)this, "numPlayers", 2f, 4f, 1f)), true); this._testMode.Add((UIComponent) new UIMenuItem("START", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._startTestMode)), true); this._testMode.Add((UIComponent) new UIText("", Color.White), true); this._testMode.Add((UIComponent) new UIMenuItem("CANCEL", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._testMode, (UIComponent)this._pauseMenu), backButton: true), true); this._testMode.Close(); this._pauseGroup.Add((UIComponent)this._testMode, false); this._pauseGroup.Close(); Level.Add((Thing)this._pauseGroup); if (this._level == "RANDOM") { LevelGenerator.MakeLevel(this._center, this._center.left && this._center.right, this._seed, this._genType, Editor._procTilesWide, Editor._procTilesHigh, Editor._procXPos, Editor._procYPos).LoadParts(0.0f, 0.0f, (Level)this, this._seed); List <SpawnPoint> source1 = new List <SpawnPoint>(); foreach (SpawnPoint spawnPoint in this.things[typeof(SpawnPoint)]) { source1.Add(spawnPoint); } List <SpawnPoint> chosenSpawns = new List <SpawnPoint>(); for (int index = 0; index < 4; ++index) { if (chosenSpawns.Count == 0) { chosenSpawns.Add(source1.ElementAt <SpawnPoint>(Rando.Int(source1.Count - 1))); } else { IOrderedEnumerable <SpawnPoint> source2 = source1.OrderByDescending <SpawnPoint, int>((Func <SpawnPoint, int>)(x => { int num = 9999999; foreach (Transform transform in chosenSpawns) { num = (int)Math.Min((transform.position - x.position).length, (float)num); } return(num); })); chosenSpawns.Add(source2.First <SpawnPoint>()); } } foreach (SpawnPoint spawnPoint in source1) { if (!chosenSpawns.Contains(spawnPoint)) { Level.Remove((Thing)spawnPoint); } } PyramidBackground pyramidBackground = new PyramidBackground(0.0f, 0.0f); pyramidBackground.visible = false; Level.Add((Thing)pyramidBackground); } else { this._level = this._level.Replace(Directory.GetCurrentDirectory() + "\\", ""); LevelData levelData = DuckFile.LoadLevel(this._level); if (levelData != null) { foreach (BinaryClassChunk node in levelData.objects.objects) { Thing t = Thing.LoadThing(node); if (t != null) { if (!t.visibleInGame) { t.visible = false; } this.AddThing(t); } } } } this.things.RefreshState(); foreach (Duck spawnPlayer in new Deathmatch((Level)this).SpawnPlayers()) { Level.Add((Thing)spawnPlayer); this.followCam.Add((Thing)spawnPlayer); } }