public void Save() { PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Coins), coins); PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Enemy_Killed), enemiesKilled); PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Skin_Size), skinsInventory.Count); // Skins Inventory for (int skinIndex = 0; skinIndex < skinsInventory.Count; ++skinIndex) { Skin skin = skinsInventory[skinIndex]; skin.Save(skinIndex); } // Current Skins // -- First Player string firstSkinURL = null; if (CurrentFirstSkin != null) { firstSkinURL = CurrentFirstSkin.SkinSpriteUrl; } PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player1_Skin), firstSkinURL); // -- Second Player string secondSkinURL = null; if (CurrentSecondSkin != null) { secondSkinURL = CurrentSecondSkin.SkinSpriteUrl; } PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player2_Skin), secondSkinURL); PlayerPrefs.Save(); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(enter)) { PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Coins), text.text); this.gameObject.SetActive(false); } }
public void LoadLevelEditor() { string name = SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level); if (name == "") { return; } PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level_Editor_Creation), 0); Application.LoadLevel("NewLevelEditor"); }
public void LevelSelect() { string name = PlayerName.text; if (name == "") { return; } PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Name), name); Application.LoadLevel("LevelSelectScene"); }
public void CreateNew() { if (MapWidth.text == "" || MapHeight.text == "") { return; } PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level_Editor_Creation), 1); PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level_Editor_Row), Int32.Parse(MapWidth.text)); PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level_Editor_Col), Int32.Parse(MapHeight.text)); Application.LoadLevel("NewLevelEditor"); }
void LoadFiles() { var info = new DirectoryInfo("Assets/Maps"); var files = info.GetFiles(); float buttonSize = 1f; float yOffset = -20; int fileCount = 0; foreach (var i in files) { if (i.Extension == ".map") { //Instantiate Button var newButton = Instantiate(button); //Set Button Parent newButton.transform.SetParent(this.transform, false); newButton.transform.localPosition = new Vector3(-120, yOffset, 0); newButton.transform.localScale = new Vector3(buttonSize, buttonSize + .1f, buttonSize); var text = newButton.GetComponentInChildren <Text>(); text.text = Path.GetFileNameWithoutExtension(i.Name); newButton.onClick.AddListener(() => { PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level), text.text); } ); ++fileCount; yOffset -= 100; } } // Set scroll rect to proper size rtransform.sizeDelta = new Vector2(40, 100 * fileCount); }
public void Load() { coins = SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Coins); enemiesKilled = SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Enemy_Killed); int skinCount = SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Skin_Size); // Before we add more to it, let's clear it skinsInventory.Clear(); // Load in the skins for (int skinIndex = 0; skinIndex < skinCount; ++skinIndex) { GameObject goSkin = Instantiate(SkinBlueprint); Skin skin = goSkin.GetComponent <Skin>(); if (skin) { skin.Load(skinIndex); skinsInventory.Add(skin); } } // Current Skins string firstSkinURL = PlayerPrefs.GetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player1_Skin)); string secondSkinURL = PlayerPrefs.GetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player2_Skin)); if (firstSkinURL != "") { CurrentFirstSkin = Instantiate(SkinBlueprint).GetComponent <Skin>(); CurrentFirstSkin.SkinSpriteUrl = firstSkinURL; } else { CurrentFirstSkin = null; } if (secondSkinURL != "") { CurrentSecondSkin = Instantiate(SkinBlueprint).GetComponent <Skin>(); CurrentSecondSkin.SkinSpriteUrl = secondSkinURL; } else { CurrentSecondSkin = null; } }
public void StartGame() { // Player 1 Left IEnumerator <Toggle> activeToggle = Player1Left.ActiveToggles().GetEnumerator(); activeToggle.MoveNext(); Toggle currentToggle = activeToggle.Current; PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player1_Left), (int)currentToggle.GetComponent <WeaponIdentifier>().Type); // Player 1 Right activeToggle = Player1Right.ActiveToggles().GetEnumerator(); activeToggle.MoveNext(); currentToggle = activeToggle.Current; PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player1_Right), (int)currentToggle.GetComponent <WeaponIdentifier>().Type); // Player 2 Left activeToggle = Player2Left.ActiveToggles().GetEnumerator(); activeToggle.MoveNext(); currentToggle = activeToggle.Current; PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player2_Left), (int)currentToggle.GetComponent <WeaponIdentifier>().Type); // Player 2 Right activeToggle = Player2Right.ActiveToggles().GetEnumerator(); activeToggle.MoveNext(); currentToggle = activeToggle.Current; PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player2_Right), (int)currentToggle.GetComponent <WeaponIdentifier>().Type); string name = SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level); if (name == "") { return; } Application.LoadLevel("GameScene"); }
// Use this for initialization void Start() { LevelEditorPanel.gameObject.SetActive(LevelEditorPanelView); WeaponSelectionPanel.gameObject.SetActive(WeaponSelectionPanelView); PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level), ""); }
public void Save(int id) { PlayerPrefs.SetString(SaveClass.GetKey(SaveClass.Save_Keys.Key_Skin_URL) + "_" + id, SkinSpriteUrl); }