예제 #1
0
파일: Factory.cs 프로젝트: mihzas/netHack
 private void OnFinishCreate()
 {
     if (_finishCreate != null)
     {
         FinishCreateEventArgs e = new FinishCreateEventArgs(_cell);
         _finishCreate(this, e);
     }
 }
예제 #2
0
파일: World.cs 프로젝트: mihzas/netHack
        // Здесь ДОЛЖЕН БЫТЬ сложный алгоритм, пока не придумал как его написать
        public void FillWorld(object sender, FinishCreateEventArgs e)
        {
            if (e._listCell[0] is Enemy)
            {
                _countEnemy = e._listCell.Capacity;

                int i = 0, y, x;
                Random r = new Random();

                while (i < e._listCell.Count)
                {
                    y = r.Next(Y);
                    x = r.Next(X);
                    if (_cells[y, x] is Way)
                    {
                        _cells[y, x] = e._listCell[i];
                        ++i;
                    }
                }
            }

            else if (e._listCell[0] is Wizard)
            {
                _cells[1, 2] = e._listCell[0];
            }

            else if (e._listCell[0] is Way)
            {

                for (int i = 1; i < _cells.GetLength(1); ++i)
                {
                    _cells[1, i] = e._listCell[0];
                }

                for (int i = 1; i < _cells.GetLength(0) / 2; ++i)
                {
                    _cells[i, 3] = e._listCell[0];
                }

                for (int i = 4; i < _cells.GetLength(1) / 2; ++i)
                {
                    _cells[3, i] = e._listCell[0];
                }

                for (int i = (_cells.GetLength(0) / 2) + 18; i < _cells.GetLength(1) - 15; ++i)
                {
                    for (int j = 4; j < 15; ++j)
                    {
                        _cells[j, i] = e._listCell[0];
                    }
                }
            }

            else if (e._listCell[0] is EmptyCell)
            {
                for (int i = 0; i < _cells.GetLength(0); ++i)
                {
                    for (int j = 0; j < _cells.GetLength(1); ++j)
                    {
                        _cells[i, j] = e._listCell[0];
                    }
                }
            }

            else if (e._listCell[0] is Cat)
            {
                _cells[1, 1] = e._listCell[0];
            }

            else if (e._listCell[0] is Smith)
            {
                _cells[14, 44] = e._listCell[0];
            }
        }