Exemple #1
0
        public static void DrawAction(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            switch (environment.Mode)
            {
            case TacticalMode.General:
                break;

            case TacticalMode.SelectingSpaceObjectForShot:
                DrawWeaponAffectedAreaBorder(screenInfo, environment);
                DrawSelectingTarget(screenInfo, environment);
                break;

            case TacticalMode.SelectingSpaceObject:
                DrawWeaponAffectedAreaBorder(screenInfo, environment);
                DrawSelectingTarget(screenInfo, environment);
                break;

            case TacticalMode.SelectingSpaceObjectWithActive:
            case TacticalMode.OpenFireScreen:
                DrawWeaponAffectedAreaBorder(screenInfo, environment);
                DrawSelectingTargetWithActive(screenInfo, environment);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        public static void DrawActiveCelestialObjects(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            var activeObject = environment.GetActiveObject();

            if (activeObject is null)
            {
                return;
            }

            var pen = new Pen(Color.Gray);

            var spaceshipScreenLocation = UITools.ToScreenCoordinates(screenInfo, activeObject.GetLocation());

            screenInfo.GraphicSurface.DrawEllipse(pen, spaceshipScreenLocation.X - 20, spaceshipScreenLocation.Y - 20, 40, 40);

            var mouseScreenLocation = UITools.ToScreenCoordinates(screenInfo, environment.GetMouseCoordinates());

            var distance  = GeometryTools.Distance(spaceshipScreenLocation, mouseScreenLocation);
            var direction = GeometryTools.Azimuth(spaceshipScreenLocation, mouseScreenLocation);

            var destinationPoint = GeometryTools.MoveObject(mouseScreenLocation, distance - 20, direction);

            if (distance > 20)
            {
                screenInfo.GraphicSurface.DrawLine(pen, mouseScreenLocation.X, mouseScreenLocation.Y, destinationPoint.X, destinationPoint.Y);
            }
        }
Exemple #3
0
        public static void DrawWeaponAffectedArea(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            if (environment.Action is null)
            {
                return;
            }
            if (environment.Action.ModuleId == 0)
            {
                return;
            }

            var activeModule = environment.Session.GetPlayerSpaceShip().GetWeaponModule(environment.Action.ModuleId);

            if (activeModule is null)
            {
                return;
            }
            if (activeModule is IWeaponModule)
            {
                if (activeModule is IRange x)
                {
                    var screenCoordinates = UITools.ToScreenCoordinates(screenInfo, environment.Session.GetPlayerSpaceShip().GetLocation());

                    var radius = x.Range;

                    screenInfo.GraphicSurface.FillEllipse(new SolidBrush(Color.FromArgb(4, 4, 4)), screenCoordinates.X - radius, screenCoordinates.Y - radius, radius * 2, radius * 2);
                    screenInfo.GraphicSurface.DrawEllipse(new Pen(Color.DimGray), screenCoordinates.X - radius, screenCoordinates.Y - radius, radius * 2, radius * 2);
                }
            }
        }
        private void Initialization(TacticalEnvironment environment)
        {
            var spaceShip = _environment.Session.GetPlayerSpaceShip().ToSpaceship();

            var countModulesPreview = 0;

            foreach (var propulsionModule in spaceShip.Modules)
            {
                var controlPropulsionModule = new ModulePreview
                {
                    Visible  = true,
                    Location = new Point(10, 100 * countModulesPreview + 40),
                    Id       = propulsionModule.Id
                };

                countModulesPreview++;

                crlCommandsContainer.Controls.Add(controlPropulsionModule);
            }

            crlCommandsContainer.Height = countModulesPreview * 100 + 50;

            crlModule.Location = new Point((Width / 2) - (crlModule.Width / 2), Height - crlModule.Height - 20);

            Logger.Info("Initialization finished successful.");
        }
Exemple #5
0
        public void Initialization(int moduleId, TacticalEnvironment gameSession)
        {
            _environment = gameSession;
            _moduleId    = moduleId;

            var module = gameSession.Session.GetPlayerSpaceShip().GetModule(_moduleId);

            actionsContainer.Controls.Clear();

            if (module is IWeaponModule)
            {
                var i = 0;

                foreach (var moduleSkill in module.Skills)
                {
                    i++;

                    var attackAction = new ActionAttack(moduleId, moduleSkill.Id, gameSession.Session)
                    {
                        Location = new Point((i - 1) * 55, 0)
                    };

                    _logger.Info($"Add action '{moduleSkill.Id}' to module '{module.Id}'");
                    attackAction.Tag    = module.Id;
                    attackAction.Click += Event_SelectAction;

                    actionsContainer.Controls.Add(attackAction);
                }
            }
        }
Exemple #6
0
        public static void DrawCelestialObjects(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            foreach (var currentObject in environment.Session.GetCelestialObjects())
            {
                switch ((CelestialObjectTypes)currentObject.Classification)
                {
                case CelestialObjectTypes.Missile:
                    DrawMissile(screenInfo, currentObject);
                    break;

                case CelestialObjectTypes.SpaceshipPlayer:
                    DrawSpaceship(screenInfo, currentObject);
                    break;

                case CelestialObjectTypes.SpaceshipNpcNeutral:
                    DrawSpaceship(screenInfo, currentObject);
                    break;

                case CelestialObjectTypes.SpaceshipNpcEnemy:
                    DrawSpaceship(screenInfo, currentObject);
                    break;

                case CelestialObjectTypes.SpaceshipNpcFriend:
                    DrawSpaceship(screenInfo, currentObject);
                    break;

                case CelestialObjectTypes.Asteroid:
                    DrawAsteroid(screenInfo, currentObject);
                    break;

                case CelestialObjectTypes.Explosion:
                    break;
                }
            }
        }
Exemple #7
0
        public static void DrawHistoryTrajectory(IScreenInfo screenInfo, TacticalEnvironment environment, Hashtable history)
        {
            foreach (var currentObject in environment.Session.GetCelestialObjects())
            {
                if (!history.ContainsKey(currentObject.Id))
                {
                    continue;
                }

                if (currentObject is Missile)
                {
                    continue;
                }

                var results = ((FixedSizedQueue <PointF>)history[currentObject.Id]).GetData();

                var points = new List <PointF>();

                foreach (var position in results)
                {
                    var screenCoordinates = UITools.ToScreenCoordinates(screenInfo, position);

                    points.Add(new PointF(screenCoordinates.X, screenCoordinates.Y));
                }

                var pen = new Pen(Color.FromArgb(77, 77, 77))
                {
                    DashStyle = DashStyle.Dot
                };

                screenInfo.GraphicSurface.DrawCurve(pen, points.ToArray());
            }
        }
Exemple #8
0
        private void Event_StartGameSession(TacticalEnvironment environment)
        {
            _environment = environment;

            Logger.Info($"Start game session for id '{_environment.Session.Id}'.");

            RefreshControl();
        }
        private void Event_EndTurn(TacticalEnvironment environment)
        {
            _environment = environment;

            Logger.Debug($"Refresh game information for turn '{_environment.Session.Turn}'.");

            this.PerformSafely(RefreshControl);
        }
Exemple #10
0
        public void OpenScreen(Form window, TacticalEnvironment environment)
        {
            window.ShowInTaskbar = false;
            window.ShowIcon      = false;
            window.StartPosition = FormStartPosition.CenterParent;

            var result = OpenModalForm(window, environment);
        }
Exemple #11
0
        public GameManager(LocalGameServer gameServer)
        {
            Environment = new TacticalEnvironment();

            _gameServer = gameServer;
            var gameSession = new GameSession(_gameServer.RefreshGameSession(gameServer.SessionId));

            Environment.RefreshGameSession(gameSession);
        }
Exemple #12
0
        private void RefreshControl(TacticalEnvironment gameSession)
        {
            var module = gameSession.Session.GetPlayerSpaceShip().GetModule(_moduleId);

            crlModuleName.Text = module.Name;

            crlReloading.Maximum      = (int)module.ReloadTime;
            crlReloading.CurrentValue = (int)module.Reloading;
        }
Exemple #13
0
        private static void DrawSelectingTarget(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            var pen = new Pen(Color.BurlyWood);

            var spaceshipScreenLocation = UITools.ToScreenCoordinates(screenInfo, environment.Session.GetPlayerSpaceShip().GetLocation());
            var mouseScreenLocation     = UITools.ToScreenCoordinates(screenInfo, environment.MouseLocation);

            screenInfo.GraphicSurface.DrawLine(pen, spaceshipScreenLocation.X, spaceshipScreenLocation.Y, mouseScreenLocation.X, mouseScreenLocation.Y);
        }
Exemple #14
0
        private void Event_EndTurn(TacticalEnvironment gameSession)
        {
            if (_moduleId == 0)
            {
                return;
            }

            this.PerformSafely(RefreshControl, gameSession);
        }
Exemple #15
0
        public void OpenScreen(string window, TacticalEnvironment environment)
        {
            var form = GetScreen(window);

            form.ShowInTaskbar = false;
            form.ShowIcon      = false;
            form.StartPosition = FormStartPosition.CenterParent;

            var result = OpenModalForm(form, environment);
        }
        private void Event_StartGameSession(TacticalEnvironment environment)
        {
            crlTacticalMap.Refresh();

            _environment = environment;

            Initialization(_environment);

            Global.Game.InitializationFinish();

            Global.Game.UiManager.HideBackGround();
        }
Exemple #17
0
        public void ShowAlertOnReloadingModule(IModule module, TacticalEnvironment environment)
        {
            //WindowAlertModuleReloadingInProgress
            var windowGameEvent = new WindowAlertModuleReloadingInProgress(module, environment.Session)
            {
                ShowInTaskbar = false,
                ShowIcon      = false,
                StartPosition = FormStartPosition.CenterParent
            };

            OpenScreen(windowGameEvent, environment);
        }
Exemple #18
0
        private void Event_EndTurn(TacticalEnvironment environment)
        {
            _environment = environment;

            UpdateTrajectoryHistory(_environment);

            Logger.Debug($"Refresh space map for turn '{_environment.Session.Turn}'.");

            if (_screenParameters.Settings.IsCenterOnSpaceship)
            {
                var spaceshipLocation = environment.Session.GetPlayerSpaceShip().GetLocation();
                _centerScreenPosition = new PointF(spaceshipLocation.X, spaceshipLocation.Y);
            }

            RefreshControl();
        }
Exemple #19
0
        public static void DrawExplosions(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            foreach (var currentObject in environment.Session.GetCelestialObjects())
            {
                if (!(currentObject is Explosion missile))
                {
                    continue;
                }

                var screenCoordinates = UITools.ToScreenCoordinates(screenInfo, new PointF(currentObject.PositionX, currentObject.PositionY));

                var radius = missile.RemoveTurn - environment.Session.Turn + missile.Radius;

                screenInfo.GraphicSurface.FillEllipse(new SolidBrush(Color.OrangeRed), screenCoordinates.X - radius / 2, screenCoordinates.Y - radius / 2, radius, radius);
                screenInfo.GraphicSurface.DrawEllipse(new Pen(Color.Brown), screenCoordinates.X - radius / 2, screenCoordinates.Y - radius / 2, radius, radius);
            }
        }
Exemple #20
0
        private DialogResult OpenModalForm(Form screen, TacticalEnvironment environment)
        {
            Form mainForm = null;

            if (Application.OpenForms.Count > 0)
            {
                mainForm = Application.OpenForms[0];
            }

            if (mainForm != null && mainForm.InvokeRequired)
            {
                RefreshCallback d = OpenModalForm;
                return((DialogResult)mainForm.Invoke(d, screen, environment));
            }

            screen.Tag = environment;

            return(screen.ShowDialog());
        }
Exemple #21
0
        public GameManager()
        {
            Environment = new TacticalEnvironment();

            switch (Global.ApplicationSettings.ServerType)
            {
            case 1:
                //_gameServer = new ScalaGameServer(_applicationSettings, null);
                break;

            case 2:
                //_gameServer = new LocalStaticGameServer();
                break;

            case 3:
                _gameServer = new LocalGameServer();
                break;
            }
        }
Exemple #22
0
        public static void DrawDirections(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            foreach (var currentObject in environment.Session.GetCelestialObjects())
            {
                Color color;

                switch ((CelestialObjectTypes)currentObject.Classification)
                {
                case CelestialObjectTypes.Missile:
                    break;

                case CelestialObjectTypes.SpaceshipPlayer:
                    color = Color.DarkOliveGreen;
                    DrawDirection(screenInfo, currentObject, color);
                    break;

                case CelestialObjectTypes.SpaceshipNpcNeutral:
                    color = Color.DarkGray;
                    DrawDirection(screenInfo, currentObject, color);
                    break;

                case CelestialObjectTypes.SpaceshipNpcEnemy:
                    color = Color.DarkRed;
                    DrawDirection(screenInfo, currentObject, color);
                    break;

                case CelestialObjectTypes.SpaceshipNpcFriend:
                    color = Color.SeaGreen;
                    DrawDirection(screenInfo, currentObject, color);
                    break;

                case CelestialObjectTypes.Asteroid:
                    color = Color.DimGray;
                    DrawDirection(screenInfo, currentObject, color);
                    break;

                case CelestialObjectTypes.Explosion:
                    break;
                }
            }
        }
Exemple #23
0
        public static void DrawRadar(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            var screenCoordinates = UITools.ToScreenCoordinates(screenInfo, environment.Session.GetPlayerSpaceShip().GetLocation());

            var color = Color.FromArgb(12, 12, 12);

            var colorLight = Color.FromArgb(28, 28, 28);

            var radarDelta = 5;

            var radarStep = 75;

            var radarSteps = 12;

            var radarSize = radarStep * radarSteps + radarDelta;

            for (var i = 0; i <= radarSteps; i++)
            {
                if (i % 2 != 0)
                {
                    DrawEllipse(colorLight, screenCoordinates.X, screenCoordinates.Y, i * radarStep, screenInfo);
                }
                else
                {
                    DrawEllipse(color, screenCoordinates.X, screenCoordinates.Y, i * radarStep, screenInfo);
                }
            }

            const int segments = 16;

            for (var i = 0; i < segments; i++)
            {
                DrawBrokenLine(color, screenCoordinates, radarSize, radarStep - radarDelta, i * (180 / segments), screenInfo);
            }

            for (var i = 0; i < 4; i++)
            {
                DrawBrokenLine(colorLight, screenCoordinates, radarSize, radarStep - radarDelta, i * (180 / 4), screenInfo);
            }
        }
Exemple #24
0
        private void DrawTacticalMapScreen(IScreenInfo screenParameters, TacticalEnvironment environment)
        {
            DrawTacticalMap.DrawBackGround(screenParameters);

            DrawTacticalMap.DrawExplosions(screenParameters, environment);

            DrawTacticalMap.DrawWeaponAffectedArea(screenParameters, environment);

            DrawTacticalMap.DrawGrid(screenParameters);

            DrawTacticalMap.DrawRadar(screenParameters, environment);

            DrawTacticalMap.DrawAction(screenParameters, environment);

            DrawTacticalMap.DrawCelestialObjects(screenParameters, environment);

            DrawTacticalMap.DrawActiveCelestialObjects(screenParameters, environment);

            DrawTacticalMap.DrawDirections(screenParameters, environment);

            DrawTacticalMap.DrawHistoryTrajectory(screenParameters, environment, _history);
        }
Exemple #25
0
        private static void DrawSelectingTargetWithActive(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            var pen = new Pen(Color.DarkOliveGreen);

            var spaceshipScreenLocation = UITools.ToScreenCoordinates(screenInfo, environment.Session.GetPlayerSpaceShip().GetLocation());

            if (environment.GetActiveObject() is null)
            {
                return;
            }

            var mouseScreenLocation = UITools.ToScreenCoordinates(screenInfo, environment.GetActiveObject().GetLocation());

            var distance  = GeometryTools.Distance(spaceshipScreenLocation, mouseScreenLocation);
            var direction = GeometryTools.Azimuth(mouseScreenLocation, spaceshipScreenLocation);

            var destinationPoint = GeometryTools.MoveObject(spaceshipScreenLocation, distance - 15, direction);

            screenInfo.GraphicSurface.DrawLine(pen, spaceshipScreenLocation.X, spaceshipScreenLocation.Y, destinationPoint.X, destinationPoint.Y);

            screenInfo.GraphicSurface.DrawEllipse(pen, mouseScreenLocation.X - 15, mouseScreenLocation.Y - 15, 30, 30);
        }
 private void Event_EndTurn(TacticalEnvironment environment)
 {
     _environment = environment;
 }
Exemple #27
0
 private void Event_Initialization(TacticalEnvironment gameSession)
 {
     this.PerformSafely(RefreshControl, gameSession);
 }
Exemple #28
0
        public static void DrawWeaponAffectedAreaBorder(IScreenInfo screenInfo, TacticalEnvironment environment)
        {
            if (environment.Action is null)
            {
                return;
            }

            var activeModule = environment.Session.GetPlayerSpaceShip().GetWeaponModule(environment.Action.ModuleId);

            if (activeModule is null)
            {
                return;
            }

            if (activeModule is IRange x)
            {
                var screenCoordinates = UITools.ToScreenCoordinates(screenInfo, environment.Session.GetPlayerSpaceShip().GetLocation());

                var radius = x.Range;

                screenInfo.GraphicSurface.DrawEllipse(new Pen(Color.DimGray), screenCoordinates.X - radius, screenCoordinates.Y - radius, radius * 2, radius * 2);

                var efficiency = (int)(x.Efficiency * x.Range);

                screenInfo.GraphicSurface.DrawEllipse(new Pen(Color.DimGray), screenCoordinates.X - efficiency, screenCoordinates.Y - efficiency, efficiency * 2, efficiency * 2);


                #region Efficiency Cross
                var efficiencyCrossLineColor = new Pen(Color.DimGray);

                screenInfo.GraphicSurface.DrawLine(efficiencyCrossLineColor,
                                                   GeometryTools.MoveObject(screenCoordinates, 12, 0),
                                                   GeometryTools.MoveObject(screenCoordinates, x.Range + 12, 0));

                screenInfo.GraphicSurface.DrawLine(efficiencyCrossLineColor,
                                                   GeometryTools.MoveObject(screenCoordinates, 12, 180),
                                                   GeometryTools.MoveObject(screenCoordinates, x.Range + 12, 180));

                screenInfo.GraphicSurface.DrawLine(efficiencyCrossLineColor,
                                                   GeometryTools.MoveObject(screenCoordinates, 12, 90),
                                                   GeometryTools.MoveObject(screenCoordinates, x.Range + 12, 90));

                screenInfo.GraphicSurface.DrawLine(efficiencyCrossLineColor,
                                                   GeometryTools.MoveObject(screenCoordinates, 12, 270),
                                                   GeometryTools.MoveObject(screenCoordinates, x.Range + 12, 270));

                #endregion


                #region Efficiency Labels

                var efficiencyLineColor = new Pen(Color.Orange);
                var efficiencyTextColor = Color.Orange;

                #region 0% EFFICIENCY

                #region 90 degree

                var point1 = GeometryTools.MoveObject(screenCoordinates, x.Range, 90);

                var point2 = GeometryTools.MoveObject(point1, 50, 135);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                var point3 = GeometryTools.MoveObject(point2, 110, 90);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                var pointLabel = new PointF(point2.X + 5, point2.Y - 15);

                using var font1 = new Font("Times New Roman", 10, FontStyle.Bold, GraphicsUnit.Pixel);

                screenInfo.GraphicSurface.DrawString("0% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #region 180 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, x.Range, 180);

                point2 = GeometryTools.MoveObject(point1, 50, 225);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 270);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X - 105, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("0% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #region 270 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, x.Range, 270);

                point2 = GeometryTools.MoveObject(point1, 50, 225);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 270);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X - 105, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("0% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #region 0 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, x.Range, 0);

                point2 = GeometryTools.MoveObject(point1, 50, 225);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 270);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X - 105, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("0% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #endregion

                #region 0% EFFICIENCY

                #region 90 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, efficiency, 90);

                point2 = GeometryTools.MoveObject(point1, 50, 135);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 90);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X + 5, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("100% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #region 180 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, efficiency, 180);

                point2 = GeometryTools.MoveObject(point1, 50, 225);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 270);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X - 105, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("100% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #region 270 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, efficiency, 270);

                point2 = GeometryTools.MoveObject(point1, 50, 225);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 270);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X - 105, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("100% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #region 0 degree

                point1 = GeometryTools.MoveObject(screenCoordinates, efficiency, 0);

                point2 = GeometryTools.MoveObject(point1, 50, 225);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point1, point2);

                point3 = GeometryTools.MoveObject(point2, 110, 270);

                screenInfo.GraphicSurface.DrawLine(efficiencyLineColor, point2, point3);

                pointLabel = new PointF(point2.X - 105, point2.Y - 15);

                screenInfo.GraphicSurface.DrawString("100% EFFICIENCY", font1, new SolidBrush(efficiencyTextColor), pointLabel);

                #endregion

                #endregion

                #endregion
            }
        }
Exemple #29
0
 private void Event_EndTurn(TacticalEnvironment gameSession)
 {
     // TODO: Open after redesign control (cross-thread problem)
     //RefreshControl(gameSession);
 }
Exemple #30
0
        // TODO: Refactor it
        private void UpdateTrajectoryHistory(TacticalEnvironment environment)
        {
            var settings = new EngineSettings();

            foreach (var currentObject in environment.Session.GetCelestialObjects())
            {
                if (_history.ContainsKey(currentObject.Id))
                {
                    var queueHistoryPoints = (FixedSizedQueue <PointF>)_history[currentObject.Id];
                    queueHistoryPoints.Enqueue(currentObject.GetLocation());
                    _history[currentObject.Id] = queueHistoryPoints;
                }
                else
                {
                    var celestialObjectTrajectoryHistory = new FixedSizedQueue <PointF>(settings.UnitsPerSecond * settings.HistoryPeriodInSeconds);

                    var reverseDirection = (currentObject.Direction - 180).To360Degrees();

                    var speedInTick = currentObject.Speed / settings.UnitsPerSecond;

                    var previousPosition = currentObject.GetLocation();

                    var positionsReverse = new List <PointF>();

                    for (int i = 0; i < settings.UnitsPerSecond * settings.HistoryPeriodInSeconds; i++)
                    {
                        var position = GeometryTools.MoveObject(
                            previousPosition,
                            speedInTick,
                            reverseDirection
                            );

                        previousPosition = new PointF(position.X, position.Y);

                        positionsReverse.Add(position);
                    }

                    for (var i = positionsReverse.Count - 1; i > 0; i--)
                    {
                        celestialObjectTrajectoryHistory.Enqueue(positionsReverse[i]);
                    }

                    try
                    {
                        _history.Add(currentObject.Id, celestialObjectTrajectoryHistory);
                    }
                    catch
                    {
                        try
                        {
                            var queueHistoryPoints = (FixedSizedQueue <PointF>)_history[currentObject.Id];
                            queueHistoryPoints.Enqueue(currentObject.GetLocation());
                            _history[currentObject.Id] = queueHistoryPoints;
                        }
                        catch
                        {
                            Logger.Error($"Error on refresh space map for turn '{environment.Session.Turn}' " +
                                         $"and object id '{currentObject.Id}' name '{currentObject.Name}'.");
                        }
                    }
                }
            }
        }