示例#1
0
        /// <summary>
        /// アリを追加ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void makeAntButton_Click(object sender, RoutedEventArgs e)
        {
            int  antCount = this._antSimulate.AntCount;
            uint antColor = ConstValue.WHITE;

            int x = this._random.Next(int.Parse(antWorldWidthText.Text));
            int y = this._random.Next(int.Parse(antWorldHeightText.Text));

            switch (antCount)
            {
            case 0:
                antColor = ConstValue.WHITE;
                break;

            case 1:
                antColor = ConstValue.RED;
                break;

            case 2:
                antColor = ConstValue.GREEN;
                break;

            case 3:
                antColor = ConstValue.BLUE;
                break;

            case 4:
                antColor = ConstValue.MAGENTA;
                break;

            case 5:
                antColor = ConstValue.YELLOW;
                break;

            case 6:
                antColor = ConstValue.CIAN;
                break;

            default:
                antColor = PaintTool.MakeColor((uint)(this._random.Next(256)), (uint)(this._random.Next(256)), (uint)(this._random.Next(256)), 0);
                break;
            }

            if (!this._antSimulate.AddAnt(x, y, this._random.Next(4), antColor))
            {
                MessageBox.Show("アリの世界がありません", "(´・ω・`)", MessageBoxButton.OK);
                return;
            }

            antCount++;
            antCountValueLabel.Content = antCount.ToString();
        }
示例#2
0
        /// <summary>
        /// アリの自動追加
        /// </summary>
        private void AddAntAuto()
        {
            uint antColor = ConstValue.WHITE;

            int x = this._random.Next(_antWorldWidth);
            int y = this._random.Next(_antWorldHeight);

            switch (this._antTotalCount)
            {
            case 0:
                antColor = ConstValue.WHITE;
                break;

            case 1:
                antColor = ConstValue.RED;
                break;

            case 2:
                antColor = ConstValue.GREEN;
                break;

            case 3:
                antColor = ConstValue.BLUE;
                break;

            case 4:
                antColor = ConstValue.MAGENTA;
                break;

            case 5:
                antColor = ConstValue.YELLOW;
                break;

            case 6:
                antColor = ConstValue.CIAN;
                break;

            default:
                antColor = PaintTool.MakeColor((uint)(this._random.Next(256)), (uint)(this._random.Next(256)), (uint)(this._random.Next(256)), 0);
                break;
            }

            this._antTotalCount++;

            AddAnt(x, y, this._random.Next(4), antColor, this._antlife);
        }
示例#3
0
 /// <summary>
 /// アリの世界を作る
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void MakeAntWorld(int width, int height)
 {
     this._antWorldWidth  = width;
     this._antWorldHeight = height;
     this._antWorldWb     = null;
     this._antWorldWb     = new WriteableBitmap(this._antWorldWidth, this._antWorldHeight, 96, 96, PixelFormats.Bgr32, null);
     PaintTool.PaintFull(ref this._antWorldWb, this._antWorldWidth, this._antWorldHeight, PaintTool.MakeColor(0, 0, 0, 0));
     this._ants = null;
     this._ants = new ArrayList();
 }