private void CreateTemplateInstance(OfflineGameProperty currentGameProperty) { if (createdInstanceProperty.Contains(currentGameProperty)) { return; } createdInstanceProperty.Add(currentGameProperty); GameObject templateInstance = Instantiate(roomLabelTemplate); templateInstance.SetActive(true); templateInstance.transform.SetParent(roomLabelTemplate.transform.parent); templateInstance.transform.localScale = new Vector3(1, 1, 1); templateInstance.transform.Find("PanelLayer/RoomName").GetComponent <Text>().text = currentGameProperty.presetName; templateInstance.transform.Find("PanelLayer/Map").GetComponent <Text>().text = currentGameProperty.gameMapEnum.ToString(); templateInstance.transform.Find("PanelLayer/Year").GetComponent <Text>().text = currentGameProperty.gameYearEnum.ToString(); templateInstance.transform.Find("PanelLayer/Button").GetComponent <Button>().onClick.AddListener(() => { OfflineGameManager._Instance.onOfflineGameRequested(currentGameProperty); }); templateInstance.transform.Find("PanelLayer/Delete").GetComponent <Button>().onClick.AddListener(() => { offlineGamePropertyAssemble.Assemble.Remove(currentGameProperty); PlayerPrefs.SetString("OfflineGamePropertyAssemble", JsonUtility.ToJson(offlineGamePropertyAssemble.Assemble)); Destroy(templateInstance); }); }
void HandleOfflineGameRequested(OfflineGameProperty gameProperty) { Debug.Log(gameProperty); if (gameProperty.gameModeEnum == GameModeEnum.InfiniteMode) { OfflineGameInfiniteModeModule inifiniteModeModule = new GameObject("OfflineGameInfiniteModeModule", typeof(OfflineGameInfiniteModeModule)).GetComponent <OfflineGameInfiniteModeModule>(); DontDestroyOnLoad(inifiniteModeModule.gameObject); inifiniteModeModule.Init(gameProperty); } }
private void GameLogic(OfflineGameProperty gameProperty, List <string> vehicleList) { if (teamA.Count < gameProperty.TeamANumber) { CreateBot(RandomVehicleFromList(vehicleList), PunTeams.Team.red); } if (teamB.Count < gameProperty.TeamBNumber) { CreateBot(RandomVehicleFromList(vehicleList), PunTeams.Team.blue); } }
private void Start() { if (PlayerPrefs.HasKey("OfflineGamePropertyAssemble")) { JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString("OfflineGamePropertyAssemble"), offlineGamePropertyAssemble); } else { offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW2Middle, presetName = "Default-WW2Middle-1V1", TeamANumber = 1, TeamBNumber = 1 } ); offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW1, presetName = "Default-WW1-1V1", TeamANumber = 1, TeamBNumber = 1 } ); offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW2Late, presetName = "Default-WW2Late-1V1", TeamANumber = 1, TeamBNumber = 1 } ); offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW2Late, presetName = "Default-WW2Late-2V2", TeamANumber = 2, TeamBNumber = 2 } ); } //设置界面 ShowGamePropertySetUIPanel_Button.onClick.AddListener(() => { GamePropertySetUIPanel.SetActive(true); }); CloseGamePropertySetUIPanel_Button.onClick.AddListener(() => { GamePropertySetUIPanel.SetActive(false); }); CreateGamePropertyPreset_Button.onClick.AddListener(() => { string presetName = GamePropertyPresetName_InputField.text; OfflineGameProperty currentGameProperty = new OfflineGameProperty(); currentGameProperty.presetName = presetName; currentGameProperty.gameMapEnum = availableGameMapList[currentGameMap]; currentGameProperty.gameYearEnum = availableGameYearList[currentGameYear]; currentGameProperty.TeamANumber = int.Parse(BattleTeamANumber_DropDown.buttonTextContent.text); currentGameProperty.TeamBNumber = int.Parse(BattleTeamBNumber_DropDown.buttonTextContent.text); offlineGamePropertyAssemble.Assemble.Add(currentGameProperty); PlayerPrefs.SetString("OfflineGamePropertyAssemble", JsonUtility.ToJson(offlineGamePropertyAssemble)); Debug.Log(JsonUtility.ToJson(offlineGamePropertyAssemble)); foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble) { CreateTemplateInstance(gameProperty); } GamePropertySetUIPanel.SetActive(false); }); for (int i = 0; i < availableGameMapList.Length; i++) { BattleMap_Dropdown.AddData(new MaterialUI.OptionData() { text = uGUI_Localsize.GetContent(availableGameMapList[i].ToString()) }); } BattleMap_Dropdown.onItemSelected.AddListener((changedValue) => { currentGameMap = changedValue; }); for (int i = 0; i < availableGameYearList.Length; i++) { BattleYear_Dropdown.AddData(new MaterialUI.OptionData() { text = uGUI_Localsize.GetContent(availableGameYearList[i].ToString()) }); } BattleYear_Dropdown.onItemSelected.AddListener((valueChanged) => { currentGameYear = valueChanged; }); //设置预设显示 roomLabelTemplate.SetActive(false); foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble) { CreateTemplateInstance(gameProperty); } OpenRaceMode_Button.onClick.AddListener(() => { OfflineGameManager._Instance.onRaceGamerequested(); }); }
private void Start() { if (PlayerPrefs.HasKey("OfflineGamePropertyAssemble")) { JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString("OfflineGamePropertyAssemble"), offlineGamePropertyAssemble); } else { offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW2Middle, presetName = "Default-WW2Middle-1V1", TeamANumber = 1, TeamBNumber = 1 } ); offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW1, presetName = "Default-WW1-1V1", TeamANumber = 1, TeamBNumber = 1 } ); offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW2Late, presetName = "Default-WW2Late-1V1", TeamANumber = 1, TeamBNumber = 1 } ); offlineGamePropertyAssemble.Assemble.Add( new OfflineGameProperty() { gameYearEnum = GameYearEnum.WW2Late, presetName = "Default-WW2Late-2V2", TeamANumber = 2, TeamBNumber = 2 } ); } //设置界面 ShowGamePropertySetUIPanel_Button.onClick.AddListener(() => { GamePropertySetUIPanel.SetActive(true); }); CloseGamePropertySetUIPanel_Button.onClick.AddListener(() => { GamePropertySetUIPanel.SetActive(false); }); CreateGamePropertyPreset_Button.onClick.AddListener(() => { string presetName = GamePropertyPresetName_InputField.text; OfflineGameProperty currentGameProperty = new OfflineGameProperty(); currentGameProperty.presetName = presetName; currentGameProperty.gameMapEnum = availableGameMapList[currentGameMap]; currentGameProperty.gameYearEnum = availableGameYearList[currentGameYear]; currentGameProperty.TeamANumber = int.Parse(BattleTeamANumber_DropDown.buttonTextContent.text); currentGameProperty.TeamBNumber = int.Parse(BattleTeamBNumber_DropDown.buttonTextContent.text); offlineGamePropertyAssemble.Assemble.Add(currentGameProperty); PlayerPrefs.SetString("OfflineGamePropertyAssemble", JsonUtility.ToJson(offlineGamePropertyAssemble)); Debug.Log(JsonUtility.ToJson(offlineGamePropertyAssemble)); foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble) { CreateTemplateInstance(gameProperty); } GamePropertySetUIPanel.SetActive(false); }); for (int i = 0; i < availableGameMapList.Length; i++) { BattleMap_Dropdown.AddData(new MaterialUI.OptionData() { text = uGUI_Localsize.GetContent(availableGameMapList[i].ToString()) }); } BattleMap_Dropdown.onItemSelected.AddListener((changedValue) => { currentGameMap = changedValue; }); for (int i = 0; i < availableGameYearList.Length; i++) { BattleYear_Dropdown.AddData(new MaterialUI.OptionData() { text = uGUI_Localsize.GetContent(availableGameYearList[i].ToString()) }); } BattleYear_Dropdown.onItemSelected.AddListener((valueChanged) => { currentGameYear = valueChanged; }); //设置预设显示 roomLabelTemplate.SetActive(false); foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble) { CreateTemplateInstance(gameProperty); } //Garage OpenGarage_Button.onClick.AddListener(() => { //ClientNetwork.Instance.StartCoroutine( // AssetBundleManager.RequestScene(true, true, "garage", (myReturnValue) => { // Hashtable vehicleList = new Hashtable(); // AccountDataManager.InstanceAllHastables(); // foreach (string Vehicle in AccountDataManager.ExcelVehicleData.Keys) { // vehicleList.Add(Vehicle, new Crew.CrewInfo()); // } // GarageTankManger.Instance.UpdataTankList(vehicleList, true); // AccountManager.Instance.DataUpdata(); // }, null) //); }); OpenRaceMode_Button.onClick.AddListener(() => { OfflineGameManager._Instance.onRaceGamerequested(); }); }
public void Init(OfflineGameProperty gameProperty) { GameDataManager.OfflineMode = true; GameEventManager.ResetActions(); if (PoolManager._Instance == null) { DontDestroyOnLoad(Instantiate(Resources.Load("PoolManager"))); } respawnPointModule = new RespawnPointModule(); respawnPointModule.CorountineRunObject = this; StartCoroutine(AssetBundleManager.RequestScene(true, true, gameProperty.gameMapEnum.ToString(), null, (onFinish) => { new ClientBuildingManagerModule(); BattleMainUIModule.Init(); List <string> vehicleList = GameYear.GetVehicleListFromYear(gameProperty.gameYearEnum); GameEventManager.onNewVehicleSpawned = (newVehicle) => { if (newVehicle.ownerTeam == PunTeams.Team.red) { teamA.Add(newVehicle); } else { teamB.Add(newVehicle); } GameLogic(gameProperty, vehicleList); }; GameEventManager.onNewVehicleDestroyed = (destroyedVehicle) => { if (destroyedVehicle.ownerTeam == PunTeams.Team.red) { teamA.Remove(destroyedVehicle); } else { teamB.Remove(destroyedVehicle); } GameLogic(gameProperty, vehicleList); }; GameEventManager.onPlayerVehicleDestroyed = () => { StartCoroutine(BattleMainUIModule._Instance.ShowDeadCountDown(5, () => { BattleMainUIModule._Instance.onToggleSelectVehicleUIObject(true); })); }; BattleMainUIModule._Instance.onUpdateVehicleList( vehicleList ); BattleMainUIModule._Instance.onVehicleSelected = (selectedPlayerVehicle, bulletList) => { CreatePlayer(selectedPlayerVehicle, bulletList); BattleMainUIModule._Instance.onToggleSelectVehicleUIObject(false); }; //CreateBot(); })); }