Example #1
0
 private void WriteEquipmentGodDate()
 {                                                                 //保存神兵数据
     for (int i = 0; i < 20; i++)
     {                                                             //创造20个数据
         EquipmentDate_God equipmentGod = new EquipmentDate_God(); //实例化,用于数据持久化
         equipmentGod.Index        = i;
         equipmentGod.equipmentGod = 1;                            //0为不存在 1为存在
         equipmentGod.type         = Random.Range(1, 50);          //种类编号
         saveDate.SaveEquipmentGod(equipmentGod);
     }
 }
    public List <EquipmentDate_God> el_g;                                                                                           //equipmentList_God神兵
    public void CreatEG(EquipmentDate_God ed_g)
    {                                                                                                                               //读取到数据后实例化神兵
        EquipmentDate_God equipment = Instantiate(ep_g, Vector3.zero, ep_g.transform.rotation).GetComponent <EquipmentDate_God> (); //实例化,用于数据持久化

        equipment.transform.parent = transform;                                                                                     //放置该实例化物体到管理物体下

        equipment.Index        = ed_g.Index;                                                                                        //输入编号
        equipment.equipmentGod = ed_g.equipmentGod;                                                                                 //0为不存在 1为存在

        equipment.name = "EquipmentGod" + equipment.Index;
        el_g.Add(equipment);
    }
Example #3
0
 private void LoadEquipmentGodDate()
 {
     for (int i = 0; i <= 999; i++)
     {                                                                    //遍历从0-999的编号
         if (PlayerPrefs.HasKey("EquipmentGod" + i))
         {                                                                //如果该key存在数据,则加载
             EquipmentDate_God newEquipmentGod = new EquipmentDate_God(); //new 一个用于储存数据的
             newEquipmentGod.Index        = i;
             newEquipmentGod.equipmentGod = 1;                            //0为不存在 1为存在
             newEquipmentGod.type         = PlayerPrefs.GetInt("EquipmentGodType" + i);
             equipmentDateManager.CreatEG(newEquipmentGod);
         }
     }
 }
Example #4
0
    //*************神兵类 0~999

    /*EquipmentGod
     * EquipmentGodType
     *
     *
     */
    public void SaveEquipmentGod(EquipmentDate_God equipmentDate_God)
    {    //保存神兵数据
        int index = equipmentDate_God.Index;

        if (equipmentDate_God.equipmentGod == 0)
        {                                                      //说明不存在需要清空数据
            PlayerPrefs.DeleteKey("EquipmentGod" + index);     //清除数据
            PlayerPrefs.DeleteKey("EquipmentGodType" + index); //清除数据
        }
        else
        {
            PlayerPrefs.SetInt("EquipmentGod" + index, 1);                          //保存神兵存在标志位
            PlayerPrefs.SetInt("EquipmentGodType" + index, equipmentDate_God.type); //保存种类编号
        }
    }