public bool loadItemsByCodes(byte[] codes, int offset, int len)
        {
            //
            if (offset < 0 || len < xnum * ynum * EquipItem.ITEM_SIZE || codes == null)
            {
                this.Invalidate();
                return(false);
            }

            EquipItem item = null;

            for (int j = 0; j < ynum; j++)
            {
                for (int i = 0; i < xnum; i++)
                {
                    if ((item = EquipItem.createItem(codes, offset + (j * xnum + i) * EquipItem.ITEM_SIZE, EquipItem.ITEM_SIZE)) != null)
                    {
                        units[i, j] = new DrawingUnit(item, i, j);
                        putItem(units[i, j], false);
                    }
                }
            }
            this.Invalidate();
            return(true);
        }
Exemple #2
0
 public bool setItem(int pos, string scodes)
 {
     if (pos < 0 || pos >= MAX_ITEM_NUM)
     {
         return(false);
     }
     items[pos] = EquipItem.createItem(scodes);
     return(items[pos] != null);
 }
        public bool loadItemsByCodes(byte[] codes, int offset, int len)
        {
            //
            if (offset < 0 || len < EquipItem.ITEM_SIZE * EquipNum || codes == null)
            {
                this.Invalidate();
                return(false);
            }

            EquipItem item = null;

            for (int i = 0; i < EquipNum; i++)
            {
                if ((item = EquipItem.createItem(codes, offset + i * EquipItem.ITEM_SIZE, EquipItem.ITEM_SIZE)) != null)
                {
                    units[i] = new DrawingUnit(item, i, 0);
                }
            }
            this.Invalidate();
            return(true);
        }