示例#1
0
        private void CharPanel_MouseMove(object sender, MouseEventArgs e)
        {
            coveredUnit = null;

            int index = findRectangle(e.X, e.Y);

            if (index >= 0)
            {
                if (units[index] != null)
                {
                    this.Cursor             = Cursors.Hand;
                    coveredUnit             = units[index];
                    editor.currentName.Text = coveredUnit.Item.Name;
                }
                else
                {
                    editor.currentName.Text = "None";
                    this.Cursor             = Cursors.Cross;
                    curUnit.X = index;
                    curUnit.Y = 1;
                }
            }
            else
            {
                curUnit.Y = -1;
                editor.currentName.Text = "None";
            }

            this.Invalidate();
        }
示例#2
0
        private void CharPanel_MouseLeave(object sender, EventArgs e)
        {
            curUnit.Item = null;
            coveredUnit  = null;

            this.Invalidate();
        }
示例#3
0
        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);
        }
示例#4
0
        public bool canPutItem(DrawingUnit unit)
        {
            EquipItem item = unit.Item;
            int       x = unit.X, y = unit.Y;

            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])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#5
0
        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);
        }
示例#6
0
        public bool putItem(DrawingUnit unit, bool add)
        {
            try
            {
                int x = unit.X, y = unit.Y;

                if (add)
                {
                    units[x, y] = new DrawingUnit(new EquipItem(), x, y);
                    units[x, y].Item.assign(unit.Item);
                }
                else
                {
                    units[x, y] = unit;
                }


                for (int i = 0; i < unit.Item.Width; i++)
                {
                    for (int j = 0; j < unit.Item.Height; j++)
                    {
                        flags[i + x, j + y] = true;
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: On item:" + unit.Item.Name + ", X:" + unit.X + ", Y: " + unit.Y + " " + ex.Message);
                return(false);
            }
        }
示例#7
0
        private void EquipPanel_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X / pixels, y = e.Y / pixels;

            coveredUnit = null;

            if (activeUnit != null)
            {
                activeUnit.X = x; activeUnit.Y = y;
            }
            else if (flags[x, y])
            {
                this.Cursor             = Cursors.Hand;
                coveredUnit             = findUnit(x, y);
                editor.currentName.Text = coveredUnit.Item.Name;
                if (selectedUnit == coveredUnit)
                {
                    coveredUnit = null;
                }
            }
            else
            {
                this.Cursor             = Cursors.Cross;
                curUnit.X               = x; curUnit.Y = y;
                editor.currentName.Text = "None";
            }

            this.Invalidate();
        }
示例#8
0
        public bool removeItem(DrawingUnit unit)
        {
            int x = unit.X;

            units[x] = null;                //remove

            return(true);
        }
示例#9
0
 private void setEquipProperty(DrawingUnit unit)
 {
     if (unit != null) //
     {
         EquipProperty prop = new EquipProperty(unit.Item);
         prop.ShowDialog();
         prop.Dispose();
     }
 }
示例#10
0
        public void clearData()
        {
            selectedUnit = null;
            coveredUnit  = null;

            for (int i = 0; i < EquipNum; i++)
            {
                units[i] = null;
            }
        }
示例#11
0
        public void clearData()
        {
            selectedUnit = null;
            coveredUnit = null;

            for (int i = 0; i < EquipNum; i++)
            {
                units[i] = null;
            }
        }
示例#12
0
 private void CharPanel_KeyDown(object sender, KeyEventArgs e)
 {
     if (selectedUnit != null)
     {
         switch ((int)e.KeyCode)
         {
         case 46:     // Delete
             removeItem(selectedUnit); selectedUnit = null; break;
         }
     }
 }
示例#13
0
 /// <summary>
 ///
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EquipPanel_KeyDown(object sender, KeyEventArgs e)
 {
     if (selectedUnit != null)
     {
         switch ((int)e.KeyCode)
         {
         case 46:
             removeItem(selectedUnit); selectedUnit = null; Invalidate(); break;
         }
     }
 }
示例#14
0
        private void drawUnit(Graphics g, DrawingUnit unit)
        {
            int       x = unit.X, y = unit.Y;
            EquipItem item = unit.Item;

            int xOffset = Math.Max((positions[x].Width - item.Width * EquipPanel.pixels) >> 1, 0);
            int yOffset = Math.Max((positions[x].Height - item.Height * EquipPanel.pixels) >> 1, 0);
            int width   = Math.Min(item.Width * EquipPanel.pixels, positions[x].Width);
            int height  = Math.Min(item.Height * EquipPanel.pixels, positions[x].Height);

            g.DrawImage(item.Img, positions[x].X + xOffset, positions[x].Y + yOffset, width, height);
        }
示例#15
0
        public bool canPutItem(DrawingUnit unit)
        {
            EquipItem item = unit.Item;
            int       x = unit.X, y = unit.Y;

            if (x < 0 && x >= EquipNum && units[x] != null)
            {
                return(false);
            }



            return(true);
        }
示例#16
0
        private void CharPanel_MouseClick(object sender, MouseEventArgs e)
        {
            int index = findRectangle(e.X, e.Y);

            if (e.Button == MouseButtons.Right)
            {
                if (index >= 0)
                {
                    if (units[index] != null)
                    {
                        selectedUnit = units[index];
                        popMenu.Show(this, e.X, e.Y);
                    }
                    else
                    {
                        selectedUnit = null;
                    }
                }
                else
                {
                    selectedUnit = null;
                }
            }
            else
            {
                if (index >= 0)
                {
                    if (units[index] != null)
                    {
                        selectedUnit            = units[index];
                        editor.currentName.Text = selectedUnit.Item.Name;
                    }
                    else if (selectedUnit != null)
                    {
                        selectedUnit            = null;
                        editor.currentName.Text = "None";
                    }
                    else
                    {
                        addEditItem(index);
                        editor.currentName.Text = "None";
                    }
                }
                else
                {
                    selectedUnit = null;
                }
            }
        }
示例#17
0
        public void clearData()
        {
            activeUnit   = null;
            selectedUnit = null;
            coveredUnit  = null;
            lastedX      = 0; lastedY = 0;

            for (int i = 0; i < xnum; i++)
            {
                for (int j = 0; j < ynum; j++)
                {
                    units[i, j] = null;
                    flags[i, j] = false;
                }
            }
        }
示例#18
0
        public bool putItem(DrawingUnit unit, bool add)
        {
            int x = unit.X, y = unit.Y;

            if (add)
            {
                units[x] = new DrawingUnit(new EquipItem(), x, y);
                units[x].Item.assign(unit.Item);
            }
            else
            {
                units[x] = unit;
            }

            return(true);
        }
示例#19
0
        private void drawUnit(Graphics g, DrawingUnit unit)
        {
            int       x = unit.X, y = unit.Y;
            EquipItem item = unit.Item;

            g.DrawImage(item.Img, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels);

            if (item.Level >= 1)
            {
                g.DrawString("+" + Convert.ToString(item.Level), new Font("Arial", 8), Brushes.White, x * pixels, y * pixels);
            }
            else if (item.IsNoDurability && item.Durability > 1)
            {
                g.DrawString(Convert.ToString(item.Durability), new Font("Arial", 6), Brushes.White, x * pixels, y * pixels);
            }
        }
示例#20
0
        private void EquipPanel_MouseLeave(object sender, EventArgs e)
        {
            curUnit.Item = null;
            coveredUnit  = null;

            if (activeUnit != null)
            {
                activeUnit.X = lastedX; activeUnit.Y = lastedY;
                if (canPutItem(activeUnit) && putItem(activeUnit, false))
                {
                    selectedUnit = activeUnit;
                    activeUnit   = null;
                }
            }
            this.Invalidate();
        }
示例#21
0
        protected DrawingUnit findUnit(int x, int y)
        {
            DrawingUnit unit = null;

            if (flags[x, y])
            {
                for (int i = 0; i < xnum; i++)
                {
                    for (int j = 0; j < ynum; j++)
                    {
                        if ((unit = units[i, j]) != null && unit.contains(x, y))
                        {
                            return(unit);
                        }
                    }
                }
            }
            return(null);
        }
示例#22
0
        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);
        }
