// Use this for initialization void Awake() { be = (BattleEntry)battleLibrary.GetEntry(battleUuid.value); tutorial = (be.backgroundHintLeft != null || be.backgroundHintRight != null); escape = tutorial; invincible.value = true; removeBattleSide.value = (int)be.removeSide; useSlowTime.value = be.useSlowTime; battleClock.gameObject.SetActive(useSlowTime.value && !tutorial); backchange = GameObject.Find("Background Background").GetComponent <BackgroundChanger>(); backchange.escapeBattleButton.interactable = be.escapeButtonEnabled; #if UNITY_EDITOR backchange.escapeBattleButton.interactable = be.escapeButtonEnabled || alwaysEscapable.value; #endif backchange.cameraNormal.enabled = false; backchange.cameraSpirit.enabled = false; backchange.gridController.enabled = false; SetupBackgrounds(); paused.value = true; StartCoroutine(CreateEnemies()); Debug.Log("Start"); }
private void SetupValues(ScrObjLibraryVariable iLib, CharacterSaveData saveData) { skills = new CharacterSkill[SKILL_SIZE]; for (int i = 0; i < saveData.skills.Count; i++) { skills[i] = (CharacterSkill)iLib.GetEntry(saveData.skills[i]); //Debug.Log("Found skill " + skills[i].uuid); } }
public void UpdateFile() { int i = saveFiles.GetPosition(); SaveFileEntry entry = saveFiles.GetEntry(); if (chapterIDs[i].value == CLEAR_GAME_ID) { entry.FillData("All maps cleared!", totalDays[i].value, playTimes[i].value); } else if (chapterIDs[i].value == "") { entry.FillData("BASE", totalDays[i].value, playTimes[i].value); } else { MapEntry map = (MapEntry)chapterLibrary.GetEntry(chapterIDs[i].value); entry.FillData(map.entryName, totalDays[i].value, playTimes[i].value); } }
/// <summary> /// Loads a list of uuids into the module list. /// </summary> /// <param name="saveData"></param> public void LoadItemData(SaveListUuid saveData, ScrObjLibraryVariable itemLibrary) { if (values.Length != saveData.size) { Debug.LogWarning("Something is wrong with the size of the module list."); } for (int i = 0; i < saveData.size; i++) { values[i] = string.IsNullOrEmpty(saveData.uuids[i]) ? null : (ItemEntry)itemLibrary.GetEntry(saveData.uuids[i]); } }
void Start() { scene = GetComponent <DialogueScene>(); dialogueLibrary.GenerateDictionary(); dialogueEntry = (DialogueEntry)dialogueLibrary.GetEntry(dialogueUuid.value); currentFrame.value = 0; scene.SetFromFrame(dialogueEntry.frames[0]); Debug.Log("Set frame 0 of dialogue " + dialogueUuid.value); backgroundChanged.Invoke(); bkgMusicChanged.Invoke(); characterChanged.Invoke(); closeupChanged.Invoke(); dialogueTextChanged.Invoke(); }
public void LeaveScoreScreen() { buttonClickEvent.Invoke(); battleLibrary.GenerateDictionary(); Debug.Log("UUID is: " + battleUuid.value); BattleEntry be = (BattleEntry)battleLibrary.GetEntry(battleUuid.value); switch (be.nextLocation) { case BattleEntry.NextLocation.OVERWORLD: paused.value = false; if (be.playerArea == Constants.OverworldArea.TOWER) { currentArea.value++; saveGame.Invoke(); } if (be.changePosition) { if (be.playerArea != Constants.OverworldArea.DEFAULT) { playerArea.value = (int)be.playerArea; } playerPosX.value = be.playerPosition.x; playerPosY.value = be.playerPosition.y; } currentArea.value = playerArea.value; Debug.Log("Battle -> Overworld"); changeMapEvent.Invoke(); break; case BattleEntry.NextLocation.DIALOGUE: currentArea.value = (int)Constants.SCENE_INDEXES.DIALOGUE; dialogueUuid.value = be.nextDialogue.uuid; Debug.Log("Battle -> Dialogue"); changeMapEvent.Invoke(); break; case BattleEntry.NextLocation.BATTLE: currentArea.value = (int)Constants.SCENE_INDEXES.BATTLE; battleUuid.value = be.nextBattle.uuid; Debug.Log("Battle -> Battle"); changeMapEvent.Invoke(); break; } }
IEnumerator CreateEnemies() { while (!MainControllerScript.instance || !MainControllerScript.instance.initiated) { Debug.Log("Waiting"); yield return(null); } battleLibrary.GenerateDictionary(); be = (BattleEntry)battleLibrary.GetEntry(battleUuid.value); // Debug.Log(JsonUtility.ToJson(be)); numberOfEnemies = be.numberOfEnemies; enemySelection = be.enemyTypes; initiated = true; Debug.Log("EnemyController is ready"); }
/// <summary> /// Set ups the save file's information and image /// </summary> /// <param name="save"></param> void SetupSaveFile(int saveIndex) { PlayerStatsSaveClass pssc = SaveController.instance.saveFiles.playerSave[saveIndex]; SaveFileButton button = saveFileButtons[saveIndex]; bool newSave = (pssc.playerArea == 0); button.emptyFile.SetActive(newSave); button.saveStats.SetActive(!newSave); if (!isCurrentlySaving.value && newSave && selectedSaveFile == saveIndex) { selectedSaveFile = -1; } button.SetImage((saveIndex == selectedSaveFile) ? selectedImage : normalImage); button.currentChapter.text = "Ch. " + pssc.currentChapterIndex; button.currentArea.text = ((Constants.OverworldArea)pssc.playerArea).ToString(); button.level.text = "Level " + new ExpLevel(pssc.expTotal).level; button.playTime.text = "Time: " + Constants.PlayTimeFromInt(pssc.playedSeconds, false); Sprite icon; for (int i = 0; i < Constants.GEAR_EQUIP_SPACE; i++) { icon = emptyEquipSlot; if (!string.IsNullOrEmpty(pssc.invItemEquip.uuids[i])) { ItemEntry item = (ItemEntry)itemLibrary.GetEntry(pssc.invItemEquip.uuids[i]); icon = item.icon; } button.equipments[i].sprite = icon; } for (int i = 0; i < Constants.MODULE_EQUIP_SPACE; i++) { icon = emptyEquipSlot; if (!string.IsNullOrEmpty(pssc.invModuleEquip.uuids[i])) { Module module = (Module)moduleLibrary.GetEntry(pssc.invModuleEquip.uuids[i]); icon = module.icon; } button.modules[i].sprite = icon; } }
/// <summary> /// Retrieves the equipped module indexes to be used in the battle and assigns a module to each /// containerModule in the WeaponSlot. /// </summary> /// <returns></returns> void SetEquippedModule() { BattleEntry be = (BattleEntry)battleLibrary.GetEntry(battleUuid.value); for (int i = 0; i < Constants.MODULE_EQUIP_SPACE; i++) { if (be.useSpecificModule) { containerModules[i].module = be.equippedModule[i]; } else { containerModules[i].module = (Module)invModuleEquip.values[i]; } containerModules[i].Initialize(i); containerModules[i].slotPos = new Rect(Screen.width * moduleWidth + i * size * 1.25f, Screen.height * moduleHeight, size, size); containerModules[i].slotFilled = new Rect(Screen.width * moduleWidth + i * size * 1.25f, Screen.height * moduleHeight, size, size); } }
/// <summary> /// Retrieves the equipped kanji indexes to be used in the battle and assigns a kanji to each /// containerKanji in the WeaponSlot. /// </summary> /// <returns></returns> void SetEquippedKanji() { BattleEntry be = (BattleEntry)battleLibrary.GetEntry(battleUuid.value); for (int i = 0; i < Constants.MAX_EQUIPPED_KANJI; i++) { if (be.useSpecificKanji) { kanji[i].kanji = be.equippedKanji[i]; } else { kanji[i].kanji = (Kanji)invKanjiEquip.values[i]; } kanji[i].Initialize(i); //slotName = new Rect(BattleConstants.kanjiXPos+slot*80,BattleConstants.kanjiYPos-16,400,100); kanji[i].slotPos = new Rect(Screen.width * kanjiWidth + i * size * 1.25f, Screen.height * kanjiHeight, size, size); kanji[i].slotFilled = new Rect(Screen.width * kanjiWidth + i * size * 1.25f, Screen.height * kanjiHeight, size, size); } }
void Start() { scene = GetComponent <DialogueScene>(); dialogueLibrary.initialized = false; dialogueLibrary.GenerateDictionary(); dialogueEntry = (DialogueEntry)dialogueLibrary.GetEntry(dialogueUuid.value); if (!overrideActionNumber.value) { currentAction.value = 0; scene.Reset(); } else { overrideActionNumber.value = false; } NextFrame(); scene.backgroundChanged.Invoke(); scene.bkgMusicChanged.Invoke(); scene.characterChanged.Invoke(); scene.closeupChanged.Invoke(); scene.dialogueTextChanged.Invoke(); }
public InventoryContainer(ScrObjLibraryVariable iLib, CharacterSaveData saveData, UpgradeCalculator calculator) { wpnSkills = new WeaponRank[WPN_SKILLS]; for (int i = 0; i < saveData.wpnSkills.Length; i++) { wpnSkills[i] = (WeaponRank)saveData.wpnSkills[i]; } for (int i = 0; i < INVENTORY_SIZE; i++) { if (i >= saveData.inventory.Count) { inventory.Add(new InventoryTuple(null, i)); } else { ItemEntry item = (ItemEntry)iLib.GetEntry(saveData.inventory[i]); inventory.Add(new InventoryTuple(item, i) { currentCharges = saveData.invCharges[i] }); inventory[i].UpdateUpgrades(calculator); } } }
public void LoadGame() { Debug.Log("###LOAD GAME FUNCTION CALLED###"); characterLibrary.GenerateDictionary(); spriteLibrary.GenerateDictionary(); SetPath(); SaveData data = ReadFile(); Debug.Log(JsonUtility.ToJson(data)); //Character PlayerCharacter character = (PlayerCharacter)characterLibrary.GetEntry(data.characterID); selectedCharacter.reference = character; for (int i = 0; i < character.spells.Length; i++) { spellRefs[i].reference = character.spells[i]; } // Player stats for (int i = 0; i < playerGains.Length; i++) { playerGains[i].value = data.playerGains[i]; } for (int i = 0; i < playerStats.Length; i++) { playerStats[i].value = data.playerStats[i]; } //Spells for (int i = 0; i < spellRefs.Length; i++) { spellRefs[i].level = data.spellLevels[i]; } Debug.Log("Finished loading stats"); //Inventory ItemEntry item; equipItems.values = new ItemEntry[data.equippedItems.Length]; for (int i = 0; i < data.equippedItems.Length; i++) { if (data.equippedItems[i] == null || !data.equippedItems[i].isItem) { continue; } item = (ItemEntry)ScriptableObject.CreateInstance("ItemEntry"); item.icon = (SpriteEntry)spriteLibrary.GetEntry(data.equippedItems[i].iconID); item.Load(data.equippedItems[i]); equipItems.values[i] = item; } bagItems.values = new ItemEntry[data.bagItems.Length]; for (int i = 0; i < data.bagItems.Length; i++) { if (data.bagItems[i] == null || !data.bagItems[i].isItem) { continue; } item = (ItemEntry)ScriptableObject.CreateInstance("ItemEntry"); item.icon = (SpriteEntry)spriteLibrary.GetEntry(data.bagItems[i].iconID); item.Load(data.bagItems[i]); bagItems.values[i] = item; } //Other playtime.value = data.playTime; Debug.Log("Finished loading"); SceneManager.LoadScene(townStr); }
private void Start() { currentMap.value = mapLibrary.GetEntry(loadMapID.value); StartCoroutine(LoadBattleScenes()); }
private void OnEnable() { dialogueEntry = (DialogueEntry)dialogueLibrary.GetEntry(dialogueUuid.value); }
/// <summary> /// Does the actual loading of all the data and puts it into the game. /// </summary> public void Load() { if (saveFileData == null) { Debug.LogError("There's no file to read!"); return; } // Read simple data currentTotalDays.value = simpleTotalDays[saveIndex.value].value; currentPlayTime.value = simplePlayTimes[saveIndex.value].value; // Read data in save file SaveData loadedData = saveFileData.saveFiles[saveIndex.value]; currentMoney.value = loadedData.money; currentScrap.value = loadedData.scrap; // Read map data currentMission.value = missionLibrary.GetEntry(loadedData.mapData.missionString); mapIndex.value = loadedData.mapData.mapIndex; loadMapID.value = (currentMission.value != null) ? ((MissionEntry)currentMission.value).maps[mapIndex.value].uuid : ""; squad1.values.Clear(); for (int i = 0; i < loadedData.mapData.squad1.Count; i++) { squad1.values.Add(new PrepCharacter(loadedData.mapData.squad1[i])); } squad2.values.Clear(); for (int i = 0; i < loadedData.mapData.squad2.Count; i++) { squad2.values.Add(new PrepCharacter(loadedData.mapData.squad2[i])); } // Read player data playerData.ResetData(); for (int i = 0; i < loadedData.upgrade.Count; i++) { UpgradeEntry upgrade = (UpgradeEntry)upgradeLibrary.GetEntry(loadedData.upgrade[i].id); playerData.upgrader.upgrades.Add(new UpgradeItem(upgrade, loadedData.upgrade[i].researched)); } for (int i = 0; i < loadedData.characters.Count; i++) { CharEntry cStats = (CharEntry)characterLibrary.GetEntry(loadedData.characters[i].id); ClassEntry cClass = (ClassEntry)classLibrary.GetEntry(loadedData.characters[i].currentClass); playerData.stats.Add(new StatsContainer(loadedData.characters[i], cStats, cClass)); playerData.inventory.Add(new InventoryContainer(itemLibrary, loadedData.characters[i], playerData.upgrader)); playerData.skills.Add(new SkillsContainer(skillLibrary, loadedData.characters[i])); playerData.baseInfo.Add(new SupportContainer(loadedData.characters[i])); } for (int i = 0; i < loadedData.items.Count; i++) { ItemEntry item = (ItemEntry)itemLibrary.GetEntry(loadedData.items[i].id); playerData.items.Add(new InventoryItem(item, loadedData.items[i].charges)); } for (int i = 0; i < loadedData.missions.Count; i++) { playerData.missions.Add(new MissionProgress(loadedData.missions[i].id, loadedData.missions[i].cleared)); } playerData.upgrader.CalculateResearch(); Debug.Log("Successfully loaded the save data!"); loadFinishedEvent.Invoke(); }