Esempio n. 1
0
 public void GridChange(GridInfo source, CraftCommandList.ChangeValGrid val, int mode)
 {
     source.DelFloor(0);
     for (int index = 0; index < val.nFloorNum[mode]; ++index)
     {
         source.AddFloor();
     }
     for (int index1 = 0; index1 < val.nFloorNum[mode]; ++index1)
     {
         for (int index2 = 0; index2 < 4; ++index2)
         {
             source.SetCanRoofSmallGrid(index2, index1, val.smallGrids[mode][index1][index2].m_canRoof);
             source.SetInRoomSmallGrid(index2, val.smallGrids[mode][index1][index2].m_inRoom, index1);
             source.ChangeSmallGrid(index2, val.smallGrids[mode][index1][index2].m_state, -1, index1, false);
             for (int changePlace = 0; changePlace < 7; ++changePlace)
             {
                 source.ChangeSmallGridItemKind(index1, index2, changePlace, val.smallGrids[mode][index1][index2].m_itemkind[changePlace]);
             }
             int num1 = 0;
             for (int index3 = 0; index3 < val.smallGrids[mode][index1][index2].m_itemstackwall.Length && val.smallGrids[mode][index1][index2].m_itemstackwall[index3] != -1; ++index3)
             {
                 ++num1;
             }
             for (int index3 = 0; index3 < num1; ++index3)
             {
                 source.ChangeSmallGridStack(index1, index2, 4, 0);
             }
             int num2 = 0;
             for (int index3 = 0; index3 < val.smallGrids[mode][index1][index2].m_itemstackwall.Length && val.smallGrids[mode][index1][index2].m_itemdupulication[index3] != -1; ++index3)
             {
                 ++num2;
             }
             for (int index3 = 0; index3 < num2; ++index3)
             {
                 source.ChangeSmallGridStack(index1, index2, val.smallGrids[mode][index1][index2].m_itemdupulication[index3], 0);
             }
             source.ChangeSmallGridUnderCarsol(index1, index2, source.GetUnderTheCarsol(index1, index2));
             source.ChangeSmallGridColor(index1, index2);
             if (val.smallGrids[mode][index1][index2].m_PutElement != null)
             {
                 for (int index3 = 0; index3 < val.smallGrids[mode][index1][index2].m_PutElement.Count; ++index3)
                 {
                     source.SetSmallGridPutElement(index1, index2, val.smallGrids[mode][index1][index2].m_PutElement[index3], false, false);
                 }
             }
         }
         source.SetUseState(index1, val.bUse[mode][index1]);
     }
     source.nFloorPartsHeight = val.nFloorPartsHeight[mode];
     if (Singleton <CraftCommandListBaseObject> .Instance.nTargetFloorCnt >= source.GetFloorNum())
     {
         --Singleton <CraftCommandListBaseObject> .Instance.nTargetFloorCnt;
     }
     ((Component)source).get_gameObject().get_transform().set_position(val.Pos[mode]);
     if (!source.GetUseState(Singleton <CraftCommandListBaseObject> .Instance.nTargetFloorCnt))
     {
         return;
     }
     ((Component)source).get_gameObject().SetActive(true);
 }