示例#23
0
        public bool removeItem(DrawingUnit unit)
        {
            try
            {
                int x = unit.X, y = unit.Y;
                units[x, y] = null;                //remove


                for (int i = 0; i < unit.Item.Width; i++)
                {
                    for (int j = 0; j < unit.Item.Height; j++)
                    {
                        flags[i + x, j + y] = false;
                    }
                }
            }
            catch (Exception)
            {
            }

            return(true);
        }
示例#24
0
        public bool moveItem(DrawingUnit unit, int x, int y)
        {
            if (null == unit || unit.Item == null)
            {
                return(false);
            }


            int oldX = unit.X, oldY = unit.Y;

            removeItem(unit);
            unit.X = x;  unit.Y = y;
            if (canPutItem(unit) && putItem(unit, false))
            {
                return(true);
            }
            else
            {
                unit.X = oldX; unit.Y = oldY;
                putItem(unit, false);
                return(false);
            }
        }
示例#25
0
 private void CharPanel_KeyDown(object sender, KeyEventArgs e)
 {
     if (selectedUnit != null)
     {
         switch ((int)e.KeyCode)
         {
             case 46: // Delete
                 removeItem(selectedUnit); selectedUnit = null; break;
         }
     }
 }
示例#26
0
        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;
        }
示例#27
0
 public void assign(DrawingUnit unit)
 {
     x = unit.X;
     y = unit.Y;
     item = unit.Item;
 }
