public void updateUI(EquipItem item) { txtName.Text = item.Name; txtEquipCodes.Text = item.ToString(); cboEquipLevel.SelectedIndex = item.Level; cboEquipExt.SelectedIndex = item.Ext; chkEquipJN.Checked = item.JN; chkEquipXY.Checked = item.XY; chkEquipZY1.Checked = item.ZY1; chkEquipZY2.Checked = item.ZY2; chkEquipZY3.Checked = item.ZY3; chkEquipZY4.Checked = item.ZY4; chkEquipZY5.Checked = item.ZY5; chkEquipZY6.Checked = item.ZY6; //chkEquipSet.Checked = item.Set; int set = item.Set; if (set == 0) chkEquipSet.Checked = false; else { chkEquipSet.Checked = true; txtSet.Text = set.ToString(); } txtDurability.Text = Convert.ToString(item.Durability); GetSocketVal(item.Socket1, ref comboSock1, ref numericSock1); GetSocketVal(item.Socket2, ref comboSock2, ref numericSock2); GetSocketVal(item.Socket3, ref comboSock3, ref numericSock3); GetSocketVal(item.Socket4, ref comboSock4, ref numericSock4); GetSocketVal(item.Socket5, ref comboSock5, ref numericSock5); //comboHarmony.SelectedIndex = (item.Harmony & 0xF0) >> 4; }
protected static EquipItem createUnknownItem() { EquipItem item = new EquipItem(); item.Name = EquipItem.UNKNOW_ITEM; item.hand = 1; item.profs = 0xFF; ResourceManager rmgr = new ResourceManager("zDBManager.Properties.Resources", Assembly.GetExecutingAssembly()); item.Img = (Image)rmgr.GetObject(UNKNOW_ITEM); return item; }
public void updateData(EquipItem item) { item.Level = (byte)(cboEquipLevel.SelectedIndex); item.Ext = cboEquipExt.SelectedIndex; item.JN = chkEquipJN.Checked; item.XY = chkEquipXY.Checked; item.ZY1 = chkEquipZY1.Checked; item.ZY2 = chkEquipZY2.Checked; item.ZY3 = chkEquipZY3.Checked; item.ZY4 = chkEquipZY4.Checked; item.ZY5 = chkEquipZY5.Checked; item.ZY6 = chkEquipZY6.Checked; //item.Set = chkEquipSet.Checked; if (chkEquipSet.Checked == false) item.Set = 0; else { item.Set = Convert.ToByte(txtSet.Text); } item.Durability = Convert.ToByte(txtDurability.Text); item.Socket1 = GetSocketNum(comboSock1, numericSock1.Value); item.Socket2 = GetSocketNum(comboSock2, numericSock2.Value); item.Socket3 = GetSocketNum(comboSock3, numericSock3.Value); item.Socket4 = GetSocketNum(comboSock4, numericSock4.Value); item.Socket5 = GetSocketNum(comboSock5, numericSock5.Value); item.Harmony = 0; if (comboHarmony.SelectedItem != null) { if (comboHarmony.SelectedIndex > 0) { item.Harmony |= Convert.ToByte((comboHarmony.SelectedIndex) << 4); item.Harmony |= Convert.ToByte(item.Level & 0x0F); } } }
public void updateUI(EquipItem item) { txtName.Text = item.Name; txtEquipCodes.Text = item.ToString(); cboEquipLevel.SelectedIndex = item.Level; cboEquipExt.SelectedIndex = item.Ext; chkEquipJN.Checked = item.JN; chkEquipXY.Checked = item.XY; chkEquipZY1.Checked = item.ZY1; chkEquipZY2.Checked = item.ZY2; chkEquipZY3.Checked = item.ZY3; chkEquipZY4.Checked = item.ZY4; chkEquipZY5.Checked = item.ZY5; chkEquipZY6.Checked = item.ZY6; //chkEquipSet.Checked = item.Set; int set = item.Set; if (set == 0) { chkEquipSet.Checked = false; } else { chkEquipSet.Checked = true; txtSet.Text = set.ToString(); } txtDurability.Text = Convert.ToString(item.Durability); GetSocketVal(item.Socket1, ref comboSock1, ref numericSock1); GetSocketVal(item.Socket2, ref comboSock2, ref numericSock2); GetSocketVal(item.Socket3, ref comboSock3, ref numericSock3); GetSocketVal(item.Socket4, ref comboSock4, ref numericSock4); GetSocketVal(item.Socket5, ref comboSock5, ref numericSock5); //comboHarmony.SelectedIndex = (item.Harmony & 0xF0) >> 4; }
public bool tryPutItem(EquipItem item, int x, int y, bool[,] flags) { if (item.Width + x > xnum || item.Height + y > ynum || x < 0 || y < 0) return false; if (flags[x, y]) return false; for (int i = 0; i < item.Width; i++) { for (int j = 0; j < item.Height; j++) { if (!flags[i + x, j + y]) flags[i + x, j + y] = true; else return false; } } return true; }
private void btnCancel_Click(object sender, EventArgs e) { item = null; }
public DrawingUnit(EquipItem item, int x, int y) { this.item = item; this.x = x; this.y = y; }
public bool putItems(EquipItem[] items) { bool isPut = true; if (canPutItems(items)) { for (int i = 0; i < items.Length ; i ++) { if (null == items[i]) continue; isPut = isPut && putItem (items[i], true); } return isPut; } return false; }
private void EquipPanel_Paint(object sender, PaintEventArgs e) { if (units == null) { return; } // Graphics g = e.Graphics; DrawingUnit unit = null; EquipItem item = null; int x = 0, y = 0; for (int i = 0; i < xnum; i++) { for (int j = 0; j < ynum; j++) { if ((unit = units[i, j]) != null && unit.Item != null) { drawUnit(g, units[i, j]); } } } if (null != selectedUnit && null != selectedUnit.Item) { Brush brush = new SolidBrush(Color.FromArgb(60, 128, 128, 128)); g.FillRectangle(brush, selectedUnit.X * pixels, selectedUnit.Y * pixels, selectedUnit.Item.Width * pixels, selectedUnit.Item.Height * pixels); } if (null != activeUnit && null != activeUnit.Item) { item = activeUnit.Item; x = activeUnit.X; y = activeUnit.Y; g.DrawImage(item.Img, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); if (canPutItem(activeUnit)) { g.DrawRectangle(Pens.Blue, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } else { g.DrawRectangle(Pens.Red, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } } if (coveredUnit != null && coveredUnit.Item != null) { item = coveredUnit.Item; x = coveredUnit.X; y = coveredUnit.Y; g.DrawRectangle(Pens.Blue, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } if (activeUnit == null && coveredUnit == null && selectedUnit == null && curUnit != null && curUnit.Item != null) { item = curUnit.Item; x = curUnit.X; y = curUnit.Y; g.DrawImage(item.Img, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); if (canPutItem(curUnit)) { g.DrawRectangle(Pens.Blue, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } else { g.DrawRectangle(Pens.Red, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } } }
public bool putItem(EquipItem item, bool add) { DrawingUnit unit = null; if (add) { unit = new DrawingUnit(new EquipItem(), 0, 0); unit.Item.assign(item); } else { unit = new DrawingUnit(item, 0, 0); } for (int j = 0; j < ynum; j++) { for (int i = 0; i < xnum; i++) { if (!flags[i, j]) { unit.X = i; unit.Y = j; if (canPutItem(unit)) { return putItem(unit, false); } } } } return false; }
public EquipItem(EquipItem baseItem, byte[] codes, int offset, int len) { this.xnum = baseItem.xnum; this.ynum = baseItem.ynum; this.name = baseItem.name; this.hand = baseItem.hand; this.profs = baseItem.profs; // 1234 5678 1234 5678 1234 5678 1234 // this.img = baseItem.img; Array.Copy(codes, offset, this.codes, 0, len); }
public static EquipItem createItem(byte code, byte type) { string codeType = getItemCodeType(code, type); EquipItem item = null; for (Int32 i = 0; i < EquipItemInfo.g_ItemInfo.m_ItemInfo.Count; i++) { if (getItemCodeType(EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Number) == codeType) { item = new EquipItem(Int32.Parse(EquipItem.getItemCodeType(EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Number)), EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Name, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].HandFlag, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Width, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Height, 0); item.Img = EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Photo; break; } } // EquipItem item = EquipImageCache.Instance.getItemByCodeType(codeType); return new EquipItem(item); // return null; }
private void btnOK_Click(object sender, EventArgs e) { if (null != item) updateData(item); item = null; this.Close(); }
public EquipItem(EquipItem baseItem) { this.xnum = baseItem.xnum; this.ynum = baseItem.ynum; this.name = baseItem.name; this.hand = baseItem.hand; this.profs = baseItem.profs; // 1234 5678 1234 5678 1234 5678 1234 // this.img = baseItem.img; }
public EquipProperty(EquipItem item) { InitializeComponent(); this.item = item; }
public DrawingUnit(EquipItem item) { this.item = item; }
public void assign(DrawingUnit unit) { x = unit.X; y = unit.Y; item = unit.Item; }
private void cboEquipName_TextChanged(object sender, EventArgs e) { string itemName = cboEquipName.Text; if (null == itemName || "" == itemName.Trim()) { return; } EquipItem item = null; for (Int32 i = 0; i < EquipItemInfo.g_ItemInfo.m_ItemInfo.Count; i++) { if (EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category == (cboEquipType.Items[cboEquipType.SelectedIndex] as EquipItemType).TypeId && EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Number == (cboEquipName.Items[cboEquipName.SelectedIndex] as Character.ComboboxItem).Value) { item = new EquipItem(Int32.Parse(EquipItem.getItemCodeType(EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Number)), itemName, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].HandFlag, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Width, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Height, 0); item.Img = EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Photo; break; } } // EquipImageCache.Instance.getItem(cboEquipName.Text); if (null != item) { if (editItem == null) editItem = new EquipItem(); editItem.assign(item); } }
public EquipItem(EquipItem baseItem, byte[] codes) { this.xnum = baseItem.xnum; this.ynum = baseItem.ynum; this.name = baseItem.name; this.hand = baseItem.hand; this.profs = baseItem.profs; // 1234 5678 1234 5678 1234 5678 1234 // this.img = baseItem.img; codes.CopyTo(this.codes, 0); }
public static EquipItem createItem(byte[] codes, int offset, int len) { if (offset < 0 || len <= 0 || (offset + len > codes.Length) || codes[offset] == 0xFF) { return null; } string codeType = getItemCodeType(codes, offset, len); EquipItem item = null; for (Int32 i = 0; i < EquipItemInfo.g_ItemInfo.m_ItemInfo.Count; i++) { if (getItemCodeType(EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Number) == codeType) { item = new EquipItem(Int32.Parse(EquipItem.getItemCodeType(EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Number)), EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Name, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].HandFlag, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Category, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Width, EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Height, 0); item.Img = EquipItemInfo.g_ItemInfo.m_ItemInfo[i].Photo; break; } } //EquipItem item = EquipImageCache.Instance.getItemByCodeType(codeType); return new EquipItem(item, codes, offset, len); }
public bool canPutItems(EquipItem[] items) { bool[,] curflags = (bool[,])flags.Clone(); foreach (EquipItem item in items) { if (null == item) continue; for (int j = 0; j < ynum; j++) { for (int i = 0; i < xnum; i++) { if (!curflags[i, j] && canPutItem (item, i, j, curflags ) && tryPutItem(item, i, j, curflags)) { goto NextItem; } } } return false; NextItem: ; } return true; }
public EquipItem assign(EquipItem other) { other.codes.CopyTo(this.codes, 0); this.xnum = other.xnum; this.ynum = other.ynum; this.name = other.name; this.hand = other.hand; this.profs = other.profs; // 1 2 3 4 5 6 7 this.img = other.img; return this; }