You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 19, 2019. It is now read-only.
function run() {
// 在新线程执行的代码
// 预计时间70秒
var exitTime = new Date().getTime() + 68000;
// 定时点击氮气
var id = setInterval(function () {
robot.click(profile.goldenPoint.x, profile.goldenPoint.y);
var now = new Date().getTime();
if (now > exitTime) {
clearInterval(id);
}
}, 1000);
}
/**
选择关卡
*/
function chooseMode(counter_loop) {
if (!counter_loop){
while (true){
if (check_state() == 3){
toast("选择关卡");
break;
}
else {
// toastLog("isEuro ?= " + check_state());
sleep(200);
}
}
}
function checkForResolution(x, y, img) {
var width = img.getWidth();
var height = img.getHeight();
if (width < height) {
var temp = x;
x = y;
y = temp;
}
return {
positionX: x,
positionY: y
};
}
/**
安卓5机器人
@constructor
*/
function LollipopRobot() {
rootAutomator = new RootAutomator();
this.click = function (x, y) {
// return rootAutomator.tap(x, y);
return Tap(x, y);
};
// 白色 #ffffffff
// 红色 #fffb1264
// 继续 绿色 #ffc3fb12
// 推荐性能分 绿色 #ffc3fc0f
// 广告黑 #ff080906
// 代币蓝 #ff0009ff
// 积分黄 #ffffc600
//选择可用的车,第一列第一张编号为1,第一列第二张为2,第二列第一张为3,依次递增.可根据自己需求修改
//填写车的编号,1920*1080上最多6张车循环,按填写先后顺序用车
const cars = [1,4,2,6,5,3];
/********** 设备 start **********/
const { width, height } = device;
const POWER_SAVE_BRIGHTNESS = 0;
const POWER_SAVE_MUSIC_VOLUME = 0;
const AUTO_BRIGHTNESS_MODE = 1;
const isAutoBrightnessMode = device.getBrightnessMode();
const previousBrightness = device.getBrightness();
const previousMusicVolume = device.getMusicVolume();
/**
*/
const _savePower = () => {
device.setBrightness(POWER_SAVE_BRIGHTNESS);
device.setMusicVolume(POWER_SAVE_MUSIC_VOLUME);
}
/**
*/
const _revertPower = () => {
isAutoBrightnessMode ? device.setBrightnessMode(AUTO_BRIGHTNESS_MODE) : device.setBrightness(previousBrightness);
device.setMusicVolume(previousMusicVolume);
}
/**
/
const enablePowerSave = enable => enable ? _savePower() : _revertPower();
/********* 设备 end **********/
var rootAutomator;
var robot = new Robot();
//1920*1080分辨率
var profile1920 = {
}
var profile;
if (height === 1920 && width == 1080) {
profile = profile1920;
}
else {
toast("该分辨率暂未支持,程序结束");
exit();
}
main();
function main() {
// toast("3秒后将开始运行程序,请迅速切换至游戏主界面");
// sleep(3000);
// toast("开局可能会弹广告,请自己手动关掉,直至保证程序正常选关为止");
deviceInfo();
//beforeRun();
}
function eventListener() {
threads.start(function () {
// 启用按键监听
events.observeKey();
// 监听音量上键按下
events.onKeyDown("volume_down", function (event) {
toastLog("程序手动退出");
if (rootAutomator != null) {
rootAutomator.exit();
}
enablePowerSave(false);
threads.shutDownAll();
exit();
});
});
}
function beforeRun() {
// 判断是否从主页开始
while (true){
}
function deviceInfo() {
auto();
if (!requestScreenCapture()) {
toastLog('请求截图失败,程序结束');
exit();
}
enablePowerSave(true);
}
function loop(counter_loop) {
}
function afterRun(counter_loop) {
sleep(68000);
toastLog(++counter_loop + "场比赛已完成");
/* var counter_next = 0;
// 完成三次结算
while (counter_next <= 2) {
if (check_state() == 5) {
robot.click(profile.goldenPoint.x, profile.goldenPoint.y);
sleep(1500);
counter_next++;
}
else if(check_state() == 9) {
}
function run() {
// 在新线程执行的代码
// 预计时间70秒
var exitTime = new Date().getTime() + 68000;
// 定时点击氮气
var id = setInterval(function () {
robot.click(profile.goldenPoint.x, profile.goldenPoint.y);
var now = new Date().getTime();
if (now > exitTime) {
clearInterval(id);
}
}, 1000);
}
/**
选择关卡
*/
function chooseMode(counter_loop) {
if (!counter_loop){
while (true){
if (check_state() == 3){
toast("选择关卡");
break;
}
else {
// toastLog("isEuro ?= " + check_state());
sleep(200);
}
}
}
sleep(700);
// 向↓滑动,选关
// for (i = 0; i < 4; i++) {
// robot.swipe(height * 2 / 3, 150, height * 2 / 3, 900, 400);
// sleep(200);
// }
profile.swipeScreen();
// toastLog("请在此处截图,截图时不要滑动屏幕");
// exit();
sleep(800);
// 选择第12关
robot.click(profile.block12.x, profile.block12.y);
sleep(500);
// 继续
robot.click(profile.goldenPoint.x, profile.goldenPoint.y);
}
/**
选车
*/
function chooseCar() {
for (let i = 0; i < cars.length; i++) {
let n = cars[i];
// toastLog(n);
var carPoint = {
x: profile.firstCar.x + profile.distance.x * parseInt((n - 1) / 2),
y: profile.firstCar.y + profile.distance.y * ((n - 1) % 2)
}
// toastLog(carPoint.x + "," + carPoint.y);
var img = captureScreen();
var carStatus = images.pixel(img, carPoint.x, carPoint.y);
// toastLog(colors.toString(carStatus));
}
}
function checkForResolution(x, y, img) {
var width = img.getWidth();
var height = img.getHeight();
if (width < height) {
var temp = x;
x = y;
y = temp;
}
}
/**
安卓5机器人
@constructor
*/
function LollipopRobot() {
rootAutomator = new RootAutomator();
this.click = function (x, y) {
// return rootAutomator.tap(x, y);
return Tap(x, y);
};
this.swipe = function (x1, y1, x2, y2, duration) {
// return rootAutomator.swipe(x1, y1, x2, y2, duration);
return Swipe(x1, y1, x2, y2, duration);
};
this.back = function () {
return Back();
}
}
/**
安卓7机器人
@constructortap
*/
function NougatRobot() {
this.click = function (x, y) {
return click(x, y);
};
this.swipe = function (x1, y1, x2, y2, duration) {
return swipe(x1, y1, x2, y2, duration);
};
this.back = function () {
return back();
}
}
/**
机器人工厂
*/
function Robot() {
if (device.sdkInt < 24) {
const hasRoot = files.exists("/sbin/su") || files.exists("/system/xbin/su") || files.exists("/system/bin/su");
if (!hasRoot) {
toast("安卓版本在安卓7以下需要root,程序结束");
exit();
}
this.robot = new LollipopRobot();
} else {
this.robot = new NougatRobot();
}
this.click = function (x, y) {
return this.robot.click(x, y);
};
this.swipe = function (x1, y1, x2, y2, duration) {
return this.robot.swipe(x1, y1, x2, y2, duration);
};
this.back = function () {
return this.robot.back();
};
}
function check_state() {
var img = captureScreen();
}
The text was updated successfully, but these errors were encountered: