Ejemplo n.º 1
0
        private void Edit()
        {
            ButtonMapSave.Enabled = true;

            string[] Prop = new string[3] {
                "", "", ""
            };

            if ((string)BackgroundSelect.SelectedItem != "Empty")
            {
                Prop[0] = (string)BackgroundSelect.SelectedItem;
            }
            else
            {
                Prop[0] = CellMap.Find(_LocationList, _Location).Properties[0];
            }
            if (RoadCheck.Checked)
            {
                Prop[1] = DrawPath(1);
            }
            if (RiverCheck.Checked)
            {
                Prop[2] = DrawPath(2);
            }

            if (CellMap.Find(_LocationList, _Location).ID == null)
            {
                _LocationList.Add(new CellMap(_Location, Prop));
                CellMap.Sort(_LocationList);
            }
            else
            {
                CellMap.Find(_LocationList, _Location).SetProp(Prop);
            }
        }
Ejemplo n.º 2
0
        private static void Sort(List <CellMap> Array, int Left, int Right)
        {
            int     LHold  = Left;
            int     RHold  = Right;
            CellMap Middle = Array[Left + (Right - Left) / 2];

            while (LHold < RHold)
            {
                while (Middle.ID > Array[LHold].ID)
                {
                    LHold++;
                }
                while (Middle.ID < Array[RHold].ID)
                {
                    RHold--;
                }
                if (LHold <= RHold)
                {
                    CellMap Buffer = Array[LHold];
                    Array[LHold] = Array[RHold];
                    Array[RHold] = Buffer;

                    LHold++; RHold--;
                }
            }

            if (Left < RHold)
            {
                Sort(Array, Left, RHold);
            }
            if (LHold < Right)
            {
                Sort(Array, LHold, Right);
            }
        }
Ejemplo n.º 3
0
        private void FogOfWar()
        {
            if (CellMap.Find(_LocationList, _Location).ID != null)
            {
                if (CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, _Location).ID == null)
                {
                    _Nation[NationSelect.SelectedIndex].Vision.Add(new CellMap(_Location, CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, _Location).Properties));
                    CellMap.Sort(_Nation[NationSelect.SelectedIndex].Vision);
                }
                else
                {
                    CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, _Location).State = CellMap.States.Visible;
                }
            }

            //for (int dir = 0; dir < _GridType.Directions; dir++)
            //{
            //	CellMap ThisCell = CellMap.Find(_LocationList, _Location.Neighbor(dir).ToAxial());
            //	//	CellMap PrevCell = CellMap.Find(_LocationList, _Location.ToAxial());

            //	if (CellMap.Find(_Nation.Vision, ThisCell.Coords).ID == null)
            //	{
            //		_Nation.Vision.Add(new CellMap(ThisCell.Coords, CellMap.Find(_LocationList, ThisCell.Coords).Properties));
            //		CellMap.Sort(_Nation.Vision);
            //	}
            //	else
            //	{
            //		CellMap.Find(_Nation.Vision, ThisCell.Coords).State = CellMap.States.Shadow;
            //	}
            //}

            CoordinatesText.Text = $"Координаты: {_Location.ToString()}";
        }
Ejemplo n.º 4
0
        private string DrawPath(int Index)
        {
            string  FinalPath = string.Empty;
            CellMap Loc;

            CubeCoord coord = _Location.ToCube();

            for (int i = 0; i < 6; i++)
            {
                if ((Loc = CellMap.Find(_LocationList, coord.Neighbor(i).ToAxial())).ID != null)
                {
                    if (Loc.Properties[Index] != "")
                    {
                        FinalPath += i + 1;
                    }
                }
            }

            if (Index == 1)
            {
                return("Road" + FinalPath);
            }
            else
            {
                return("River" + FinalPath);
            }
        }
Ejemplo n.º 5
0
        private void LoadMap()
        {
            ButtonMapLoad.Enabled       = false;
            ButtonMapScreenShot.Enabled = true;

            _Path = CellMap.Load(_LocationList, @"Resources/Map.txt");
        }
