Esempio n. 1
0
        private void MoveHero(Hero hero, Cell cell)
        {
            // no more movement points
            if (hero._movementPointLeft <= 0) return;

            // move hero
            {
                hero._cell._hero = null;
                hero._cell = cell;
                cell._hero = hero;

                hero._movementPointLeft -= 1;
                if (hero._movementPointLeft == 0)
                {
                    hero._image = _currentPlayer._heroImage;
                }
            }

            int goldMineType = (int)Heroes.Core.MineTypeEnum.Gold;

            if (cell._mine != null)
            {
                if (cell._mine._player == null)
                {
                    cell._mine._player = _currentPlayer;
                    cell._mine._image = _currentPlayer._goldMine;

                    _currentPlayer._mineKTypes[goldMineType].Add(cell._mine);

                    this.label_mines.Text = _currentPlayer._mineKTypes[goldMineType].Count.ToString();
                }
                else
                {
                    if (cell._mine._player == _currentPlayer)
                    { }
                    else
                    {
                        Player p = (Player)cell._mine._player;
                        p._mineKTypes[goldMineType].Remove(cell._mine);
                        cell._mine._player = _currentPlayer;
                        cell._mine._image = _currentPlayer._goldMine;
                        _currentPlayer._mineKTypes[goldMineType].Add(cell._mine);
                        this.label_mines.Text = _currentPlayer._mineKTypes[goldMineType].Count.ToString();
                    }
                }
                // replace image

                // change income
            }

            Draw();
        }
Esempio n. 2
0
 private List<Cell> GetNearbyCell(Cell currentCell, DirectionEnum direction)
 {
     Cell ccell;
     List<Cell> listcell = new List<Cell>();
     for (int zz = 1; zz < _currentHero._movementPointLeft; zz++)
     {
         ccell = new Cell();
         ccell._col = currentCell._col - zz;
         listcell.Add(ccell);
         ccell = new Cell();
         ccell._col = currentCell._col + zz;
         listcell.Add(ccell);
         ccell = new Cell();
         ccell._row = currentCell._row - zz;
         listcell.Add(ccell);
         ccell = new Cell();
         ccell._row = currentCell._row + zz;
         listcell.Add(ccell);
     }
     return listcell;
 }
Esempio n. 3
0
        private Cell GetNextCell(Cell currentCell, DirectionEnum direction)
        {
            switch (direction)
            {
                case DirectionEnum.Up:
                    {
                        if (currentCell._row - 1 < 0) return null;

                        Cell cell = _cells[currentCell._row - 1, currentCell._col];
                        return cell;
                    }
                case DirectionEnum.Down:
                    {
                        if (currentCell._row + 1 >= _rowCount) return null;
                        //if (_cells[currentCell._row + 1, currentCell._col]._hero != null) return null;

                        Cell cell = _cells[currentCell._row + 1, currentCell._col];
                        return cell;
                    }
                case DirectionEnum.Left:
                    {
                        if (currentCell._col - 1 < 0) return null;
                        //if (_cells[currentCell._row, currentCell._col -1]._hero != null) return null;

                        Cell cell = _cells[currentCell._row, currentCell._col - 1];
                        return cell;
                    }
                case DirectionEnum.Right:
                    {
                        if (currentCell._col + 1 >= _colCount) return null;
                        //if (_cells[currentCell._row, currentCell._col + 1]._hero != null) return null;

                        Cell cell = _cells[currentCell._row, currentCell._col + 1];
                        return cell;
                    }
            }

            return null;
        }
Esempio n. 4
0
 private DirectionEnum GetDirection(Cell cellSrc, Cell cellDest)
 {
     return DirectionEnum.None;
 }
Esempio n. 5
0
 private void FindPath(Cell cell)
 {
 }
Esempio n. 6
0
        private void CreateCells()
        {
            int rowCount = _rowCount;
            int colCount = _colCount;
            _cells = new Cell[rowCount, colCount];

            int w = 50;
            int h = 50;
            int starty = 45;
            int startx = 39;
            int x = startx;
            int y = starty;

            for (int row = 0; row < rowCount; row++)
            {
                x = startx;

                for (int col = 0; col < colCount; col++)
                {
                    Cell cell = new Cell();
                    cell._row = row;
                    cell._col = col;

                    cell.BorderStyle = BorderStyle.None;
                    cell.BackColor = Color.Transparent;
                    cell.Left = x;
                    cell.Top = y;
                    cell.Width = w;
                    cell.Height = h;
                    this.Controls.Add(cell);

                    cell.MouseClick += new MouseEventHandler(cell_MouseClick);
                    cell.MouseHover += new EventHandler(cell_MouseHover);
                    cell.MouseLeave += new EventHandler(cell_MouseLeave);
                    cell.MouseDoubleClick += new MouseEventHandler(cell_MouseDoubleClick);

                    _cells[row, col] = cell;

                    x += w;
                }

                y += h;
            }
        }
Esempio n. 7
0
        private void Attack(Cell cell)
        {
            // confirmation message
            if (MessageBox.Show("Do you want to attack?", "Attack", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                != DialogResult.Yes) return;

            // minus movement point
            _currentHero._movementPointLeft -= 1;
            if (_currentHero._movementPointLeft == 0)
            {
                _currentHero._image = _currentPlayer._heroImage;
                Draw();
            }

            // start battle
            {
                // clone
                Heroes.Core.Hero attackHero = _currentHero;
                //Heroes.Core.Hero attackHero = new Heroes.Core.Hero();
                //attackHero.CopyFrom(_currentHero);

                Heroes.Core.Hero defendHero = cell._hero;
                //Heroes.Core.Hero defendHero = new Heroes.Core.Hero();
                //defendHero.CopyFrom(cell._hero);

                Heroes.Core.Monster monster = cell._monster;

                Heroes.Core.Town castle = cell._castle;

                StartingBattleEventArg eventArg = new StartingBattleEventArg(attackHero, defendHero, monster, castle);
                OnStartingBattle(eventArg);

                // set battle result
                if (!_isMultiPlayer)
                {
                    if (eventArg._victory == 1)
                    {
                        // attacker win

                        // remove defender
                        Heroes.Core.Player player = cell._hero._player;
                        player._heroes.Remove(cell._hero);
                        cell._hero = null;
                    }
                    else
                    {
                        // defender win

                        // remove attacker
                        Heroes.Core.Player player = _currentHero._player;
                        player._heroes.Remove(_currentHero);
                        cell._hero = null;
                    }

                    Draw();
                }
            }
        }
Esempio n. 8
0
        private void VisitCastle(Cell cell)
        {
            cell._castle._heroVisit = _currentHero;

            VisitingCastleEventArg eventArg = new VisitingCastleEventArg(cell._castle);
            OnVisitingCastle(eventArg);

            // minus movement point
            _currentHero._movementPointLeft -= 1;
            if (_currentHero._movementPointLeft == 0)
            {
                _currentHero._image = _currentPlayer._heroImage;
                Draw();
            }
        }