Esempio n. 1
0
        public frmGameWindow()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            GameRoot root = GameRoot.GetGameRoot();

            root.ActiveUnitChanged += new System.EventHandler(ActiveUnitChanged);
        }
Esempio n. 2
0
        public void StartGame(Civilization playerCivilization, ArrayList civilizations, string leaderName, WorldSize mapSize)
        {
            _cityBitmap = new Bitmap("City.bmp");
            _cityBitmap.MakeTransparent(TransparentColor.Value);
            _gameRoot      = GameRoot.GetGameRoot();
            _villageBitmap = new Bitmap("village.bmp");
            _villageBitmap.MakeTransparent(TransparentColor.Value);
            _roadNSBitmap = new Bitmap("road_ns.bmp");
            _roadNSBitmap.MakeTransparent(TransparentColor.Value);
            _roadEWBitmap = new Bitmap("road_ew.bmp");
            _roadEWBitmap.MakeTransparent(TransparentColor.Value);
            _activeBitmap = new Bitmap("active.bmp");
            _activeBitmap.MakeTransparent(TransparentColor.Value);
            _irrigationBitmap = new Bitmap("irrigation.bmp");
            _irrigationBitmap.MakeTransparent(TransparentColor.Value);
            _grassBitmap = new Bitmap(@"images\grass.bmp");
            _grassBitmap.MakeTransparent(TransparentColor.Value);

            _gameRoot.StatusChanged += new StatusChangedEventHandler(OnStatusChanged);
            _gameRoot.MapSize        = mapSize;
            _gameRoot.Start(playerCivilization, civilizations, leaderName);
        }
Esempio n. 3
0
        private void frmGameWindow_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            GameRoot root = GameRoot.GetGameRoot();

            e.Handled = true;
            switch (e.KeyCode)
            {
            case Keys.NumPad3:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.BottomCell);
                }
                break;

            case Keys.NumPad7:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.TopCell);
                }
                break;

            case Keys.NumPad1:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.LeftCell);
                }
                break;

            case Keys.NumPad9:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.RightCell);
                }
                break;

            case Keys.NumPad4:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.TopCell.LeftCell);
                }
                break;

            case Keys.NumPad6:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.RightCell.BottomCell);
                }
                break;

            case Keys.NumPad2:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.BottomCell.LeftCell);
                }
                break;

            case Keys.NumPad8:
                if (root.ActiveUnit != null)
                {
                    root.ActiveUnit.MoveTo((GridCell)root.ActiveUnit.Location.TopCell.RightCell);
                }
                break;

            case Keys.B:
                BuildNewCity();
                break;

            case Keys.I:
                Irrigate();
                break;

            case Keys.Space:
                _gameRoot.DoTurn();
                break;

            case Keys.R:
                BuildNewRoad();
                break;

            case Keys.M:
                BuildMine();
                break;
            }

            if (_gameRoot.Year > 0)
            {
                _yearPanel.Text =
                    Convert.ToInt32(Math.Abs(_gameRoot.Year)).ToString() + " A.D.";
            }
            else
            {
                _yearPanel.Text =
                    Convert.ToInt32(Math.Abs(_gameRoot.Year)).ToString() + " B.C.";
            }

            if (root.ActiveUnit != null)
            {
                _movesLeftPanel.Text =
                    root.ActiveUnit.MovesLeft.ToString() + " moves left";

                if (root.ActiveUnit.MovesLeft == 0)
                {
                    if (root.GetNextUnit() == null)
                    {
                        _gameRoot.DoTurn();
                    }
                }
            }
            else if (e.KeyCode != Keys.Space)
            {
                _gameRoot.DoTurn();
            }

            _gameWindow.Refresh();
            e.Handled = true;
        }