void Update() { KeepData.PlayerScore = PinCount; text.text = PinCount.ToString(); KeepData.SetHighScore(); // can't use panelscoretext here because we did not declare the text at the top, look at showdata script. }
void Start() { KeepData saveData = SaveData._Sav.GetSaveData(); _skillpoint.text = saveData._Skill.ToString(); SaveData._Sav.SaveGameData(); }
//获取存档文件,并初始化 public KeepData GetSaveData(bool isInit = false) { //强制初始化,并返回 if (isInit) { InitSaveData(); return(_save); } // 如果save为null if (_save == null) { //如果save不存在,对save文件进行初始化 if (!DataProcess.IsGameDataExist(_SAVE_NAME)) { Debug.Log("不存在存档"); InitSaveData(); return(_save); } //存在存档文件,读取并返回 _save = LoadGameData(); Debug.Log(_save._Gold); return(_save); } //如果存档已存在,直接返回 return(_save); }
public KeepData LoadGameData() { //读取文档 KeepData readGold = DataProcess.LoadGameData(typeof(KeepData), _SAVE_NAME, false) as KeepData; return(readGold); }
/// 使用道具 /// </summary> /// <param name="i">The index.</param> /// <param name="item">Item.</param> void Click(int i, Pic item) { KeepData saveData = SaveData._Sav.GetSaveData(); Itemsave s = GameObject.FindObjectOfType <Itemsave> (); saveData._HaveItemId.Remove(i); saveData._ItemId.Add(i); Destroy(item.gameObject); //道具栏显示道具 if (i < 10) { saveData._HaveItemOn [saveData._Djnum] = i; SaveData._Sav.SaveGameData(); if (saveData._HaveItemOn [saveData._Djnum] == i) { for (int q = 0; q < saveData._HaveItemOn.Count; q++) { if (saveData._HaveItemOn[q] < 10) { _dj [saveData._Djnum].GetComponent <Button> ().image.sprite = s._item [saveData._HaveItemOn [q]]; } _dj [saveData._Djnum].GetComponent <Button> ().image.color = new Color(1, 1, 1, 1); } } } }
public void ChangeTranslateDJ() { KeepData saveData = SaveData._Sav.GetSaveData(); _obj.anchoredPosition = new Vector2(-17, -saveData._Slidery * _s.value); SaveData._Sav.SaveGameData(); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "PickUp") { other.gameObject.SetActive(false); count += 1; ScoreText.text = "Score: " + count; KeepData.GethighScore(); numCount = count; if (count >= 16) { WinText.gameObject.SetActive(true); if (KeepData.RoundsPlayed >= KeepData.PlayerLives) { SceneManager.LoadScene("End"); } else if (KeepData.RoundsPlayed < KeepData.PlayerLives) { SceneManager.LoadScene("MainScene"); KeepData.Round(); } } } }
public void MyMoney() { KeepData saveData = SaveData._Sav.GetSaveData(); _mymoney.text = saveData._Gold.ToString(); SaveData._Sav.SaveGameData(); }
void Update() { KeepData saveData = SaveData._Sav.GetSaveData(); if (Input.GetAxis("Mouse ScrollWheel") != 0) { _s.value = _s.value - (Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * 80); } }
public void Show1(int i) { KeepData saveData = SaveData._Sav.GetSaveData(); if (saveData._IsUclockItem[i] == false) { _jiesuo.SetActive(true); } }
public void EnterScene(int i) { KeepData saveData = SaveData._Sav.GetSaveData(); if (saveData._GuanQiaData[i]) { SceneManager.LoadScene("Game"); } }
/// <summary> /// 更新所有道具图片 /// </summary> void UpdateAllItemPic() { KeepData saveData = SaveData._Sav.GetSaveData(); for (int i = 0; i < _itemPic.Count; i++) { Gx(_itemPic[i]); } }
public void Show(int i) { KeepData saveData = SaveData._Sav.GetSaveData(); if (saveData._IsUclockItem [i] == false) { _jiesuo.SetActive(true); GameObject.Find("youling").GetComponent <EnemyAI> ().enabled = false; GameObject.Find("player").GetComponent <Move2> ().enabled = false; GameObject.Find("player").GetComponent <Player1> ().enabled = false; } }
/// <summary> /// 更新一个道具上所有技能点 /// </summary> /// <param name="item">Item.</param> void Gx(Pic item) { KeepData saveData = SaveData._Sav.GetSaveData(); for (int t = 0; t < item._Skill.Count; t++) { if (saveData._IsUclockSkill[item._Id]._a[t]) { item._Skill[t].image.sprite = s2; } } }
public void Onclick(int j) { KeepData saveData = SaveData._Sav.GetSaveData(); _buy [j].onClick.AddListener(delegate() { if (int.Parse(_storelist [j].text) <= saveData._Gold) { saveData._Gold = saveData._Gold - int.Parse(_storelist [j].text); saveData._HaveItemId.Add(j); } _mymoney.text = saveData._Gold.ToString(); SaveData._Sav.SaveGameData(); }); }
void OnTriggerEnter2D(Collider2D coll) { KeepData saveData = SaveData._Sav.GetSaveData(); if (coll.gameObject.tag == "coin") { saveData._Gold++; _getmoney1++; SaveData._Sav.SaveGameData(); _mymoney.text = saveData._Gold.ToString(); _getmoney.text = _getmoney1.ToString(); } _mymoney.text = saveData._Gold.ToString(); SaveData._Sav.SaveGameData(); }
void Start() { KeepData saveData = SaveData._Sav.GetSaveData(); int _skillmoney1 = int.Parse(_skillmoney.text); _skillbuy.onClick.AddListener(delegate { if (saveData._Gold >= _skillmoney1) { saveData._Gold = saveData._Gold - int.Parse(_skillmoney.text); saveData._Skill++; SaveData._Sav.SaveGameData(); _skillpoint.text = saveData._Skill.ToString(); _mymoney.text = saveData._Gold.ToString(); } }); _mymoney.text = saveData._Gold.ToString(); _skillpoint.text = saveData._Skill.ToString(); }
void Click2(int i, Pic item) { KeepData saveData = SaveData._Sav.GetSaveData(); Itemsave s = GameObject.FindObjectOfType <Itemsave> (); saveData._HaveItemId.Remove(i); saveData._ItemId.Add(i); Destroy(item.gameObject); //道具栏显示道具 if (i < 10) { saveData._HaveItemOn.Add(i); saveData._HaveItemOn.Reverse(); SaveData._Sav.SaveGameData(); _dj [1].GetComponent <Button> ().image.sprite = s._item [i]; } }
public void Show(int i) { KeepData saveData = SaveData._Sav.GetSaveData(); int _jsmoney1 = int.Parse(_jsMoney.text); if (_jsmoney1 > saveData._Gold) { _jiesuo.SetActive(false); } if (saveData._IsUclockItem [i] == false) { if (_jsmoney1 <= saveData._Gold) { _jiesuo.SetActive(true); saveData._Gold = saveData._Gold - _jsmoney1; SaveData._Sav.SaveGameData(); _mymoney.text = saveData._Gold.ToString(); } } _mymoney.text = saveData._Gold.ToString(); SaveData._Sav.SaveGameData(); }
/*void Click3(int i,Pic item) * { int m = 0; * KeepData saveData = SaveData._Sav.GetSaveData (); * Itemsave s = GameObject.FindObjectOfType<Itemsave> (); * saveData._HaveItemId.Remove(i); * saveData._ItemId.Add (i); * //Destroy (item.gameObject); * item.gameObject.SetActive(false); * * //道具栏显示道具 * if (i < 10) * { * saveData._HaveItemOn.Add (i); * saveData._HaveItemOn.Reverse (); * * SaveData._Sav.SaveGameData (); * * GameObject dj = GameObject.Instantiate (btn); * dj.transform.SetParent (_DJ); * dj.GetComponent<Button> ().image.sprite = null; * dj.transform.GetComponent<RectTransform> ().anchoredPosition= new Vector2 (75+150*saveData._Djnum , -50); * _dj [m].GetComponent<Button> ().image.sprite = s._item [i]; * m++; * _dj.Add (dj); * _dj.Reverse (); * * } * } */ /// <summary> /// 技能加点 /// </summary> /// <param name="t">T.</param> /// <param name="item">Item.</param> /// <param name="id">Identifier.</param> void SkillJs(int t, Pic item, int id) { KeepData saveData = SaveData._Sav.GetSaveData(); item._Skill [t].onClick.AddListener(delegate { if (saveData._IsUclockSkill[id]._a[t] == false) { if (saveData._Skill >= 1) { saveData._Skill--; SaveData._Sav.SaveGameData(); _skillpoint.text = saveData._Skill.ToString(); // 遍历该道具所有等级,解锁一个等级 for (sbyte i = 0; i < saveData._IsUclockSkill[id]._a.Count; i++) { // 已经解锁,继续循环 if (saveData._IsUclockSkill[id]._a[i]) { continue; } // 未解锁则解锁并退出 saveData._IsUclockSkill[id]._a[i] = true; SaveData._Sav.SaveGameData(); if (saveData._IsUclockSkill[id]._a[i]) { item._Skill[i].image.sprite = s2; } // 更新所有道具图片 UpdateAllItemPic(); break; } } } }); }
/// <summary> /// 卸下该栏装备 /// </summary> /// <param name="i">The index.</param> void DropItem(int i) { // 卸下空道具,退出 if (_dj [i].GetComponent <Button>().image.sprite == null) { return; } KeepData saveData = SaveData._Sav.GetSaveData(); // 卸下道具,图片为空 //if (saveData._HaveItemOn [i] != 10 && saveData._IsUclockItem [i] == true) { saveData._HaveItemId.Add(saveData._HaveItemOn [i]); saveData._ItemId.Remove(saveData._HaveItemOn [i]); saveData._HaveItemOn.Remove(i); SaveData._Sav.SaveGameData(); _dj [i].GetComponent <Button> ().image.sprite = null; _dj [i].SetActive(false); //Destroy (_dj [i]); saveData._Djnum--; SaveData._Sav.SaveGameData(); //} // 更新道具栏 int z = saveData._HaveItemId.Count - 1; Pic item = GameObject.Instantiate(_itemPrefab); item._Id = saveData._HaveItemId [z]; //更新技能点 Gx(item); item.GetComponentInChildren <Text> ().text = saveData._HaveItemName [saveData._HaveItemId [z]]; item.Shuoming.text = "" + item._shuoming [saveData._HaveItemId [i]]; item.pic.sprite = item._pic [saveData._HaveItemId[i]]; item.transform.SetParent(_canvas); x = -196 * (Mathf.Pow(-1, (z % colunm_count))); saveData._Slidery = 118 - 195 * (z / colunm_count); SaveData._Sav.SaveGameData(); item.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(x, saveData._Slidery); item._Use.onClick.AddListener(delegate() { //道具装备个数小于道具解锁个数 if (saveData._Djnum < saveData._IsUclockItemNum) { if (item._Id < 10) { Click2(item._Id, item); saveData._Djnum++; SaveData._Sav.SaveGameData(); } } }); // 把道具图片加入列表 _itemPic.Add(item); for (int t = 0; t < item._Skill.Count; t++) { SkillJs(t, item, item._Id); } GameObject dj = GameObject.Instantiate(btn); dj.transform.SetParent(_DJ); dj.GetComponent <Button> ().image.sprite = null; dj.GetComponent <Button> ().image.color = new Color(0, 0, 0, 0); dj.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(75 + 150 * saveData._Djnum, -50); _dj.Add(dj); _dj.Reverse(); }
void Start() { KeepData saveData = SaveData._Sav.GetSaveData(); Itemsave s = GameObject.FindObjectOfType <Itemsave> (); Debug.Log(saveData._Slidery); for (int q = 0; q < saveData._HaveItemOn.Count; q++) { GameObject dj = GameObject.Instantiate(btn); dj.transform.SetParent(_DJL); dj.GetComponent <Button> ().image.sprite = s._item [saveData._HaveItemOn[q]]; dj.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(45 + 85 * q, 44); _dj.Add(dj); } for (int t = 0; t < saveData._IsUclockItem.Count; t++) { if (saveData._IsUclockItem[t] == true) { _dj [t].GetComponent <Button> ().image.sprite = null; _dj [t].GetComponent <Button> ().image.color = new Color(0, 0, 0, 0); //saveData._HaveItemOn [t] = 10; _dj[t].transform.SetParent(_DJ); } } for (int q = 0; q < saveData._HaveItemOn.Count; q++) { if (saveData._HaveItemOn [q] < 10) { _dj [q].GetComponent <Button> ().image.sprite = s._item [saveData._HaveItemOn [q]]; _dj [q].GetComponent <Button> ().image.color = new Color(1, 1, 1, 1); } } _itemPic = new List <Pic> (saveData._HaveItemId.Count); for (int i = 0; i < saveData._HaveItemId.Count; i++) { Pic item = GameObject.Instantiate(_itemPrefab); item._Id = saveData._HaveItemId [i]; //更新技能点 Gx(item); item.GetComponentInChildren <Text> ().text = saveData._HaveItemName [saveData._HaveItemId [i]]; item.Shuoming.text = "" + item._shuoming [saveData._HaveItemId [i]]; item.pic.sprite = item._pic [saveData._HaveItemId[i]]; item.transform.SetParent(_canvas); x = -196 * (Mathf.Pow(-1, (i % colunm_count))); saveData._Slidery = 118 - 195 * (i / colunm_count); SaveData._Sav.SaveGameData(); item.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(x, saveData._Slidery); //已解锁道具个数大于可装备道具个数 item._Use.onClick.AddListener(delegate() { //道具装备个数小于道具解锁个数 if (saveData._Djnum < saveData._IsUclockItemNum) { if (item._Id < 10) { Click(item._Id, item); saveData._Djnum++; SaveData._Sav.SaveGameData(); } } }); // 把道具图片加入列表 _itemPic.Add(item); for (int t = 0; t < item._Skill.Count; t++) { SkillJs(t, item, item._Id); } } for (int k = 0; k < _dj.Count; k++) { int index = k; if (saveData._IsUclockItem [k] == true) { _dj [k].GetComponent <Button> ().onClick.AddListener(delegate() { if (saveData._Djnum > 0) { DropItem(index); } }); } } for (int k = 0; k < saveData._HaveItemOn.Count; k++) { int index = k; if (saveData._IsUclockItem [k] == true) { _dj[k].GetComponent <Button>().onClick.AddListener(delegate() { if (saveData._Djnum > 0) { DropItem(index); } }); } // 装备栏为空处理 if (saveData._HaveItemOn [k] == -1 && saveData._IsUclockItem[k] == true) { _dj[k].GetComponent <Button>().image.sprite = null; } // 有装备处理 for (int j = 0; j < 10; j++) { if (saveData._HaveItemOn [k] == j) { _dj[k].GetComponent <Button>().image.sprite = s._item [j]; } } } }
//初始化存档文件 public void InitSaveData() { _save = new KeepData(); _save._IsUclockItem = new List <bool>(); _save._HaveItemName = new List <string> (); _save._HaveItemId = new List <int> (); _save._HaveItemOn = new List <int>() { 10, 11, 11, 11, 11 }; _save._Slidery = new float(); _save._Skill = new int(); _save._ItemId = new List <int> (); #region 技能点解锁 t0._a = new List <bool> () { false, false, false, false, false }; t1._a = new List <bool> () { false, false, false, false, false }; t2._a = new List <bool> () { false, false, false, false, false }; t3._a = new List <bool> () { false, false, false, false, false }; t4._a = new List <bool> () { false, false, false, false, false }; t5._a = new List <bool> () { false, false, false, false, false }; t6._a = new List <bool> () { false, false, false, false, false }; t7._a = new List <bool> () { false, false, false, false, false }; t8._a = new List <bool> () { false, false, false, false, false }; t9._a = new List <bool> () { false, false, false, false, false }; t10._a = new List <bool> () { false, false, false, false, false }; t11._a = new List <bool> () { false, false, false, false, false }; t12._a = new List <bool> () { false, false, false, false, false }; t13._a = new List <bool> () { false, false, false, false, false }; t14._a = new List <bool> () { false, false, false, false, false }; _save._IsUclockSkill = new List <TestList> () { t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14 }; #endregion #region 主题解锁 _save._ZhuTiData = new List <bool> { true, false, false, false }; #endregion #region 关卡解锁 _save._GuanQiaData = new List <bool> { true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }; #endregion #region 道具栏解锁 _save._IsUclockItem = new List <bool>() { true, false, false, false, false }; #endregion #region 道具名 _save._HaveItemName.Add("慢慢胶"); _save._HaveItemName.Add("飞镖"); _save._HaveItemName.Add("陷阱"); _save._HaveItemName.Add("推手"); _save._HaveItemName.Add("幽灵"); _save._HaveItemName.Add("透视镜"); _save._HaveItemName.Add("保护罩"); _save._HaveItemName.Add("超级泡泡"); _save._HaveItemName.Add("寒冰"); _save._HaveItemName.Add("磁铁"); _save._HaveItemName.Add("鞋子"); _save._HaveItemName.Add("炸弹"); _save._HaveItemName.Add("威力"); _save._HaveItemName.Add("生命"); SaveGameData(); #endregion }