예제 #1
0
        /// <summary>
        /// 鼠标移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            foreach (Place p in Globle.AllPlaceList)
            {
                if (Draw.IsPointInPolygon(e.Location, p.Points))
                {
                    if (currentPlace != null && currentPlace != p)//前一个,且当前选择地块变化后则重置
                    {
                        Draw.DrawPlaceHexagon(Globle.G1, currentPlace);
                        //Place sectp = Draw.GetAroundPlaceList(Globle.AllPlaceList, currentPlace).Find(obj => obj.Sect != null);
                        //if (sectp != null)//周围有门派地块,重绘
                        //{
                        //    Draw.DrawPlaceHexagon(Globle.G, sectp);
                        //}
                    }

                    if (Globle.CurrentPathList != null && Globle.CurrentPathList.Count > 0)
                    {
                        foreach (var item in Globle.CurrentPathList)
                        {
                            Draw.DrawPlaceHexagon(Globle.G1, item.Place);//路径地点重绘,删掉线路
                        }
                        Globle.CurrentPathList = null;
                    }

                    if (Globle.IsSelect == true && Globle.StartPlace != null /*&& Globle.StartPlace != currentPlace*/)
                    {
                        List <Place> places = Globle.AllPlaceList.FindAll(obj => obj.TerrainType == 0 || obj.TerrainType == 1);
                        if (places.Contains(currentPlace))
                        {
                            Globle.EndPlace        = currentPlace;                                                    //寻路终点确定
                            Globle.CurrentPathList = AStar.AStarFindPath(Globle.StartPlace, Globle.EndPlace, places); //得到路径
                            Draw.DrawPathLine(Globle.G1, Globle.CurrentPathList, null);
                        }
                    }
                    if (currentPlace != p && Globle.IsSelect == false)//减少不必要的重复绘制
                    {
                        Brush brush = new SolidBrush(Color.FromArgb(50, Color.White));
                        Draw.DrawPlaceHexagon(Globle.G1, p, Pens.White, true, brush);//鼠标位置白色覆盖变化效果
                        brush.Dispose();
                    }
                    currentPlace = p;
                    if (Globle.IsSelect == false)
                    {
                        Globle.StartPlace = null;
                        Globle.EndPlace   = null;
                    }
                    pictureBox1.Invalidate();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// 生成门派按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     //double d= Draw.ComparePoints(Globle.AllPlaceList[29].Coordinate, Globle.AllPlaceList[30].Coordinate);
     if (Globle.AllSectList.Count > 0)
     {
         Globle.AllSectList = new List <Sect>();
         Settings1.Default.Sect_UsedName = "";
     }
     Sect.RandomCreateSectsPlace(Globle.AllPlaceList, 20, Globle.Seed, 10);//生成sect
     for (int i = 0; i < Globle.AllSectList.Count; i++)
     {
         Draw.DrawPlaceHexagon(Globle.G1, Globle.AllSectList[i].SectPlaceList[0]);
     }
     pictureBox1.Refresh();//刷新
 }
예제 #3
0
        /// <summary>
        /// 随机生成place事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            DrawMap();
            textBox1.Text = DateTime.Now.Millisecond.ToString();
            Globle.Seed   = Convert.ToInt32(textBox1.Text);
            List <Place> plainPlaceList = Terrain.GetRandomPlaces(Globle.AllPlaceList, Globle.Seed, 0.6, 8);//生成随机地块数组

            foreach (var p in plainPlaceList)
            {
                p.TerrainType = 0;
            }
            Terrain.SetUnUsedPlacesType(Globle.AllPlaceList);      //设置地块地形
            Draw.DrawPlaceHexagon(Globle.G1, Globle.AllPlaceList); //绘制所有地块
            //随机设置地块区域
            Terrain.SetPlaceDistrict(Globle.AllPlaceList, Globle.Seed);
        }
예제 #4
0
 /// <summary>
 /// 绘制和填充地块六边形,按默认颜色填充传入的所有place
 /// </summary>
 /// <param name="g">绘版</param>
 /// <param name="allPlaces">需填充的place集合</param>
 public static void DrawPlaceHexagon(Graphics g, List <Place> allPlaces)
 {
     foreach (Place p in allPlaces)
     {
         //Draw.DrawRegularPoly(g, p.Coordinate,30,6, Pens.Black, true, Brushes.Green);
         if (p.TerrainType == 0)//plain
         {
             Draw.DrawPlaceHexagon(g, p, Pens.Black, true, Brushes.LightGreen);
         }
         else if (p.TerrainType == 2)//ocean
         {
             Draw.DrawPlaceHexagon(g, p, Pens.Black, true, Brushes.LightSkyBlue);
         }
         else if (p.TerrainType == 1)//lake
         {
             Draw.DrawPlaceHexagon(g, p, Pens.Black, true, Brushes.SkyBlue);
         }
         Brush brush;
         Color color;
         if (p.IsExplore == false)                       //未探索
         {
             color = Color.FromArgb(150, 100, 100, 100); //覆盖
             brush = new SolidBrush(color);
             g.FillPolygon(brush, p.Points);
         }
         if (p.Sect != null)                               //有门派
         {
             color = Color.FromArgb(50, p.Sect.SectColor); //覆盖颜色
             brush = new SolidBrush(p.Sect.SectColor);
             g.FillPolygon(brush, p.Points);
             DrawStringPathAndFill(g, p.Sect.SectName + p.Sect.SectSuffix, null, p.Coordinate, null, true, null);//绘制门派名称
         }
         ////测试点位通过时间
         //if (p.DistrictList != null)
         //    g.DrawString(p.DistrictList.Sum(obj => obj.CrossingTime).ToString(), new Font("黑体", 10), Brushes.White, p.Coordinate);
     }
 }