Scriptum/Assets/NewGame.cs
2023-01-07 12:02:47 +01:00

118 lines
4.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class NewGame : MonoBehaviour
{
public void ResetSettings()
{
// when new game is started, clear all rememberred vars (for now, added for this one with dynamic names)
PlayerPrefs.DeleteAll();
// !!! TODO do local save in other way !!!
// !!! comment on changed elements
int rock = 1;
PlayerPrefs.SetInt("rock", rock); // Is it used anywhere? I have not found it
/*
string pickaxe1 = "create";
PlayerPrefs.SetString("pickaxe1", pickaxe1);
*/
PlayerPrefs.SetFloat("exp", 0);
PlayerPrefs.SetInt("lvl", 1);
PlayerPrefs.SetFloat("maxExp", 10);
PlayerPrefs.SetInt(AccountBalanceManager.PLAYER_ACCOUNT_VALUE, 0);
string name = "none";
PlayerPrefs.SetString("name", name);
int isQuest = 1;
PlayerPrefs.SetInt("lumberjack", isQuest);
/*
int isKilled = 0;
PlayerPrefs.SetInt("bat0", isKilled);
PlayerPrefs.SetInt("bat1", isKilled);
PlayerPrefs.SetInt("skeleton0", isKilled);
PlayerPrefs.SetInt("slime0", isKilled);
PlayerPrefs.SetInt("slime1", isKilled);
*/
float health = 10.0f;
PlayerPrefs.SetFloat("maxHealth", 10);
PlayerPrefs.SetFloat("health", 10);
//PlayerPrefs.SetInt("continued", 0);
PlayerPrefs.SetInt("rock", 0); // Is it used anywhere? I have not found it
//PlayerPrefs.SetInt("goldOre", 0);
PlayerPrefs.SetInt("pickaxe", 0);
// PLAYER SKILLS ------------------------------------------------------
PlayerPrefs.SetInt(SkillsPointsManger.PLAYER_SKILS_FREE_POINTS, 0);
PlayerPrefs.SetInt(SkillsPointsManger.PLAYER_SKILS_HEALTH_POINTS, 0); // healthPoints
PlayerPrefs.SetInt(SkillsPointsManger.PLAYER_SKILS_DEFENSE_POINTS, 0); // defensePoints
PlayerPrefs.SetInt(SkillsPointsManger.PLAYER_SKILS_STRENGHT_POINTS, 0); // StrengthPoints
PlayerPrefs.SetInt(SkillsPointsManger.PLAYER_SKILS_INTELIGENCE_POINTS, 0); // IntelligencePoints
// --------------------------------------------------------------------
//DEFAULT CONTROLS
if (!PlayerPrefs.HasKey("Interact"))
{
PlayerPrefs.SetString("Interact","E");
}
if (!PlayerPrefs.HasKey("Attack"))
{
PlayerPrefs.SetString("Attack","Space");
}
if (!PlayerPrefs.HasKey("Skills"))
{
PlayerPrefs.SetString("Skills","U");
}
if (!PlayerPrefs.HasKey("Inventory"))
{
PlayerPrefs.SetString("Inventory","I");
}
if (!PlayerPrefs.HasKey("Settings"))
{
PlayerPrefs.SetString("Settings","Escape");
}
// --------------------------------------------------------------------
//LETTER --------------------------------------------------------------
PlayerPrefs.SetInt("PrologueLetter.WhereDisplayed", 0);
PlayerPrefs.SetInt("ControlLetter.WhereDisplayed", 0);
// --------------------------------------------------------------------
//NPC ACTIONS HERE ----------------------------------------------------
// -> Wizard House
PlayerPrefs.SetInt("Wizard.FirstMission", 0);
// --------------------------------------------------------------------
OnMapAppearanceMethod.SetNewGameStatus();
// remove all binary files from Application.persistentDataPath + "/";
System.IO.DirectoryInfo di = new DirectoryInfo(Application.persistentDataPath);
foreach (FileInfo file in di.GetFiles())
{
if (file.FullName.Contains("Player.log"))
continue;
file.Delete();
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
dir.Delete(true);
}
}
}