Created
December 6, 2012 10:27
-
-
Save kamuflage661/4223525 to your computer and use it in GitHub Desktop.
URSUS MK3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Robot = function(robot) { | |
| //robot.clone(); | |
| }; | |
| var timer = 10; | |
| //scan :1, scannedEnemy:2, escape:3 | |
| var action = 1; | |
| Robot.prototype.onIdle = function(ev) { | |
| var robot = ev.robot; | |
| if(action == 1){ | |
| scan(robot); | |
| }else if(action == 2){ | |
| preciseScan(robot); | |
| } else if (action == 3){ | |
| escape(robot); | |
| action = 1; | |
| } | |
| }; | |
| function scan(robot){ | |
| robot.rotateCannon(1); | |
| } | |
| function preciseScan(robot){ | |
| timer = timer -1; | |
| robot.rotateCannon(5); | |
| robot.rotateCannon(-5); | |
| if(timer == 0) { | |
| timer =10; | |
| action = 1; | |
| } | |
| } | |
| function escape(robot){ | |
| robot.ahead(50); | |
| robot.turn(10); | |
| } | |
| Robot.prototype.onScannedRobot = function(ev) { | |
| var robot = ev.robot; | |
| var scannedRobot = ev.scannedRobot; | |
| if(scannedRobot.parentId == null){ | |
| robot.fire(); | |
| action = 2; | |
| } | |
| }; | |
| Robot.prototype.onHitByBullet = function(ev) { | |
| var robot = ev.robot; | |
| action = 3; | |
| }; | |
| Robot.prototype.onRobotCollision = function(ev) { | |
| var robot = ev.robot; | |
| var collidedRobot = ev.collidedRobot; | |
| if(collidedRobot.parentId == null){ | |
| robot.fire(); | |
| } else { | |
| robot.back(30); | |
| } | |
| }; | |
| Robot.prototype.onWallCollision = function(ev) { | |
| var robot = ev.robot; | |
| action = 1; | |
| robot.turn(5); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment