/// <summary> /// Called on player victory to decide what comes next /// </summary> void PlayerVictory() { //Debug.Log("Winner"); // increase number of battles until level up BattleCounter.GetInstance().IncreaseCurrentBattleCount(); // if no more battles if (BattleCounter.GetInstance().GetRemainingBattles() <= 0) { //Debug.Log("Increasing Difficulty"); // increase difficulty DifficultyLevel.GetInstance().IncreaseDifficulty(); // increase number of battles to difficulty level BattleCounter.GetInstance().SetBattlesNeeded(DifficultyLevel.GetInstance().GetDifficultyMultiplier()); // start back from 0 battles BattleCounter.GetInstance().ResetCurrentBattleCount(); // set a checkpoint for enemy stat creation EnemyStats.GetInstance().SetCheckpoint(); // go to town, no more battles to be fought this round LoadStatSelect(); _backgroundManager.BackgroundChange(); } else { //Debug.Log("On to the next battle!"); // check to see if player wants to use a camp kit (only if they have one!) if (this.player.inventory.CampKits > 0) { // check if player wants to camp out before next battle // load camp kit check scene? } // No more resetting stats on retreat. So this is to save the stats after each battle. EnemyStats.GetInstance().SetCheckpoint(); LoadNextBattle(); } }
/// <summary> /// Ends the game. /// </summary> private void EndGame() { // player dead TransferGoldOnDeath(); // this.player.transform.localPosition = this.prevPos; // check for high score if (PlayerPrefs.GetInt("score") > PlayerPrefs.GetInt("hiscore")) { // set new HighScore PlayerPrefs.SetInt("hiscore", PlayerPrefs.GetInt("score")); } // reset score/turn PlayerPrefs.SetInt("turn", 0); // reset difficulty DifficultyLevel.GetInstance().ResetDifficulty(); BattleCounter.GetInstance().ResetCurrentBattleCount(); BattleCounter.GetInstance().ResetBattlesNeeded(); // Set the idle animation to town idle player.playerAnimator.SetBool("InBattle", false); if (!waiting) { // load death scene LevelLoadHandler.Instance.LoadLevel("DeathScene_LVP", false); } }
// Use this for initialization void Start() { SceneFadeHandler.Instance.levelStarting = true; AudioManager.Instance.PlayNewSong("ForestOverworld"); // initialize references this.player = FindObjectOfType <PlayerController>(); this.prevPos = this.player.transform.localPosition; newPos = new Vector3(-14f, -2.5f); this.player.gameObject.transform.localPosition = newPos; if (PlayerPrefs.GetInt("midgame") == 1) { this.backButton.gameObject.SetActive(false); this.numCredits = 1; } if (PlayerPrefs.GetInt("score") == 0) { EnemyStats.GetInstance().SetVeryFirstEnemy(true); } else { EnemyStats.GetInstance().SetVeryFirstEnemy(false); } if (BattleCounter.GetInstance().GetCurrentBattleCount() == 0) { EnemyStats.GetInstance().SetStartOfRun(true); } // get stats from player this.baseHealth = this.player.totalHealth; this.baseDamage = this.player.physicalDamage; this.baseArmor = this.player.armor; this.baseEnergy = this.player.totalEnergy; // variables to be changed this.newHealth = this.baseHealth; this.newDamage = this.baseDamage; this.newArmor = this.baseArmor; this.newEnergy = this.baseEnergy; this.healthAmt.text = this.newHealth.ToString(); this.armorAmt.text = this.newArmor.ToString(); this.energyAmt.text = this.newEnergy.ToString(); this.damageAmt.text = this.newDamage.ToString(); this.creditText.text = "CREDITS: " + numCredits; // value per credit: this.healthInc = 25; this.damageInc = 5; this.armorInc = 10; this.energyInc = 10; this.player.InBattle(false); //first Enemy handling Invoke("FirstEnemy", 0.01f); }
private void EnemyStart() { this.dollarBalance = 35 + (BattleCounter.GetInstance().GetCurrentBattleCount() * 10); if (this.dollarBalance > 150) { this.dollarBalance = 150; } CreateStats(); //remainingEnergy = totalEnergy; //remainingHealth = totalHealth; }
void Awake() { PlayerPrefs.SetInt("midgame", 0); // reset to level 1 DifficultyLevel.GetInstance().ResetDifficulty(); // make sure we start at 0 BattleCounter.GetInstance().ResetCurrentBattleCount(); BattleCounter.GetInstance().ResetBattlesNeeded(); // set number of battles BattleCounter.GetInstance().SetBattlesNeeded(DifficultyLevel.GetInstance().GetDifficultyMultiplier()); }
void Awake() { PlayerPrefs.SetInt("retreated", 0); SceneFadeHandler.Instance.levelStarting = true; EscapeHandler.instance.GetButtons(); // Combat AI Controller reference this.combatController = FindObjectOfType <CombatController>(); // inventory animator this.invAnim = FindObjectOfType <InventoryAnimation>(); this.player = FindObjectOfType <PlayerController>(); this.enemy = FindObjectOfType <BaseEnemyController>(); currentBattle = BattleCounter.GetInstance().GetCurrentBattleCount(); remainingBattles = BattleCounter.GetInstance().GetRemainingBattles(); _backgroundManager = FindObjectOfType <BackgroundManager>(); _backgroundManager.SetBackground(); }
public void LoadGame() { // if there is a game to load if (PlayerPrefs.GetInt("GameToLoad") == 1) { Debug.Log("Loading game data..."); // load player data string gameData = PlayerPrefs.GetString("GameData"); Debug.Log(gameData); char[] delim0 = { '_' }; char[] delim1 = { ';' }; char[] delim2 = { ':' }; string[] data0 = gameData.Split(delim0); // split on '_' to split game/player/LF/cP, gives groups of stats //for (int i = 0; i < data0.Length; i++ ) // Debug.Log(data0[i] + " "); string[] gameStats = data0[0].Split(delim1); // gives STAT:### on each index string[] playerStats = data0[1].Split(delim1); // gives STAT:### on each index string[] lastFoughtStats = data0[2].Split(delim1); // gives STAT:### on each index string[] checkpointStats = data0[3].Split(delim1); // gives STAT:### on each index int thp = 0, tnrg = 0, rhp = 0, rnrg = 0, dmg = 0, arm = 0; for (int i = 0; i < data0.Length; i++) { switch (i) { // game data on data0[0]; case 0: Debug.Log("Loading Game info..."); for (int j = 0; j < gameStats.Length; j++) { string[] statSet = gameStats[j].Split(delim2); // Gives [0]:STAT [1]: ### switch (statSet[0]) { case "inB": // in Battle? if (Convert.ToInt32(statSet[1]) == 1) { this.inBattle = true; } else { this.inBattle = false; } break; case "PLVL": // current battle no BattleCounter.GetInstance().SetCurrentBattleCount(Convert.ToInt32(statSet[1])); break; case "LVL": // remaining battles BattleCounter.GetInstance().SetBattlesNeeded(Convert.ToInt32(statSet[1])); break; case "NEK": // num enemies killed PlayerPrefs.SetInt("score", Convert.ToInt32(statSet[1])); break; case "HTL": // Healing turns left this.player.numTurnsLeftToHeal = Convert.ToInt32(statSet[1]); break; } } break; // player data on data0[1]; case 1: Debug.Log("Loading Player info..."); for (int j = 0; j < playerStats.Length; j++) { string[] statSet = playerStats[j].Split(delim2); // Gives [0]:STAT [1]: ### //Debug.Log(playerStats[j]); switch (statSet[0]) { case "rHP": // rem HP this.player.remainingHealth = Convert.ToInt32(statSet[1]); break; case "tHP": // total HP this.player.totalHealth = Convert.ToInt32(statSet[1]); break; case "rNRG": // rem NRG this.player.remainingEnergy = Convert.ToInt32(statSet[1]); break; case "tNRG": // total NRG this.player.totalEnergy = Convert.ToInt32(statSet[1]); break; /*case "Magic" * // magical damage * this.player.magicalDamage= Convert.ToInt32(statSet[1]); * break; */ case "DMG": // base physical damage this.player.physicalDamage = Convert.ToInt32(statSet[1]); break; case "ARM": // base armor this.player.armor = Convert.ToInt32(statSet[1]); break; case "wDMG": // weapon damage stat this.player.playerWeapon.SetDamage(Convert.ToInt32(statSet[1])); break; case "wARM": // weapon armor stat this.player.playerWeapon.SetArmor(Convert.ToInt32(statSet[1])); break; case "aDMG": //armor damage stat this.player.playerArmor.SetDamage(Convert.ToInt32(statSet[1])); break; case "aARM": // armor armor stat this.player.playerArmor.SetArmor(Convert.ToInt32(statSet[1])); break; case "iA": // inventory: apples this.player.inventory.Apples = Convert.ToInt32(statSet[1]); break; case "iB": // inventory: Bread this.player.inventory.Bread = Convert.ToInt32(statSet[1]); break; case "iC": // inventory: Cheese this.player.inventory.Cheese = Convert.ToInt32(statSet[1]); break; case "iH": // inventory: HPots this.player.inventory.HealthPotions = Convert.ToInt32(statSet[1]); break; case "iE": // inventory: EPots this.player.inventory.EnergyPotions = Convert.ToInt32(statSet[1]); break; } } break; // last fought on data0[2]; case 2: Debug.Log("Loading Enemy info..."); for (int j = 0; j < lastFoughtStats.Length; j++) { string[] statSet = lastFoughtStats[j].Split(delim2); // Gives [0]:STAT [1]: ### switch (statSet[0]) { case "etHP": thp = Convert.ToInt32(statSet[1]); break; case "erHP": rhp = Convert.ToInt32(statSet[1]); break; case "etNRG": tnrg = Convert.ToInt32(statSet[1]); break; case "erNRG": rnrg = Convert.ToInt32(statSet[1]); break; case "eDMG": dmg = Convert.ToInt32(statSet[1]); break; case "eARM": arm = Convert.ToInt32(statSet[1]); break; default: break; } } // Recreates enemy EnemyStats.GetInstance().LoadNewEnemy(rhp, thp, rnrg, tnrg, dmg, arm); enemyLoadedFromFile = true; //this.enemy.SetStats(thp, rhp, rnrg, tnrg, dmg, arm); break; // check point on data0[3]; case 3: Debug.Log("Loading CheckPoint info..."); for (int j = 0; j < checkpointStats.Length; j++) { string[] statSet = lastFoughtStats[j].Split(delim2); // Gives [0]:STAT [1]: ### switch (statSet[0]) { case "eHP": thp = Convert.ToInt32(statSet[1]); break; case "eNRG": tnrg = Convert.ToInt32(statSet[1]); break; case "eDMG": dmg = Convert.ToInt32(statSet[1]); break; case "eARM": arm = Convert.ToInt32(statSet[1]); break; default: break; } } EnemyStats.GetInstance().SetCheckpointData(thp, tnrg, dmg, arm); break; case 4: // Sprites // LoadSprites(); break; default: break; } } Debug.Log("Load Complete"); } else { Debug.Log("NO GAME TO BE LOADED"); } }
public void SaveGame() { if (this.player != null) { string statString = ""; // generate a CSV string for stats // FORMAT: STAT:###; // strip on semi colons first, then colons // FORMAT: /* in battle? (1/0) * current battle * remaining battles * Num Enemies Killed * PlayerStats */ /* * remHP * totHP * remNRG * totNRG * [Magic] * DMG * ARM * wDMG * wARM * aDMG * aARM */ // TODO: PLAYER INVENTORY!!*** // HEAL TURNS /* EnemyStats*/ /* Last Fought Enemy * eHP * eNRG * eDMG * eARM */ /* Checkpoint Enemy * eHP * eNRG * eDMG * eARM */ if (this.player.inBattle) { statString += "inB:" + 1 + ";"; } else { statString += "inB:" + 0 + ";"; } if (this.enemy != null) { EnemyStats.GetInstance().SetLastFoughtEnemyStatString(this.enemy.GetEnemyStatString()); } // current battle number(10/15 battles) statString += "PLVL:" + BattleCounter.GetInstance().GetCurrentBattleCount() + ";"; // Level (total number of battles needed) statString += "LVL:" + BattleCounter.GetInstance().GetBattlesNeeded() + ";"; // Number Enemies Killed statString += "NEK:" + PlayerPrefs.GetInt("score") + ";"; // Healing Turns Left statString += "HTL:" + this.player.numTurnsLeftToHeal + ";"; // BREAK statString += "_"; // get player stats statString += this.player.GetPlayerStatString(); // Inventory statString += "iA:" + this.player.inventory.Apples + ";"; statString += "iB:" + this.player.inventory.Bread + ";"; statString += "iC:" + this.player.inventory.Cheese + ";"; statString += "iH:" + this.player.inventory.HealthPotions + ";"; statString += "iE:" + this.player.inventory.EnergyPotions + ";"; // BREAK statString += "_"; // get enemy stats // SAVE LAST FOUGHT ENEMY stats // Last fought if (EnemyStats.GetInstance().GetLastFoughtEnemyStatString() == "" || EnemyStats.GetInstance().GetLastFoughtEnemyStatString() == null) { if (this.enemy != null) { EnemyStats.GetInstance().SetLastFoughtEnemyStatString(this.enemy.GetEnemyStatString()); } else { EnemyStats.GetInstance().SetLastFoughtEnemyStatString(this.player.GetEnemyStatString()); } } statString += EnemyStats.GetInstance().GetLastFoughtEnemyStatString(); // BREAK statString += "_"; // Checkpoint if (EnemyStats.GetInstance().GetCheckpointEnemyString() == "" || EnemyStats.GetInstance().GetCheckpointEnemyString() == null) { if (this.enemy != null) { EnemyStats.GetInstance().SetCheckpointEnemyStatString(this.enemy.GetEnemyStatString()); } else { EnemyStats.GetInstance().SetLastFoughtEnemyStatString(this.player.GetEnemyStatString()); } } statString += EnemyStats.GetInstance().GetCheckpointEnemyString(); // BREAK statString += "_"; // get sprite info // statString += SaveSprites(); // Save to PlayerPrefs PlayerPrefs.SetString("GameData", statString); Debug.Log(statString); // set flag for game to load next time PlayerPrefs.SetInt("GameToLoad", 1); } }