package game;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.lang.*;
import java.io.*;
//主类
public class Action
{
static int TimeNumber=0;
public static void main(String[] args)
{
ViewFlow vf=new ViewFlow();
vf.addActionlistener();
}
}
==============================================================================
package game;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.lang.*;
import java.io.*;
class MyActionListener2 implements ActionListener//核心类(实现主要功能)
{
static int ip=0;
public void actionPerformed(ActionEvent e2)
{
try
{
Robot robot=new Robot();
int x=73,y=23,
x2=ViewFlow.slider1.getValue(),
y2=23,
x3=228,y3=26,
x4=0,y4=0;
/*
int i=ViewFlow.slider1.getValue(),j=23,k=0;
{
try
{
Robot rb=new Robot();
while(k<1)
{
rb.mouseMove(i,j);
rb.getPixelColor(i,j);
System.out.print((k++)+": "+rb.getPixelColor(i,j)+": ");
System.out.println("(i="+(i++)+",j="+j+");");
}
}
catch(AWTException e3){}
}
*/
if(robot.getPixelColor(x,y).equals(new Color(255,75,53))&&MyActionListener2.ip==1)//自动打怪
{
robot.keyPress(KeyEvent.VK_5);//捡东西
if( robot.getPixelColor(x3,y3).equals(new Color(255,107,87))
||robot.getPixelColor(x3,y3).equals(new Color(255,107,86)))
{
robot.keyPress(KeyEvent.VK_1);//技能1
//robot.keyPress(KeyEvent.VK_2);//技能2
//robot.keyPress(KeyEvent.VK_3);//技能3
//robot.keyPress(KeyEvent.VK_4);//打怪1
}
else
{
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
}
}
//System.out.println(MyActionListener.myTimer.getDelay());//改变加血速度测试
if(!robot.getPixelColor(x,y).equals(new Color(255,75,53)))
{
ViewFlow.setText1("提示:请启动游戏");
//System.out.println(ViewFlow.slider1.getValue());//测试1
//System.out.println(ViewFlow.slider2.getValue());//测试2
}
else if( robot.getPixelColor(x2,y2).equals(new Color(255,75,53)) //加血位置与血的颜色相等
||robot.getPixelColor(x,y).equals(robot.getPixelColor(x2,y2)) //加血位置与指定的理想的血的位置的颜色相等
/*
||robot.getPixelColor(x2,y2).equals(new Color(255,159,147)) //加血位置与指血的颜色1比较
||robot.getPixelColor(x2,y2).equals(new Color(247,193,186)) //加血位置与指血的颜色2比较
||robot.getPixelColor(x2,y2).equals(new Color(228,103,88)) //加血位置与指血的颜色3比较
||robot.getPixelColor(x2,y2).equals(new Color(245,72,51)) //加血位置与指血的颜色4比较
||robot.getPixelColor(x2,y2).equals(new Color(255,183,174)) //加血位置与指血的颜色5比较
||robot.getPixelColor(x2,y2).equals(new Color(228,91,75)) //加血位置与指血的颜色6比较
||robot.getPixelColor(x2,y2).equals(new Color(248,73,52)) //加血位置与指血的颜色7比较
||robot.getPixelColor(x2,y2).equals(new Color(225,195,188)) //加血位置与指血的颜色8比较
||robot.getPixelColor(x2,y2).equals(new Color(235,141,130)) //加血位置与指血的颜