예제 #1
0
    /// <summary>
    /// 创建存档文件
    /// </summary>
    /// <param name="only">是否只保存家具</param>
    /// <returns></returns>
    private Save CreateSaveGameObject(bool SaveBuilding)
    {
        Save save = new Save();

        if (SaveBuilding)
        {
            //读取场景数据
            foreach (KeyValuePair <InstrumentEnum, List <GameObject> > item in InstrumentMgr.Instance.GetInstrumentGameObjectDic())
            {
                foreach (var obj in item.Value)
                {
                    save.AddInstrument(obj);
                }
            }

            foreach (var wall in BuildingInfo.Instance.Walls)
            {
                save.AddWall(wall);
            }
            foreach (var wall in BuildingInfo.Instance._Walls)
            {
                save.AddWall(wall);
            }
            foreach (var top in BuildingInfo.Instance.Tops)
            {
                save.AddTops(top);
            }
            foreach (var flood in BuildingInfo.Instance.Floors)
            {
                save.AddFlood(flood);
            }
        }
        else
        {
            foreach (KeyValuePair <InstrumentEnum, List <GameObject> > item in InstrumentMgr.Instance.GetInstrumentGameObjectDic())
            {
                foreach (var obj in item.Value)
                {
                    if (obj.GetComponent <WindowsillBuild>() || obj.GetComponent <Doorframe>() || obj.GetComponent <Window1Build>() || obj.GetComponent <Door>())
                    {
                        break;
                    }
                    save.AddInstrument(obj);
                }
            }
        }



        return(save);
    }