Ejemplo n.º 6
0
        private void MapEditor_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Q)
            {
                _Location = _Location.ToCube().Neighbor((int)CubeCoord.Directions.UpLeft).ToAxial();
            }
            else if (e.KeyCode == Keys.W)
            {
                _Location = _Location.ToCube().Neighbor((int)CubeCoord.Directions.Up).ToAxial();
            }
            else if (e.KeyCode == Keys.E)
            {
                _Location = _Location.ToCube().Neighbor((int)CubeCoord.Directions.UpRight).ToAxial();
            }
            else if (e.KeyCode == Keys.A)
            {
                _Location = _Location.ToCube().Neighbor((int)CubeCoord.Directions.DownLeft).ToAxial();
            }
            else if (e.KeyCode == Keys.S)
            {
                _Location = _Location.ToCube().Neighbor((int)CubeCoord.Directions.Down).ToAxial();
            }
            else if (e.KeyCode == Keys.D)
            {
                _Location = _Location.ToCube().Neighbor((int)CubeCoord.Directions.DownRight).ToAxial();
            }
            else if (e.KeyCode == Keys.R)
            {
                CellMap.Find(_LocationList, _Location).RemoveProp(e.Shift);
            }
            else if (e.KeyCode == Keys.F)
            {
                Edit();
            }
            else if (e.KeyCode == Keys.C)
            {
                _StartPos = new Point((int)Math.Round(MapBox.Width / 2.0), (int)Math.Round(MapBox.Height / 2.0));
                _Location = _Nation[NationSelect.SelectedIndex].NationCoord;
            }

            if (FogOfWarCheck.Checked)
            {
                FogOfWar();
            }

            DrawField();

            CoordinatesText.Text = $"Координаты: {_Location.ToString()}";
        }
Ejemplo n.º 7
0
        private void DrawImage(AxialCoord Pt, int Index, Bitmap SecondImg = null)
        {
            try
            {
                PointF coord = _GridType.Draw(Pt.Subtract(_Location), _StartPos);

                Bitmap Img = (Bitmap)GexesList.Images[Index];

                if (SecondImg != null)
                {
                    Img = ImageAdditions(Img, SecondImg, 200);
                }

                _Gr.DrawImage(Img, (int)Math.Round(coord.X - 32), (int)Math.Round(coord.Y - 28));
            }
            catch
            {
                MessageBox.Show(CellMap.Find(_LocationList, Pt).ToString());
            }
        }
Ejemplo n.º 8
0
        //== ==//
        private void DrawField()
        {
            GC.Collect();
            _Gr.Clear(_Back_Color);

            AxialCoord[] Coord_ = _GridType.СubeSpiral(_Location, 5);

            for (int Loc = 0; Loc < Coord_.Length; Loc++)
            {
                if (FogOfWarCheck.Checked && CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, Coord_[Loc]).State == CellMap.States.Hidden)
                {
                    DrawImage(Coord_[Loc], "Hidden");
                }
                else if (FogOfWarCheck.Checked && CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, Coord_[Loc]).State == CellMap.States.Shadow)
                {
                    for (int Prop = 0; Prop < 3; Prop++)
                    {
                        if (CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, Coord_[Loc]).Properties[Prop] != "")
                        {
                            DrawImage(Coord_[Loc], CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, Coord_[Loc]).Properties[Prop], (Bitmap)GexesList.Images[GexesList.Images.IndexOfKey("Shadow")]);
                        }
                    }
                }
                else
                {
                    for (int Prop = 0; Prop < 3; Prop++)
                    {
                        if (CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, Coord_[Loc]).Properties[Prop] != "")
                        {
                            DrawImage(Coord_[Loc], CellMap.Find(_Nation[NationSelect.SelectedIndex].Vision, Coord_[Loc]).Properties[Prop]);
                        }
                    }
                }
            }

            RefreshMap();
        }
Ejemplo n.º 9
0
 public bool IsBlockVision(CellMap prev) => prev.LevelGround >= HeightTerrain;
Ejemplo n.º 10
0
        private void ButtonSaveMap_Click(object sender, EventArgs e)
        {
            ButtonMapSave.Enabled = false;

            CellMap.Save(_LocationList, _Path);
        }