예제 #1
0
        public TravelScreen(InterfaceManager manager)
            : base(manager)
        {
            screenTitle      = new Title(null, "Star Map", GraphicConsole.BufferWidth / 2 - 11, 1, Title.TextAlignModes.Center);
            starMap          = new StarMap();
            starMap.Position = new System.Drawing.Point(1, 2);
            starMap.Size     = new System.Drawing.Point(74, 33);

            systemTitle                    = new Title(null, "Current System", 87, 1, Title.TextAlignModes.Center);
            systemDescriptionBox           = new TextBox(null, 76, 3, 23, 15);
            systemDescriptionBox.FillColor = new Color4(0.15f, 0.15f, 0.15f, 1f);

            up    = new Button(null, "▲", 87, 30);
            down  = new Button(null, "▼", 87, 34);
            left  = new Button(null, "◄", 84, 32);
            right = new Button(null, "►", 90, 32);

            systemButton = new Button(null, "System", 76, 27);
            travelButton = new Button(null, "Travel", 76, 30);
            ambushButton = new Button(null, "Ambush", 76, 33);
            cargoButton  = new Button(null, "Cargo", GraphicConsole.BufferWidth - 7, 27);
            stockButton  = new Button(null, "Stock", GraphicConsole.BufferWidth - 7, 30);

            screenTitle.Text = GameManager.GalacticDate.ToShortDateString();

            clock          = new Clock(null, 10, 5);
            clock.Position = new System.Drawing.Point(63, 1);

            playButton   = new Button(null, "►", 74, 1, 1, 1);
            fasterButton = new Button(null, "+", 61, 1, 1, 1);
            slowerButton = new Button(null, "-", 62, 1, 1, 1);

            //UI Events
            #region Map Panning Events
            up.Click += (sender, e) =>
            {
                starMap.PanMap(0f, 100f);
                InterfaceManager.DrawStep();
            };
            down.Click += (sender, e) =>
            {
                starMap.PanMap(0f, -100f);
                InterfaceManager.DrawStep();
            };
            left.Click += (sender, e) =>
            {
                starMap.PanMap(100f, 0f);
                InterfaceManager.DrawStep();
            };
            right.Click += (sender, e) =>
            {
                starMap.PanMap(-100f, 0f);
                InterfaceManager.DrawStep();
            };
            #endregion
            #region Button Events
            systemButton.Click += (sender, e) =>
            {
                if (!GameManager.PlayerShip.Pilot.IsTraveling)
                {
                    InterfaceManager.ChangeInterface("System");
                }
            };
            travelButton.Click += (sender, e) =>
            {
                if (starMap.HasSystemSelected && !GameManager.PlayerShip.Pilot.IsTraveling && GameManager.PlayerShip.CanFly())
                {
                    startTraveling();
                }
            };
            ambushButton.Click += (sender, e) =>
            {
                if (!GameManager.PlayerShip.Pilot.IsTraveling)
                {
                    InterfaceManager.ChangeInterface("Combat");
                }
            };
            cargoButton.Click += (sender, e) =>
            {
                if (!GameManager.PlayerShip.Pilot.IsTraveling)
                {
                    InterfaceManager.ChangeInterface("Ship");
                }
            };
            stockButton.Click += (sender, e) =>
            {
                if (!GameManager.PlayerShip.Pilot.IsTraveling)
                {
                    InterfaceManager.ChangeInterface("Stock");
                }
            };
            #endregion

            starMap.Selected += (sender, e) =>
            {
                highlitedPath = GameManager.Pathfinder.FindPath(GameManager.CurrentSystem, e, GameManager.PlayerShip);
                starMap.SetPath(highlitedPath);

                updateScreenInformation();
                InterfaceManager.DrawStep();
            };

            #region Clock Events
            clock.TimerLapse += (sender, e) =>
            {
                screenTitle.Text = GameManager.GalacticDate.ToShortDateString();
            };
            clock.TimerTick += (sender, e) =>
            {
                GameManager.SimulateGame(0.1);
            };

            playButton.Click += (sender, e) =>
            {
                playButton.Text = (playButton.Text == "■") ? "►" : "■";
                clock.Toggle();

                InterfaceManager.DrawStep();
            };
            fasterButton.Click += (sender, e) =>
            {
                clock.TickRate -= 0.5;
            };
            slowerButton.Click += (sender, e) =>
            {
                clock.TickRate += 0.5;
            };
            #endregion

            #region ControlRegister
            RegisterControl(screenTitle);
            RegisterControl(systemTitle);
            RegisterControl(systemDescriptionBox);
            RegisterControl(starMap);
            RegisterControl(up);
            RegisterControl(down);
            RegisterControl(left);
            RegisterControl(right);
            RegisterControl(playButton);
            RegisterControl(fasterButton);
            RegisterControl(slowerButton);
            RegisterControl(travelButton);
            RegisterControl(ambushButton);
            RegisterControl(systemButton);
            RegisterControl(cargoButton);
            RegisterControl(stockButton);
            RegisterControl(clock);
            #endregion
        }