Example #1
0
        private static void DrawPlayground(Graphics graphics,
                                           Map map,
                                           int xCoordinate,
                                           int yCoordinate,
                                           int cellSize,
                                           int lineSize,
                                           PlaygroundType visiblePlayground)
        {
            DrawUserObjects(graphics, map, xCoordinate, yCoordinate, cellSize, lineSize, visiblePlayground);

            DrawNumbering(
                graphics,
                xCoordinate + cellSize / 4,
                yCoordinate + (cellSize + lineSize) * 10 + cellSize / 4,
                cellSize,
                lineSize);
        }
Example #2
0
        private static void DrawUserObjects(
            Graphics graphics,
            Map map,
            int xCoordinateStart,
            int yCoordinateStart,
            int cellSize,
            int lineSize,
            PlaygroundType playgroundType)
        {
            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    var cell = map.CellsStatuses[x, y];

                    float xCoordinate = xCoordinateStart + x * (cellSize + lineSize);
                    float yCoordinate = yCoordinateStart + 10 * (cellSize + lineSize) + lineSize - (cellSize + lineSize) - y * (cellSize + lineSize);

                    Brush brush;

                    switch (playgroundType)
                    {
                    case PlaygroundType.VisiblePlayground:
                        switch (cell)
                        {
                        case CellStatus.Water:
                            brush = new SolidBrush(Color.Aquamarine);
                            break;

                        case CellStatus.HittedWater:
                            brush = new SolidBrush(Color.DarkCyan);
                            break;

                        case CellStatus.PartOfShip:
                            brush = new SolidBrush(Color.LightSlateGray);
                            break;

                        case CellStatus.DamagedPartOfShip:
                            brush = new SolidBrush(Color.LightCoral);
                            break;

                        case CellStatus.DestroyedShip:
                            brush = new SolidBrush(Color.Red);
                            break;

                        default:
                            throw new Exception("Неожиданный тип клетки");
                        }
                        break;

                    case PlaygroundType.InvisiblePlayground:
                        switch (cell)
                        {
                        case CellStatus.Water:
                            brush = new SolidBrush(Color.White);
                            break;

                        case CellStatus.HittedWater:
                            brush = new SolidBrush(Color.DimGray);
                            break;

                        case CellStatus.PartOfShip:
                            brush = new SolidBrush(Color.White);
                            break;

                        case CellStatus.DamagedPartOfShip:
                            brush = new SolidBrush(Color.LightCoral);
                            break;

                        case CellStatus.DestroyedShip:
                            brush = new SolidBrush(Color.Red);
                            break;

                        default:
                            throw new Exception("Неожиданный тип клетки");
                        }
                        break;

                    default:
                        throw new Exception("Неожиданный тип игрового поля");
                    }


                    graphics.FillRectangle(brush, xCoordinate, yCoordinate, cellSize, cellSize);
                }
            }
        }
Example #3
0
        public void Save(XElement e)
        {
            XElement elemGameSetting = new XElement("GameSetting");

            e.Add(elemGameSetting);

            XElement   elem  = new XElement("OurTeamOffensive");
            XAttribute attri = new XAttribute("Value", OurTeamOffensive.ToString());

            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("Scaling");
            attri = new XAttribute("Value", Scaling.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            // 11-09-2010 Scott
            elem  = new XElement("ScalingAnimation");
            attri = new XAttribute("Value", ScalingAnimation.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            // 10-08-2010 Scott
            elem  = new XElement("OffensiveMainField");
            attri = new XAttribute("Value", OffensiveMainField.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("OffensiveSubField");
            attri = new XAttribute("Value", OffensiveSubField.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("DefensiveMainField");
            attri = new XAttribute("Value", DefensiveMainField.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("DefensiveSubField");
            attri = new XAttribute("Value", DefensiveSubField.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            // 10-26-2011 Scott
            elem  = new XElement("KickMainField");
            attri = new XAttribute("Value", KickMainField.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("KickSubField");
            attri = new XAttribute("Value", KickSubField.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);
            // end

            elem  = new XElement("UserFolder");
            attri = new XAttribute("Value", UserFolder);
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("UserType");
            attri = new XAttribute("Value", UserType.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("ProductType");
            attri = new XAttribute("Value", ProductType.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlaygroundType");
            attri = new XAttribute("Value", PlaygroundType.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("CurrentTheme");
            attri = new XAttribute("Value", CurrentTheme);
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("GridLine");
            attri = new XAttribute("Value", GridLine.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("SnapValue");
            attri = new XAttribute("Value", SnapValue.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("SnapToGrid");
            attri = new XAttribute("Value", SnapToGrid.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("ShowBall");
            attri = new XAttribute("Value", ShowBall.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("BallSize");
            attri = new XAttribute("Value", BallSize.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("Landscape");
            attri = new XAttribute("Value", Landscape.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("ShowPlayground");
            attri = new XAttribute("Value", ShowPlayground.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("EnableColor");
            attri = new XAttribute("Value", EnableColor.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("EnableSymbolColor");
            attri = new XAttribute("Value", EnableSymbolColor.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("EnableTitle");
            attri = new XAttribute("Value", EnableTitle.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlayerAngle");
            attri = new XAttribute("Value", PlayerAngle.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlayerAppearance");
            attri = new XAttribute("Value", PlayerAppearance.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlayerDash");
            attri = new XAttribute("Value", PlayerDash.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlayerSzie");
            attri = new XAttribute("Value", PlayerSize.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlayerTextVisibility");
            attri = new XAttribute("Value", PlayerTextVisibility.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("PlayerThickness");
            attri = new XAttribute("Value", PlayerThickness.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("ImageShowPlayground");
            attri = new XAttribute("Value", ImageShowPlayground.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("ImageEnableColor");
            attri = new XAttribute("Value", ImageEnableColor.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);

            elem  = new XElement("ImageEnableSymbolColor");
            attri = new XAttribute("Value", ImageEnableSymbolColor.ToString());
            elem.Add(attri);
            elemGameSetting.Add(elem);
        }