Ejemplo n.º 1
0
        /// <summary>
        /// Procon29_Showの初期化を行います。
        /// </summary>
        /// <param name="procon29_Calc">表示する計算機</param>
        /// <param name="pictureBox">表示するピクチャボックス</param>
        public Show(Calc procon29_Calc, PictureBox pictureBox)
        {
            Calc       = procon29_Calc;
            PictureBox = pictureBox;

            // ResourceManagerを取得する
            System.Resources.ResourceManager resource = Properties.Resources.ResourceManager;

            //画像ファイルを読み込んで、Imageオブジェクトとして取得する
            AgentBitmap    = new Bitmap[2];
            AgentBitmap[0] = (Bitmap)resource.GetObject("Orange");
            AgentBitmap[1] = (Bitmap)resource.GetObject("Lime");
            FairyBitmap    = new Bitmap[4];
            FairyBitmap[0] = (Bitmap)resource.GetObject("Strawberry");
            FairyBitmap[1] = (Bitmap)resource.GetObject("Apple");
            FairyBitmap[2] = (Bitmap)resource.GetObject("Kiwi");
            FairyBitmap[3] = (Bitmap)resource.GetObject("Muscat");

            foreach (Team team in Enum.GetValues(typeof(Team)))
            {
                foreach (AgentNumber agent in Enum.GetValues(typeof(AgentNumber)))
                {
                    AgentsActivityData[team, agent] = new AgentActivityData(AgentStatusCode.RequestMovement, Calc.Agents[team, agent].Position);
                }
            }

            ClickField = new ClickField(Calc, PictureBox);
            DrawField  = new DrawField(Calc, new Bitmap(pictureBox.Width, pictureBox.Height));
        }
Ejemplo n.º 2
0
 public Bitmap NoCursorMakePictureBox(PictureBox pictureBox, Bitmap canvas, Graphics graphics, int turn)
 {
     Bitmap                       = canvas;
     DrawField.Bitmap             = canvas;
     DrawField.AgentsActivityData = AgentsActivityData;
     DrawField.Draw(turn);
     return(canvas);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// PictureBoxを新たに生成します。
        /// </summary>
        /// <param name="pictureBox">表示するPictureBox</param>
        /// <param name="canvas">表示するBitmap</param>
        /// <param name="graphics">表示するGraphics</param>
        /// <param name="turn">表示するターン</param>
        /// <returns></returns>
        public Bitmap MakePictureBox(PictureBox pictureBox, Bitmap canvas, Graphics graphics, int turn)
        {
            var fieldWidth  = ((pictureBox.Width <= 0) ? 1 : pictureBox.Width) / Calc.Field.Width;
            var fieldHeight = ((pictureBox.Height <= 0) ? 1 : pictureBox.Height) / Calc.Field.Height;

            Bitmap = canvas;

            var cursor = CursorPosition(PictureBox);

            DrawField.Bitmap             = canvas;
            DrawField.AgentsActivityData = AgentsActivityData;
            DrawField.Draw(turn, cursor);
            precursor = cursor;
            try
            {
                foreach (var agent in Calc.Agents)
                {
                    if (ClickField.ClickedAgent == agent && cursor.ChebyshevDistance(agent.Position) == 1)
                    {
                        DrawField.DrawArrow(agent.Team, agent.Position, cursor);
                        break;
                    }
                    else if (cursor.ChebyshevDistance(agent.Position) == 1 && cursor.ChebyshevDistance(ClickField.ClickedAgent.Position) != 1)
                    {
                        DrawField.DrawArrow(agent.Team, agent.Position, cursor);
                        break;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("フィールドの外です。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(canvas);
        }