示例#28
0
        private void CharPanel_MouseLeave(object sender, EventArgs e)
        {
            curUnit.Item = null;
            coveredUnit = null;

            this.Invalidate();
        }
示例#29
0
        private void CharPanel_MouseMove(object sender, MouseEventArgs e)
        {
            coveredUnit = null;

            int index = findRectangle (e.X, e.Y);
            if (index >= 0) 
            {
                if (units[index] != null)
                {
                    this.Cursor = Cursors.Hand;
                    coveredUnit = units[index];
                    editor.currentName.Text = coveredUnit.Item.Name;
                }
                else
                {
                    editor.currentName.Text = "None";
                    this.Cursor = Cursors.Cross;
                    curUnit.X = index;
                    curUnit.Y = 1;
                }
            }
            else
            {
                curUnit.Y = -1;
                editor.currentName.Text = "None";
            }

            this.Invalidate();
        }
示例#30
0
        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);
                }
            }
        }
示例#31
0
        private void drawUnit(Graphics g, DrawingUnit unit)
        {

            int x = unit.X, y = unit.Y;
            EquipItem item = unit.Item;

            int xOffset = Math.Max((positions[x].Width - item.Width * EquipPanel.pixels) >> 1, 0);
            int yOffset = Math.Max((positions[x].Height - item.Height * EquipPanel.pixels) >> 1, 0);
            int width = Math.Min(item.Width * EquipPanel.pixels, positions[x].Width);
            int height = Math.Min(item.Height * EquipPanel.pixels, positions[x].Height);
            g.DrawImage(item.Img, positions[x].X + xOffset, positions[x].Y + yOffset, width, height);

        }
示例#32
0
        public bool removeItem(DrawingUnit unit)
        {
            try
            {
                int x = unit.X, y = unit.Y;
                units[x, y] = null;                //remove


                for (int i = 0; i < unit.Item.Width; i++)
                {
                    for (int j = 0; j < unit.Item.Height; j++)
                    {
                        flags[i + x, j + y] = false;
                    }
                }
            }
            catch(Exception)
            {
            }

            return true;
        }
示例#33
0
        public bool moveItem(DrawingUnit unit, int x, int y)
        {
            if (null == unit || unit.Item == null)
            {
                return false;
            }


            int oldX = unit.X, oldY = unit.Y;
            removeItem(unit);
            unit.X = x;  unit.Y = y;
            if (canPutItem(unit) && putItem(unit, false))
            {
                return true;
            }
            else
            {
                unit.X = oldX; unit.Y = oldY;
                putItem(unit, false); 
                return false;
            }
        }
示例#34
0
        public bool canPutItem(DrawingUnit unit)
        {
            EquipItem item = unit.Item;
            int x = unit.X, y = unit.Y;

            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])
                        return false;
                }
            }
            return true;
        }
示例#35
0
        private void drawUnit(Graphics g, DrawingUnit unit)
        {
            int x = unit.X, y = unit.Y;
            EquipItem item = unit.Item;
            g.DrawImage(item.Img, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels);

            if (item.Level >= 1)
            {
                g.DrawString("+" + Convert.ToString(item.Level), new Font("Arial", 8), Brushes.White, x * pixels, y * pixels);
            } else if (item.IsNoDurability && item.Durability > 1)
            {
                g.DrawString (Convert.ToString(item.Durability), new Font("Arial", 6), Brushes.White, x * pixels, y * pixels);
            }
        }
