コード例 #1
0
 public void ChangeCraftMap(List <GameObject> GridList, int floorCnt = 0)
 {
     int[] numArray = new int[5];
     for (int index1 = 0; index1 < this.nNumZ; ++index1)
     {
         for (int index2 = 0; index2 < this.nNumX; ++index2)
         {
             GridInfo component = (GridInfo)GridList[index2 / 2 + this.nNumX / 2 * (index1 / 2)].GetComponent <GridInfo>();
             if (index1 % 2 == 0)
             {
                 int[] stackWallOnSmallGrid = component.GetStackWallOnSmallGrid(index2 % 2, floorCnt);
                 this.Map[index1, index2].PartsOnMap       = component.GetPartOnSmallGrid(index2 % 2, floorCnt);
                 this.Map[index1, index2].StackWallOnMap   = stackWallOnSmallGrid;
                 this.Map[index1, index2].GridID           = index2 / 2 + this.nNumX / 2 * (index1 / 2);
                 this.Map[index1, index2].smallGridID      = index2 % 2;
                 this.Map[index1, index2].smallGridCanRoof = component.GetSmallGridCanRoof(index2 % 2, floorCnt);
             }
             else
             {
                 int[] stackWallOnSmallGrid = component.GetStackWallOnSmallGrid(2 + index2 % 2, floorCnt);
                 this.Map[index1, index2].PartsOnMap       = component.GetPartOnSmallGrid(2 + index2 % 2, floorCnt);
                 this.Map[index1, index2].StackWallOnMap   = stackWallOnSmallGrid;
                 this.Map[index1, index2].GridID           = index2 / 2 + this.nNumX / 2 * (index1 / 2);
                 this.Map[index1, index2].smallGridID      = 2 + index2 % 2;
                 this.Map[index1, index2].smallGridCanRoof = component.GetSmallGridCanRoof(index2 % 2, floorCnt);
             }
         }
     }
 }
コード例 #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();
    }