示例#1
0
    void Start()
    {
        int i, j;

        storageWidth  = GetComponentInParent <Storage>().storageWidth;
        storageHeight = GetComponentInParent <Storage>().storageHeight;
        myIndex       = GetComponentInParent <Storage>().IndexOfRefrigeratorIndex(gameObject);
        marker        = transform.parent.GetChild(1).gameObject;
        storage       = new Inventory[storageWidth, storageHeight]; //가로 5 x 세로 6 (칸)

        //storage 초기화
        List <Inventory> bufferInventory = SaveAndLoad.LoadInventory(myIndex);   //세이브 파일에서 Inventory정보를 읽어옴
        int hor, ver;

        for (i = 0; i < bufferInventory.Count; i++)
        {
            hor = bufferInventory[i].horIndex;
            ver = bufferInventory[i].verIndex;
            storage[hor, ver] = bufferInventory[i];
        }

        for (i = 0; i < storageHeight; i++)
        {
            for (j = 0; j < storageWidth; j++)
            {
                //채워지지 않은 칸은 초기화
                if (storage[j, i] == null)
                {
                    storage[j, i] = new Inventory('\0', 0, 0, j, i);
                }
            }
        }

        GetComponentInParent <Storage>().AddRefrigeratorStorage(transform.parent.gameObject, storage);
    }