Exemple #1
0
        /// <summary>
        /// 生成按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            int    AllStar = 200;
            Random rd      = new Random(DateTime.Now.Second);
            Bitmap pic1    = (Bitmap)pictureBox1.Image;

            bmpWidth = pic1.Width;
            bmpHigth = pic1.Height;
            for (int i = 0; i < AllStar; i++)
            {
                //W:1519 H:657
                int roil   = rd.Next(1, 10);
                int localx = rd.Next(pic1.Width - 10);
                int localy = rd.Next(pic1.Height - 10);
                int direct = rd.Next(0, 360);
                roillist.Add(roil);
                localxlist.Add(localx);
                localylist.Add(localy);
                EarthInfo eif = new EarthInfo(roil, localx, localy, i, direct);
                g_listEarth.Add(eif);
            }
            this.pictureBox1.Invalidate();
            //get all earth
            EarthCacl.calcAllEarthDiss(ref g_listEarth);
        }
Exemple #2
0
        /// <summary>
        /// 融合两个圆点
        /// </summary>
        /// <param name="listData"></param>
        public static void combineEarth(ref List <EarthInfo> listData)
        {
            EarthInfo[] buffTempEti = new EarthInfo[listData.Count];
            int         index       = 0;

            foreach (var eti in listData)
            {
                try
                {
                    if (buffTempEti.Contains(eti) == true)
                    {
                        continue;
                    }
                    foreach (KeyValuePair <string, double> kvp in eti.dictOtherDiss)
                    {
                        EarthInfo tempEti = EarthCacl.getEarthForName(kvp.Key, listData);
                        // if tempEti will move
                        if (buffTempEti.Contains(tempEti) == true)
                        {
                            continue;
                        }
                        if (tempEti.roil + eti.roil >= (int)kvp.Value)
                        {
                            // 发生融合
                            eti.localx = (int)((eti.localx + tempEti.localx) / 2);
                            eti.localy = (int)((eti.localy + tempEti.localy) / 2);
                            eti.calcEarthNewRoil(tempEti.roil);
                            eti.oldName.Add(tempEti.name);
                            //移除这个位
                            buffTempEti[index++] = tempEti;
                        }
                    } //foreach
                }     //try
                catch (Exception)
                {
                    System.Console.Write("name:" + eti.name + " 不存在");
                }
            }// foreach
            foreach (var tt in buffTempEti)
            {
                listData.Remove(tt);
            }
        }