示例#36
0
        public bool canPutItem(DrawingUnit unit)
        {
            EquipItem item = unit.Item;
            int x = unit.X, y = unit.Y;

            if (x < 0 && x >= EquipNum && units[x] != null)
                return false;
            


            return true;
        }
示例#37
0
 /// <summary>
 ///
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EquipPanel_KeyDown(object sender, KeyEventArgs e)
 {
     if (selectedUnit != null)
     {
         switch ((int)e.KeyCode)
         {
             case 46:
                 removeItem(selectedUnit); selectedUnit = null; Invalidate(); break;
         }
     }
 }
示例#38
0
 public void clearData()
 {
     activeUnit = null;
     selectedUnit = null;
     coveredUnit = null;
     lastedX = 0; lastedY = 0;
     
     for (int i = 0; i < xnum; i++)
     {
         for (int j = 0; j < ynum; j++)
         {
             units[i, j] = null;
             flags[i, j] = false;
         }
     }
 }
示例#39
0
        public bool putItem(DrawingUnit unit, bool add)
        {
            try
            {

                int x = unit.X, y = unit.Y;

                if (add)
                {
                    units[x, y] = new DrawingUnit(new EquipItem(), x, y);
                    units[x, y].Item.assign(unit.Item);
                }
                else
                {
                    units[x, y] = unit;
                }


                for (int i = 0; i < unit.Item.Width; i++)
                {
                    for (int j = 0; j < unit.Item.Height; j++)
                    {
                        flags[i + x, j + y] = true;
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: On item:" + unit.Item.Name + ", X:" + unit.X + ", Y: " + unit.Y + " " + ex.Message);
                return false;
            }
        }
示例#40
0
        private void CharPanel_MouseClick(object sender, MouseEventArgs e)
        {
            int index = findRectangle(e.X, e.Y);

            if (e.Button == MouseButtons.Right)
            {
                if (index >= 0)
                {
                    if (units[index] != null)
                    {
                        selectedUnit = units[index];
                        popMenu.Show(this, e.X, e.Y);
                    }
                    else 
                    {
                        selectedUnit = null;
                    }
                }
                else
                {
                    selectedUnit = null;
                }
            }
            else
            {
                if (index >= 0)
                {
                    if (units[index] != null)
                    {
                        selectedUnit = units[index];
                        editor.currentName.Text = selectedUnit.Item.Name;
                    }
                    else if (selectedUnit != null)
                    {
                        selectedUnit = null;
                        editor.currentName.Text = "None";
                    }
                    else
                    {
                        addEditItem(index);
                        editor.currentName.Text = "None";
                    }
                }
                else
                {
                    selectedUnit = null;
                }
            }
        }
示例#41
0
        private void EquipPanel_MouseLeave(object sender, EventArgs e)
        {
            curUnit.Item = null;
            coveredUnit = null;

            if (activeUnit != null)
            {
                activeUnit.X = lastedX; activeUnit.Y = lastedY;
                if (canPutItem(activeUnit) && putItem(activeUnit, false))
                {
                    selectedUnit = activeUnit;
                    activeUnit = null;
                }
            }
            this.Invalidate();
        }
示例#42
0
 public void assign(DrawingUnit unit)
 {
     x    = unit.X;
     y    = unit.Y;
     item = unit.Item;
 }
示例#43
0
        private void EquipPanel_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X / pixels, y = e.Y / pixels;
            coveredUnit = null;

            if (activeUnit != null)
            {
                activeUnit.X = x; activeUnit.Y = y;
            }
            else if (flags[x, y])
            {
                this.Cursor = Cursors.Hand;
                coveredUnit = findUnit(x, y);
                editor.currentName.Text = coveredUnit.Item.Name;
                if (selectedUnit == coveredUnit)
                {
                    coveredUnit = null;
                }
            }
            else
            {
                this.Cursor = Cursors.Cross;
                curUnit.X = x; curUnit.Y = y;
                editor.currentName.Text = "None";
            }

            this.Invalidate();
        }
示例#44
0
        private void EquipPanel_MouseClick(object sender, MouseEventArgs e)
        {
            DrawingUnit unit = null;
            int x = e.X / pixels, y = e.Y / pixels;
            if (e.Button == MouseButtons.Right)
            {
                if (activeUnit != null)
                {
                    activeUnit.X = lastedX; activeUnit.Y = lastedY;
                    if (canPutItem(activeUnit) && putItem(activeUnit, false))         
                    {
                        selectedUnit = activeUnit;
                        activeUnit = null;
                    }
                }
                else if ((unit = findUnit(x, y)) != null)
                {
                    selectedUnit = unit;
                    popMenu.Show(this, e.X, e.Y);
                }else
                {
                    selectedUnit = null;
                }
            }
            else
            {
                if (activeUnit == null)
                {
                    if (!flags[x, y])
                    {
                        if (selectedUnit == null)
                        {
                            editor.currentName.Text = "None";
                            addEditItem(x, y);
                        }
                        else
                        {
                            selectedUnit = null;
                            editor.currentName.Text = "None";
                        }
                    }
                    else if ((unit = findUnit(x, y)) != null && unit == selectedUnit)
                    {
                        removeItem(selectedUnit);
                        activeUnit = selectedUnit;
                        lastedX = selectedUnit.X; lastedY = selectedUnit.Y ;
                        selectedUnit = null;
                    }
                    else
                    {
                        selectedUnit = unit;
                        editor.currentName.Text = selectedUnit.Item.Name;
                    }
                }
                else
                {
                    activeUnit .X = x; activeUnit .Y = y;
                    if (canPutItem(activeUnit) && putItem (activeUnit, false))
                    {
                        selectedUnit = activeUnit;
                        activeUnit = null;
                    }
                }
            }

            this.Invalidate();
        }
示例#45
0
        private void EquipPanel_MouseClick(object sender, MouseEventArgs e)
        {
            DrawingUnit unit = null;
            int         x = e.X / pixels, y = e.Y / pixels;

            if (e.Button == MouseButtons.Right)
            {
                if (activeUnit != null)
                {
                    activeUnit.X = lastedX; activeUnit.Y = lastedY;
                    if (canPutItem(activeUnit) && putItem(activeUnit, false))
                    {
                        selectedUnit = activeUnit;
                        activeUnit   = null;
                    }
                }
                else if ((unit = findUnit(x, y)) != null)
                {
                    selectedUnit = unit;
                    popMenu.Show(this, e.X, e.Y);
                }
                else
                {
                    selectedUnit = null;
                }
            }
            else
            {
                if (activeUnit == null)
                {
                    if (!flags[x, y])
                    {
                        if (selectedUnit == null)
                        {
                            editor.currentName.Text = "None";
                            addEditItem(x, y);
                        }
                        else
                        {
                            selectedUnit            = null;
                            editor.currentName.Text = "None";
                        }
                    }
                    else if ((unit = findUnit(x, y)) != null && unit == selectedUnit)
                    {
                        removeItem(selectedUnit);
                        activeUnit   = selectedUnit;
                        lastedX      = selectedUnit.X; lastedY = selectedUnit.Y;
                        selectedUnit = null;
                    }
                    else
                    {
                        selectedUnit            = unit;
                        editor.currentName.Text = selectedUnit.Item.Name;
                    }
                }
                else
                {
                    activeUnit.X = x; activeUnit.Y = y;
                    if (canPutItem(activeUnit) && putItem(activeUnit, false))
                    {
                        selectedUnit = activeUnit;
                        activeUnit   = null;
                    }
                }
            }

            this.Invalidate();
        }
示例#46
0
        public bool putItem(DrawingUnit unit, bool add)
        {
            int x = unit.X, y = unit.Y;

            if (add)
            {
                units[x] = new DrawingUnit(new EquipItem(), x, y);
                units[x].Item.assign(unit.Item); 
            }
            else
            {
                units[x] = unit;
            }

            return true;
        }
示例#47
0
        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;
        }
示例#48
0
 private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     removeItem(selectedUnit);
     selectedUnit = null;
 }
示例#49
0
 private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     removeItem(selectedUnit);
     selectedUnit = null;
 }
示例#50
0
        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;
        }
示例#51
0
        public bool removeItem(DrawingUnit unit)
        {
            int x = unit.X;
            units[x] = null;                //remove

            return true;
        }
示例#52
0
 private void setEquipProperty(DrawingUnit unit)
 {
     if (unit != null) //
     {
         EquipProperty prop = new EquipProperty(unit.Item);
         prop.ShowDialog();
         prop.Dispose();
     }
 }