public void OpenCampaign(Campaign campaign) { try { unlockAllMissions = campaign.info.allUnlocked; if (campaign.background == null) { _backgroundImage.color = new Color(1, 1, 1, 0); } else { _backgroundImage.color = new Color(1, 1, 1, campaign.info.backgroundAlpha); _backgroundImage.sprite = campaign.background; } MenuLightsPresetSO customLights = Instantiate(baseDefaultLights); SimpleColorSO color = ScriptableObject.CreateInstance <SimpleColorSO>(); color.SetColor(new Color(campaign.info.lightColor.r, campaign.info.lightColor.g, campaign.info.lightColor.b)); foreach (LightIdColorPair pair in customLights.lightIdColorPairs) { pair.baseColor = color; } _campaignFlowCoordinator.SetPrivateField("_defaultLightsPreset", customLights); MissionNode[] missionNodes = new MissionNode[campaign.info.mapPositions.Count]; curCampaignNodes = missionNodes; MissionStage[] missionStages; if (campaign.info.unlockGate.Count == 0 || unlockAllMissions) { //campaigns require an unlock gate so I make a fake one above the visible map area missionStages = new MissionStage[1]; missionStages[0] = Instantiate(baseMissionStages[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionStages[0].SetPrivateField("_minimumMissionsToUnlock", 0); missionStages[0].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(0, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 + 1000, 0); } else { missionStages = new MissionStage[campaign.info.unlockGate.Count + 1]; for (int i = 0; i < missionStages.Length - 1; i++) { missionStages[i] = Instantiate(baseMissionStages[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionStages[i].SetPrivateField("_minimumMissionsToUnlock", campaign.info.unlockGate[i].clearsToPass); missionStages[i].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(campaign.info.unlockGate[i].x * EDITOR_TO_GAME_UNITS, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 - campaign.info.unlockGate[i].y * EDITOR_TO_GAME_UNITS, 0); } //ghost unlock gate required for some reason as last unlock gate never gets cleared missionStages[campaign.info.unlockGate.Count] = Instantiate(baseMissionStages[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionStages[campaign.info.unlockGate.Count].SetPrivateField("_minimumMissionsToUnlock", campaign.info.mapPositions.Count + 1); missionStages[campaign.info.unlockGate.Count].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(0, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 + 1000, 0); } curMissionStages = missionStages; _missionStagesManager.SetPrivateField("_missionStages", (from stage in missionStages orderby stage.minimumMissionsToUnlock select stage).ToArray()); for (int i = 0; i < missionNodes.Length; i++) { CampainMapPosition mapPosition = campaign.info.mapPositions[i]; missionNodes[i] = Instantiate(baseNodes[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionNodes[i].gameObject.SetActive(true); missionNodes[i].SetPrivateField("_missionDataSO", campaign.challenges[i].GetMissionData(campaign)); missionNodes[i].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(mapPosition.x * EDITOR_TO_GAME_UNITS, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 - mapPosition.y * EDITOR_TO_GAME_UNITS, 0); missionNodes[i].GetPrivateField <RectTransform>("_rectTransform").sizeDelta = new Vector2(12 * mapPosition.scale, 12 * mapPosition.scale); missionNodes[i].SetPrivateField("_letterPartName", mapPosition.letterPortion); missionNodes[i].SetPrivateField("_numberPartName", mapPosition.numberPortion); } for (int i = 0; i < missionNodes.Length; i++) { MissionNode[] children = new MissionNode[campaign.info.mapPositions[i].childNodes.Length]; for (int j = 0; j < children.Length; j++) { children[j] = missionNodes[campaign.info.mapPositions[i].childNodes[j]]; } missionNodes[i].SetPrivateField("_childNodes", children); } _missionNodesManager.SetPrivateField("_rootMissionNode", missionNodes[0]); _mapScrollView.GetPrivateField <RectTransform>("_contentRectTransform").SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET); CampaignInit(); PresentFlowCoordinator(_campaignFlowCoordinator, delegate() { _campaignFlowCoordinator.InvokePrivateMethod("SetTitle", new object[] { campaign.info.name, ViewController.AnimationType.In }); _missionNodeSelectionManager.didSelectMissionNodeEvent -= _missionSelectionMapViewController.HandleMissionNodeSelectionManagerDidSelectMissionNode; _missionLevelDetailViewController.didPressPlayButtonEvent -= _missionSelectionNavigationController.HandleMissionLevelDetailViewControllerDidPressPlayButton; _missionResultsViewController.retryButtonPressedEvent += HandleMissionResultsViewControllerRetryButtonPressed; _missionResultsViewController.retryButtonPressedEvent -= _campaignFlowCoordinator.HandleMissionResultsViewControllerRetryButtonPressed; _campaignFlowCoordinator.didFinishEvent -= BeatSaberUI.MainFlowCoordinator.HandleCampaignFlowCoordinatorDidFinish; _campaignFlowCoordinator.didFinishEvent += CloseCampaign; _missionSelectionMapViewController.didSelectMissionLevelEvent += HandleMissionSelectionMapViewControllerDidSelectMissionLevel; _missionResultsViewController.continueButtonPressedEvent += HandleMissionResultsViewControllerContinueButtonPressed; _missionMapAnimationController.ScrollToTopMostNotClearedMission(); _playButton.interactable = true; }); _missionNodeSelectionManager.didSelectMissionNodeEvent += HandleMissionNodeSelectionManagerDidSelectMissionNode; (_campaignChallengeLeaderbaordViewController.table.transform.GetChild(1).GetChild(0).transform as RectTransform).localScale = new Vector3(1, 0.9f, 1); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
private static void SetStage(MissionStage newStage) { if (IsActive) { switch (newStage) { case MissionStage.LoseCops: _missionStage = newStage; _objectiveText = "Lose the cops."; foreach (Blip blip in _missionBlips.Values) { if (blip != null) { blip.ShowRoute = false; blip.Alpha = 0; } } break; case MissionStage.GetInVehicle: if (Game.Player.WantedLevel > 0) { _missionStage = MissionStage.LoseCops; _objectiveText = "Lose the cops."; foreach (Blip blip in _missionBlips.Values) { if (blip != null) { blip.Alpha = 0; blip.ShowRoute = false; } } } else { if (_missionBlips["vehicle"] != null) { _missionBlips["vehicle"].Alpha = 255; } _missionStage = MissionStage.GetInVehicle; _objectiveText = _missionType == MissionType.Setup ? "Steal the ~b~supply truck." : "Get in the ~b~delivery vehicle."; if (_missionBlips["deliveryPoint"] != null) { _missionBlips["deliveryPoint"].ShowRoute = false; _missionBlips["deliveryPoint"].Alpha = 0; } } break; case MissionStage.DeliverVehicle: if (_missionBlips["vehicle"] != null) { _missionBlips["vehicle"].Alpha = 0; } if (Game.Player.WantedLevel > 0) { _missionStage = MissionStage.LoseCops; _objectiveText = "Lose the cops."; foreach (Blip blip in _missionBlips.Values) { if (blip != null) { blip.ShowRoute = false; blip.Alpha = 0; } } } else { if (_missionBlips["deliveryPoint"] != null) { _missionBlips["deliveryPoint"].ShowRoute = true; _missionBlips["deliveryPoint"].Alpha = 255; } _missionStage = MissionStage.DeliverVehicle; _objectiveText = _missionType == MissionType.Setup ? "Deliver the truck to the ~y~meth lab." : "Go to the ~y~delivery point."; } break; } } }
public void StateChanged(MissionStage state, Int32 inSpeed, Int32 outSpeed) { }
public static void Stop(MissionFailReason failReason = MissionFailReason.None) { if (IsActive) { switch (failReason) { case MissionFailReason.MissionFlag: Util.NotifyWithPicture("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, try focusing on your task at hand next time!", "CHAR_LJT", 1); break; case MissionFailReason.Arrested: Util.NotifyWithPicture("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, be more careful with the cops next time!", "CHAR_LJT", 1); break; case MissionFailReason.Wasted: Util.NotifyWithPicture("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, that was really... unprofessional.", "CHAR_LJT", 1); break; case MissionFailReason.CharacterChange: Util.NotifyWithPicture("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, that was not a good time to have a personality change...", "CHAR_LJT", 1); break; case MissionFailReason.OutOfTime: Util.NotifyWithPicture("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, I've seen slow, but this? This is something new...", "CHAR_LJT", 1); break; case MissionFailReason.VehicleDead: Util.NotifyWithPicture("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, be more careful with the vehicle next time!", "CHAR_LJT", 1); break; } if (_missionVehicle != null) { if (failReason == MissionFailReason.ScriptExit) { _missionVehicle.Delete(); } else { Function.Call((Hash)0x260BE8F09E326A20, _missionVehicle.Handle, 3.0, 1); Function.Call(Hash.SET_VEHICLE_IS_CONSIDERED_BY_PLAYER, _missionVehicle.Handle, false); if (Game.Player.Character.IsInVehicle(_missionVehicle)) { Game.Player.Character.Task.LeaveVehicle(); } _missionVehicle.IsPersistent = false; _missionVehicle.MarkAsNoLongerNeeded(); } _missionVehicle = null; } if (_missionType == MissionType.Delivery && failReason != MissionFailReason.ScriptExit) { Main.MethLabs[_missionLabIdx].Product -= _productAmount; Main.Save(); } foreach (Blip blip in _missionBlips.Values) { blip.Remove(); } foreach (Lab lab in Main.MethLabs) { lab.SetBlipVisible(true); } _missionType = MissionType.None; _missionStage = MissionStage.None; _missionEndTime = -1; _missionModel = -1; _missionLabIdx = -1; _productAmount = 0; _objectiveCoords.Clear(); _missionBlips.Clear(); IsActive = false; } }
public void StateChanged(MissionStage state, Int32 inSpeed, Int32 outSpeed) { }