Пример #1
0
        private void OnWorldPaint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;

            g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            _frame = new Frame(g, Width, Height, 0.5f);

            if (_isConnected)
            {
                _frame.LookAt(currentState.Position);

                var rq = new List <TankState>();
                rq.Add(currentState);
                rq.AddRange(enemiesStates);

                foreach (var state in rq)
                {
                    if (state != default)
                    {
                        _t1Appliance.Render(_frame, state);
                        var bounds = _t1Appliance.Bounds
                                     .Rotate(_t1Appliance.Origin, state.Rotation)
                                     .Move(state.Position);
                        _frame.DrawPolygon(bounds, Color.Lime);

                        var ray = new VectorGroup(state.Position,
                                                  state.Position + Vector.FromAngle(state.GunRotation - 90f) * 2000f);
                        if (state.Loading > 1)
                        {
                            _frame.DrawPolygon(ray, Color.Chocolate);
                        }
                    }
                }

                foreach (var wall in _map.Walls)
                {
                    _frame.FillPolygon(wall.Bounds.Move(wall.Position).Scale(_map.ScallingFactor),
                                       Color.FromName(wall.ColorCode));

                    var bounds = wall.Bounds
                                 .Move(wall.Position)
                                 .Scale(_map.ScallingFactor);

                    _frame.DrawPolygon(bounds, Color.MediumPurple);
                }

                g.DrawString($"Score {currentState.Score}", new Font(FontFamily.GenericMonospace, 20), Brushes.Black, 0, 0);
            }
            else
            {
                g.DrawString("Connecting", new Font(FontFamily.GenericMonospace, 20), Brushes.Black, 0, 0);
            }

            if (currentState?.IsInters ?? false)
            {
                g.DrawString("Oh no", new Font(FontFamily.GenericMonospace, 20), Brushes.PaleVioletRed, 0, 0);
            }

            /*if (currentState != null)
             *  View.PlaceCamOn(currentState);*/
        }