Esempio n. 1
0
 public static ItemInventory convert(int size,ItemData[] itemdatas)
 {
     ItemInventory ret = new ItemInventory(size);
     ItemBasis item;
     foreach (ItemData itemdata in itemdatas) {
         item = itemdata.toItem();
         item.IsInitalized = true;
         Debug.LogFormat("Data:{0}, Item:{1}",itemdata.type,item.Name);
         ret.add(item,true);
     }
     return ret;
 }
Esempio n. 2
0
 public static ItemInventory create(int size,ItemBasis[] items)
 {
     ItemInventory ret =  new ItemInventory(size);
     ret.add(items);
     return ret;
 }
Esempio n. 3
0
 public static void testWrite()
 {
     if (!Directory.Exists(savedir)) {
         Debug.LogError("Save Directory is None!");
         Directory.CreateDirectory(savedir);
     }
     LocalSaveData test = new LocalSaveData();
     test.Player.Position = new Vector2(3, 7);
     test.Player.PlayerName = "たかし";
     var ken = new IronSword();
     ken.init(3);
     var arrow = new WoodArrow();
     arrow.init(12);
     var tubo = new HOZON();
     tubo.init(4);
     tubo.putinItem(arrow);
     Debug.Log("Pot: "+tubo.showInventory());
     ItemInventory inv = new ItemInventory(10);
     inv.add(ken,tubo,arrow);
     test.Player.ParameterData.Inventory = ItemData.convert(inv);
     test.Player.ParameterData.InventorySize = inv.InventorySize;
     string json =  JsonUtility.ToJson(test,true);
     Debug.Log(json);
     string savepath = savedir + @"\saveTest";
     using (FileStream fs = new FileStream(savepath,FileMode.Create,FileAccess.Write)) {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(fs, json);
     }
     testLoad();
 }