// load boards from save file. public void LoadBoard2(string filename, Transform[] board) { int card_index = 0; // access all string arrays in the save file. string[] board_data = SaveLoadController.LoadBoard(filename); // transfer saved boards into the board selector screen. for (int i = 0; i < board_data.Length; i++) { if (board_data[i] == "Blank2" || board_data[i] == "Blank3") { board[i].GetComponent <Image>().sprite = Resources.Load <Sprite>("Blank2"); } else { // search for cards using the string aquired from the save file. while (_card_img[card_index].name != board_data[i]) { card_index++; } board[i].GetComponent <Image>().sprite = _card_img[card_index]; card_index = 0; } } }
//Initialization void Start() { //Initialize Parent for instantiated prefabs emptyGridParent = new GameObject(); emptyGridParent.name = "Empty Grid Parent"; playerOXParent = new GameObject(); playerOXParent.name = "Player OX Parent"; //Generate grids gridSquareList = new List <List <GameObject> >(); List <GameObject> tempGridList; for (float i = 0; i < gridSize; ++i) { tempGridList = new List <GameObject>(); for (float j = 0; j < gridSize; ++j) { GameObject emptyGrid = Instantiate(emptyGridPrefab, new Vector3(i * spaceBetweenGrids, j * spaceBetweenGrids), Quaternion.identity) as GameObject; emptyGrid.GetComponent <GridEvent>().setGridPos((int)(i), (int)(j)); //Set the grid index position tempGridList.Add(emptyGrid); //add one grid to one column emptyGrid.transform.SetParent(emptyGridParent.transform); //group instantiated object to a parent } gridSquareList.Add(tempGridList); //add one column of grid to a row } emptyGridCount = (int)(gridSize * gridSize); //Other initialization xTurn = firstTurnIsX; gameVisual = gameObject.GetComponent <GameVisualController>(); gameEnd = false; saveLoad = new SaveLoadController(); }
public void SaveMaybeOverwrite(SaveLoadController saveLoad, string id, GameBundle.Metadata metadata, Texture2D thumbnail, System.Action onSaveComplete) { string dir = GetBundleDirectory(id); Util.SetNormalFileAttributes(dir); Directory.CreateDirectory(dir); GameBundle bundle = new GameBundle(dir); if (thumbnail != null) { Util.SetNormalFileAttributes(bundle.GetThumbnailPath()); Util.SaveTextureToPng(thumbnail, bundle.GetThumbnailPath()); } Util.SetNormalFileAttributes(bundle.GetMetadataPath()); File.WriteAllText(bundle.GetMetadataPath(), JsonUtility.ToJson(metadata)); Util.SetNormalFileAttributes(bundle.GetVoosPath()); saveLoad.RequestSave(bundle.GetVoosPath(), onSaveComplete); #if !USE_STEAMWORKS workshop.Save(bundle.GetAssetsPath()); #endif }
void MasterClientInit() { SaveGameToLoad saveGameToLoad = FindObjectOfType <SaveGameToLoad>(); string bundleId = GameBuilderApplication.CurrentGameOptions.bundleIdToLoad; if (saveGameToLoad) { Debug.Log("Loading saved game!"); saveLoad.Load(saveGameToLoad.saved, saveGameToLoad.voosFilePath); GameObject.Destroy(saveGameToLoad.gameObject); } else if (!bundleId.IsNullOrEmpty()) { Debug.Log($"Loading game bundle {bundleId}"); string voosPath = gameBundleLibrary.GetBundle(bundleId).GetVoosPath(); saveLoad.Load(SaveLoadController.ReadSaveGame(voosPath), voosPath); #if !USE_STEAMWORKS workshop.Load(gameBundleLibrary.GetBundle(bundleId).GetAssetsPath()); #endif lastLoadedBundleId = bundleId; } else { SaveLoadController.SaveGame save = SaveLoadController.ReadSaveGame(GameBuilderSceneController.GetMinimalScenePath(mode == Mode.Online)); saveLoad.Load(save); } using (Util.Profile("SpawnLocalobjects")) SpawnLocalObjects(); StartCoroutine(LoadingSequence()); }
public void PurchaseConfirmed() { //Confirm purchase and adjust coin amount accordigly currentCoinAmount -= itemInCart.goldPrice; coins.text = "Coins: " + currentCoinAmount.ToString(); confirmPopUp.SetActive(false); EventManager.TriggerEvent(EventTypes.PURCHASE_CONFIRMED); SaveLoadController.GetInstance().GetPlayer().AddTotalCoins(-itemInCart.goldPrice); //substract coins from player SaveLoadController.GetInstance().GetPlayer().AddUnlockedItem(itemInCart.itemID); //unlock skin for player SetSkinActive(itemInCart.itemID); // Set skin active. This also saves the game // Send event data // This is very ugly but ok for now switch (itemInCart.skinName) { case "Vladimir": GooglePlayHelper.GetInstance().ReportEvent(GPGSConstant.event_store_default_skin_bought, 1); break; default: break; } itemInCart = null; }
// call this if loading the board will affect selected cards on board creation. public static void LoadBoards(bool[,] already_picked) { string[] board_data; for (int i = 0; i < boards.Length; i++) { string filename = "board" + (i + 1) + ".sav"; board_data = SaveLoadController.LoadBoard(filename); boards[i].isFull = true; int card_i = 0; if (board_data != null) { foreach (string cardname in board_data) { boards[i].cards[card_i].GetComponent <Image>().sprite = Resources.Load <Sprite>(cardname); if (cardname == "Blank2" || cardname == "Blank3") { boards[i].isFull = false; } //already_picked[ i, dict[cardname] ] = true; card_i++; } } else if (board_data == null) { boards[i].cards[card_i].GetComponent <Image>().sprite = Resources.Load <Sprite>("Blank2"); boards[i].isFull = false; card_i++; } //Debug.Log(i + "::" + boards[i].isFull); } }
private void MainFormLoad(object sender, EventArgs e) { mViewHandler.LoadTheme(); mViewHandler.LoadGenresToCombobox(currentSection); PrepareSection(currentSection); SaveLoadController.LoadList(currentSection, settingsForm, currentListView); }
public void SaveGame() { CurrentRoom = FindObjectOfType <Room>(); if (CurrentRoom != null) { if (locationsStates.ContainsKey(SceneManager.GetActiveScene().name)) { locationsStates[SceneManager.GetActiveScene().name] = CurrentRoom.SaveState(); } else { locationsStates.Add(SceneManager.GetActiveScene().name, CurrentRoom.SaveState()); } } SaveGameData data = new SaveGameData(); data.itemsId = InventoryController.Instance.items.Select(i => i.idItem).ToArray(); data.notesId = JournalController.Instance.notes.Select(n => n.idNote).ToArray(); data.tasksId = JournalController.Instance.tasks.Select(t => t.idTask).ToArray(); data.completeTasksId = JournalController.Instance.completeTasks.Select(t => t.idTask).ToArray(); data.locationsStates = locationsStates; data.globalValues = Values; data.locationName = SceneManager.GetActiveScene().name; data.playerPosition = new Vector4Serializer(PlayerController.Instance.transform.position); data.playerRotation = new Vector4Serializer(PlayerController.Instance.transform.rotation); data.playerHealth = PlayerController.Instance.Health; data.equipedWearId = InventoryController.Instance.CurrentDress == null ? "" : InventoryController.Instance.CurrentDress.idItem; SaveLoadController.SaveGame(data); }
// Returns an ID for the bundle. The current VOOS state will be saved as the scene. public string SaveNew(SaveLoadController saveLoad, GameBundle.Metadata metadata, Texture2D thumbnail, System.Action onSaveComplete) { string id = GenerateBundleId(); SaveMaybeOverwrite(saveLoad, id, metadata, thumbnail, onSaveComplete); return(id); }
// load board from save file to display on the WinInfo screen. private void LoadBoard(string filename, Transform[] board) { string[] _board_data = SaveLoadController.LoadBoard(filename + ".sav"); // insert cards into board. int card_index = 0; for (int i = 0; i < _board_data.Length; i++) { if (_board_data[i] == "Blank2" || _board_data[i] == "Blank3") { board[i].GetComponent <Image>().sprite = Resources.Load <Sprite>("Blank2"); } else { while (_board_data[i] != card_img_winInfo[card_index].name) { card_index++; } Debug.Log(i); board[i].GetComponent <Image>().sprite = card_img_winInfo[card_index]; card_index = 0; } } }
void OnGameOver(object arg0) { PlayerSave player = SaveLoadController.GetInstance().GetPlayer(); EndlessSessionSave gameSession = SaveLoadController.GetInstance().GetEndlessSession(); GooglePlayHelper gph = GooglePlayHelper.GetInstance(); player.AddTotalGamesPlayed(1); // report events gph.ReportEvent(GPGSConstant.event_amount_of_endless_games_started, 1); gph.ReportEvent(GPGSConstant.event_score_endless_mode, gameSession.GetTotalScore()); gph.ReportEvent(GPGSConstant.event_health_potions_picked_up, gameSession.GetResourcesGathered()); // save current stats gph.SaveGame(); // TODO: keep track of timeplayed // check for achievements AchievementChecker.CheckForEndlessScoreAchievement(gameSession.GetTotalScore()); AchievementChecker.CheckForWelcomeAchievement(); // highscore post if (gameSession.GetTotalScore() > player.GetHighscore()) { EventManager.TriggerEvent(EventTypes.NEW_HIGHSCORE); player.SetHighscore(gameSession.GetTotalScore()); gph.PostHighscore(player.GetHighscore(), GPGSConstant.leaderboard_endless_mode); } // start game over screen LoadingController.LoadScene(LoadingController.Scenes.GAME_OVER); }
private void OnPlayerCoinPickedUp(object coins) { SaveLoadController slc = SaveLoadController.GetInstance(); slc.GetPlayer().AddTotalCoins((int)coins); slc.GetEndlessSession().AddCoinsCollected((int)coins); }
public void UpdateScoreBoard() { //Load score saveLoad = new SaveLoadController(); saveLoad.Load(); //Shows 2 digits numbers max string oScore = Mathf.Clamp(SaveLoadController.loadedOScore, 0, 99).ToString(); string xScore = Mathf.Clamp(SaveLoadController.loadedXScore, 0, 99).ToString(); //Properly display the score on the number board if (oScore.Length > 1) { oDigitBack.text = oScore[1].ToString(); oDigitFront.text = oScore[0].ToString(); } else { oDigitFront.text = "0"; oDigitBack.text = oScore[0].ToString(); } if (xScore.Length > 1) { xDigitBack.text = xScore[1].ToString(); xDigitFront.text = xScore[0].ToString(); } else { xDigitFront.text = "0"; xDigitBack.text = xScore[0].ToString(); } }
public override void Init(SaveLoadController controller) { FILE_PATH = Application.persistentDataPath + "/save.dat"; this.controller = controller; DefinePlatform(); isInitialized = true; }
public static SaveLoadController GetInstance() { if (instance == null) { instance = new SaveLoadController(); } return(instance); }
private void RegisterControllers() { _steamController = new SteamController(CuratorDataSet); _consoleController = new ConsoleController(CuratorDataSet.Console); _romController = new RomController(CuratorDataSet.ROM); _romFolderController = new RomFolderController(CuratorDataSet.RomFolder); _saveLoadController = new SaveLoadController(CuratorDataSet); }
private void OnPlayerDied(object arg0) { DebugMP.Log("Opponent won."); SaveLoadController.GetInstance().GetMultiplayerSession().SetOpponentWon(); StartCoroutine("TriggerGameOverScreen"); // send message to opponent saying you died SendMessage(GPMPEvents.Types.GPMP_OPPONENT_DIED, new List <byte>()); }
private void PrepareSection(Sections section) { input_fields_panel.VerticalScroll.Value = 0; currentSection = section; SetCurrentListView(); SetFilePath(); SaveLoadController.LoadList(currentSection, settingsForm, currentListView); mViewHandler.SectionTransition(section); }
// Use this for initialization void Start() { text = GetComponent <Text>(); text.text = "0"; ess = SaveLoadController.GetInstance().GetEndlessSession(); coinAnimator = coinImage.GetComponent <Animator>(); EventManager.StartListening(EventTypes.GAME_RESUME, OnGameResume); EventManager.StartListening(EventTypes.GAME_PAUSED, OnGamePaused); EventManager.StartListening(PowerupEvents.PLAYER_COIN_PICKUP, OnCoinPickedUp); }
public void SetOptions(OptionsConfig config) { Config = config; SaveLoadController.SaveOptions(Config); Localization.Instance.SetLanguage(Config.language); if (onConfigChanged != null) { onConfigChanged(Config); } }
private void FileExistenceControl() { if (listPath == string.Empty) { CreateFileAndSave(); } else if (listPath != string.Empty) { SaveLoadController.SaveList(true, SaveButton, currentSection, currentListView); } }
public void ExitToMenu() { ds.PlaySoundScript("event:/UI/ui_click", 0, 0); Battle.won = true; Battle.worldObjName = ""; Battle.playerEntity.CurrentExperience = 0; Battle.playerEntity.CurrentHealth = 0; Battle.playerEntity.InitStats("Dragon", 1); SaveLoadController.ResetValues(); SceneManager.LoadScene("main_menu_scene"); }
// Use this for initialization void Start() { farm = GameObject.FindObjectOfType <Farm>(); uiController = GameObject.FindObjectOfType <UIController>(); saveLoadController = GameObject.FindObjectOfType <SaveLoadController>(); isTodayGrowth = false; currentMoney = 0; temp = DateTime.Now; uiController.UpdateMoneyText(); }
protected override void Awake() { base.Awake(); OptionsConfig optionsConfig = SaveLoadController.LoadOptions(); if (optionsConfig == null) { optionsConfig = GetDefaultOptions(); } SetOptions(optionsConfig); }
private void Start() { //Disable confirm purchase popup confirmPopUp.SetActive(false); notEnoughFunds.SetActive(false); itemInCart = null; //Show amount of coins from savegame coinAmountFromSave = SaveLoadController.GetInstance().GetPlayer().GetTotalCoins(); currentCoinAmount = coinAmountFromSave; coins.text = "Coins: " + currentCoinAmount.ToString(); }
private void OnOpponentDied(object arg0) { DebugMP.Log("You won!"); SaveLoadController slc = SaveLoadController.GetInstance(); slc.GetMultiplayerSession().SetPlayerWon(); slc.GetPlayer().AddTotalMultiplayerMatchesWon(1); AchievementChecker.CheckForMultiplayerAchievement(slc.GetPlayer().GetTotalMultiplayerMatchesWon()); GooglePlayHelper.GetInstance().PostHighscore(slc.GetPlayer().GetTotalMultiplayerMatchesWon(), GPGSConstant.leaderboard_multiplayer_mode); StartCoroutine("TriggerGameOverScreen"); GooglePlayHelper.GetInstance().SaveGame(); }
void Awake() { if (control == null) { DontDestroyOnLoad(gameObject); control = this; } else if (control != this) { Destroy(gameObject); } }
private void FixedUpdate() { if (!buttonReady) { unlockedItems = SaveLoadController.GetInstance().GetPlayer().GetUnlockedItems(); itemTitle.text = storeItem.skinName; itemPrice.text = storeItem.goldPrice.ToString(); storeButton.GetComponent <Image>().sprite = storeItem.skinSprite; SpriteState st = new SpriteState(); st.disabledSprite = storeItem.activeSkinSprite; st.highlightedSprite = storeItem.highlightedSprite; st.pressedSprite = storeItem.highlightedSprite; storeButton.spriteState = st; foreach (int item in unlockedItems) { if (item == storeItem.itemID) { itemUnlocked = true; //pricePanel.SetActive(false); goldImages.SetActive(false); itemPrice.text = "Unlocked"; } } if (!itemUnlocked) { itemUnlocked = false; goldImages.SetActive(true); pricePanel.SetActive(true); } buttonReady = true; } if (newSkinActive) { newActiveSkinID = SaveLoadController.GetInstance().GetPlayer().GetActiveSkinID(); if (newActiveSkinID == storeItem.itemID) { storeButton.interactable = false; } else { storeButton.interactable = true; } newSkinActive = false; } }
// Use this for initialization void Start() { playerMoveScript = GameObject.Find("PlayerContainer").GetComponent <PlayerMovement>(); pauseMenu = GameObject.Find("PauseMenu"); waveSpawner = transform.GetComponent <WaveSpawner>(); baseHpController = GameObject.Find("BaseInfo").GetComponent <BaseHpController>(); scoreController = GameObject.Find("ScoreInfo").GetComponent <ScoreController>(); pauseMenu.SetActive(false); isPaused = false; gameOverPanel = GameObject.Find("GameOverPanel"); gameOverPanel.SetActive(false); highscore = SaveLoadController.LoadScore(); }
// Use this for initialization void Start() { playerSubFarmCount = 1; subFarms = new GameObject[transform.childCount]; uiController = GameObject.FindObjectOfType <UIController>(); mainGameController = GameObject.FindObjectOfType <MainGameController>(); saveLoadController = GameObject.FindObjectOfType <SaveLoadController>(); CheckSubFarmCount(); currentActiveSubFarmIndex = 0; SetSubFarmActive(0); }