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()}"; }
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); } }
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); } }
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()}"; }
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()); } }
//== ==// 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(); }