コード例 #1
0
        private IntPtr HotKeyHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            if (msg == WM_HOTKEY)
            {
                var plant1 = new PVZ.Plant((int)NudPlantIndex1.Value);
                var plant2 = new PVZ.Plant((int)NudPlantIndex2.Value);
                switch (wParam.ToInt32())
                {
                case 100:
                    plant1.Row--;
                    break;

                case 101:
                    plant1.Row++;
                    break;

                case 102:
                    plant1.Column--;
                    break;

                case 103:
                    plant1.Column++;
                    break;

                case 104:
                    plant2.Row--;
                    break;

                case 105:
                    plant2.Row++;
                    break;

                case 106:
                    plant2.Column--;
                    break;

                case 107:
                    plant2.Column++;
                    break;
                }
                var pos = new System.Drawing.Point(plant1.Row, plant1.Column);
                PVZ.RCToXY(ref pos);
                plant1.X = pos.X;
                plant1.Y = pos.Y;
                pos      = new System.Drawing.Point(plant2.Row, plant2.Column);
                PVZ.RCToXY(ref pos);
                plant2.X = pos.X;
                plant2.Y = pos.Y;
                Refresh();
            }
            return(IntPtr.Zero);
        }
コード例 #2
0
 private void FindGame_Click(object sender, RoutedEventArgs e)
 {
     PVZ.CloseGame();
     if (PVZ.RunGame())
     {
         (Tag as Window).Title = "已找到游戏";
     }
     else
     {
         (Tag as Window).Title = "未找到游戏";
     }
 }
コード例 #3
0
        private void KeyboardHook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            var plant1 = new PVZ.Plant((int)NudPlantIndex1.Value);
            var plant2 = new PVZ.Plant((int)NudPlantIndex2.Value);

            switch (e.KeyValue)
            {
            case (int)Keys.Up:
                plant1.Row--;
                break;

            case (int)Keys.Down:
                plant1.Row++;
                break;

            case (int)Keys.Left:
                plant1.Column--;
                break;

            case (int)Keys.Right:
                plant1.Column++;
                break;

            case (int)Keys.W:
                plant2.Row--;
                break;

            case (int)Keys.S:
                plant2.Row++;
                break;

            case (int)Keys.A:
                plant2.Column--;
                break;

            case (int)Keys.D:
                plant2.Column++;
                break;
            }
            var pos = new System.Drawing.Point(plant1.Row, plant1.Column);

            PVZ.RCToXY(ref pos);
            plant1.X = pos.X;
            plant1.Y = pos.Y;
            pos      = new System.Drawing.Point(plant2.Row, plant2.Column);
            PVZ.RCToXY(ref pos);
            plant2.X = pos.X;
            plant2.Y = pos.Y;
            Refresh();
        }
コード例 #4
0
 //按钮[布阵]被点击的事件处理器,事件由UserControl.xaml的162行152列挂载
 private void SetFormat_Click(object sender, RoutedEventArgs e)
 {
     //先将游戏场上的所有植物清除
     foreach (var plant in PVZ.AllPlants)
     {
         plant.Exist = false;
     }
     //再将LawnScene中所有的植物种在指定的行列,Fix则是使植物不要动
     foreach (Image item in LawnScene.Children)
     {
         if ((int)item.Tag == (int)PVZ.PlantType.Tallnut)
         {
             PVZ.CreatePlant((PVZ.PlantType)item.Tag, Grid.GetRow(item), (byte)Grid.GetColumn(item)).Fix();
         }
         else
         {
             PVZ.CreatePlant((PVZ.PlantType)item.Tag, Grid.GetRow(item) - 1, (byte)Grid.GetColumn(item)).Fix();
         }
     }
 }
コード例 #5
0
 public static void Main(string[] args)
 {
     PVZ.RunGame();
     PVZ.CreatePlant(PVZ.PlantType.Blover, 0, 2);
     PVZ.CreateZombie(PVZ.ZombieType.Zomboin, 0, 2);
 }
コード例 #6
0
        static void Main(string[] args)
        {
            Clazz        target = pvz;
            bool         isfile = false;
            StreamReader sr     = null;

            if (args.Length >= 1 && args[0].ToUpper().EndsWith(".PVZS"))
            {
                isfile = true;
                sr     = new StreamReader(args[0], Encoding.Default);
                if (args.Length >= 2)
                {
                    PVZ.GameName = args[1];
                }
                if (args.Length >= 3)
                {
                    PVZ.GameTitle = args[2];
                }
            }
            if (PVZ.RunGame())
            {
                Console.WriteLine("PVZScript [版本 2.0.0.5]");
                Console.WriteLine("With PVZClass By 冥谷川恋(Meiyagawa Koishi) [版本 1.0.4.9]");
                Console.WriteLine("StartScript");
                while (true)
                {
                    Interpreter script;
                    if (isfile)
                    {
                        script = new Interpreter(sr.ReadLine());
                    }
                    else
                    {
                        Console.Write(target.Instance.Name + ">>");
                        script = new Interpreter(Console.ReadLine());
                    }
                    var lf = script.IsFor(target);
                    if (lf.Valid)
                    {
                        while (true)
                        {
                            var temp = new Clazz(lf.objs);
                            if (isfile)
                            {
                                script = new Interpreter(sr.ReadLine());
                            }
                            else
                            {
                                Console.Write(temp.Instance.Name + ">>");
                                script = new Interpreter(Console.ReadLine());
                            }
                            if (script.Dealing == "EndFor")
                            {
                                target = pvz;
                                break;
                            }
                            foreach (var item in lf.objs)
                            {
                                target = new Clazz(item);
                                if (!Mainloop(script, ref target, isfile))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (!Mainloop(script, ref target, isfile))
                    {
                        break;
                    }
                }
                PVZ.CloseGame();
            }
        }