void setItem() { var pot = new HOZON(); var cane = new Sanctuary(); var weapon = new IronSword(); var potion = new SleepPotion(); var potion2 = new LevelUpPotion(); pot.init(5); cane.init(); weapon.init(0); potion.init(); potion2.init(); Vector2 pos = new Vector2(5, 8); ObjectEntityFactory.createItemEntity(pot, pos + new Vector2(0,0),true); ObjectEntityFactory.createItemEntity(cane, pos+new Vector2(0,1), true); ObjectEntityFactory.createItemEntity(weapon, pos + new Vector2(0, 2), true); ObjectEntityFactory.createItemEntity(potion, pos + new Vector2(0, 3), true); pos += new Vector2(1, 0); ObjectEntityFactory.createItemEntity(pot, pos + new Vector2(0, 0), true); ObjectEntityFactory.createItemEntity(cane, pos + new Vector2(0, 1), true); ObjectEntityFactory.createItemEntity(weapon, pos + new Vector2(0, 2), true); ObjectEntityFactory.createItemEntity(potion, pos + new Vector2(0, 3), true); pos += new Vector2(1, 0); ObjectEntityFactory.createItemEntity(pot, pos + new Vector2(0, 0), true); ObjectEntityFactory.createItemEntity(cane, pos + new Vector2(0, 1), true); ObjectEntityFactory.createItemEntity(weapon, pos + new Vector2(0, 2), true); ObjectEntityFactory.createItemEntity(potion2, pos + new Vector2(0, 3), true); pos += new Vector2(1, 0); ObjectEntityFactory.createItemEntity(pot, pos + new Vector2(0, 0), true); ObjectEntityFactory.createItemEntity(cane, pos + new Vector2(0, 1), true); ObjectEntityFactory.createItemEntity(weapon, pos + new Vector2(0, 2), true); ObjectEntityFactory.createItemEntity(potion2, pos + new Vector2(0, 3), true); pos += new Vector2(1, 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(); }