protected void LoadContraptionFromSlot(int slotIndex) { if (this.ContraptionProto) { if (this.ContraptionProto.HasTurboCharge) { GameProgress.AddTurboCharge(1); EventManager.Send(new InGameBuildMenu.ApplyTurboChargeEvent(GameProgress.TurboChargeCount(), false)); } if (this.ContraptionProto.HasNightVision) { GameProgress.AddNightVision(1); EventManager.Send(new InGameBuildMenu.ApplyNightVisionEvent(GameProgress.NightVisionCount(), false)); } if (this.ContraptionProto.HasSuperGlue) { GameProgress.AddSuperGlue(1); EventManager.Send(new InGameBuildMenu.ApplySuperGlueEvent(GameProgress.SuperGlueCount(), false)); } if (this.ContraptionProto.HasSuperMagnet) { GameProgress.AddSuperMagnet(1); EventManager.Send(new InGameBuildMenu.ApplySuperMagnetEvent(GameProgress.SuperMagnetCount(), false)); } foreach (BasePart basePart in this.ContraptionProto.Parts) { this.ContraptionProto.DataSet.AddPart(basePart.m_coordX, basePart.m_coordY, (int)basePart.m_partType, basePart.customPartIndex, basePart.m_gridRotation, basePart.m_flipped); } this.ContraptionProto.SaveContraption(this.GetCurrentContraptionName()); this.levelManager.ConstructionUI.ClearContraption(); this.Destroy(this.ContraptionProto.gameObject); this.ContraptionProto = null; } this.CurrentContraptionIndex = slotIndex; Vector3 position = (!this.levelStart) ? Vector3.zero : this.levelStart.transform.position; if (this.gameData.m_contraptionPrefab) { Transform transform = UnityEngine.Object.Instantiate(this.gameData.m_contraptionPrefab, position, Quaternion.identity); this.ContraptionProto = transform.GetComponent <Contraption>(); } this.levelManager.ConstructionUI.SetCurrentContraption(); this.BuildContraption(WPFPrefs.LoadContraptionDataset(this.GetCurrentContraptionName())); foreach (ConstructionUI.PartDesc partDesc in this.levelManager.ConstructionUI.PartDescriptors) { EventManager.Send(new PartCountChanged(partDesc.part.m_partType, partDesc.CurrentCount)); } this.levelManager.ConstructionUI.SetMoveButtonStates(); this.levelManager.SetGameState(LevelManager.GameState.Building); }
public Contraption CreateContraption(TextAsset contraptionData) { this.m_contraptionData = contraptionData; Vector2 v = base.transform.position; v.x = -5f + -15f * (float)Screen.width / (float)Screen.height; base.transform.position = v; Transform transform = UnityEngine.Object.Instantiate <Transform>(this.m_gameData.m_contraptionPrefab, base.transform.position, Quaternion.identity); transform.parent = base.transform; this.m_contraption = transform.GetComponent <Contraption>(); ContraptionDataset cds = WPFPrefs.LoadContraptionDataset(this.m_contraptionData); this.BuildContraption(cds); this.m_contraption.StartContraption(); this.m_contraption.ActivateAllPoweredParts(); return(this.m_contraption); }
public override void InitGameMode() { base.CurrentConstructionGridRows = this.levelManager.m_constructionGridRows; int num = 1; int newGridHeight = 1; for (int i = 0; i < base.CurrentConstructionGridRows.Count; i++) { if (base.CurrentConstructionGridRows[i] != 0) { int numberOfHighestBit = WPFMonoBehaviour.GetNumberOfHighestBit(base.CurrentConstructionGridRows[i]); if (numberOfHighestBit + 1 > num) { num = numberOfHighestBit + 1; } newGridHeight = i + 1; } } int newGridXMin = -(num - 1) / 2; int newGridXMax = num / 2; Vector3 position = (!this.levelStart) ? Vector3.zero : this.levelStart.transform.position; this.levelManager.CreateGrid(num, newGridHeight, newGridXMin, newGridXMax, position); if (this.levelManager.ConstructionUI) { if (GameProgress.HasKey(SchematicButton.LastLoadedSlotKey, GameProgress.Location.Local, null)) { base.CurrentContraptionIndex = GameProgress.GetInt(SchematicButton.LastLoadedSlotKey, 0, GameProgress.Location.Local, null); } base.BuildContraption(WPFPrefs.LoadContraptionDataset(base.GetCurrentContraptionName())); } foreach (ConstructionUI.PartDesc partDesc in this.levelManager.ConstructionUI.PartDescriptors) { EventManager.Send(new PartCountChanged(partDesc.part.m_partType, partDesc.CurrentCount)); } GameObject gameObject = new GameObject("CollectibleStash"); gameObject.transform.parent = this.levelManager.transform; this.FindChallenges(); this.levelManager.m_CollectedDessertsCount = 0; this.PlaceDesserts(false); this.InitializeChallenges(); }
public override void InitGameMode() { CakeRaceInfo?cakeRaceInfo = CakeRaceMode.cakeRaceInfo; if (cakeRaceInfo == null) { this.FindCakeRaceInfo(CakeRaceMode.currentRaceTrackIndex); } else { CakeRaceMode.currentRaceTrackIndex = CakeRaceMode.cakeRaceInfo.Value.TrackIndex; } this.gainedXP = 0; this.IsRaceOn = false; this.InitScoreVariables(); this.CreateCakes(); this.CreateProps(); base.Preview = this.CreatePreview(); base.CurrentConstructionGridRows = CakeRaceMode.cakeRaceInfo.Value.Start.GridData; base.CameraLimits = CakeRaceMode.cakeRaceInfo.Value.CameraLimits; base.GridCellPrefab = CakeRaceMode.cakeRaceInfo.Value.GridCellPrefab; base.TutorialPage = CakeRaceMode.cakeRaceInfo.Value.TutorialBookPrefab; int num = 1; int newGridHeight = 1; for (int i = 0; i < base.CurrentConstructionGridRows.Count; i++) { if (base.CurrentConstructionGridRows[i] != 0) { int numberOfHighestBit = WPFMonoBehaviour.GetNumberOfHighestBit(base.CurrentConstructionGridRows[i]); if (numberOfHighestBit + 1 > num) { num = numberOfHighestBit + 1; } newGridHeight = i + 1; } } int newGridXMin = -(num - 1) / 2; int newGridXMax = num / 2; this.levelManager.CreateGrid(num, newGridHeight, newGridXMin, newGridXMax, CakeRaceMode.cakeRaceInfo.Value.Start.Position); base.ContraptionProto.transform.position = CakeRaceMode.cakeRaceInfo.Value.Start.Position; this.InitParts(); base.CameraOffset = new Vector3(0f, 15f, 0f); base.PreviewOffset = new Vector3(0f, 15f, 0f); base.ConstructionOffset = new Vector3(0f, 0f, 0f); this.timeRunning = false; if (this.levelManager.ConstructionUI) { if (GameProgress.HasKey(SchematicButton.LastLoadedSlotKey, GameProgress.Location.Local, null)) { base.CurrentContraptionIndex = GameProgress.GetInt(SchematicButton.LastLoadedSlotKey, 0, GameProgress.Location.Local, null); } base.BuildContraption(WPFPrefs.LoadContraptionDataset(base.GetCurrentContraptionName())); foreach (ConstructionUI.PartDesc partDesc in this.levelManager.ConstructionUI.PartDescriptors) { EventManager.Send(new PartCountChanged(partDesc.part.m_partType, partDesc.CurrentCount)); } } EventManager.Connect(new EventManager.OnEvent <TimeBomb.BombOutOfBounds>(this.OnBombOutOfBounds)); }