Beispiel #1
0
        private void ClickToPlant(Point NowLocation)
        {
            int m_X, m_Y;

            m_X = MapManager.FixXLocation(NowLocation.X);
            m_Y = MapManager.FixYLocation(NowLocation.Y);
            if (m_X > 8 || m_Y > 4)
            {
                return;
            }
            if (Map_HavePlant[m_X, m_Y] == 0)//判断该点是否已有植物
            {
                Map_HavePlant[m_X, m_Y] = 1;
                plant_1 m_plant = new plant_1();
                switch (NowSettingPlant)
                {
                case plant_1.Plants.sunflower:
                {
                    //m_plant.bitmap = Properties.Resources.SunFlower1;
                    //m_plant.LoadBitmap(@".\bitmaps\Sunflower\");              //对读取路径的多个测试
                    //Graphics M_g = this.CreateGraphics();
                    m_plant = plantFactory.CreatPlant(MapManager.ReturnFixX(m_X), MapManager.ReturnFixY(m_Y), plant_1.Plants.sunflower);        //放置栅格化定位植物位置
                    m_plant.SetFartherForm(this);
                    m_plant.m_g = BufferedGraphics.Graphics;
                    m_plant.SetDrawFactory();

                    break;
                }

                case plant_1.Plants.peashooter:
                {
                    //m_plant.bitmap = Properties.Resources.Peashooter1;
                    //m_plant.LoadBitmap(@".\bitmaps\Peashooter\");
                    //Graphics M_g = this.CreateGraphics();
                    m_plant = plantFactory.CreatPlant(MapManager.ReturnFixX(m_X), MapManager.ReturnFixY(m_Y), plant_1.Plants.peashooter);        //放置栅格化定位植物位置
                    m_plant.SetFartherForm(this);
                    m_plant.m_g = BufferedGraphics.Graphics;
                    m_plant.SetDrawFactory();

                    break;
                }
                }
                plantlist.Add(m_plant);
            }
            else
            {
                return;
            }
        }
Beispiel #2
0
 public void DrawItem(IDrawFactory drawFactory, Graphics g, plant_1 plant)
 {
     drawFactory.TargetDraw(plant.bitmap, g, plant.Location.X, plant.Location.Y);
 }
Beispiel #3
0
        public plant_1 CreatPlant(int X, int Y, plant_1.Plants plants)
        {
            plant_1 newplant = new plant_1(X, Y, plants);

            return(newplant);
        }