예제 #1
0
    void OnIsoClick(int index)
    {
        if (mWndCtrl.IsoListSelectIndex > -1)
        {
            mWndCtrl.ClearCostList();

            BSIsoHeadData header = m_IsoHeaders[mWndCtrl.IsoListSelectIndex];
            foreach (var kvp in header.costs)
            {
                int item_id = PEBuildingMan.GetBlockItemProtoID(kvp.Key);

                //				if (item_id < PEBuildingMan.c_MinItemProtoID || item_id > PEBuildingMan.c_MaxItemProtoID)
                //					continue;
                if (item_id == -1)
                {
                    return;
                }

                ItemProto proto = ItemProto.Mgr.Instance.Get(item_id);
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
                int player_cnt = pkg.GetItemCount(item_id);
                int final_cnt  = Mathf.Clamp(player_cnt, 0, 9999);
                mWndCtrl.AddCostListItem(proto.GetName(), Mathf.CeilToInt(kvp.Value / 4.0f).ToString() + '/' + final_cnt.ToString(), proto.icon[0], "Icon");
            }
            IsoRePos = true;
            //mWndCtrl.ResetCostPostion();
        }
    }
예제 #2
0
 // byte buffer
 public static int ExtractHeader(byte[] buffer, out BSIsoHeadData iso_header)
 {
     iso_header = new BSIsoHeadData();
     if (buffer == null)
     {
         return(0);
     }
     using (MemoryStream ms = new MemoryStream(buffer))
     {
         return(ExtractHeader(ms, out iso_header));
     }
 }
예제 #3
0
    void OnIsoExportClick(int index)
    {
        BSIsoHeadData head = m_IsoHeaders[index];

        CreateBrush(BrushType.bt_iso);
        BSIsoBrush brush = m_CurBrush as BSIsoBrush;

        brush.File_Name      = head.Name;
        brush.Gen            = true;
        brush.onCancelClick += OnIsoCancelClick;

        mWndCtrl.Hide();

        if (onIsoExport != null)
        {
            onIsoExport(head);
        }
    }
예제 #4
0
 // file
 public static int ExtractHeader(string filename, out BSIsoHeadData iso_header)
 {
     iso_header = new BSIsoHeadData();
     if (!File.Exists(filename))
     {
         return(0);
     }
     try
     {
         iso_header.Name = filename;
         using (FileStream fs = File.Open(filename, FileMode.Open))
         {
             return(ExtractHeader(fs, out iso_header));
         }
     }
     catch (System.Exception)
     {
         return(0);
     }
 }
예제 #5
0
    public void Init(EBSVoxelType voxel_type)
    {
        Destroy();

        m_Voxels = new Dictionary <int, BSVoxel>();

        // Init header
        m_HeadInfo         = new BSIsoHeadData();
        m_HeadInfo.Version = ISO_VERSION;
        m_HeadInfo.Mode    = voxel_type;
        m_HeadInfo.Author  = "";
        m_HeadInfo.Name    = "";
        m_HeadInfo.Desc    = "";
        m_HeadInfo.Remarks = "<REMARKS />";
        m_HeadInfo.xSize   = 256;
        m_HeadInfo.ySize   = 256;
        m_HeadInfo.zSize   = 256;
        m_HeadInfo.IconTex = new byte [0];
        m_HeadInfo.costs   = new Dictionary <byte, UInt32>();
        m_HeadInfo.EnsureIconTexValid();
    }
예제 #6
0
    // Extract Header
    private static int ExtractHeader(Stream stream, out BSIsoHeadData iso_header)
    {
        iso_header = new BSIsoHeadData();
        int len = 0;

        iso_header.Init();
        try
        {
            BinaryReader r = new BinaryReader(stream);

            // Header
            string check_str = r.ReadString();                  // r, string
            if (check_str != "BSISO")
            {
                /************
                 *  Older Building System
                 * *********/

                r.BaseStream.Seek(0, SeekOrigin.Begin);

                int version = r.ReadInt32();
                int count   = r.ReadInt32();

                switch (version)
                {
                case 1:

                    Dictionary <IntVector3, B45Block> old_blocks = new Dictionary <IntVector3, B45Block>();
                    for (int i = 0; i < count; i++)
                    {
                        IntVector3 index = new IntVector3(r.ReadInt32(), r.ReadInt32(), r.ReadInt32());
                        old_blocks[index] = new B45Block(r.ReadByte(), r.ReadByte());
                    }
                    int    texDataSize = r.ReadInt32();
                    byte[] tex_bytes   = r.ReadBytes(texDataSize);

                    iso_header.IconTex = tex_bytes;

                    // Calculate Bound
                    IntVector3 min = new IntVector3(10000, 10000, 10000);
                    IntVector3 max = new IntVector3(-10000, -10000, -10000);

                    foreach (IntVector3 index in old_blocks.Keys)
                    {
                        if (min.x > index.x)
                        {
                            min.x = index.x;
                        }
                        else if (max.x < index.x)
                        {
                            max.x = index.x;
                        }

                        if (min.y > index.y)
                        {
                            min.y = index.y;
                        }
                        else if (max.y < index.y)
                        {
                            max.y = index.y;
                        }

                        if (min.z > index.z)
                        {
                            min.z = index.z;
                        }
                        else if (max.z < index.z)
                        {
                            max.z = index.z;
                        }
                    }

                    IntVector3 size = new IntVector3(max.x - min.x + 1, max.y - min.y + 1, max.z - min.z + 1);

                    iso_header.xSize = size.x;
                    iso_header.ySize = size.y;
                    iso_header.zSize = size.z;

                    foreach (KeyValuePair <IntVector3, B45Block> kvp in old_blocks)
                    {
                        //IntVector3 ipos = new IntVector3(kvp.Key.x + size.x / 2, kvp.Key.y , kvp.Key.z + size.z / 2);
//						int key = IPosToKey(ipos);
//						m_Voxels.Add(key, new BSVoxel( kvp.Value));
                        if (iso_header.costs.ContainsKey(kvp.Value.materialType))
                        {
                            iso_header.costs[kvp.Value.materialType]++;
                        }
                        else
                        {
                            iso_header.costs.Add(kvp.Value.materialType, 1);
                        }
                    }

                    break;

                default:
                    break;
                }
                r.Close();
                len = (int)stream.Length;
                return(len);
            }

//			int l = 0;
            iso_header.Version = r.ReadInt32();                 // r, int
            iso_header.Mode    = (EBSVoxelType)r.ReadInt32();
            iso_header.Author  = r.ReadString();
            iso_header.Name    = r.ReadString();
            iso_header.Desc    = r.ReadString();
            iso_header.Remarks = r.ReadString();
            iso_header.xSize   = r.ReadInt32();
            iso_header.ySize   = r.ReadInt32();
            iso_header.zSize   = r.ReadInt32();

            int length = r.ReadInt32();
            iso_header.IconTex = r.ReadBytes(length);
            length             = r.ReadInt32();
            for (int i = 0; i < length; i++)
            {
                iso_header.costs.Add(r.ReadByte(), r.ReadUInt32());
            }

            len = (int)(stream.Length);
            stream.Close();
        }
        catch (System.Exception)
        {
            return(0);
        }

        iso_header.EnsureIconTexValid();

        return(len);
    }