Esempio n. 2
0
    public void Save(ObjPool Grid)
    {
        List <BuildPartsPool>[] baseParts = Singleton <CraftCommandListBaseObject> .Instance.BaseParts;
        int nMaxFloorCnt = Singleton <CraftCommandListBaseObject> .Instance.nMaxFloorCnt;

        this.data.MaxFloorNum  = nMaxFloorCnt;
        this.data.nPutPartsNum = Singleton <CraftCommandListBaseObject> .Instance.nPutPartsNum;
        List <GameObject> list1 = Grid.GetList();

        for (int index = 0; index < list1.Count; ++index)
        {
            this.data.SmallGridState.Add(new List <List <int> >());
            this.data.SmallGridOnParts.Add(new List <List <int[]> >());
            this.data.SmallGridOnStackWall.Add(new List <List <int[]> >());
            this.data.SmallGridCanRoofState.Add(new List <List <int> >());
            this.data.SmallGridInRoomState.Add(new List <List <bool> >());
            GridInfo component = (GridInfo)list1[index].GetComponent <GridInfo>();
            this.data.GridPos.Add(component.InitPos);
            for (int floorcnt = 0; floorcnt < nMaxFloorCnt; ++floorcnt)
            {
                this.data.SmallGridState[index].Add(new List <int>());
                this.data.SmallGridOnParts[index].Add(new List <int[]>());
                this.data.SmallGridOnStackWall[index].Add(new List <int[]>());
                this.data.SmallGridCanRoofState[index].Add(new List <int>());
                this.data.SmallGridInRoomState[index].Add(new List <bool>());
                this.data.GridUseState.Add(component.GetUseState(floorcnt));
                this.data.nFloorPartsHeight.Add(component.nFloorPartsHeight[floorcnt]);
                for (int id = 0; id < 4; ++id)
                {
                    this.data.SmallGridState[index][floorcnt].Add(component.GetStateSmallGrid(id, floorcnt));
                    int[] partOnSmallGrid = component.GetPartOnSmallGrid(id, floorcnt);
                    this.data.SmallGridOnParts[index][floorcnt].Add(partOnSmallGrid);
                    this.data.SmallGridOnStackWall[index][floorcnt].Add(component.GetStackWallOnSmallGrid(id, floorcnt));
                    this.data.SmallGridCanRoofState[index][floorcnt].Add(component.GetSmallGridCanRoof(id, floorcnt));
                    this.data.SmallGridInRoomState[index][floorcnt].Add(component.GetSmallGridInRoom(id, floorcnt));
                }
            }
        }
        for (int index1 = 0; index1 < baseParts.Length; ++index1)
        {
            for (int index2 = 0; index2 < baseParts[index1].Count; ++index2)
            {
                List <GameObject> list2 = baseParts[index1][index2].GetList();
                for (int ID = 0; ID < list2.Count; ++ID)
                {
                    if (baseParts[index1][index2].ReserveListCheck(ID))
                    {
                        BuildPartsInfo component = (BuildPartsInfo)list2[ID].GetComponent <BuildPartsInfo>();
                        this.data.BuildPartsGridKind.Add(index1);
                        this.data.BuildPartsKind.Add(index2);
                        this.data.BuildPartsFloor.Add(component.nPutFloor);
                        this.data.BuildPartsPos.Add(list2[ID].get_transform().get_localPosition());
                        this.data.BuildPartsRot.Add(list2[ID].get_transform().get_localRotation());
                        this.data.BuildPartsPutGridInfos.Add(component.putGridInfos.Select <GridInfo, int>((Func <GridInfo, int>)(v => v.nID)).ToList <int>());
                        this.data.BuildPartsPutSmallGridInfos.Add(component.putSmallGridInfos);
                        this.data.BuildPartsPutGridInfosNum.Add(component.putGridInfos.Count);
                    }
                }
            }
        }
        this.data.tmpGridActiveList       = Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveList;
        this.data.tmpGridActiveListUpdate = Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveListUpdate;
        this.data.MaxPutHeight            = Singleton <CraftCommandListBaseObject> .Instance.MaxPutHeight;
        BinaryWriter binaryWriter = new BinaryWriter((Stream) new FileStream(Application.get_dataPath() + "/in-house/Scripts/Game/Scene/Map/Craft/SaveData" + string.Format("/CraftSave{0}_{1:MM}{2}_{3:HH}{4:mm}_{5:ss}{6:ff}.png", (object)DateTime.Now.Year, (object)DateTime.Now, (object)DateTime.Now.Day, (object)DateTime.Now, (object)DateTime.Now, (object)DateTime.Now, (object)DateTime.Now), FileMode.Create, FileAccess.Write), Encoding.UTF8);

        this.pngData = this.CreatePngScreen(320, 180);
        binaryWriter.Write(this.pngData);
        binaryWriter.Write(this.data.MaxFloorNum);
        binaryWriter.Write(this.data.nPutPartsNum);
        for (int index = 0; index < this.data.GridPos.Count; ++index)
        {
            binaryWriter.Write((double)this.data.GridPos[index].x);
            binaryWriter.Write((double)this.data.GridPos[index].y);
            binaryWriter.Write((double)this.data.GridPos[index].z);
        }
        binaryWriter.Write("P");
        for (int index = 0; index < this.data.GridUseState.Count; ++index)
        {
            binaryWriter.Write(this.data.GridUseState[index]);
        }
        binaryWriter.Write("U");
        for (int index = 0; index < this.data.nFloorPartsHeight.Count; ++index)
        {
            binaryWriter.Write(this.data.nFloorPartsHeight[index]);
        }
        binaryWriter.Write("F");
        for (int index1 = 0; index1 < list1.Count; ++index1)
        {
            for (int index2 = 0; index2 < nMaxFloorCnt; ++index2)
            {
                for (int index3 = 0; index3 < this.data.SmallGridState[index1][index2].Count; ++index3)
                {
                    binaryWriter.Write(this.data.SmallGridState[index1][index2][index3]);
                    for (int index4 = 0; index4 < this.data.SmallGridOnParts[index1][index2][index3].Length; ++index4)
                    {
                        binaryWriter.Write(this.data.SmallGridOnParts[index1][index2][index3][index4]);
                    }
                    for (int index4 = 0; index4 < this.data.SmallGridOnStackWall[index1][index2][index3].Length; ++index4)
                    {
                        binaryWriter.Write(this.data.SmallGridOnStackWall[index1][index2][index3][index4]);
                    }
                    binaryWriter.Write(this.data.SmallGridCanRoofState[index1][index2][index3]);
                    binaryWriter.Write(this.data.SmallGridInRoomState[index1][index2][index3]);
                }
            }
        }
        binaryWriter.Write("S");
        for (int index1 = 0; index1 < this.data.BuildPartsPos.Count; ++index1)
        {
            binaryWriter.Write(this.data.BuildPartsGridKind[index1]);
            binaryWriter.Write(this.data.BuildPartsKind[index1]);
            binaryWriter.Write(this.data.BuildPartsFloor[index1]);
            binaryWriter.Write((double)this.data.BuildPartsPos[index1].x);
            binaryWriter.Write((double)this.data.BuildPartsPos[index1].y);
            binaryWriter.Write((double)this.data.BuildPartsPos[index1].z);
            binaryWriter.Write((double)this.data.BuildPartsRot[index1].x);
            binaryWriter.Write((double)this.data.BuildPartsRot[index1].y);
            binaryWriter.Write((double)this.data.BuildPartsRot[index1].z);
            binaryWriter.Write((double)this.data.BuildPartsRot[index1].w);
            binaryWriter.Write(this.data.BuildPartsPutGridInfosNum[index1]);
            for (int index2 = 0; index2 < this.data.BuildPartsPutGridInfos[index1].Count; ++index2)
            {
                binaryWriter.Write(this.data.BuildPartsPutGridInfos[index1][index2]);
                binaryWriter.Write(this.data.BuildPartsPutSmallGridInfos[index1][index2]);
            }
        }
        binaryWriter.Write("B");
        for (int index1 = 0; index1 < this.data.MaxFloorNum; ++index1)
        {
            for (int index2 = 0; index2 < this.data.GridPos.Count; ++index2)
            {
                binaryWriter.Write(this.data.tmpGridActiveList[index1][index2]);
            }
            binaryWriter.Write(this.data.tmpGridActiveListUpdate[index1]);
            binaryWriter.Write(this.data.MaxPutHeight[index1]);
        }
        binaryWriter.Write("A");
        binaryWriter.Close();
        this.data.MaxFloorNum  = 0;
        this.data.nPutPartsNum = 0;
        this.data.GridPos.Clear();
        this.data.GridUseState.Clear();
        this.data.nFloorPartsHeight.Clear();
        this.data.SmallGridState.Clear();
        this.data.SmallGridOnParts.Clear();
        this.data.SmallGridOnStackWall.Clear();
        this.data.SmallGridCanRoofState.Clear();
        this.data.SmallGridInRoomState.Clear();
        this.data.BuildPartsGridKind.Clear();
        this.data.BuildPartsKind.Clear();
        this.data.BuildPartsFloor.Clear();
        this.data.BuildPartsPos.Clear();
        this.data.BuildPartsRot.Clear();
        this.data.BuildPartsPutGridInfos.Clear();
        this.data.BuildPartsPutSmallGridInfos.Clear();
        this.data.BuildPartsPutGridInfosNum.Clear();
        this.data.tmpGridActiveList.Clear();
        this.data.tmpGridActiveListUpdate.Clear();
        this.data.MaxPutHeight.Clear();
    }