Compare commits
89 Commits
liangshawn
...
master
Author | SHA1 | Date |
---|---|---|
![]() |
c8a60b61ab | |
![]() |
2abb17fb2a | |
![]() |
a750f517f8 | |
![]() |
9ea2ce7c39 | |
![]() |
ea56f7703b | |
![]() |
499629a174 | |
![]() |
09eb70541f | |
![]() |
22bca973c9 | |
![]() |
80aaeb5288 | |
![]() |
8de83a6245 | |
![]() |
2dbd928306 | |
![]() |
baa3315df7 | |
![]() |
6687629e85 | |
![]() |
f639d9d3e1 | |
![]() |
8c9f513b35 | |
![]() |
bdbbb305fd | |
![]() |
ea887f280b | |
![]() |
92e6225590 | |
![]() |
4e13437171 | |
![]() |
0834814b9a | |
![]() |
ed407d3129 | |
![]() |
ac3d4364c7 | |
![]() |
6fd462a76e | |
![]() |
da27092d28 | |
![]() |
8e20070a07 | |
![]() |
f8948118bd | |
![]() |
510f51c303 | |
![]() |
a04eb85256 | |
![]() |
d5c0f102d7 | |
![]() |
2e7d5f9fdb | |
![]() |
a661442f94 | |
![]() |
62c8ddd3f0 | |
|
ade31c7f50 | |
![]() |
0679bddf0b | |
![]() |
a7fad02107 | |
|
909839b4ec | |
|
9e827864ef | |
|
2bc998a290 | |
|
d9b7ed8e0f | |
![]() |
bb59db6867 | |
![]() |
27ca01fea9 | |
![]() |
4402a27f5d | |
![]() |
da1104c10c | |
![]() |
bccf1bc9b1 | |
![]() |
52dc88f7e0 | |
![]() |
07fd4ac9c8 | |
|
80d198777c | |
|
72d31f0fae | |
|
72f1b998ac | |
![]() |
9db2ee6127 | |
![]() |
923e6a1a58 | |
![]() |
40d7a56d23 | |
![]() |
e8b545d55a | |
|
d5740acf90 | |
|
e825b1b219 | |
|
c663b87709 | |
|
884b71721d | |
![]() |
46217e8275 | |
![]() |
d5cd1a6b3d | |
![]() |
1d5f0aad08 | |
|
cc6cbb98f1 | |
|
4c04c28b5b | |
![]() |
d974e4b4b4 | |
![]() |
316f891873 | |
|
d4ce4fe6da | |
|
e8fbb18cf0 | |
|
04d40c636d | |
![]() |
7b06d38064 | |
|
0746f606f0 | |
|
759678eb8c | |
![]() |
6dbb1da167 | |
![]() |
e2dc6a6019 | |
![]() |
88878d2fc6 | |
![]() |
4278e1e696 | |
![]() |
6471effdae | |
![]() |
ecdbf0829d | |
![]() |
4f24e8c195 | |
|
8caf8c0c3d | |
|
6a946da64d | |
|
4d9a75cac1 | |
|
f89346e981 | |
![]() |
450816a390 | |
![]() |
f97bd58fae | |
![]() |
96d304112c | |
![]() |
ff97ccfd1d | |
![]() |
d2229cb09d | |
![]() |
d17eab5a30 | |
![]() |
f7d471f18f | |
|
4eeecd15ed |
Binary file not shown.
Binary file not shown.
|
@ -1,149 +0,0 @@
|
|||
package com.pandafighter;
|
||||
import robocode.*;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.Color;
|
||||
public class pandafighter extends AdvancedRobot
|
||||
{
|
||||
double moveDirection;
|
||||
enemyStat enemy = new enemyStat();
|
||||
public void run()
|
||||
{
|
||||
setBodyColor(Color.black);
|
||||
setGunColor(Color.WHITE);
|
||||
setRadarColor(Color.WHITE);
|
||||
setScanColor(Color.BLACK);
|
||||
setBulletColor(Color.YELLOW);
|
||||
setAdjustGunForRobotTurn(true);
|
||||
setAdjustRadarForGunTurn(true);
|
||||
setTurnRadarRightRadians(2*Math.PI); //让雷达一直转
|
||||
while(true)
|
||||
{
|
||||
doFire();
|
||||
doScannedRobot();
|
||||
doMovement() ;
|
||||
execute();
|
||||
}
|
||||
}
|
||||
public void onScannedRobot(ScannedRobotEvent e)
|
||||
{
|
||||
enemy.updateStat(e, this);
|
||||
}
|
||||
public void doMovement()//随机移动
|
||||
{ //程序首先判断运动是否完成,若完成,随机选出一个座标点,移动到该点
|
||||
if( Math.abs( getDistanceRemaining() ) < 1 )
|
||||
{
|
||||
double myX = getX();
|
||||
double myY = getY();
|
||||
double nextX, nextY; // the next point move to
|
||||
nextX = Math.random() * ( getBattleFieldWidth() - 100 ) + 50;
|
||||
nextY = Math.random() * ( getBattleFieldHeight() - 100 ) + 50;
|
||||
double turnAngle =getAngle(myX,myY,nextX,nextY );
|
||||
turnAngle = normalizeBearing( turnAngle - getHeadingRadians() );
|
||||
double moveDistance = Point2D.distance( myX, myY, nextX, nextY );
|
||||
double moveDirection = 1;
|
||||
if ( Math.abs( turnAngle ) >Math.PI/2)
|
||||
{
|
||||
turnAngle = normalizeBearing( turnAngle + Math.PI);
|
||||
moveDirection *= -1;
|
||||
}
|
||||
setTurnRightRadians( turnAngle );
|
||||
setAhead( moveDirection * moveDistance ); }
|
||||
}
|
||||
public static double getAngle(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
return Math.atan2( x2 - x1, y2 - y1 );
|
||||
}
|
||||
public void doScannedRobot()
|
||||
{
|
||||
if (getTime()-enemy.time>1)
|
||||
{
|
||||
setTurnRadarRightRadians(3*Math.PI);
|
||||
}
|
||||
else
|
||||
{
|
||||
double absolation_bearing=(getHeadingRadians()+enemy.relative_bearing)%(2*Math.PI);
|
||||
double relative_radar_bearing=getRadarHeadingRadians()-absolation_bearing;
|
||||
double a=normalizeBearing(relative_radar_bearing);
|
||||
setTurnRadarLeftRadians(a);
|
||||
}
|
||||
}
|
||||
public double normalizeBearing( double angle )
|
||||
{
|
||||
if ( angle < -Math.PI )
|
||||
angle += 2*Math.PI;
|
||||
if ( angle > Math.PI )
|
||||
angle -= 2*Math.PI;
|
||||
return angle;
|
||||
}
|
||||
public void doFire()
|
||||
{
|
||||
double heading_offset=enemy.en_heading-enemy.pre_heading+0.000001;
|
||||
double distance=enemy.distance;
|
||||
double bullet_velocity=20-3*3;
|
||||
double r=enemy.velocity/heading_offset;
|
||||
double heading=0.0;
|
||||
for(int i=0;i<4;i++)//迭代 使预测更加准确
|
||||
{
|
||||
double b_travel_ti=distance/bullet_velocity;
|
||||
double predict_heading_r=enemy.en_heading+heading_offset*b_travel_ti;
|
||||
double predict_x=enemy.xCoordinate-r*Math.cos(predict_heading_r)+r*Math.cos(enemy.en_heading);
|
||||
double predict_y=enemy.yCoordinate+r*Math.sin(predict_heading_r)-r*Math.sin(enemy.en_heading);
|
||||
heading=Math.atan2(predict_x-getX(),predict_y-getY());
|
||||
double diatance=Point2D.distance( getX(), getY(), predict_x, predict_y );
|
||||
}
|
||||
double a=normalizeBearing(heading-getGunHeadingRadians());
|
||||
setTurnGunRightRadians(a);
|
||||
setFire(3);
|
||||
}
|
||||
public void onHitByBullet(HitByBulletEvent e)
|
||||
{
|
||||
if(getX()>150&&getY()>150&&enemy.battle_w-getX()>150&&enemy.battle_h-getY()>150)
|
||||
{
|
||||
double dist=150;
|
||||
double a=normalizeBearing(90 - (getHeading() - e.getHeading()));
|
||||
if(Math.abs(a)>Math.PI/2)
|
||||
{
|
||||
a=normalizeBearing(a+Math.PI);
|
||||
}
|
||||
setTurnRight( a);
|
||||
setAhead(dist);
|
||||
dist *= -1;
|
||||
}
|
||||
}
|
||||
public void onWin(WinEvent e)
|
||||
{
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
turnGunRightRadians(Math.PI*3/4);
|
||||
turnGunLeftRadians(Math.PI*3/4);
|
||||
}
|
||||
}
|
||||
}
|
||||
class enemyStat //方法
|
||||
|
||||
{ public double pre_heading;
|
||||
public double en_heading;
|
||||
double xCoordinate;
|
||||
double yCoordinate;
|
||||
double direction;
|
||||
double battle_h;
|
||||
double battle_w;
|
||||
double relative_bearing;
|
||||
double velocity;
|
||||
double time;
|
||||
double distance;
|
||||
public void updateStat(ScannedRobotEvent e,AdvancedRobot ar)
|
||||
{
|
||||
pre_heading=en_heading;
|
||||
en_heading=e.getHeadingRadians();
|
||||
battle_h=ar.getBattleFieldHeight();
|
||||
battle_w=ar.getBattleFieldWidth();
|
||||
relative_bearing=e.getBearingRadians();
|
||||
direction = relative_bearing + ar.getHeadingRadians();
|
||||
xCoordinate= ar.getX() + Math.sin( direction ) * distance;
|
||||
yCoordinate = ar.getY() + Math.cos( direction ) *distance;
|
||||
velocity=e.getVelocity();
|
||||
time=e.getTime();
|
||||
distance=e.getDistance();
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
package net.sf.robocode.test.robotscs;
|
||||
|
||||
|
||||
import net.sf.robocode.test.helpers.Assert;
|
||||
import net.sf.robocode.test.helpers.RobocodeTestBed;
|
||||
|
||||
import robocode.control.events.TurnEndedEvent;
|
||||
|
||||
|
||||
/**
|
||||
* @author Flemming N. Larsen (original)
|
||||
*/
|
||||
public class TestMaxTurnRate extends RobocodeTestBed {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
@Override
|
||||
public String getRobotNames() {
|
||||
return "tested.robotscs.MaxTurnRate,SampleCs.Target";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitialPositions() {
|
||||
return "(50,50,0), (150,50,0)"; // Make sure the robots do not collide!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTurnEnded(TurnEndedEvent event) {
|
||||
super.onTurnEnded(event);
|
||||
|
||||
buf.append(event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot());
|
||||
|
||||
if (event.getTurnSnapshot().getTurn() == 26) {
|
||||
final String out = buf.toString();
|
||||
|
||||
Assert.assertTrue(out.contains("1: 0.0, 0.0") || out.contains("1: 0.0, -0.0"));
|
||||
Assert.assertTrue(out.contains("2: 0.0, -1.0") || out.contains("2: 0.0, -0.999999999"));
|
||||
Assert.assertTrue(out.contains("3: 0.0, -2.0") || out.contains("3: 0.0, -1.999999999"));
|
||||
Assert.assertTrue(out.contains("4: 0.0, -3.0") || out.contains("4: 0.0, -2.999999999"));
|
||||
Assert.assertTrue(out.contains("5: 0.0, -4.0") || out.contains("5: 0.0, -3.999999999"));
|
||||
Assert.assertTrue(out.contains("6: 0.0, -5.0") || out.contains("6: 0.0, -4.999999999"));
|
||||
Assert.assertTrue(out.contains("7: 0.0, -6.0") || out.contains("7: 0.0, -5.999999999"));
|
||||
Assert.assertTrue(out.contains("8: 0.0, -7.0") || out.contains("8: 0.0, -6.999999999"));
|
||||
Assert.assertTrue(out.contains("9: 0.0, -8.0") || out.contains("9: 0.0, -7.999999999"));
|
||||
Assert.assertTrue(out.contains("10: 0.0, -9.0") || out.contains("10: 0.0, -8.999999999"));
|
||||
Assert.assertTrue(out.contains("11: 0.0, -10.0") || out.contains("11: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("12: 0.0, -10.0") || out.contains("12: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("13: 0.0, -10.0") || out.contains("13: 0.0, -9.999999999"));
|
||||
|
||||
Assert.assertTrue(out.contains("14: 0.0, 0.0") || out.contains("14: 0.0, -0.0"));
|
||||
Assert.assertTrue(out.contains("15: 0.0, 1.0") || out.contains("15: 0.0, 0.999999999"));
|
||||
Assert.assertTrue(out.contains("16: 0.0, 2.0") || out.contains("16: 0.0, 1.999999999"));
|
||||
Assert.assertTrue(out.contains("17: 0.0, 3.0") || out.contains("17: 0.0, 2.999999999"));
|
||||
Assert.assertTrue(out.contains("18: 0.0, 4.0") || out.contains("18: 0.0, 3.999999999"));
|
||||
Assert.assertTrue(out.contains("19: 0.0, 5.0") || out.contains("19: 0.0, 4.999999999"));
|
||||
Assert.assertTrue(out.contains("20: 0.0, 6.0") || out.contains("20: 0.0, 5.999999999"));
|
||||
Assert.assertTrue(out.contains("21: 0.0, 7.0") || out.contains("21: 0.0, 6.999999999"));
|
||||
Assert.assertTrue(out.contains("22: 0.0, 8.0") || out.contains("22: 0.0, 7.999999999"));
|
||||
Assert.assertTrue(out.contains("23: 0.0, 9.0") || out.contains("23: 0.0, 8.999999999"));
|
||||
Assert.assertTrue(out.contains("24: 0.0, 10.0") || out.contains("24: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("25: 0.0, 10.0") || out.contains("25: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("26: 0.0, 10.0") || out.contains("26: 0.0, 9.999999999"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>robocode.api</name>
|
||||
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Launch Dir Builder.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,188 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
package robocode;
|
||||
|
||||
|
||||
import robocode.robotinterfaces.ITeamEvents;
|
||||
import robocode.robotinterfaces.ITeamRobot;
|
||||
import robocode.robotinterfaces.peer.ITeamRobotPeer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
/**
|
||||
* An advanced type of robot that supports sending messages between team
|
||||
* mates in a robot team.
|
||||
* <p/>
|
||||
* If you have not done already, you should create a {@link Robot} or
|
||||
* {@link AdvancedRobot} first.
|
||||
*
|
||||
* @see JuniorRobot
|
||||
* @see Robot
|
||||
* @see AdvancedRobot
|
||||
* @see RateControlRobot
|
||||
* @see Droid
|
||||
* @see BorderSentry
|
||||
*
|
||||
* @author Mathew A. Nelson (original)
|
||||
* @author Flemming N. Larsen (contributor)
|
||||
* @author Pavel Savara (contributor)
|
||||
*/
|
||||
public class TeamRobot extends AdvancedRobot implements ITeamRobot, ITeamEvents {
|
||||
|
||||
/**
|
||||
* Broadcasts a message to all teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void run() {
|
||||
* broadcastMessage("I'm here!");
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param message the message to broadcast to all teammates
|
||||
* @throws IOException if the message could not be broadcasted to the
|
||||
* teammates
|
||||
* @see #isTeammate(String)
|
||||
* @see #getTeammates()
|
||||
* @see #sendMessage(String, Serializable)
|
||||
*/
|
||||
public void broadcastMessage(Serializable message) throws IOException {
|
||||
if (peer != null) {
|
||||
((ITeamRobotPeer) peer).broadcastMessage(message);
|
||||
} else {
|
||||
uninitializedException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector containing all MessageEvents currently in the robot's
|
||||
* queue. You might, for example, call this while processing another event.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* for (MessageEvent e : getMessageEvents()) {
|
||||
* // do something with e
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @return a vector containing all MessageEvents currently in the robot's
|
||||
* queue
|
||||
* @see #onMessageReceived(MessageEvent)
|
||||
* @see MessageEvent
|
||||
* @since 1.2.6
|
||||
*/
|
||||
public Vector<MessageEvent> getMessageEvents() {
|
||||
if (peer != null) {
|
||||
return new Vector<MessageEvent>(((ITeamRobotPeer) peer).getMessageEvents());
|
||||
}
|
||||
uninitializedException();
|
||||
return null; // never called
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not call this method!
|
||||
* <p/>
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public final ITeamEvents getTeamEventListener() {
|
||||
return this; // this robot is listening
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of all teammates, or {@code null} there is no
|
||||
* teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void run() {
|
||||
* // Prints out all teammates
|
||||
* String[] teammates = getTeammates();
|
||||
* if (teammates != null) {
|
||||
* for (String member : teammates) {
|
||||
* out.println(member);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @return a String array containing the names of all your teammates, or
|
||||
* {@code null} if there is no teammates. The length of the String array
|
||||
* is equal to the number of teammates.
|
||||
* @see #isTeammate(String)
|
||||
* @see #broadcastMessage(Serializable)
|
||||
* @see #sendMessage(String, Serializable)
|
||||
*/
|
||||
public String[] getTeammates() {
|
||||
if (peer != null) {
|
||||
return ((ITeamRobotPeer) peer).getTeammates();
|
||||
}
|
||||
uninitializedException();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given robot name is the name of one of your teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void onScannedRobot(ScannedRobotEvent e) {
|
||||
* if (isTeammate(e.getName()) {
|
||||
* return;
|
||||
* }
|
||||
* fire(1);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param name the robot name to check
|
||||
* @return {@code true} if the specified name belongs to one of your
|
||||
* teammates; {@code false} otherwise.
|
||||
* @see #getTeammates()
|
||||
* @see #broadcastMessage(Serializable)
|
||||
* @see #sendMessage(String, Serializable)
|
||||
*/
|
||||
public boolean isTeammate(String name) {
|
||||
if (peer != null) {
|
||||
return ((ITeamRobotPeer) peer).isTeammate(name);
|
||||
}
|
||||
uninitializedException();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void onMessageReceived(MessageEvent event) {}
|
||||
|
||||
/**
|
||||
* Sends a message to one (or more) teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void run() {
|
||||
* sendMessage("sample.DroidBot", "I'm here!");
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param name the name of the intended recipient of the message
|
||||
* @param message the message to send
|
||||
* @throws IOException if the message could not be sent
|
||||
* @see #isTeammate(String)
|
||||
* @see #getTeammates()
|
||||
* @see #broadcastMessage(Serializable)
|
||||
*/
|
||||
public void sendMessage(String name, Serializable message) throws IOException {
|
||||
if (peer != null) {
|
||||
((ITeamRobotPeer) peer).sendMessage(name, message);
|
||||
} else {
|
||||
uninitializedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
package robocode.robotinterfaces.peer;
|
||||
|
||||
|
||||
import robocode.MessageEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* The team robot peer for team robots like {@link robocode.TeamRobot}.
|
||||
* <p/>
|
||||
* A robot peer is the object that deals with game mechanics and rules, and
|
||||
* makes sure your robot abides by them.
|
||||
*
|
||||
* @see IBasicRobotPeer
|
||||
* @see IStandardRobotPeer
|
||||
* @see IAdvancedRobotPeer
|
||||
* @see IJuniorRobotPeer
|
||||
*
|
||||
* @author Pavel Savara (original)
|
||||
* @author Flemming N. Larsen (contributor)
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ITeamRobotPeer extends IAdvancedRobotPeer {
|
||||
|
||||
/**
|
||||
* Returns the names of all teammates, or {@code null} there is no
|
||||
* teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void run() {
|
||||
* // Prints out all teammates
|
||||
* String[] teammates = getTeammates();
|
||||
* if (teammates != null) {
|
||||
* for (String member : teammates) {
|
||||
* out.println(member);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @return a String array containing the names of all your teammates, or
|
||||
* {@code null} if there is no teammates. The length of the String array
|
||||
* is equal to the number of teammates.
|
||||
* @see #isTeammate(String)
|
||||
* @see #broadcastMessage(Serializable)
|
||||
* @see #sendMessage(String, Serializable)
|
||||
*/
|
||||
String[] getTeammates();
|
||||
|
||||
/**
|
||||
* Checks if a given robot name is the name of one of your teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void onScannedRobot(ScannedRobotEvent e) {
|
||||
* if (isTeammate(e.getName()) {
|
||||
* return;
|
||||
* }
|
||||
* fire(1);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param name the robot name to check
|
||||
* @return {@code true} if the specified name belongs to one of your
|
||||
* teammates; {@code false} otherwise.
|
||||
* @see #getTeammates()
|
||||
* @see #broadcastMessage(Serializable)
|
||||
* @see #sendMessage(String, Serializable)
|
||||
*/
|
||||
boolean isTeammate(String name);
|
||||
|
||||
/**
|
||||
* Broadcasts a message to all teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void run() {
|
||||
* broadcastMessage("I'm here!");
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param message the message to broadcast to all teammates
|
||||
* @throws IOException if the message could not be broadcasted to the
|
||||
* teammates
|
||||
* @see #isTeammate(String)
|
||||
* @see #getTeammates()
|
||||
* @see #sendMessage(String, Serializable)
|
||||
*/
|
||||
void broadcastMessage(Serializable message) throws IOException;
|
||||
|
||||
/**
|
||||
* Sends a message to one (or more) teammates.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void run() {
|
||||
* sendMessage("sample.DroidBot", "I'm here!");
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param name the name of the intended recipient of the message
|
||||
* @param message the message to send
|
||||
* @throws IOException if the message could not be sent
|
||||
* @see #isTeammate(String)
|
||||
* @see #getTeammates()
|
||||
* @see #broadcastMessage(Serializable)
|
||||
*/
|
||||
void sendMessage(String name, Serializable message) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a vector containing all MessageEvents currently in the robot's
|
||||
* queue. You might, for example, call this while processing another event.
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* for (MessageEvent e : getMessageEvents()) {
|
||||
* // do something with e
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @return a vector containing all MessageEvents currently in the robot's
|
||||
* queue
|
||||
* @see robocode.robotinterfaces.ITeamEvents#onMessageReceived(MessageEvent)
|
||||
* onMessageReceived(MessageEvent)
|
||||
* @see MessageEvent
|
||||
* @since 1.2.6
|
||||
*/
|
||||
List<MessageEvent> getMessageEvents();
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>robocode.content</name>
|
||||
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects>
|
||||
<project>robocode.samples</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java" />
|
||||
<classpathentry kind="src" path="src/main/resources"
|
||||
excluding="**/_svn/**|**/.svn/**|**/.git/**|**/*.java" />
|
||||
<classpathentry kind="output" path="target/classes" />
|
||||
<classpathentry kind="con"
|
||||
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" />
|
||||
<classpathentry kind="src" path="/robocode.api" />
|
||||
<classpathentry kind="src" path="/robocode.core" />
|
||||
<classpathentry kind="var"
|
||||
path="M2_REPO/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar" />
|
||||
<classpathentry kind="src" path="/robocode.battle" />
|
||||
<classpathentry kind="src" path="/robocode.host" />
|
||||
<classpathentry kind="src" path="/robocode.repository" />
|
||||
<classpathentry kind="var"
|
||||
path="M2_REPO/net/sf/robocode/codesize/1.1/codesize-1.1.jar" />
|
||||
<classpathentry kind="src" path="/robocode.sound" />
|
||||
</classpath>
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>robocode.ui</name>
|
||||
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the
|
||||
maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects>
|
||||
<project>robocode.api</project>
|
||||
<project>robocode.core</project>
|
||||
<project>robocode.battle</project>
|
||||
<project>robocode.host</project>
|
||||
<project>robocode.repository</project>
|
||||
<project>robocode.sound</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,9 +0,0 @@
|
|||
#Tue Nov 27 22:12:09 CET 2012
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -1,218 +0,0 @@
|
|||
<!--
|
||||
|
||||
Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://robocode.sourceforge.net/license/epl-v10.html
|
||||
|
||||
-->
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
background-color: lightgray;
|
||||
font-family: sans-serif;
|
||||
font-size: 9px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 11px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.contributor {
|
||||
font-weight: bold;
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="{$background-color}" leftmargin="5px" topmargin="5px"
|
||||
marginwidth="5px" marginheight="5px">
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td><img src="{$robocode-icon-url}" align="middle"></td>
|
||||
<td class="title"> Robocode version
|
||||
{$robocode-version}
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td><img src="{$transparent}" width="1" height="5" border="0"></td>
|
||||
</tr>
|
||||
</table> © Copyright 2001-2016 Robocode contributors. All
|
||||
rights reserved.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td><img src="{$transparent}" width="1" height="3" border="0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<strong>Original Author:</strong>
|
||||
<span class="contributor">Mathew A. Nelson</span>.
|
||||
|
||||
<strong>Original Graphics:</strong>
|
||||
<span class="contributor">Garett S. Hourihan</span>.
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td><img src="{$transparent}" width="1" height="10" border="0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Running on
|
||||
<strong>Java {$java-version}</strong> by
|
||||
{$java-vendor} |
|
||||
<a href="http://www.java.com/en/download/index.jsp">Download</a> |
|
||||
<a href="http://docs.oracle.com/javase/6/docs/api/">Java 6 API
|
||||
documentation</a>
|
||||
<br>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td><img src="{$transparent}" width="1" height="10" border="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="black"><img src="{$transparent}" width="1"
|
||||
height="2" border="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="{$transparent}" width="1" height="4" border="0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a href="http://robocode.sourceforge.net/docs/ReadMe.html">ReadMe</a>
|
||||
|
|
||||
<a href="http://robocode.sourceforge.net/license/epl-v10.html">License</a>
|
||||
|
|
||||
<a href="http://robocode.sourceforge.net/">Home Page</a> |
|
||||
<a href="http://sourceforge.net/projects/robocode/">Project Home</a>
|
||||
|
|
||||
<a href="http://github.com/robo-code/robocode/blob/master/versions.md">Versions</a>
|
||||
|
|
||||
<a href="http://robo-code.blogspot.com/">News</a> |
|
||||
<a href="http://robowiki.net">RoboWiki</a> |
|
||||
<a href="http://robocoderepository.com/">Robocode Repository</a>
|
||||
|
|
||||
<a
|
||||
href="https://groups.google.com/forum/?fromgroups#!forum/robocode-developers">Robocode
|
||||
Developers</a>
|
||||
<br>
|
||||
<a href="http://sourceforge.net/projects/robocode/files/">Download</a>
|
||||
|
|
||||
<a
|
||||
href="http://robowiki.net/w/index.php?title=Robocode/Getting_Started">Getting
|
||||
started</a> |
|
||||
<a href="http://robocode.sourceforge.net/docs/robocode/">Java API</a>
|
||||
|
|
||||
<a
|
||||
href="http://robocode.sourceforge.net/docs/robocode.dotnet/Index.html">.NET
|
||||
API</a> |
|
||||
<a href="http://robowiki.net/w/index.php?title=Robocode/FAQ">FAQ</a>
|
||||
|
|
||||
<a href="https://groups.google.com/forum/?fromgroups#!forum/robocode">Google
|
||||
Group</a> |
|
||||
<a href="http://sourceforge.net/p/robocode/discussion/116459/">Help
|
||||
Forum</a> |
|
||||
<a href="http://sourceforge.net/p/robocode/bugs/">Bug Reports</a>
|
||||
|
|
||||
<a href="http://sourceforge.net/p/robocode/feature-requests/">Feature
|
||||
Requests</a>
|
||||
|
||||
<h2>Main Contributors</h2>
|
||||
<span class="contributor">Mathew A. Nelson</span>: Original developer
|
||||
(2001-2005)
|
||||
<br>
|
||||
<span class="contributor">Flemming N. Larsen</span>: Administrator,
|
||||
developer, integrator, lots of features (2005-2016)
|
||||
<br>
|
||||
<span class="contributor">Pavel Savara</span>: Administrator,
|
||||
developer, integrator, robot interfaces, refactorings, .NET plugin
|
||||
(2008-2011)
|
||||
<br>
|
||||
|
||||
<h2>Contributors</h2>
|
||||
<span class="contributor">Aaron Rotenberg</span>: Robot Cache Cleaner
|
||||
utility
|
||||
<br>
|
||||
<span class="contributor">Albert Perez</span>: RoboRumble@Home client
|
||||
<br>
|
||||
<span class="contributor">Alexander Schultz</span>: Reporting lots of
|
||||
bugs and good solutions for fixing these
|
||||
<br>
|
||||
<span class="contributor">Ascander Jr</span>: Graphics for background
|
||||
tiles
|
||||
<br>
|
||||
<span class="contributor">Christian D. Schnell</span>: Codesize 1.0
|
||||
utility
|
||||
<br>
|
||||
<span class="contributor">Cubic Creative</span>: Design and ideas for
|
||||
the JuniorRobot class
|
||||
<br>
|
||||
<span class="contributor">Dan Lynn</span>: The Robocode Repository that
|
||||
is the central place for storing your robots and also find other robots
|
||||
<br>
|
||||
<span class="contributor">Endre Palatinus</span>,
|
||||
<span class="contributor">Eniko Nagy</span>,
|
||||
<span class="contributor">Attila Csizofszki</span> and
|
||||
<span class="contributor">Laszlo Vigh</span>: Score percentage in
|
||||
results/rankings
|
||||
<br>
|
||||
<span class="contributor">Jerome Lavigne</span>: Added "Smart Battles"
|
||||
to MeleeRumble, developer and admin of the RoboRumble server
|
||||
<br>
|
||||
<span class="contributor">Joachim Hofer</span>: Fixing problem with
|
||||
wrong results in RoboRumble
|
||||
<br>
|
||||
<span class="contributor">Joshua Galecki</span>: Added the
|
||||
RateControlRobot
|
||||
<br>
|
||||
<span class="contributor">Julian Kent</span>: Nano precision timing of
|
||||
allowed robot time
|
||||
<br>
|
||||
<span class="contributor">Luis Crespo</span>: Sound engine, single-step
|
||||
debugging, ranking panel
|
||||
<br>
|
||||
<span class="contributor">Matthew Reeder</span>: Editor enhancements,
|
||||
keyboard shortcuts, HyperThreading bugfixes
|
||||
<br>
|
||||
<span class="contributor">Nathaniel Troutman</span>: Fixing memory
|
||||
leaks
|
||||
<br>
|
||||
<span class="contributor">Patrick Cupka</span>,
|
||||
<span class="contributor">Julian Kent</span>,
|
||||
<span class="contributor">Nat Pavasant</span>, and
|
||||
<span class="contributor">"Positive"</span>: Redesigned robot movement
|
||||
method
|
||||
<br>
|
||||
<span class="contributor">Robert D. Maupin</span>: Optimizations with
|
||||
collections and improved CPU constant benchmark
|
||||
<br>
|
||||
<span class="contributor">Ruben Moreno Montoliu</span>: Added paths
|
||||
with buttons to Developement Options
|
||||
<br>
|
||||
<span class="contributor">Stefan Westen</span>: onPaint method from
|
||||
RobocodeSG
|
||||
<br>
|
||||
<span class="contributor">Titus Chen</span>: Bugfixes for robot
|
||||
teleportation, bad wall collision detection, team ranking, replay
|
||||
scores and robot color flickering
|
||||
<br>
|
||||
<span class="contributor">Tuan Anh Nguyen</span>: Interactive_v2 sample
|
||||
robot
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td><img src="{$transparent}" width="1" height="10" border="0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<strong>Thanks goes to every contributor as well to all users
|
||||
reporting bugs and suggesting new features for Robocode.</strong>
|
||||
</body>
|
|
@ -3,9 +3,9 @@ target
|
|||
build.xml
|
||||
maven-build.xml
|
||||
maven-build.properties
|
||||
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.sln
|
||||
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.suo
|
||||
ucdetector_reports
|
||||
/plugins/dotnet/*.suo
|
||||
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.sln
|
||||
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.suo
|
||||
ucdetector_reports
|
||||
/plugins/dotnet/*.suo
|
||||
*.class
|
||||
.recommenders
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>RemoteSystemsTempFiles</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,17 +1,17 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
|
||||
@rem NOTE: Here we expect jacobe.exe to be installed on system PATH
|
||||
|
||||
@echo off
|
||||
if exist "%~dp0\tools\lib\jacobe.jar" goto jacobe
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
|
||||
:jacobe
|
||||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
|
||||
@rem NOTE: Here we expect jacobe.exe to be installed on system PATH
|
||||
|
||||
@echo off
|
||||
if exist "%~dp0\tools\lib\jacobe.jar" goto jacobe
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
|
||||
:jacobe
|
||||
call "%~dp0\tools\bin\ant.bat" -buildfile "%~dp0\tools\jacobe\build.xml"
|
|
@ -1,15 +1,15 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
if not exist "%~dp0\tools\lib\maven-*-uber.jar" (
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
)
|
||||
|
||||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
if not exist "%~dp0\tools\lib\maven-*-uber.jar" (
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
)
|
||||
|
||||
call "%~dp0\tools\bin\mvn.bat" %*
|
|
@ -1,12 +1,12 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
mvn clean install ant:ant -DskipTests=false %*
|
||||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
mvn clean install ant:ant -DskipTests=false %*
|
||||
rem mvn eclipse:eclipse
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>plugins</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>plugins</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,41 +1,41 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
rem set JAVA_HOME=%JDK6_HOME%
|
||||
rem set PATH=%JAVA_HOME%\bin;%PATH%
|
||||
|
||||
set NET_FRAMEWORK_HOME=C:\Windows\Microsoft.NET\Framework\v3.5
|
||||
set PATH=%NET_FRAMEWORK_HOME%;%PATH%
|
||||
|
||||
if exist "%~dp0\tools\lib\proxygen.exe" goto gen
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
|
||||
:gen
|
||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.control.proxygen.xml
|
||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.xml
|
||||
|
||||
if exist "%~dp0\robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll" goto gen1
|
||||
echo cat't find robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll, please compile it
|
||||
goto end
|
||||
|
||||
:gen1
|
||||
if exist "%~dp0\tools\lib\robocode.dll" goto gen3
|
||||
if exist "%~dp0\robocode.dotnet.api\target\robocode.dll" goto gen2
|
||||
echo cat't find \robocode.dotnet.api\target\robocode.dll, please compile it
|
||||
goto end
|
||||
|
||||
:gen2
|
||||
|
||||
copy "%~dp0\robocode.dotnet.api\target\robocode.dll" "%~dp0\tools\lib"
|
||||
|
||||
:gen3
|
||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.net.xml
|
||||
|
||||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
rem set JAVA_HOME=%JDK6_HOME%
|
||||
rem set PATH=%JAVA_HOME%\bin;%PATH%
|
||||
|
||||
set NET_FRAMEWORK_HOME=C:\Windows\Microsoft.NET\Framework\v3.5
|
||||
set PATH=%NET_FRAMEWORK_HOME%;%PATH%
|
||||
|
||||
if exist "%~dp0\tools\lib\proxygen.exe" goto gen
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
|
||||
:gen
|
||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.control.proxygen.xml
|
||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.xml
|
||||
|
||||
if exist "%~dp0\robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll" goto gen1
|
||||
echo cat't find robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll, please compile it
|
||||
goto end
|
||||
|
||||
:gen1
|
||||
if exist "%~dp0\tools\lib\robocode.dll" goto gen3
|
||||
if exist "%~dp0\robocode.dotnet.api\target\robocode.dll" goto gen2
|
||||
echo cat't find \robocode.dotnet.api\target\robocode.dll, please compile it
|
||||
goto end
|
||||
|
||||
:gen2
|
||||
|
||||
copy "%~dp0\robocode.dotnet.api\target\robocode.dll" "%~dp0\tools\lib"
|
||||
|
||||
:gen3
|
||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.net.xml
|
||||
|
||||
:end
|
|
@ -1,20 +1,20 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
if not exist "%~dp0\tools\lib" (
|
||||
mkdir "%~dp0\tools\lib"
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
)
|
||||
|
||||
if not exist "%~dp0\..\..\tools\lib\maven-*-uber.jar" (
|
||||
call "%~dp0\..\..\tools\loadTools.cmd"
|
||||
)
|
||||
|
||||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
if not exist "%~dp0\tools\lib" (
|
||||
mkdir "%~dp0\tools\lib"
|
||||
call "%~dp0\tools\loadTools.cmd"
|
||||
)
|
||||
|
||||
if not exist "%~dp0\..\..\tools\lib\maven-*-uber.jar" (
|
||||
call "%~dp0\..\..\tools\loadTools.cmd"
|
||||
)
|
||||
|
||||
call "%~dp0\..\..\mvn" %*
|
|
@ -1,12 +1,12 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
mvn clean install ant:ant -DskipTests=false %*
|
||||
@REM
|
||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are made available under the terms of the Eclipse Public License v1.0
|
||||
@REM which accompanies this distribution, and is available at
|
||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
mvn clean install ant:ant -DskipTests=false %*
|
||||
rem mvn eclipse:eclipse
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>robocode.dotnet.api</name>
|
||||
<comment>.NET Robot API for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects/>
|
||||
<buildSpec/>
|
||||
<natures/>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>robocode.dotnet.api</name>
|
||||
<comment>.NET Robot API for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects/>
|
||||
<buildSpec/>
|
||||
<natures/>
|
||||
</projectDescription>
|
|
@ -1,10 +1,10 @@
|
|||
#Tue Nov 27 22:34:10 CET 2012
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
#Tue Nov 27 22:34:10 CET 2012
|
||||
encoding/src/test/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
encoding/src/main/resources=8859_1
|
||||
encoding/src/main/java=8859_1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
eclipse.preferences.version=1
|
||||
encoding/src/test/resources=8859_1
|
||||
encoding/src=8859_1
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,87 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<!-- The configuration and platform will be used to determine which
|
||||
assemblies to include from solution and project documentation
|
||||
sources -->
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{90f0d09b-f58d-4f2e-ac8a-164d89979ef1}</ProjectGuid>
|
||||
<SHFBSchemaVersion>1.9.5.0</SHFBSchemaVersion>
|
||||
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
|
||||
Studio adds them anyway -->
|
||||
<AssemblyName>Documentation</AssemblyName>
|
||||
<RootNamespace>Documentation</RootNamespace>
|
||||
<Name>Documentation</Name>
|
||||
<!-- SHFB properties -->
|
||||
<OutputPath>.\target\Help\</OutputPath>
|
||||
<HtmlHelpName>RobotAPI</HtmlHelpName>
|
||||
<DocumentationSources>
|
||||
<DocumentationSource sourceFile="target\robocode.dll" xmlns="" />
|
||||
<DocumentationSource sourceFile="target\robocode.xml" xmlns="" />
|
||||
</DocumentationSources>
|
||||
<MissingTags>AutoDocumentCtors, AutoDocumentDispose</MissingTags>
|
||||
<HelpTitle>Robocode Robot API for .NET</HelpTitle>
|
||||
<FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
|
||||
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
|
||||
<ApiFilter>
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.io" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.nio" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.peer" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.security" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.serialization" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="robocode" isExposed="True">
|
||||
<Filter entryType="Class" fullName="robocode.Keys" filterName="Keys" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="robocode.exception" isExposed="True">
|
||||
<Filter entryType="Class" fullName="robocode.exception.EventInterruptedException" filterName="EventInterruptedException" isExposed="False" />
|
||||
<Filter entryType="Class" fullName="robocode.exception.RobotException" filterName="RobotException" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="System" isExposed="True">
|
||||
<Filter entryType="Class" fullName="System.Attribute" filterName="Attribute" isExposed="False" />
|
||||
<Filter entryType="Class" fullName="System.Exception" filterName="Exception" isExposed="False" />
|
||||
<Filter entryType="Class" fullName="System.Object" filterName="Object" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="System.Security" isExposed="True">
|
||||
<Filter entryType="Class" fullName="System.Security.CodeAccessPermission" filterName="CodeAccessPermission" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="System.Security.Permissions" isExposed="True">
|
||||
<Filter entryType="Class" fullName="System.Security.Permissions.SecurityAttribute" filterName="SecurityAttribute" isExposed="False" />
|
||||
</Filter>
|
||||
</ApiFilter>
|
||||
<VisibleItems>InheritedMembers, Protected, SealedProtected</VisibleItems>
|
||||
<NamespaceSummaries>
|
||||
<NamespaceSummaryItem name="robocode" isDocumented="True" xmlns="">Robot API used for writing robots for Robocode</NamespaceSummaryItem>
|
||||
<NamespaceSummaryItem name="robocode.robotinterfaces" isDocumented="True" xmlns="">Robot Interfaces used for creating new robot types, e.g. with other programming languages.</NamespaceSummaryItem>
|
||||
<NamespaceSummaryItem name="robocode.robotinterfaces.peer" isDocumented="True" xmlns="">Robot peers available for implementing new robot types based on the Robot Interfaces.</NamespaceSummaryItem>
|
||||
<NamespaceSummaryItem name="robocode.util" isDocumented="True" xmlns="">Utility classes that can be used when writing robots. Kept for compatibility with legacy robots.</NamespaceSummaryItem>
|
||||
</NamespaceSummaries>
|
||||
<ProjectSummary>Robocode Robot API for .NET</ProjectSummary>
|
||||
<CopyrightText>Copyright %28c%29 2001-2016 Mathew A. Nelson and Robocode contributors</CopyrightText>
|
||||
<FeedbackEMailAddress>fnl%40users.sourceforge.net</FeedbackEMailAddress>
|
||||
<FeedbackEMailLinkText>administator and maintainer of Robocode</FeedbackEMailLinkText>
|
||||
<PresentationStyle>vs2010</PresentationStyle>
|
||||
</PropertyGroup>
|
||||
<!-- There are no properties for these groups. AnyCPU needs to appear in
|
||||
order for Visual Studio to perform the build. The others are optional
|
||||
common platform types that may appear. -->
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
|
||||
</PropertyGroup>
|
||||
<!-- Import the SHFB build targets -->
|
||||
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<!-- The configuration and platform will be used to determine which
|
||||
assemblies to include from solution and project documentation
|
||||
sources -->
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{90f0d09b-f58d-4f2e-ac8a-164d89979ef1}</ProjectGuid>
|
||||
<SHFBSchemaVersion>1.9.5.0</SHFBSchemaVersion>
|
||||
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
|
||||
Studio adds them anyway -->
|
||||
<AssemblyName>Documentation</AssemblyName>
|
||||
<RootNamespace>Documentation</RootNamespace>
|
||||
<Name>Documentation</Name>
|
||||
<!-- SHFB properties -->
|
||||
<OutputPath>.\target\Help\</OutputPath>
|
||||
<HtmlHelpName>RobotAPI</HtmlHelpName>
|
||||
<DocumentationSources>
|
||||
<DocumentationSource sourceFile="target\robocode.dll" xmlns="" />
|
||||
<DocumentationSource sourceFile="target\robocode.xml" xmlns="" />
|
||||
</DocumentationSources>
|
||||
<MissingTags>AutoDocumentCtors, AutoDocumentDispose</MissingTags>
|
||||
<HelpTitle>Robocode Robot API for .NET</HelpTitle>
|
||||
<FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
|
||||
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
|
||||
<ApiFilter>
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.io" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.nio" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.peer" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.security" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="net.sf.robocode.serialization" isExposed="False" />
|
||||
<Filter entryType="Namespace" fullName="robocode" isExposed="True">
|
||||
<Filter entryType="Class" fullName="robocode.Keys" filterName="Keys" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="robocode.exception" isExposed="True">
|
||||
<Filter entryType="Class" fullName="robocode.exception.EventInterruptedException" filterName="EventInterruptedException" isExposed="False" />
|
||||
<Filter entryType="Class" fullName="robocode.exception.RobotException" filterName="RobotException" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="System" isExposed="True">
|
||||
<Filter entryType="Class" fullName="System.Attribute" filterName="Attribute" isExposed="False" />
|
||||
<Filter entryType="Class" fullName="System.Exception" filterName="Exception" isExposed="False" />
|
||||
<Filter entryType="Class" fullName="System.Object" filterName="Object" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="System.Security" isExposed="True">
|
||||
<Filter entryType="Class" fullName="System.Security.CodeAccessPermission" filterName="CodeAccessPermission" isExposed="False" />
|
||||
</Filter>
|
||||
<Filter entryType="Namespace" fullName="System.Security.Permissions" isExposed="True">
|
||||
<Filter entryType="Class" fullName="System.Security.Permissions.SecurityAttribute" filterName="SecurityAttribute" isExposed="False" />
|
||||
</Filter>
|
||||
</ApiFilter>
|
||||
<VisibleItems>InheritedMembers, Protected, SealedProtected</VisibleItems>
|
||||
<NamespaceSummaries>
|
||||
<NamespaceSummaryItem name="robocode" isDocumented="True" xmlns="">Robot API used for writing robots for Robocode</NamespaceSummaryItem>
|
||||
<NamespaceSummaryItem name="robocode.robotinterfaces" isDocumented="True" xmlns="">Robot Interfaces used for creating new robot types, e.g. with other programming languages.</NamespaceSummaryItem>
|
||||
<NamespaceSummaryItem name="robocode.robotinterfaces.peer" isDocumented="True" xmlns="">Robot peers available for implementing new robot types based on the Robot Interfaces.</NamespaceSummaryItem>
|
||||
<NamespaceSummaryItem name="robocode.util" isDocumented="True" xmlns="">Utility classes that can be used when writing robots. Kept for compatibility with legacy robots.</NamespaceSummaryItem>
|
||||
</NamespaceSummaries>
|
||||
<ProjectSummary>Robocode Robot API for .NET</ProjectSummary>
|
||||
<CopyrightText>Copyright %28c%29 2001-2016 Mathew A. Nelson and Robocode contributors</CopyrightText>
|
||||
<FeedbackEMailAddress>fnl%40users.sourceforge.net</FeedbackEMailAddress>
|
||||
<FeedbackEMailLinkText>administator and maintainer of Robocode</FeedbackEMailLinkText>
|
||||
<PresentationStyle>vs2010</PresentationStyle>
|
||||
</PropertyGroup>
|
||||
<!-- There are no properties for these groups. AnyCPU needs to appear in
|
||||
order for Visual Studio to perform the build. The others are optional
|
||||
common platform types that may appear. -->
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
|
||||
</PropertyGroup>
|
||||
<!-- Import the SHFB build targets -->
|
||||
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
|
||||
</Project>
|
|
@ -1,3 +1,3 @@
|
|||
/obj
|
||||
/robocode.dotnet.api.sln
|
||||
/robocode.dotnet.api.suo
|
||||
/robocode.dotnet.api.sln
|
||||
/robocode.dotnet.api.suo
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System.Security;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System.Security;
|
||||
|
||||
[assembly: AllowPartiallyTrustedCallers]
|
|
@ -1,132 +1,132 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using net.sf.robocode.security;
|
||||
|
||||
namespace net.sf.robocode.io
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
///<summary>
|
||||
/// This is a class used for logging.
|
||||
///</summary>
|
||||
/// <exclude/>
|
||||
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
||||
public class LoggerN
|
||||
{
|
||||
public static TextWriter realOut = Console.Out;
|
||||
public static TextWriter realErr = Console.Error;
|
||||
public static TextWriter robotOut = Console.Out;
|
||||
|
||||
private static ILoggerN logListener;
|
||||
private static readonly StringBuilder logBuffer = new StringBuilder();
|
||||
[ThreadStatic] public static bool IsSafeThread;
|
||||
|
||||
public static void setLogListener(ILoggerN logListener)
|
||||
{
|
||||
LoggerN.logListener = logListener;
|
||||
}
|
||||
|
||||
public static void logMessage(string s)
|
||||
{
|
||||
logMessage(s, true);
|
||||
}
|
||||
|
||||
public static void logMessage(Exception e)
|
||||
{
|
||||
logMessage(e.StackTrace);
|
||||
}
|
||||
|
||||
public static void logMessage(string message, Exception t)
|
||||
{
|
||||
logMessage(message + ":\n" + t.StackTrace);
|
||||
}
|
||||
|
||||
public static void logError(string message, Exception t)
|
||||
{
|
||||
logError(message + ":\n" + t.StackTrace);
|
||||
}
|
||||
|
||||
public static void logError(Exception t)
|
||||
{
|
||||
logError(t.StackTrace);
|
||||
}
|
||||
|
||||
public static void logMessage(string s, bool newline)
|
||||
{
|
||||
if (logListener == null)
|
||||
{
|
||||
if (newline)
|
||||
{
|
||||
realOut.WriteLine(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
realOut.Write(s);
|
||||
realOut.Flush();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (logBuffer)
|
||||
{
|
||||
if (!IsSafeThread)
|
||||
{
|
||||
// we just queue it, to not let unsafe thread travel thru system
|
||||
logBuffer.Append(s);
|
||||
logBuffer.Append("\n");
|
||||
}
|
||||
else if (newline)
|
||||
{
|
||||
logMessage(logBuffer + s, true);
|
||||
logBuffer.Length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
logBuffer.Append(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void logError(string s)
|
||||
{
|
||||
if (logListener == null)
|
||||
{
|
||||
realErr.WriteLine(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
logListener.logError(s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteLineToRobotsConsole(string s)
|
||||
{
|
||||
if (robotOut != null)
|
||||
{
|
||||
robotOut.WriteLine(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
logMessage(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
public interface ILoggerN
|
||||
{
|
||||
void logMessage(string s, bool newline);
|
||||
void logError(string s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using net.sf.robocode.security;
|
||||
|
||||
namespace net.sf.robocode.io
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
///<summary>
|
||||
/// This is a class used for logging.
|
||||
///</summary>
|
||||
/// <exclude/>
|
||||
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
||||
public class LoggerN
|
||||
{
|
||||
public static TextWriter realOut = Console.Out;
|
||||
public static TextWriter realErr = Console.Error;
|
||||
public static TextWriter robotOut = Console.Out;
|
||||
|
||||
private static ILoggerN logListener;
|
||||
private static readonly StringBuilder logBuffer = new StringBuilder();
|
||||
[ThreadStatic] public static bool IsSafeThread;
|
||||
|
||||
public static void setLogListener(ILoggerN logListener)
|
||||
{
|
||||
LoggerN.logListener = logListener;
|
||||
}
|
||||
|
||||
public static void logMessage(string s)
|
||||
{
|
||||
logMessage(s, true);
|
||||
}
|
||||
|
||||
public static void logMessage(Exception e)
|
||||
{
|
||||
logMessage(e.StackTrace);
|
||||
}
|
||||
|
||||
public static void logMessage(string message, Exception t)
|
||||
{
|
||||
logMessage(message + ":\n" + t.StackTrace);
|
||||
}
|
||||
|
||||
public static void logError(string message, Exception t)
|
||||
{
|
||||
logError(message + ":\n" + t.StackTrace);
|
||||
}
|
||||
|
||||
public static void logError(Exception t)
|
||||
{
|
||||
logError(t.StackTrace);
|
||||
}
|
||||
|
||||
public static void logMessage(string s, bool newline)
|
||||
{
|
||||
if (logListener == null)
|
||||
{
|
||||
if (newline)
|
||||
{
|
||||
realOut.WriteLine(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
realOut.Write(s);
|
||||
realOut.Flush();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (logBuffer)
|
||||
{
|
||||
if (!IsSafeThread)
|
||||
{
|
||||
// we just queue it, to not let unsafe thread travel thru system
|
||||
logBuffer.Append(s);
|
||||
logBuffer.Append("\n");
|
||||
}
|
||||
else if (newline)
|
||||
{
|
||||
logMessage(logBuffer + s, true);
|
||||
logBuffer.Length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
logBuffer.Append(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void logError(string s)
|
||||
{
|
||||
if (logListener == null)
|
||||
{
|
||||
realErr.WriteLine(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
logListener.logError(s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteLineToRobotsConsole(string s)
|
||||
{
|
||||
if (robotOut != null)
|
||||
{
|
||||
robotOut.WriteLine(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
logMessage(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
public interface ILoggerN
|
||||
{
|
||||
void logMessage(string s, bool newline);
|
||||
void logError(string s);
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,380 +1,380 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
// This class is based on the source code from Sun's Java 1.5.0 API for java.nio.HeapByteBuffer, but
|
||||
// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode.
|
||||
|
||||
using System;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace net.sf.robocode.nio
|
||||
{
|
||||
/// <summary>
|
||||
/// A read/write HeapByteBuffer.
|
||||
/// </summary>
|
||||
/// <exclude/>
|
||||
internal class HeapByteBuffer : ByteBuffer
|
||||
{
|
||||
internal HeapByteBuffer(int cap, int lim)
|
||||
: base(-1, 0, lim, cap, new byte[cap], 0)
|
||||
{
|
||||
}
|
||||
|
||||
internal HeapByteBuffer(byte[] buf, int off, int len)
|
||||
: base(-1, off, off + len, buf.Length, buf, 0)
|
||||
{
|
||||
}
|
||||
|
||||
protected HeapByteBuffer(byte[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
: base(mark, pos, lim, cap, buf, off)
|
||||
{
|
||||
}
|
||||
|
||||
public override ByteBuffer slice()
|
||||
{
|
||||
return new HeapByteBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
remaining(),
|
||||
remaining(),
|
||||
position() + _offset);
|
||||
}
|
||||
|
||||
public override ByteBuffer duplicate()
|
||||
{
|
||||
return new HeapByteBuffer(hb,
|
||||
markValue(),
|
||||
position(),
|
||||
limit(),
|
||||
capacity(),
|
||||
_offset);
|
||||
}
|
||||
|
||||
public override ByteBuffer asReadOnlyBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
protected int ix(int i)
|
||||
{
|
||||
return i + _offset;
|
||||
}
|
||||
|
||||
public override byte get()
|
||||
{
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public override byte get(int i)
|
||||
{
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
public override ByteBuffer get(byte[] dst, int offset, int length)
|
||||
{
|
||||
checkBounds(offset, length, dst.Length);
|
||||
if (length > remaining())
|
||||
throw new BufferUnderflowException();
|
||||
Array.Copy(hb, ix(position()), dst, offset, length);
|
||||
position(position() + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override bool isDirect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override bool isReadOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(byte x)
|
||||
{
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(int i, byte x)
|
||||
{
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(byte[] src, int offset, int length)
|
||||
{
|
||||
checkBounds(offset, length, src.Length);
|
||||
if (length > remaining())
|
||||
throw new BufferOverflowException();
|
||||
Array.Copy(src, offset, hb, ix(position()), length);
|
||||
position(position() + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(ByteBuffer src)
|
||||
{
|
||||
if (src is HeapByteBuffer)
|
||||
{
|
||||
if (src == this)
|
||||
throw new ArgumentException();
|
||||
var sb = (HeapByteBuffer) src;
|
||||
int n = sb.remaining();
|
||||
if (n > remaining())
|
||||
throw new BufferOverflowException();
|
||||
Array.Copy(sb.hb, sb.ix(sb.position()),
|
||||
hb, ix(position()), n);
|
||||
sb.position(sb.position() + n);
|
||||
position(position() + n);
|
||||
}
|
||||
else if (src.isDirect())
|
||||
{
|
||||
int n = src.remaining();
|
||||
if (n > remaining())
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(position()), n);
|
||||
position(position() + n);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.put(src);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer compact()
|
||||
{
|
||||
Array.Copy(hb, ix(position()), hb, ix(0), remaining());
|
||||
position(remaining());
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
internal override byte _get(int i)
|
||||
{
|
||||
return hb[i];
|
||||
}
|
||||
|
||||
internal override void _put(int i, byte b)
|
||||
{
|
||||
hb[i] = b;
|
||||
}
|
||||
|
||||
public override char getChar()
|
||||
{
|
||||
return BitConverter.ToChar(hb, ix(nextGetIndex(2)));
|
||||
}
|
||||
|
||||
public override char getChar(int i)
|
||||
{
|
||||
return BitConverter.ToChar(hb, ix(checkIndex(i, 2)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putChar(char x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putChar(int i, char x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asCharBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override short getShort()
|
||||
{
|
||||
return BitConverter.ToInt16(hb, ix(nextGetIndex(2)));
|
||||
}
|
||||
|
||||
public override short getShort(int i)
|
||||
{
|
||||
return BitConverter.ToInt16(hb, ix(checkIndex(i, 2)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putShort(short x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putShort(int i, short x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asShortBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override int getInt()
|
||||
{
|
||||
return BitConverter.ToInt32(hb, ix(nextGetIndex(4)));
|
||||
}
|
||||
|
||||
public override int getInt(int i)
|
||||
{
|
||||
return BitConverter.ToInt32(hb, ix(checkIndex(i, 4)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putInt(int x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putInt(int i, int x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asIntBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// long
|
||||
|
||||
|
||||
public override long getLong()
|
||||
{
|
||||
return BitConverter.ToInt64(hb, ix(nextGetIndex(8)));
|
||||
}
|
||||
|
||||
public override long getLong(int i)
|
||||
{
|
||||
return BitConverter.ToInt64(hb, ix(checkIndex(i, 8)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putLong(long x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putLong(int i, long x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asLongBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// float
|
||||
|
||||
|
||||
public override float getFloat()
|
||||
{
|
||||
return BitConverter.ToSingle(hb, ix(nextGetIndex(4)));
|
||||
}
|
||||
|
||||
public override float getFloat(int i)
|
||||
{
|
||||
return BitConverter.ToSingle(hb, ix(checkIndex(i, 4)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putFloat(float x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putFloat(int i, float x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asFloatBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// double
|
||||
|
||||
|
||||
public override double getDouble()
|
||||
{
|
||||
return BitConverter.ToDouble(hb, ix(nextGetIndex(8)));
|
||||
}
|
||||
|
||||
public override double getDouble(int i)
|
||||
{
|
||||
return BitConverter.ToDouble(hb, ix(checkIndex(i, 8)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putDouble(double x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putDouble(int i, double x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asDoubleBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
// This class is based on the source code from Sun's Java 1.5.0 API for java.nio.HeapByteBuffer, but
|
||||
// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode.
|
||||
|
||||
using System;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace net.sf.robocode.nio
|
||||
{
|
||||
/// <summary>
|
||||
/// A read/write HeapByteBuffer.
|
||||
/// </summary>
|
||||
/// <exclude/>
|
||||
internal class HeapByteBuffer : ByteBuffer
|
||||
{
|
||||
internal HeapByteBuffer(int cap, int lim)
|
||||
: base(-1, 0, lim, cap, new byte[cap], 0)
|
||||
{
|
||||
}
|
||||
|
||||
internal HeapByteBuffer(byte[] buf, int off, int len)
|
||||
: base(-1, off, off + len, buf.Length, buf, 0)
|
||||
{
|
||||
}
|
||||
|
||||
protected HeapByteBuffer(byte[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
: base(mark, pos, lim, cap, buf, off)
|
||||
{
|
||||
}
|
||||
|
||||
public override ByteBuffer slice()
|
||||
{
|
||||
return new HeapByteBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
remaining(),
|
||||
remaining(),
|
||||
position() + _offset);
|
||||
}
|
||||
|
||||
public override ByteBuffer duplicate()
|
||||
{
|
||||
return new HeapByteBuffer(hb,
|
||||
markValue(),
|
||||
position(),
|
||||
limit(),
|
||||
capacity(),
|
||||
_offset);
|
||||
}
|
||||
|
||||
public override ByteBuffer asReadOnlyBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
protected int ix(int i)
|
||||
{
|
||||
return i + _offset;
|
||||
}
|
||||
|
||||
public override byte get()
|
||||
{
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public override byte get(int i)
|
||||
{
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
public override ByteBuffer get(byte[] dst, int offset, int length)
|
||||
{
|
||||
checkBounds(offset, length, dst.Length);
|
||||
if (length > remaining())
|
||||
throw new BufferUnderflowException();
|
||||
Array.Copy(hb, ix(position()), dst, offset, length);
|
||||
position(position() + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override bool isDirect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override bool isReadOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(byte x)
|
||||
{
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(int i, byte x)
|
||||
{
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(byte[] src, int offset, int length)
|
||||
{
|
||||
checkBounds(offset, length, src.Length);
|
||||
if (length > remaining())
|
||||
throw new BufferOverflowException();
|
||||
Array.Copy(src, offset, hb, ix(position()), length);
|
||||
position(position() + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer put(ByteBuffer src)
|
||||
{
|
||||
if (src is HeapByteBuffer)
|
||||
{
|
||||
if (src == this)
|
||||
throw new ArgumentException();
|
||||
var sb = (HeapByteBuffer) src;
|
||||
int n = sb.remaining();
|
||||
if (n > remaining())
|
||||
throw new BufferOverflowException();
|
||||
Array.Copy(sb.hb, sb.ix(sb.position()),
|
||||
hb, ix(position()), n);
|
||||
sb.position(sb.position() + n);
|
||||
position(position() + n);
|
||||
}
|
||||
else if (src.isDirect())
|
||||
{
|
||||
int n = src.remaining();
|
||||
if (n > remaining())
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(position()), n);
|
||||
position(position() + n);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.put(src);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer compact()
|
||||
{
|
||||
Array.Copy(hb, ix(position()), hb, ix(0), remaining());
|
||||
position(remaining());
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
internal override byte _get(int i)
|
||||
{
|
||||
return hb[i];
|
||||
}
|
||||
|
||||
internal override void _put(int i, byte b)
|
||||
{
|
||||
hb[i] = b;
|
||||
}
|
||||
|
||||
public override char getChar()
|
||||
{
|
||||
return BitConverter.ToChar(hb, ix(nextGetIndex(2)));
|
||||
}
|
||||
|
||||
public override char getChar(int i)
|
||||
{
|
||||
return BitConverter.ToChar(hb, ix(checkIndex(i, 2)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putChar(char x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putChar(int i, char x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asCharBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override short getShort()
|
||||
{
|
||||
return BitConverter.ToInt16(hb, ix(nextGetIndex(2)));
|
||||
}
|
||||
|
||||
public override short getShort(int i)
|
||||
{
|
||||
return BitConverter.ToInt16(hb, ix(checkIndex(i, 2)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putShort(short x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putShort(int i, short x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 2));
|
||||
Array.Copy(bytes, 0, hb, index, 2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asShortBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override int getInt()
|
||||
{
|
||||
return BitConverter.ToInt32(hb, ix(nextGetIndex(4)));
|
||||
}
|
||||
|
||||
public override int getInt(int i)
|
||||
{
|
||||
return BitConverter.ToInt32(hb, ix(checkIndex(i, 4)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putInt(int x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putInt(int i, int x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asIntBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// long
|
||||
|
||||
|
||||
public override long getLong()
|
||||
{
|
||||
return BitConverter.ToInt64(hb, ix(nextGetIndex(8)));
|
||||
}
|
||||
|
||||
public override long getLong(int i)
|
||||
{
|
||||
return BitConverter.ToInt64(hb, ix(checkIndex(i, 8)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putLong(long x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putLong(int i, long x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asLongBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// float
|
||||
|
||||
|
||||
public override float getFloat()
|
||||
{
|
||||
return BitConverter.ToSingle(hb, ix(nextGetIndex(4)));
|
||||
}
|
||||
|
||||
public override float getFloat(int i)
|
||||
{
|
||||
return BitConverter.ToSingle(hb, ix(checkIndex(i, 4)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putFloat(float x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putFloat(int i, float x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 4));
|
||||
Array.Copy(bytes, 0, hb, index, 4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asFloatBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// double
|
||||
|
||||
|
||||
public override double getDouble()
|
||||
{
|
||||
return BitConverter.ToDouble(hb, ix(nextGetIndex(8)));
|
||||
}
|
||||
|
||||
public override double getDouble(int i)
|
||||
{
|
||||
return BitConverter.ToDouble(hb, ix(checkIndex(i, 8)));
|
||||
}
|
||||
|
||||
|
||||
public override ByteBuffer putDouble(double x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(nextPutIndex(8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ByteBuffer putDouble(int i, double x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
int index = ix(checkIndex(i, 8));
|
||||
Array.Copy(bytes, 0, hb, index, 8);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Buffer asDoubleBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,116 +1,116 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace net.sf.robocode.nio
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class InvalidMarkException : Exception
|
||||
{
|
||||
public InvalidMarkException()
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidMarkException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidMarkException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected InvalidMarkException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class BufferUnderflowException : Exception
|
||||
{
|
||||
public BufferUnderflowException()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferUnderflowException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public BufferUnderflowException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected BufferUnderflowException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class BufferOverflowException : Exception
|
||||
{
|
||||
public BufferOverflowException()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferOverflowException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public BufferOverflowException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected BufferOverflowException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class ReadOnlyBufferException : Exception
|
||||
{
|
||||
public ReadOnlyBufferException()
|
||||
{
|
||||
}
|
||||
|
||||
public ReadOnlyBufferException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ReadOnlyBufferException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected ReadOnlyBufferException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace net.sf.robocode.nio
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class InvalidMarkException : Exception
|
||||
{
|
||||
public InvalidMarkException()
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidMarkException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidMarkException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected InvalidMarkException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class BufferUnderflowException : Exception
|
||||
{
|
||||
public BufferUnderflowException()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferUnderflowException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public BufferUnderflowException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected BufferUnderflowException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class BufferOverflowException : Exception
|
||||
{
|
||||
public BufferOverflowException()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferOverflowException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public BufferOverflowException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected BufferOverflowException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public class ReadOnlyBufferException : Exception
|
||||
{
|
||||
public ReadOnlyBufferException()
|
||||
{
|
||||
}
|
||||
|
||||
public ReadOnlyBufferException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ReadOnlyBufferException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
protected ReadOnlyBufferException(SerializationInfo info,
|
||||
StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace net.sf.robocode.peer
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
|
||||
/// <exclude/>
|
||||
public interface IRobotStaticsN
|
||||
{
|
||||
bool IsInteractiveRobot();
|
||||
|
||||
bool IsPaintRobot();
|
||||
|
||||
bool IsAdvancedRobot();
|
||||
|
||||
bool IsTeamRobot();
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace net.sf.robocode.peer
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
|
||||
/// <exclude/>
|
||||
public interface IRobotStaticsN
|
||||
{
|
||||
bool IsInteractiveRobot();
|
||||
|
||||
bool IsPaintRobot();
|
||||
|
||||
bool IsAdvancedRobot();
|
||||
|
||||
bool IsTeamRobot();
|
||||
}
|
||||
}
|
|
@ -1,131 +1,131 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using net.sf.robocode.io;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
||||
public class HiddenAccessN
|
||||
{
|
||||
private static IHiddenEventHelper eventHelper;
|
||||
private static IHiddenBulletHelper bulletHelper;
|
||||
private static IHiddenStatusHelper statusHelper;
|
||||
private static IHiddenRulesHelper rulesHelper;
|
||||
private static bool initialized;
|
||||
public static IHiddenRandomHelper randomHelper;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MethodInfo method;
|
||||
|
||||
try
|
||||
{
|
||||
method = typeof (Event).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
eventHelper = (IHiddenEventHelper) method.Invoke(null, null);
|
||||
|
||||
method = typeof (Bullet).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
bulletHelper = (IHiddenBulletHelper) method.Invoke(null, null);
|
||||
|
||||
method = typeof (RobotStatus).GetMethod("createHiddenSerializer",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
statusHelper = (IHiddenStatusHelper) method.Invoke(null, null);
|
||||
|
||||
method = typeof (BattleRules).GetMethod("createHiddenHelper",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
rulesHelper = (IHiddenRulesHelper) method.Invoke(null, null);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerN.logError(e);
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsCriticalEvent(Event e)
|
||||
{
|
||||
return eventHelper.IsCriticalEvent(e);
|
||||
}
|
||||
|
||||
public static void SetEventTime(Event e, long newTime)
|
||||
{
|
||||
eventHelper.SetTime(e, newTime);
|
||||
}
|
||||
|
||||
public static void SetEventPriority(Event e, int newPriority)
|
||||
{
|
||||
eventHelper.SetPriority(e, newPriority);
|
||||
}
|
||||
|
||||
public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
eventHelper.Dispatch(evnt, robot, statics, graphics);
|
||||
}
|
||||
|
||||
public static void SetDefaultPriority(Event e)
|
||||
{
|
||||
eventHelper.SetDefaultPriority(e);
|
||||
}
|
||||
|
||||
public static byte GetSerializationType(Event e)
|
||||
{
|
||||
return eventHelper.GetSerializationType(e);
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
public static void UpdateBullets(Event e, Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
eventHelper.UpdateBullets(e, bullets);
|
||||
}
|
||||
|
||||
public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
||||
{
|
||||
bulletHelper.update(bullet, x, y, victimName, isActive);
|
||||
}
|
||||
|
||||
public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading, double velocity, double bodyTurnRemaining,
|
||||
double radarTurnRemaining, double gunTurnRemaining,
|
||||
double distanceRemaining, double gunHeat, int others, int numSentries,
|
||||
int roundNum, int numRounds, long time)
|
||||
{
|
||||
return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity,
|
||||
bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining,
|
||||
gunHeat, others, numSentries, roundNum, numRounds, time);
|
||||
}
|
||||
|
||||
public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
||||
{
|
||||
return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
||||
}
|
||||
|
||||
public static string GetRobotName()
|
||||
{
|
||||
string name = (string)AppDomain.CurrentDomain.GetData("robotName");
|
||||
return name ?? "";
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
|
||||
//happy
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using net.sf.robocode.io;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
||||
public class HiddenAccessN
|
||||
{
|
||||
private static IHiddenEventHelper eventHelper;
|
||||
private static IHiddenBulletHelper bulletHelper;
|
||||
private static IHiddenStatusHelper statusHelper;
|
||||
private static IHiddenRulesHelper rulesHelper;
|
||||
private static bool initialized;
|
||||
public static IHiddenRandomHelper randomHelper;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MethodInfo method;
|
||||
|
||||
try
|
||||
{
|
||||
method = typeof (Event).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
eventHelper = (IHiddenEventHelper) method.Invoke(null, null);
|
||||
|
||||
method = typeof (Bullet).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
bulletHelper = (IHiddenBulletHelper) method.Invoke(null, null);
|
||||
|
||||
method = typeof (RobotStatus).GetMethod("createHiddenSerializer",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
statusHelper = (IHiddenStatusHelper) method.Invoke(null, null);
|
||||
|
||||
method = typeof (BattleRules).GetMethod("createHiddenHelper",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
rulesHelper = (IHiddenRulesHelper) method.Invoke(null, null);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerN.logError(e);
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsCriticalEvent(Event e)
|
||||
{
|
||||
return eventHelper.IsCriticalEvent(e);
|
||||
}
|
||||
|
||||
public static void SetEventTime(Event e, long newTime)
|
||||
{
|
||||
eventHelper.SetTime(e, newTime);
|
||||
}
|
||||
|
||||
public static void SetEventPriority(Event e, int newPriority)
|
||||
{
|
||||
eventHelper.SetPriority(e, newPriority);
|
||||
}
|
||||
|
||||
public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
eventHelper.Dispatch(evnt, robot, statics, graphics);
|
||||
}
|
||||
|
||||
public static void SetDefaultPriority(Event e)
|
||||
{
|
||||
eventHelper.SetDefaultPriority(e);
|
||||
}
|
||||
|
||||
public static byte GetSerializationType(Event e)
|
||||
{
|
||||
return eventHelper.GetSerializationType(e);
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
public static void UpdateBullets(Event e, Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
eventHelper.UpdateBullets(e, bullets);
|
||||
}
|
||||
|
||||
public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
||||
{
|
||||
bulletHelper.update(bullet, x, y, victimName, isActive);
|
||||
}
|
||||
|
||||
public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading, double velocity, double bodyTurnRemaining,
|
||||
double radarTurnRemaining, double gunTurnRemaining,
|
||||
double distanceRemaining, double gunHeat, int others, int numSentries,
|
||||
int roundNum, int numRounds, long time)
|
||||
{
|
||||
return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity,
|
||||
bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining,
|
||||
gunHeat, others, numSentries, roundNum, numRounds, time);
|
||||
}
|
||||
|
||||
public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
||||
{
|
||||
return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
||||
}
|
||||
|
||||
public static string GetRobotName()
|
||||
{
|
||||
string name = (string)AppDomain.CurrentDomain.GetData("robotName");
|
||||
return name ?? "";
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
|
||||
//happy
|
|
@ -1,20 +1,20 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using Robocode;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenBulletHelper
|
||||
{
|
||||
void update(Bullet bullet, double x, double y, string victimName, bool isActive);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using Robocode;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenBulletHelper
|
||||
{
|
||||
void update(Bullet bullet, double x, double y, string victimName, bool isActive);
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
|
@ -1,29 +1,29 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenEventHelper
|
||||
{
|
||||
void SetDefaultPriority(Event evnt);
|
||||
void SetPriority(Event evnt, int newPriority);
|
||||
void SetTime(Event evnt, long newTime);
|
||||
bool IsCriticalEvent(Event evnt);
|
||||
void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics);
|
||||
byte GetSerializationType(Event evnt);
|
||||
void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets); // Needed for .NET version
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenEventHelper
|
||||
{
|
||||
void SetDefaultPriority(Event evnt);
|
||||
void SetPriority(Event evnt, int newPriority);
|
||||
void SetTime(Event evnt, long newTime);
|
||||
bool IsCriticalEvent(Event evnt);
|
||||
void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics);
|
||||
byte GetSerializationType(Event evnt);
|
||||
void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets); // Needed for .NET version
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
|
@ -1,20 +1,20 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenRandomHelper
|
||||
{
|
||||
Random GetRandom();
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenRandomHelper
|
||||
{
|
||||
Random GetRandom();
|
||||
}
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using Robocode;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenRulesHelper
|
||||
{
|
||||
BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int borderSentryRobotAttackRange);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using Robocode;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenRulesHelper
|
||||
{
|
||||
BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int borderSentryRobotAttackRange);
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
|
@ -1,25 +1,25 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using Robocode;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenStatusHelper
|
||||
{
|
||||
RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading,
|
||||
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
||||
double gunTurnRemaining,
|
||||
double distanceRemaining, double gunHeat, int others, int numSentries,
|
||||
int roundNum, int numRounds, long time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using Robocode;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface IHiddenStatusHelper
|
||||
{
|
||||
RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading,
|
||||
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
||||
double gunTurnRemaining,
|
||||
double distanceRemaining, double gunHeat, int others, int numSentries,
|
||||
int roundNum, int numRounds, long time);
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
|
@ -1,151 +1,151 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public sealed class RobocodeInternalPermission : CodeAccessPermission, IUnrestrictedPermission
|
||||
{
|
||||
private bool unrestricted;
|
||||
|
||||
public RobocodeInternalPermission(PermissionState state)
|
||||
{
|
||||
unrestricted = state == PermissionState.Unrestricted;
|
||||
}
|
||||
|
||||
#region IUnrestrictedPermission Members
|
||||
|
||||
public bool IsUnrestricted()
|
||||
{
|
||||
return unrestricted;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override IPermission Copy()
|
||||
{
|
||||
//Create a new instance of RobocodeInternalPermission with the current
|
||||
//value of unrestricted.
|
||||
var copy = new RobocodeInternalPermission(PermissionState.None);
|
||||
|
||||
copy.unrestricted = IsUnrestricted();
|
||||
//Return the copy.
|
||||
return copy;
|
||||
}
|
||||
|
||||
public override IPermission Intersect(IPermission target)
|
||||
{
|
||||
//If nothing was passed, return null.
|
||||
if (null == target)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
//Create a new instance of RobocodeInternalPermission from the passed object.
|
||||
var PassedPermission = (RobocodeInternalPermission) target;
|
||||
|
||||
//If one class has an unrestricted value of false, then the
|
||||
//intersection will have an unrestricted value of false.
|
||||
//Return the passed class with the unrestricted value of false.
|
||||
if (!PassedPermission.unrestricted)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
//Return a copy of the current class if the passed one has
|
||||
//an unrestricted value of true.
|
||||
return Copy();
|
||||
}
|
||||
//Catch an InvalidCastException.
|
||||
//Throw ArgumentException to notify the user.
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsSubsetOf(IPermission target)
|
||||
{
|
||||
//If nothing was passed and unrestricted is false,
|
||||
//then return true.
|
||||
if (null == target)
|
||||
{
|
||||
return !unrestricted;
|
||||
}
|
||||
try
|
||||
{
|
||||
//Create a new instance of RobocodeInternalPermission from the passed object.
|
||||
var passedpermission = (RobocodeInternalPermission) target;
|
||||
|
||||
//If unrestricted has the same value in both objects, then
|
||||
//one is the subset of the other.
|
||||
return unrestricted == passedpermission.unrestricted;
|
||||
}
|
||||
//Catch an InvalidCastException.
|
||||
//Throw ArgumentException to notify the user.
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FromXml(SecurityElement PassedElement)
|
||||
{
|
||||
//Get the unrestricted value from the XML and initialize
|
||||
//the current instance of unrestricted to that value.
|
||||
string element = PassedElement.Attribute("Unrestricted");
|
||||
|
||||
if (null != element)
|
||||
{
|
||||
unrestricted = Convert.ToBoolean(element);
|
||||
}
|
||||
}
|
||||
|
||||
public override SecurityElement ToXml()
|
||||
{
|
||||
//Encode the current permission to XML using the
|
||||
//SecurityElement class.
|
||||
var element = new SecurityElement("IPermission");
|
||||
Type type = GetType();
|
||||
var AssemblyName = new StringBuilder(type.Assembly.ToString());
|
||||
AssemblyName.Replace('\"', '\'');
|
||||
element.AddAttribute("class", type.FullName + ", " + AssemblyName);
|
||||
element.AddAttribute("version", "1");
|
||||
element.AddAttribute("Unrestricted", unrestricted.ToString());
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <exclude/>
|
||||
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class RobocodeInternalPermissionAttribute : CodeAccessSecurityAttribute
|
||||
{
|
||||
public RobocodeInternalPermissionAttribute(SecurityAction action)
|
||||
: base(action)
|
||||
{
|
||||
Unrestricted = false;
|
||||
}
|
||||
|
||||
public override IPermission CreatePermission()
|
||||
{
|
||||
return Unrestricted
|
||||
? new RobocodeInternalPermission(PermissionState.Unrestricted)
|
||||
: new RobocodeInternalPermission(PermissionState.None);
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
|
||||
namespace net.sf.robocode.security
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
[Serializable]
|
||||
public sealed class RobocodeInternalPermission : CodeAccessPermission, IUnrestrictedPermission
|
||||
{
|
||||
private bool unrestricted;
|
||||
|
||||
public RobocodeInternalPermission(PermissionState state)
|
||||
{
|
||||
unrestricted = state == PermissionState.Unrestricted;
|
||||
}
|
||||
|
||||
#region IUnrestrictedPermission Members
|
||||
|
||||
public bool IsUnrestricted()
|
||||
{
|
||||
return unrestricted;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override IPermission Copy()
|
||||
{
|
||||
//Create a new instance of RobocodeInternalPermission with the current
|
||||
//value of unrestricted.
|
||||
var copy = new RobocodeInternalPermission(PermissionState.None);
|
||||
|
||||
copy.unrestricted = IsUnrestricted();
|
||||
//Return the copy.
|
||||
return copy;
|
||||
}
|
||||
|
||||
public override IPermission Intersect(IPermission target)
|
||||
{
|
||||
//If nothing was passed, return null.
|
||||
if (null == target)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
//Create a new instance of RobocodeInternalPermission from the passed object.
|
||||
var PassedPermission = (RobocodeInternalPermission) target;
|
||||
|
||||
//If one class has an unrestricted value of false, then the
|
||||
//intersection will have an unrestricted value of false.
|
||||
//Return the passed class with the unrestricted value of false.
|
||||
if (!PassedPermission.unrestricted)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
//Return a copy of the current class if the passed one has
|
||||
//an unrestricted value of true.
|
||||
return Copy();
|
||||
}
|
||||
//Catch an InvalidCastException.
|
||||
//Throw ArgumentException to notify the user.
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsSubsetOf(IPermission target)
|
||||
{
|
||||
//If nothing was passed and unrestricted is false,
|
||||
//then return true.
|
||||
if (null == target)
|
||||
{
|
||||
return !unrestricted;
|
||||
}
|
||||
try
|
||||
{
|
||||
//Create a new instance of RobocodeInternalPermission from the passed object.
|
||||
var passedpermission = (RobocodeInternalPermission) target;
|
||||
|
||||
//If unrestricted has the same value in both objects, then
|
||||
//one is the subset of the other.
|
||||
return unrestricted == passedpermission.unrestricted;
|
||||
}
|
||||
//Catch an InvalidCastException.
|
||||
//Throw ArgumentException to notify the user.
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FromXml(SecurityElement PassedElement)
|
||||
{
|
||||
//Get the unrestricted value from the XML and initialize
|
||||
//the current instance of unrestricted to that value.
|
||||
string element = PassedElement.Attribute("Unrestricted");
|
||||
|
||||
if (null != element)
|
||||
{
|
||||
unrestricted = Convert.ToBoolean(element);
|
||||
}
|
||||
}
|
||||
|
||||
public override SecurityElement ToXml()
|
||||
{
|
||||
//Encode the current permission to XML using the
|
||||
//SecurityElement class.
|
||||
var element = new SecurityElement("IPermission");
|
||||
Type type = GetType();
|
||||
var AssemblyName = new StringBuilder(type.Assembly.ToString());
|
||||
AssemblyName.Replace('\"', '\'');
|
||||
element.AddAttribute("class", type.FullName + ", " + AssemblyName);
|
||||
element.AddAttribute("version", "1");
|
||||
element.AddAttribute("Unrestricted", unrestricted.ToString());
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <exclude/>
|
||||
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class RobocodeInternalPermissionAttribute : CodeAccessSecurityAttribute
|
||||
{
|
||||
public RobocodeInternalPermissionAttribute(SecurityAction action)
|
||||
: base(action)
|
||||
{
|
||||
Unrestricted = false;
|
||||
}
|
||||
|
||||
public override IPermission CreatePermission()
|
||||
{
|
||||
return Unrestricted
|
||||
? new RobocodeInternalPermission(PermissionState.Unrestricted)
|
||||
: new RobocodeInternalPermission(PermissionState.None);
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using net.sf.robocode.nio;
|
||||
|
||||
namespace net.sf.robocode.serialization
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface ISerializableHelperN
|
||||
{
|
||||
int sizeOf(RbSerializerN serializer, object obj);
|
||||
void serialize(RbSerializerN serializer, ByteBuffer buffer, object obj);
|
||||
object deserialize(RbSerializerN serializer, ByteBuffer buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using net.sf.robocode.nio;
|
||||
|
||||
namespace net.sf.robocode.serialization
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public interface ISerializableHelperN
|
||||
{
|
||||
int sizeOf(RbSerializerN serializer, object obj);
|
||||
void serialize(RbSerializerN serializer, ByteBuffer buffer, object obj);
|
||||
object deserialize(RbSerializerN serializer, ByteBuffer buffer);
|
||||
}
|
||||
}
|
||||
|
||||
//happy
|
File diff suppressed because it is too large
Load Diff
|
@ -1,164 +1,164 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{7E0900D3-6E8F-48EB-86DB-AA767AA90B84}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>robocode</RootNamespace>
|
||||
<AssemblyName>robocode</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\tools\keys\robocode.snk</AssemblyOriginatorKeyFile>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\target\</OutputPath>
|
||||
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\target\robocode.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\target\</OutputPath>
|
||||
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\target\build-sources\generated-sources\META-INF\AssemblyInfo.cs">
|
||||
<Link>AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInf.cs" />
|
||||
<Compile Include="net\sf\robocode\io\LoggerN.cs" />
|
||||
<Compile Include="net\sf\robocode\peer\IRobotStaticsN.cs" />
|
||||
<Compile Include="net\sf\robocode\security\HiddenAccessN.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenBulletHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenEventHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenRandomHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenRulesHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenStatusHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\RobocodeInternalPermission.cs" />
|
||||
<Compile Include="net\sf\robocode\serialization\ISerializableHelperN.cs" />
|
||||
<Compile Include="net\sf\robocode\serialization\RbSerializerN.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\Buffer.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\ByteBuffer.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\HeapByteBuffer.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\InvalidMarkException.cs" />
|
||||
<Compile Include="robocode\AdvancedRobot.cs" />
|
||||
<Compile Include="robocode\BattleEndedEvent.cs" />
|
||||
<Compile Include="robocode\BattleResults.cs" />
|
||||
<Compile Include="robocode\BattleRules.cs" />
|
||||
<Compile Include="robocode\Bullet.cs" />
|
||||
<Compile Include="robocode\BulletHitBulletEvent.cs" />
|
||||
<Compile Include="robocode\BulletHitEvent.cs" />
|
||||
<Compile Include="robocode\BulletMissedEvent.cs" />
|
||||
<Compile Include="robocode\Condition.cs" />
|
||||
<Compile Include="robocode\IBorderSentry.cs" />
|
||||
<Compile Include="robocode\CustomEvent.cs" />
|
||||
<Compile Include="robocode\DeathEvent.cs" />
|
||||
<Compile Include="robocode\IDroid.cs" />
|
||||
<Compile Include="robocode\Event.cs" />
|
||||
<Compile Include="robocode\exception\EventInterruptedException.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="robocode\exception\RobotException.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="robocode\IGraphics.cs" />
|
||||
<Compile Include="robocode\GunTurnCompleteCondition.cs" />
|
||||
<Compile Include="robocode\HitByBulletEvent.cs" />
|
||||
<Compile Include="robocode\HitRobotEvent.cs" />
|
||||
<Compile Include="robocode\HitWallEvent.cs" />
|
||||
<Compile Include="robocode\JuniorRobot.cs" />
|
||||
<Compile Include="robocode\KeyEvent.cs" />
|
||||
<Compile Include="robocode\KeyPressedEvent.cs" />
|
||||
<Compile Include="robocode\KeyReleasedEvent.cs" />
|
||||
<Compile Include="robocode\Keys.cs" />
|
||||
<Compile Include="robocode\KeyTypedEvent.cs" />
|
||||
<Compile Include="robocode\MessageEvent.cs" />
|
||||
<Compile Include="robocode\MouseClickedEvent.cs" />
|
||||
<Compile Include="robocode\MouseDraggedEvent.cs" />
|
||||
<Compile Include="robocode\MouseEnteredEvent.cs" />
|
||||
<Compile Include="robocode\MouseEvent.cs" />
|
||||
<Compile Include="robocode\MouseExitedEvent.cs" />
|
||||
<Compile Include="robocode\MouseMovedEvent.cs" />
|
||||
<Compile Include="robocode\MousePressedEvent.cs" />
|
||||
<Compile Include="robocode\MouseReleasedEvent.cs" />
|
||||
<Compile Include="robocode\MouseWheelMovedEvent.cs" />
|
||||
<Compile Include="robocode\MoveCompleteCondition.cs" />
|
||||
<Compile Include="robocode\PaintEvent.cs" />
|
||||
<Compile Include="robocode\RadarTurnCompleteCondition.cs" />
|
||||
<Compile Include="robocode\RateControlRobot.cs" />
|
||||
<Compile Include="robocode\Robot.cs" />
|
||||
<Compile Include="robocode\RobotDeathEvent.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IAdvancedEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IAdvancedRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicEvents2.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicEvents3.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IInteractiveEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IInteractiveRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IJuniorRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IPaintEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IPaintRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\ITeamEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\ITeamRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IAdvancedRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IBasicRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IJuniorRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IStandardRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\ITeamRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IRunnable.cs" />
|
||||
<Compile Include="robocode\RobotStatus.cs" />
|
||||
<Compile Include="robocode\RoundEndedEvent.cs" />
|
||||
<Compile Include="robocode\Rules.cs" />
|
||||
<Compile Include="robocode\Thread.cs" />
|
||||
<Compile Include="robocode\ScannedRobotEvent.cs" />
|
||||
<Compile Include="robocode\SkippedTurnEvent.cs" />
|
||||
<Compile Include="robocode\StatusEvent.cs" />
|
||||
<Compile Include="robocode\TeamRobot.cs" />
|
||||
<Compile Include="robocode\TurnCompleteCondition.cs" />
|
||||
<Compile Include="robocode\util\Utils.cs" />
|
||||
<Compile Include="robocode\WinEvent.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target"</PostBuildEvent>
|
||||
<PreBuildEvent>if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\
|
||||
echo [assembly: System.Reflection.AssemblyVersion("1.9.2.4")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{7E0900D3-6E8F-48EB-86DB-AA767AA90B84}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>robocode</RootNamespace>
|
||||
<AssemblyName>robocode</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\tools\keys\robocode.snk</AssemblyOriginatorKeyFile>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\target\</OutputPath>
|
||||
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\target\robocode.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\target\</OutputPath>
|
||||
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\target\build-sources\generated-sources\META-INF\AssemblyInfo.cs">
|
||||
<Link>AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInf.cs" />
|
||||
<Compile Include="net\sf\robocode\io\LoggerN.cs" />
|
||||
<Compile Include="net\sf\robocode\peer\IRobotStaticsN.cs" />
|
||||
<Compile Include="net\sf\robocode\security\HiddenAccessN.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenBulletHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenEventHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenRandomHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenRulesHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\IHiddenStatusHelper.cs" />
|
||||
<Compile Include="net\sf\robocode\security\RobocodeInternalPermission.cs" />
|
||||
<Compile Include="net\sf\robocode\serialization\ISerializableHelperN.cs" />
|
||||
<Compile Include="net\sf\robocode\serialization\RbSerializerN.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\Buffer.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\ByteBuffer.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\HeapByteBuffer.cs" />
|
||||
<Compile Include="net\sf\robocode\nio\InvalidMarkException.cs" />
|
||||
<Compile Include="robocode\AdvancedRobot.cs" />
|
||||
<Compile Include="robocode\BattleEndedEvent.cs" />
|
||||
<Compile Include="robocode\BattleResults.cs" />
|
||||
<Compile Include="robocode\BattleRules.cs" />
|
||||
<Compile Include="robocode\Bullet.cs" />
|
||||
<Compile Include="robocode\BulletHitBulletEvent.cs" />
|
||||
<Compile Include="robocode\BulletHitEvent.cs" />
|
||||
<Compile Include="robocode\BulletMissedEvent.cs" />
|
||||
<Compile Include="robocode\Condition.cs" />
|
||||
<Compile Include="robocode\IBorderSentry.cs" />
|
||||
<Compile Include="robocode\CustomEvent.cs" />
|
||||
<Compile Include="robocode\DeathEvent.cs" />
|
||||
<Compile Include="robocode\IDroid.cs" />
|
||||
<Compile Include="robocode\Event.cs" />
|
||||
<Compile Include="robocode\exception\EventInterruptedException.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="robocode\exception\RobotException.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="robocode\IGraphics.cs" />
|
||||
<Compile Include="robocode\GunTurnCompleteCondition.cs" />
|
||||
<Compile Include="robocode\HitByBulletEvent.cs" />
|
||||
<Compile Include="robocode\HitRobotEvent.cs" />
|
||||
<Compile Include="robocode\HitWallEvent.cs" />
|
||||
<Compile Include="robocode\JuniorRobot.cs" />
|
||||
<Compile Include="robocode\KeyEvent.cs" />
|
||||
<Compile Include="robocode\KeyPressedEvent.cs" />
|
||||
<Compile Include="robocode\KeyReleasedEvent.cs" />
|
||||
<Compile Include="robocode\Keys.cs" />
|
||||
<Compile Include="robocode\KeyTypedEvent.cs" />
|
||||
<Compile Include="robocode\MessageEvent.cs" />
|
||||
<Compile Include="robocode\MouseClickedEvent.cs" />
|
||||
<Compile Include="robocode\MouseDraggedEvent.cs" />
|
||||
<Compile Include="robocode\MouseEnteredEvent.cs" />
|
||||
<Compile Include="robocode\MouseEvent.cs" />
|
||||
<Compile Include="robocode\MouseExitedEvent.cs" />
|
||||
<Compile Include="robocode\MouseMovedEvent.cs" />
|
||||
<Compile Include="robocode\MousePressedEvent.cs" />
|
||||
<Compile Include="robocode\MouseReleasedEvent.cs" />
|
||||
<Compile Include="robocode\MouseWheelMovedEvent.cs" />
|
||||
<Compile Include="robocode\MoveCompleteCondition.cs" />
|
||||
<Compile Include="robocode\PaintEvent.cs" />
|
||||
<Compile Include="robocode\RadarTurnCompleteCondition.cs" />
|
||||
<Compile Include="robocode\RateControlRobot.cs" />
|
||||
<Compile Include="robocode\Robot.cs" />
|
||||
<Compile Include="robocode\RobotDeathEvent.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IAdvancedEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IAdvancedRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicEvents2.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicEvents3.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IBasicRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IInteractiveEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IInteractiveRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IJuniorRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IPaintEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IPaintRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\ITeamEvents.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\ITeamRobot.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IAdvancedRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IBasicRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IJuniorRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\IStandardRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\peer\ITeamRobotPeer.cs" />
|
||||
<Compile Include="robocode\robotinterfaces\IRunnable.cs" />
|
||||
<Compile Include="robocode\RobotStatus.cs" />
|
||||
<Compile Include="robocode\RoundEndedEvent.cs" />
|
||||
<Compile Include="robocode\Rules.cs" />
|
||||
<Compile Include="robocode\Thread.cs" />
|
||||
<Compile Include="robocode\ScannedRobotEvent.cs" />
|
||||
<Compile Include="robocode\SkippedTurnEvent.cs" />
|
||||
<Compile Include="robocode\StatusEvent.cs" />
|
||||
<Compile Include="robocode\TeamRobot.cs" />
|
||||
<Compile Include="robocode\TurnCompleteCondition.cs" />
|
||||
<Compile Include="robocode\util\Utils.cs" />
|
||||
<Compile Include="robocode\WinEvent.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target"</PostBuildEvent>
|
||||
<PreBuildEvent>if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\
|
||||
echo [assembly: System.Reflection.AssemblyVersion("1.9.2.4")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,126 +1,126 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// A BattleEndedEvent is sent to <see cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||
/// when the battle is ended.
|
||||
/// You can use the information contained in this event to determine if the
|
||||
/// battle was aborted and also get the results of the battle.
|
||||
/// <seealso cref="BattleResults"/>
|
||||
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BattleEndedEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
||||
|
||||
private readonly bool aborted;
|
||||
private readonly BattleResults results;
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// Called by the game to create a new BattleEndedEvent.
|
||||
///</summary>
|
||||
public BattleEndedEvent(bool aborted, BattleResults results)
|
||||
{
|
||||
this.aborted = aborted;
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Checks if this battle was aborted.
|
||||
/// Returns true if the battle was aborted
|
||||
///</summary>
|
||||
public bool IsAborted
|
||||
{
|
||||
get { return aborted; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the battle results.
|
||||
///</summary>
|
||||
public BattleResults Results
|
||||
{
|
||||
get { return results; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Priority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (robot != null)
|
||||
{
|
||||
var listener = robot.GetBasicEventListener() as IBasicEvents2;
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBattleEnded(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool IsCriticalEvent
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BattleEndedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BattleEndedEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_BOOL
|
||||
+ serializer.sizeOf(RbSerializerN.BattleResults_TYPE, obj.results);
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BattleEndedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.aborted);
|
||||
serializer.serialize(buffer, RbSerializerN.BattleResults_TYPE, obj.results);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
bool aborted = serializer.deserializeBoolean(buffer);
|
||||
var results = (BattleResults) serializer.deserializeAny(buffer);
|
||||
|
||||
return new BattleEndedEvent(aborted, results);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// A BattleEndedEvent is sent to <see cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||
/// when the battle is ended.
|
||||
/// You can use the information contained in this event to determine if the
|
||||
/// battle was aborted and also get the results of the battle.
|
||||
/// <seealso cref="BattleResults"/>
|
||||
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BattleEndedEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
||||
|
||||
private readonly bool aborted;
|
||||
private readonly BattleResults results;
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// Called by the game to create a new BattleEndedEvent.
|
||||
///</summary>
|
||||
public BattleEndedEvent(bool aborted, BattleResults results)
|
||||
{
|
||||
this.aborted = aborted;
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Checks if this battle was aborted.
|
||||
/// Returns true if the battle was aborted
|
||||
///</summary>
|
||||
public bool IsAborted
|
||||
{
|
||||
get { return aborted; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the battle results.
|
||||
///</summary>
|
||||
public BattleResults Results
|
||||
{
|
||||
get { return results; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Priority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (robot != null)
|
||||
{
|
||||
var listener = robot.GetBasicEventListener() as IBasicEvents2;
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBattleEnded(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool IsCriticalEvent
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BattleEndedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BattleEndedEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_BOOL
|
||||
+ serializer.sizeOf(RbSerializerN.BattleResults_TYPE, obj.results);
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BattleEndedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.aborted);
|
||||
serializer.serialize(buffer, RbSerializerN.BattleResults_TYPE, obj.results);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
bool aborted = serializer.deserializeBoolean(buffer);
|
||||
var results = (BattleResults) serializer.deserializeAny(buffer);
|
||||
|
||||
return new BattleEndedEvent(aborted, results);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//docl
|
|
@ -1,225 +1,225 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.serialization;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// Contains the battle results returned by <see cref="BattleEndedEvent.Results"/>
|
||||
/// when a battle has ended.
|
||||
/// <seealso cref="BattleEndedEvent.Results"/>
|
||||
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public class BattleResults : IComparable<BattleResults>
|
||||
{
|
||||
internal string teamLeaderName;
|
||||
internal int rank;
|
||||
internal double score;
|
||||
internal double survival;
|
||||
internal double lastSurvivorBonus;
|
||||
internal double bulletDamage;
|
||||
internal double bulletDamageBonus;
|
||||
internal double ramDamage;
|
||||
internal double ramDamageBonus;
|
||||
internal int firsts;
|
||||
internal int seconds;
|
||||
internal int thirds;
|
||||
|
||||
///<summary>
|
||||
/// Constructs this BattleResults object.
|
||||
///</summary>
|
||||
public BattleResults(
|
||||
string teamLeaderName,
|
||||
int rank,
|
||||
double score,
|
||||
double survival,
|
||||
double lastSurvivorBonus,
|
||||
double bulletDamage,
|
||||
double bulletDamageBonus,
|
||||
double ramDamage,
|
||||
double ramDamageBonus,
|
||||
int firsts,
|
||||
int seconds,
|
||||
int thirds
|
||||
)
|
||||
{
|
||||
this.teamLeaderName = teamLeaderName;
|
||||
this.rank = rank;
|
||||
this.score = score;
|
||||
this.survival = survival;
|
||||
this.lastSurvivorBonus = lastSurvivorBonus;
|
||||
this.bulletDamage = bulletDamage;
|
||||
this.bulletDamageBonus = bulletDamageBonus;
|
||||
this.ramDamage = ramDamage;
|
||||
this.ramDamageBonus = ramDamageBonus;
|
||||
this.firsts = firsts;
|
||||
this.seconds = seconds;
|
||||
this.thirds = thirds;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the team leader in the team or the name of the
|
||||
/// robot if the robot is not participating in a team.
|
||||
///</summary>
|
||||
public string TeamLeaderName
|
||||
{
|
||||
get { return teamLeaderName; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the rank of this robot in the battle results.
|
||||
///</summary>
|
||||
public int Rank
|
||||
{
|
||||
get { return rank; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the total score of this robot in the battle.
|
||||
///</summary>
|
||||
public int Score
|
||||
{
|
||||
get { return (int) (score + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the survival score of this robot in the battle.
|
||||
///</summary>
|
||||
public int Survival
|
||||
{
|
||||
get { return (int) (survival + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the last survivor score of this robot in the battle.
|
||||
///</summary>
|
||||
public int LastSurvivorBonus
|
||||
{
|
||||
get { return (int) (lastSurvivorBonus + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet damage score of this robot in the battle.
|
||||
///</summary>
|
||||
public int BulletDamage
|
||||
{
|
||||
get { return (int) (bulletDamage + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet damage bonus of this robot in the battle.
|
||||
///</summary>
|
||||
public int BulletDamageBonus
|
||||
{
|
||||
get { return (int) (bulletDamageBonus + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the ram damage score of this robot in the battle.
|
||||
///</summary>
|
||||
public int RamDamage
|
||||
{
|
||||
get { return (int) (ramDamage + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the ram damage bonus of this robot in the battle.
|
||||
///</summary>
|
||||
public int RamDamageBonus
|
||||
{
|
||||
get { return (int) (ramDamageBonus + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds this robot placed first in the battle.
|
||||
///</summary>
|
||||
public int Firsts
|
||||
{
|
||||
get { return firsts; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds this robot placed second in the battle.
|
||||
///</summary>
|
||||
public int Seconds
|
||||
{
|
||||
get { return seconds; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds this robot placed third in the battle.
|
||||
///</summary>
|
||||
public int Thirds
|
||||
{
|
||||
get { return thirds; }
|
||||
}
|
||||
|
||||
public int CompareTo(BattleResults o)
|
||||
{
|
||||
return score.CompareTo(o.score);
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BattleResults) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.teamLeaderName) +
|
||||
4*RbSerializerN.SIZEOF_INT
|
||||
+ 7*RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BattleResults) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.teamLeaderName);
|
||||
serializer.serialize(buffer, obj.rank);
|
||||
serializer.serialize(buffer, obj.score);
|
||||
serializer.serialize(buffer, obj.survival);
|
||||
serializer.serialize(buffer, obj.lastSurvivorBonus);
|
||||
serializer.serialize(buffer, obj.bulletDamage);
|
||||
serializer.serialize(buffer, obj.bulletDamageBonus);
|
||||
serializer.serialize(buffer, obj.ramDamage);
|
||||
serializer.serialize(buffer, obj.ramDamageBonus);
|
||||
serializer.serialize(buffer, obj.firsts);
|
||||
serializer.serialize(buffer, obj.seconds);
|
||||
serializer.serialize(buffer, obj.thirds);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
string teamLeaderName = serializer.deserializeString(buffer);
|
||||
int rank = buffer.getInt();
|
||||
double score = buffer.getDouble();
|
||||
double survival = buffer.getDouble();
|
||||
double lastSurvivorBonus = buffer.getDouble();
|
||||
double bulletDamage = buffer.getDouble();
|
||||
double bulletDamageBonus = buffer.getDouble();
|
||||
double ramDamage = buffer.getDouble();
|
||||
double ramDamageBonus = buffer.getDouble();
|
||||
int firsts = buffer.getInt();
|
||||
int seconds = buffer.getInt();
|
||||
int thirds = buffer.getInt();
|
||||
|
||||
return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage,
|
||||
bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.serialization;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// Contains the battle results returned by <see cref="BattleEndedEvent.Results"/>
|
||||
/// when a battle has ended.
|
||||
/// <seealso cref="BattleEndedEvent.Results"/>
|
||||
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public class BattleResults : IComparable<BattleResults>
|
||||
{
|
||||
internal string teamLeaderName;
|
||||
internal int rank;
|
||||
internal double score;
|
||||
internal double survival;
|
||||
internal double lastSurvivorBonus;
|
||||
internal double bulletDamage;
|
||||
internal double bulletDamageBonus;
|
||||
internal double ramDamage;
|
||||
internal double ramDamageBonus;
|
||||
internal int firsts;
|
||||
internal int seconds;
|
||||
internal int thirds;
|
||||
|
||||
///<summary>
|
||||
/// Constructs this BattleResults object.
|
||||
///</summary>
|
||||
public BattleResults(
|
||||
string teamLeaderName,
|
||||
int rank,
|
||||
double score,
|
||||
double survival,
|
||||
double lastSurvivorBonus,
|
||||
double bulletDamage,
|
||||
double bulletDamageBonus,
|
||||
double ramDamage,
|
||||
double ramDamageBonus,
|
||||
int firsts,
|
||||
int seconds,
|
||||
int thirds
|
||||
)
|
||||
{
|
||||
this.teamLeaderName = teamLeaderName;
|
||||
this.rank = rank;
|
||||
this.score = score;
|
||||
this.survival = survival;
|
||||
this.lastSurvivorBonus = lastSurvivorBonus;
|
||||
this.bulletDamage = bulletDamage;
|
||||
this.bulletDamageBonus = bulletDamageBonus;
|
||||
this.ramDamage = ramDamage;
|
||||
this.ramDamageBonus = ramDamageBonus;
|
||||
this.firsts = firsts;
|
||||
this.seconds = seconds;
|
||||
this.thirds = thirds;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the team leader in the team or the name of the
|
||||
/// robot if the robot is not participating in a team.
|
||||
///</summary>
|
||||
public string TeamLeaderName
|
||||
{
|
||||
get { return teamLeaderName; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the rank of this robot in the battle results.
|
||||
///</summary>
|
||||
public int Rank
|
||||
{
|
||||
get { return rank; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the total score of this robot in the battle.
|
||||
///</summary>
|
||||
public int Score
|
||||
{
|
||||
get { return (int) (score + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the survival score of this robot in the battle.
|
||||
///</summary>
|
||||
public int Survival
|
||||
{
|
||||
get { return (int) (survival + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the last survivor score of this robot in the battle.
|
||||
///</summary>
|
||||
public int LastSurvivorBonus
|
||||
{
|
||||
get { return (int) (lastSurvivorBonus + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet damage score of this robot in the battle.
|
||||
///</summary>
|
||||
public int BulletDamage
|
||||
{
|
||||
get { return (int) (bulletDamage + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet damage bonus of this robot in the battle.
|
||||
///</summary>
|
||||
public int BulletDamageBonus
|
||||
{
|
||||
get { return (int) (bulletDamageBonus + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the ram damage score of this robot in the battle.
|
||||
///</summary>
|
||||
public int RamDamage
|
||||
{
|
||||
get { return (int) (ramDamage + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the ram damage bonus of this robot in the battle.
|
||||
///</summary>
|
||||
public int RamDamageBonus
|
||||
{
|
||||
get { return (int) (ramDamageBonus + 0.5); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds this robot placed first in the battle.
|
||||
///</summary>
|
||||
public int Firsts
|
||||
{
|
||||
get { return firsts; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds this robot placed second in the battle.
|
||||
///</summary>
|
||||
public int Seconds
|
||||
{
|
||||
get { return seconds; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds this robot placed third in the battle.
|
||||
///</summary>
|
||||
public int Thirds
|
||||
{
|
||||
get { return thirds; }
|
||||
}
|
||||
|
||||
public int CompareTo(BattleResults o)
|
||||
{
|
||||
return score.CompareTo(o.score);
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BattleResults) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.teamLeaderName) +
|
||||
4*RbSerializerN.SIZEOF_INT
|
||||
+ 7*RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BattleResults) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.teamLeaderName);
|
||||
serializer.serialize(buffer, obj.rank);
|
||||
serializer.serialize(buffer, obj.score);
|
||||
serializer.serialize(buffer, obj.survival);
|
||||
serializer.serialize(buffer, obj.lastSurvivorBonus);
|
||||
serializer.serialize(buffer, obj.bulletDamage);
|
||||
serializer.serialize(buffer, obj.bulletDamageBonus);
|
||||
serializer.serialize(buffer, obj.ramDamage);
|
||||
serializer.serialize(buffer, obj.ramDamageBonus);
|
||||
serializer.serialize(buffer, obj.firsts);
|
||||
serializer.serialize(buffer, obj.seconds);
|
||||
serializer.serialize(buffer, obj.thirds);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
string teamLeaderName = serializer.deserializeString(buffer);
|
||||
int rank = buffer.getInt();
|
||||
double score = buffer.getDouble();
|
||||
double survival = buffer.getDouble();
|
||||
double lastSurvivorBonus = buffer.getDouble();
|
||||
double bulletDamage = buffer.getDouble();
|
||||
double bulletDamageBonus = buffer.getDouble();
|
||||
double ramDamage = buffer.getDouble();
|
||||
double ramDamageBonus = buffer.getDouble();
|
||||
int firsts = buffer.getInt();
|
||||
int seconds = buffer.getInt();
|
||||
int thirds = buffer.getInt();
|
||||
|
||||
return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage,
|
||||
bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,137 +1,137 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.security;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the battle rules returned by <see cref="Robocode.Control.Events.BattleStartedEvent.BattleRules">BattleStartedEvent.BattleRules</see>
|
||||
/// when a battle is started and <see cref="Robocode.Control.Events.BattleCompletedEvent.BattleRules">BattleCompletedEvent.BattleRules</see>
|
||||
/// when a battle is completed.
|
||||
/// </summary>
|
||||
/// <seealso cref="Robocode.Control.Events.BattleStartedEvent">BattleStartedEvent</seealso>
|
||||
/// <seealso cref="Robocode.Control.Events.BattleCompletedEvent">BattleCompletedEvent</seealso>
|
||||
[Serializable]
|
||||
public sealed class BattleRules
|
||||
{
|
||||
private readonly int battlefieldWidth;
|
||||
private readonly int battlefieldHeight;
|
||||
private readonly int numRounds;
|
||||
private readonly double gunCoolingRate;
|
||||
private readonly long inactivityTime;
|
||||
private readonly bool hideEnemyNames;
|
||||
private readonly int sentryBorderSize;
|
||||
|
||||
///<summary>
|
||||
/// Returns the battlefield width.
|
||||
///</summary>
|
||||
public int BattlefieldWidth
|
||||
{
|
||||
get { return battlefieldWidth; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the battlefield height.
|
||||
///</summary>
|
||||
public int BattlefieldHeight
|
||||
{
|
||||
get { return battlefieldHeight; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds.
|
||||
///</summary>
|
||||
public int NumRounds
|
||||
{
|
||||
get { return numRounds; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn.
|
||||
/// <p />
|
||||
/// The gun cooling rate is default 0.1 per turn, but can be changed by the battle setup.
|
||||
/// So don't count on the cooling rate being 0.1!
|
||||
/// <seealso cref="Robot.GunHeat"/>
|
||||
/// <seealso cref="Robot.Fire(double)"/>
|
||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||
///</summary>
|
||||
public double GunCoolingRate
|
||||
{
|
||||
get { return gunCoolingRate; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped.
|
||||
/// The inactivity time is measured in turns, and is the allowed time that a robot is allowed to omit taking
|
||||
/// action before being punished by the game by zapping.
|
||||
/// <p />
|
||||
/// When a robot is zapped by the game, it will loose 0.1 energy points per turn. Eventually the robot will be
|
||||
/// killed by zapping until the robot takes action. When the robot takes action, the inactivity time counter is
|
||||
/// reset.
|
||||
/// <p />
|
||||
/// The allowed inactivity time is per default 450 turns, but can be changed by the battle setup.
|
||||
/// So don't count on the inactivity time being 450 turns!
|
||||
/// <seealso cref="Robot.DoNothing()"/>
|
||||
/// <seealso cref="AdvancedRobot.Execute()"/>
|
||||
///</summary>
|
||||
public long InactivityTime
|
||||
{
|
||||
get { return inactivityTime; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns true if the enemy names are hidden, i.e. anonymous; false otherwise.
|
||||
///</summary>
|
||||
public bool HideEnemyNames
|
||||
{
|
||||
get { return hideEnemyNames; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the sentry border size for a <see cref="Robocode.BorderSentry">BorderSentry</see> that defines the how
|
||||
/// far a BorderSentry is allowed to move from the border edges measured in units.<br/>
|
||||
/// Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that
|
||||
/// BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the
|
||||
/// distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this
|
||||
/// border area.
|
||||
///</summary>
|
||||
public int SentryBorderSize
|
||||
{
|
||||
get { return sentryBorderSize; }
|
||||
}
|
||||
|
||||
private BattleRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int sentryBorderSize)
|
||||
{
|
||||
this.battlefieldWidth = battlefieldWidth;
|
||||
this.battlefieldHeight = battlefieldHeight;
|
||||
this.numRounds = numRounds;
|
||||
this.gunCoolingRate = gunCoolingRate;
|
||||
this.inactivityTime = inactivityTime;
|
||||
this.hideEnemyNames = hideEnemyNames;
|
||||
this.sentryBorderSize = sentryBorderSize;
|
||||
}
|
||||
|
||||
private static IHiddenRulesHelper createHiddenHelper()
|
||||
{
|
||||
return new HiddenHelper();
|
||||
}
|
||||
|
||||
private class HiddenHelper : IHiddenRulesHelper
|
||||
{
|
||||
public BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
||||
{
|
||||
return new BattleRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.security;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the battle rules returned by <see cref="Robocode.Control.Events.BattleStartedEvent.BattleRules">BattleStartedEvent.BattleRules</see>
|
||||
/// when a battle is started and <see cref="Robocode.Control.Events.BattleCompletedEvent.BattleRules">BattleCompletedEvent.BattleRules</see>
|
||||
/// when a battle is completed.
|
||||
/// </summary>
|
||||
/// <seealso cref="Robocode.Control.Events.BattleStartedEvent">BattleStartedEvent</seealso>
|
||||
/// <seealso cref="Robocode.Control.Events.BattleCompletedEvent">BattleCompletedEvent</seealso>
|
||||
[Serializable]
|
||||
public sealed class BattleRules
|
||||
{
|
||||
private readonly int battlefieldWidth;
|
||||
private readonly int battlefieldHeight;
|
||||
private readonly int numRounds;
|
||||
private readonly double gunCoolingRate;
|
||||
private readonly long inactivityTime;
|
||||
private readonly bool hideEnemyNames;
|
||||
private readonly int sentryBorderSize;
|
||||
|
||||
///<summary>
|
||||
/// Returns the battlefield width.
|
||||
///</summary>
|
||||
public int BattlefieldWidth
|
||||
{
|
||||
get { return battlefieldWidth; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the battlefield height.
|
||||
///</summary>
|
||||
public int BattlefieldHeight
|
||||
{
|
||||
get { return battlefieldHeight; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the number of rounds.
|
||||
///</summary>
|
||||
public int NumRounds
|
||||
{
|
||||
get { return numRounds; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn.
|
||||
/// <p />
|
||||
/// The gun cooling rate is default 0.1 per turn, but can be changed by the battle setup.
|
||||
/// So don't count on the cooling rate being 0.1!
|
||||
/// <seealso cref="Robot.GunHeat"/>
|
||||
/// <seealso cref="Robot.Fire(double)"/>
|
||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||
///</summary>
|
||||
public double GunCoolingRate
|
||||
{
|
||||
get { return gunCoolingRate; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped.
|
||||
/// The inactivity time is measured in turns, and is the allowed time that a robot is allowed to omit taking
|
||||
/// action before being punished by the game by zapping.
|
||||
/// <p />
|
||||
/// When a robot is zapped by the game, it will loose 0.1 energy points per turn. Eventually the robot will be
|
||||
/// killed by zapping until the robot takes action. When the robot takes action, the inactivity time counter is
|
||||
/// reset.
|
||||
/// <p />
|
||||
/// The allowed inactivity time is per default 450 turns, but can be changed by the battle setup.
|
||||
/// So don't count on the inactivity time being 450 turns!
|
||||
/// <seealso cref="Robot.DoNothing()"/>
|
||||
/// <seealso cref="AdvancedRobot.Execute()"/>
|
||||
///</summary>
|
||||
public long InactivityTime
|
||||
{
|
||||
get { return inactivityTime; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns true if the enemy names are hidden, i.e. anonymous; false otherwise.
|
||||
///</summary>
|
||||
public bool HideEnemyNames
|
||||
{
|
||||
get { return hideEnemyNames; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the sentry border size for a <see cref="Robocode.BorderSentry">BorderSentry</see> that defines the how
|
||||
/// far a BorderSentry is allowed to move from the border edges measured in units.<br/>
|
||||
/// Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that
|
||||
/// BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the
|
||||
/// distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this
|
||||
/// border area.
|
||||
///</summary>
|
||||
public int SentryBorderSize
|
||||
{
|
||||
get { return sentryBorderSize; }
|
||||
}
|
||||
|
||||
private BattleRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int sentryBorderSize)
|
||||
{
|
||||
this.battlefieldWidth = battlefieldWidth;
|
||||
this.battlefieldHeight = battlefieldHeight;
|
||||
this.numRounds = numRounds;
|
||||
this.gunCoolingRate = gunCoolingRate;
|
||||
this.inactivityTime = inactivityTime;
|
||||
this.hideEnemyNames = hideEnemyNames;
|
||||
this.sentryBorderSize = sentryBorderSize;
|
||||
}
|
||||
|
||||
private static IHiddenRulesHelper createHiddenHelper()
|
||||
{
|
||||
return new HiddenHelper();
|
||||
}
|
||||
|
||||
private class HiddenHelper : IHiddenRulesHelper
|
||||
{
|
||||
public BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
||||
{
|
||||
return new BattleRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
|
@ -1,217 +1,217 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.security;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.Util;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///
|
||||
///<summary>
|
||||
/// Represents a bullet. This is returned from <see cref="Robot.FireBullet(double)"/>
|
||||
/// and <see cref="AdvancedRobot.SetFireBullet(double)"/>, and all the bullet-related
|
||||
/// events.
|
||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||
/// <seealso cref="AdvancedRobot.SetFireBullet(double)"/>
|
||||
/// <seealso cref="BulletHitEvent"/>
|
||||
/// <seealso cref="BulletMissedEvent"/>
|
||||
/// <seealso cref="BulletHitBulletEvent"/>
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public class Bullet
|
||||
{
|
||||
private readonly double headingRadians;
|
||||
private double x;
|
||||
private double y;
|
||||
private readonly double power;
|
||||
private readonly string ownerName;
|
||||
private string victimName;
|
||||
private bool _isActive;
|
||||
private readonly int bulletId;
|
||||
|
||||
///<summary>
|
||||
/// Called by the game to create a new Bullet object
|
||||
///</summary>
|
||||
public Bullet(double heading, double x, double y, double power, string ownerName, string victimName,
|
||||
bool isActive, int bulletId)
|
||||
{
|
||||
headingRadians = heading;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.power = power;
|
||||
this.ownerName = ownerName;
|
||||
this.victimName = victimName;
|
||||
_isActive = isActive;
|
||||
this.bulletId = bulletId;
|
||||
}
|
||||
|
||||
public override bool Equals(Object obj)
|
||||
{
|
||||
if (obj is Bullet)
|
||||
{
|
||||
Bullet bullet = (Bullet)obj;
|
||||
return bullet.bulletId == bulletId;
|
||||
}
|
||||
return Equals(obj);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the direction the bullet is/was heading, in degrees
|
||||
/// (0 <= getHeading() < 360). This is not relative to the direction you are facing.
|
||||
///</summary>
|
||||
public double Heading
|
||||
{
|
||||
get { return Utils.ToDegrees(headingRadians); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the direction the bullet is/was heading, in radians
|
||||
/// (0 <= getHeadingRadians() < 2 * Math.PI). This is not relative to the direction you are facing.
|
||||
///</summary>
|
||||
public double HeadingRadians
|
||||
{
|
||||
get { return headingRadians; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the robot that fired this bullet.
|
||||
///</summary>
|
||||
public string Name
|
||||
{
|
||||
get { return ownerName; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the power of this bullet.
|
||||
/// <p />
|
||||
/// The bullet will do (4 * power) damage if it hits another robot.
|
||||
/// If power is greater than 1, it will do an additional 2 * (power - 1)
|
||||
/// damage. You will get (3 * power) back if you hit the other robot.
|
||||
///</summary>
|
||||
public double Power
|
||||
{
|
||||
get { return power; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the velocity of this bullet. The velocity of the bullet is
|
||||
/// constant once it has been fired.
|
||||
///</summary>
|
||||
public double Velocity
|
||||
{
|
||||
get { return Rules.GetBulletSpeed(power); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the robot that this bullet hit, or null if
|
||||
/// the bullet has not hit a robot.
|
||||
///</summary>
|
||||
public string Victim
|
||||
{
|
||||
get { return victimName; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the X position of the bullet.
|
||||
///</summary>
|
||||
public double X
|
||||
{
|
||||
get { return x; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the Y position of the bullet.
|
||||
///</summary>
|
||||
public double Y
|
||||
{
|
||||
get { return y; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Checks if this bullet is still active on the battlefield.
|
||||
///</summary>
|
||||
public bool IsActive
|
||||
{
|
||||
get { return _isActive; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Updates this bullet based on the specified bullet status.
|
||||
///</summary>
|
||||
// this method is invisible on RobotAPI
|
||||
private void update(double x, double y, string victimName, bool isActive)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.victimName = victimName;
|
||||
_isActive = isActive;
|
||||
}
|
||||
|
||||
internal int getBulletId()
|
||||
{
|
||||
return bulletId;
|
||||
}
|
||||
|
||||
private static IHiddenBulletHelper createHiddenHelper()
|
||||
{
|
||||
return new HiddenBulletHelper();
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new HiddenBulletHelper();
|
||||
}
|
||||
|
||||
private class HiddenBulletHelper : IHiddenBulletHelper, ISerializableHelperN
|
||||
{
|
||||
public void update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
||||
{
|
||||
bullet.update(x, y, victimName, isActive);
|
||||
}
|
||||
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (Bullet)objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 4 * RbSerializerN.SIZEOF_DOUBLE + serializer.sizeOf(obj.ownerName)
|
||||
+ serializer.sizeOf(obj.victimName) + RbSerializerN.SIZEOF_BOOL + RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (Bullet)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.headingRadians);
|
||||
serializer.serialize(buffer, obj.x);
|
||||
serializer.serialize(buffer, obj.y);
|
||||
serializer.serialize(buffer, obj.power);
|
||||
serializer.serialize(buffer, obj.ownerName);
|
||||
serializer.serialize(buffer, obj.victimName);
|
||||
serializer.serialize(buffer, obj._isActive);
|
||||
serializer.serialize(buffer, obj.bulletId);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
double headingRadians = buffer.getDouble();
|
||||
double x = buffer.getDouble();
|
||||
double y = buffer.getDouble();
|
||||
double power = buffer.getDouble();
|
||||
string ownerName = serializer.deserializeString(buffer);
|
||||
string victimName = serializer.deserializeString(buffer);
|
||||
bool isActive = serializer.deserializeBoolean(buffer);
|
||||
int bulletId = serializer.deserializeInt(buffer);
|
||||
|
||||
return new Bullet(headingRadians, x, y, power, ownerName, victimName, isActive, bulletId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.security;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.Util;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///
|
||||
///<summary>
|
||||
/// Represents a bullet. This is returned from <see cref="Robot.FireBullet(double)"/>
|
||||
/// and <see cref="AdvancedRobot.SetFireBullet(double)"/>, and all the bullet-related
|
||||
/// events.
|
||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||
/// <seealso cref="AdvancedRobot.SetFireBullet(double)"/>
|
||||
/// <seealso cref="BulletHitEvent"/>
|
||||
/// <seealso cref="BulletMissedEvent"/>
|
||||
/// <seealso cref="BulletHitBulletEvent"/>
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public class Bullet
|
||||
{
|
||||
private readonly double headingRadians;
|
||||
private double x;
|
||||
private double y;
|
||||
private readonly double power;
|
||||
private readonly string ownerName;
|
||||
private string victimName;
|
||||
private bool _isActive;
|
||||
private readonly int bulletId;
|
||||
|
||||
///<summary>
|
||||
/// Called by the game to create a new Bullet object
|
||||
///</summary>
|
||||
public Bullet(double heading, double x, double y, double power, string ownerName, string victimName,
|
||||
bool isActive, int bulletId)
|
||||
{
|
||||
headingRadians = heading;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.power = power;
|
||||
this.ownerName = ownerName;
|
||||
this.victimName = victimName;
|
||||
_isActive = isActive;
|
||||
this.bulletId = bulletId;
|
||||
}
|
||||
|
||||
public override bool Equals(Object obj)
|
||||
{
|
||||
if (obj is Bullet)
|
||||
{
|
||||
Bullet bullet = (Bullet)obj;
|
||||
return bullet.bulletId == bulletId;
|
||||
}
|
||||
return Equals(obj);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the direction the bullet is/was heading, in degrees
|
||||
/// (0 <= getHeading() < 360). This is not relative to the direction you are facing.
|
||||
///</summary>
|
||||
public double Heading
|
||||
{
|
||||
get { return Utils.ToDegrees(headingRadians); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the direction the bullet is/was heading, in radians
|
||||
/// (0 <= getHeadingRadians() < 2 * Math.PI). This is not relative to the direction you are facing.
|
||||
///</summary>
|
||||
public double HeadingRadians
|
||||
{
|
||||
get { return headingRadians; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the robot that fired this bullet.
|
||||
///</summary>
|
||||
public string Name
|
||||
{
|
||||
get { return ownerName; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the power of this bullet.
|
||||
/// <p />
|
||||
/// The bullet will do (4 * power) damage if it hits another robot.
|
||||
/// If power is greater than 1, it will do an additional 2 * (power - 1)
|
||||
/// damage. You will get (3 * power) back if you hit the other robot.
|
||||
///</summary>
|
||||
public double Power
|
||||
{
|
||||
get { return power; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the velocity of this bullet. The velocity of the bullet is
|
||||
/// constant once it has been fired.
|
||||
///</summary>
|
||||
public double Velocity
|
||||
{
|
||||
get { return Rules.GetBulletSpeed(power); }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the robot that this bullet hit, or null if
|
||||
/// the bullet has not hit a robot.
|
||||
///</summary>
|
||||
public string Victim
|
||||
{
|
||||
get { return victimName; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the X position of the bullet.
|
||||
///</summary>
|
||||
public double X
|
||||
{
|
||||
get { return x; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the Y position of the bullet.
|
||||
///</summary>
|
||||
public double Y
|
||||
{
|
||||
get { return y; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Checks if this bullet is still active on the battlefield.
|
||||
///</summary>
|
||||
public bool IsActive
|
||||
{
|
||||
get { return _isActive; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Updates this bullet based on the specified bullet status.
|
||||
///</summary>
|
||||
// this method is invisible on RobotAPI
|
||||
private void update(double x, double y, string victimName, bool isActive)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.victimName = victimName;
|
||||
_isActive = isActive;
|
||||
}
|
||||
|
||||
internal int getBulletId()
|
||||
{
|
||||
return bulletId;
|
||||
}
|
||||
|
||||
private static IHiddenBulletHelper createHiddenHelper()
|
||||
{
|
||||
return new HiddenBulletHelper();
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new HiddenBulletHelper();
|
||||
}
|
||||
|
||||
private class HiddenBulletHelper : IHiddenBulletHelper, ISerializableHelperN
|
||||
{
|
||||
public void update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
||||
{
|
||||
bullet.update(x, y, victimName, isActive);
|
||||
}
|
||||
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (Bullet)objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 4 * RbSerializerN.SIZEOF_DOUBLE + serializer.sizeOf(obj.ownerName)
|
||||
+ serializer.sizeOf(obj.victimName) + RbSerializerN.SIZEOF_BOOL + RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (Bullet)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.headingRadians);
|
||||
serializer.serialize(buffer, obj.x);
|
||||
serializer.serialize(buffer, obj.y);
|
||||
serializer.serialize(buffer, obj.power);
|
||||
serializer.serialize(buffer, obj.ownerName);
|
||||
serializer.serialize(buffer, obj.victimName);
|
||||
serializer.serialize(buffer, obj._isActive);
|
||||
serializer.serialize(buffer, obj.bulletId);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
double headingRadians = buffer.getDouble();
|
||||
double x = buffer.getDouble();
|
||||
double y = buffer.getDouble();
|
||||
double power = buffer.getDouble();
|
||||
string ownerName = serializer.deserializeString(buffer);
|
||||
string victimName = serializer.deserializeString(buffer);
|
||||
bool isActive = serializer.deserializeBoolean(buffer);
|
||||
int bulletId = serializer.deserializeInt(buffer);
|
||||
|
||||
return new Bullet(headingRadians, x, y, power, ownerName, victimName, isActive, bulletId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,116 +1,116 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// This event is sent to <see cref="Robot.OnBulletHitBullet(BulletHitBulletEvent)"/>
|
||||
/// when one of your bullets has hit another bullet.
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BulletHitBulletEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 55;
|
||||
|
||||
private Bullet bullet;
|
||||
private readonly Bullet hitBullet;
|
||||
|
||||
///<summary>
|
||||
/// Called by the game to create a new BulletHitEvent.
|
||||
///</summary>
|
||||
public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet)
|
||||
{
|
||||
this.bullet = bullet;
|
||||
this.hitBullet = hitBullet;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns your bullet that hit another bullet.
|
||||
///</summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet that was hit by your bullet.
|
||||
///</summary>
|
||||
public Bullet HitBullet
|
||||
{
|
||||
get { return hitBullet; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBulletHitBullet(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
// we need to pass same instance
|
||||
bullet = bullets[bullet.getBulletId()];
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BulletHitBulletEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BulletHitBulletEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT
|
||||
+ serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BulletHitBulletEvent) objec;
|
||||
|
||||
// no need to transmit whole bullet, rest of it is already known to proxy side
|
||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||
var hitBullet = (Bullet) serializer.deserializeAny(buffer);
|
||||
|
||||
return new BulletHitBulletEvent(bullet, hitBullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// This event is sent to <see cref="Robot.OnBulletHitBullet(BulletHitBulletEvent)"/>
|
||||
/// when one of your bullets has hit another bullet.
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BulletHitBulletEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 55;
|
||||
|
||||
private Bullet bullet;
|
||||
private readonly Bullet hitBullet;
|
||||
|
||||
///<summary>
|
||||
/// Called by the game to create a new BulletHitEvent.
|
||||
///</summary>
|
||||
public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet)
|
||||
{
|
||||
this.bullet = bullet;
|
||||
this.hitBullet = hitBullet;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns your bullet that hit another bullet.
|
||||
///</summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet that was hit by your bullet.
|
||||
///</summary>
|
||||
public Bullet HitBullet
|
||||
{
|
||||
get { return hitBullet; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBulletHitBullet(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
// we need to pass same instance
|
||||
bullet = bullets[bullet.getBulletId()];
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BulletHitBulletEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BulletHitBulletEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT
|
||||
+ serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BulletHitBulletEvent) objec;
|
||||
|
||||
// no need to transmit whole bullet, rest of it is already known to proxy side
|
||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||
var hitBullet = (Bullet) serializer.deserializeAny(buffer);
|
||||
|
||||
return new BulletHitBulletEvent(bullet, hitBullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
|
@ -1,128 +1,128 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// This event is sent to <see cref="Robot.OnBulletHit(BulletHitEvent)"/>
|
||||
/// when one of your bullets has hit another robot.
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BulletHitEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 50;
|
||||
|
||||
private readonly string name;
|
||||
private readonly double energy;
|
||||
private Bullet bullet;
|
||||
|
||||
///<summary>
|
||||
/// Called by the game to create a new BulletHitEvent.
|
||||
///</summary>
|
||||
public BulletHitEvent(string name, double energy, Bullet bullet)
|
||||
{
|
||||
this.name = name;
|
||||
this.energy = energy;
|
||||
this.bullet = bullet;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet of yours that hit the robot.
|
||||
///</summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the remaining energy of the robot your bullet has hit (after the
|
||||
/// damage done by your bullet).
|
||||
///</summary>
|
||||
public double VictimEnergy
|
||||
{
|
||||
get { return energy; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the robot your bullet hit.
|
||||
///</summary>
|
||||
public string VictimName
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBulletHit(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
// we need to pass same instance
|
||||
bullet = bullets[bullet.getBulletId()];
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BulletHitEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BulletHitEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT + serializer.sizeOf(obj.name)
|
||||
+ RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BulletHitEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||
serializer.serialize(buffer, obj.name);
|
||||
serializer.serialize(buffer, obj.energy);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||
string name = serializer.deserializeString(buffer);
|
||||
double energy = buffer.getDouble();
|
||||
|
||||
return new BulletHitEvent(name, energy, bullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// This event is sent to <see cref="Robot.OnBulletHit(BulletHitEvent)"/>
|
||||
/// when one of your bullets has hit another robot.
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BulletHitEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 50;
|
||||
|
||||
private readonly string name;
|
||||
private readonly double energy;
|
||||
private Bullet bullet;
|
||||
|
||||
///<summary>
|
||||
/// Called by the game to create a new BulletHitEvent.
|
||||
///</summary>
|
||||
public BulletHitEvent(string name, double energy, Bullet bullet)
|
||||
{
|
||||
this.name = name;
|
||||
this.energy = energy;
|
||||
this.bullet = bullet;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the bullet of yours that hit the robot.
|
||||
///</summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the remaining energy of the robot your bullet has hit (after the
|
||||
/// damage done by your bullet).
|
||||
///</summary>
|
||||
public double VictimEnergy
|
||||
{
|
||||
get { return energy; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Returns the name of the robot your bullet hit.
|
||||
///</summary>
|
||||
public string VictimName
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBulletHit(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
// we need to pass same instance
|
||||
bullet = bullets[bullet.getBulletId()];
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BulletHitEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (BulletHitEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT + serializer.sizeOf(obj.name)
|
||||
+ RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BulletHitEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||
serializer.serialize(buffer, obj.name);
|
||||
serializer.serialize(buffer, obj.energy);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||
string name = serializer.deserializeString(buffer);
|
||||
double energy = buffer.getDouble();
|
||||
|
||||
return new BulletHitEvent(name, energy, bullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
|
@ -1,102 +1,102 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// This event is sent to <see cref="Robot.OnBulletMissed(BulletMissedEvent)"/>
|
||||
/// when one of your bullets has missed, i.e. when the bullet has
|
||||
/// reached the border of the battlefield.
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BulletMissedEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 60;
|
||||
|
||||
private Bullet bullet;
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// Called by the game to create a new BulletMissedEvent.
|
||||
///</summary>
|
||||
public BulletMissedEvent(Bullet bullet)
|
||||
{
|
||||
this.bullet = bullet;
|
||||
}
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// Returns the bullet that missed.
|
||||
///</summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBulletMissed(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
// we need to pass same instance
|
||||
bullet = bullets[bullet.getBulletId()];
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BulletMissedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BulletMissedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||
|
||||
return new BulletMissedEvent(bullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
///<summary>
|
||||
/// This event is sent to <see cref="Robot.OnBulletMissed(BulletMissedEvent)"/>
|
||||
/// when one of your bullets has missed, i.e. when the bullet has
|
||||
/// reached the border of the battlefield.
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public sealed class BulletMissedEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 60;
|
||||
|
||||
private Bullet bullet;
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// Called by the game to create a new BulletMissedEvent.
|
||||
///</summary>
|
||||
public BulletMissedEvent(Bullet bullet)
|
||||
{
|
||||
this.bullet = bullet;
|
||||
}
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// Returns the bullet that missed.
|
||||
///</summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnBulletMissed(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
// we need to pass same instance
|
||||
bullet = bullets[bullet.getBulletId()];
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.BulletMissedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (BulletMissedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||
|
||||
return new BulletMissedEvent(bullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,155 +1,155 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.io;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition is used to define custom <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
||||
/// and custom events for an AdvancedRobot. The code below is taken from the sample robot
|
||||
/// named samplecs.Target. See the samplecs/Target.cs for details.
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// AddCustomEvent(
|
||||
/// new Condition("triggerhit", (c) =>
|
||||
/// {
|
||||
/// return Energy <= trigger;
|
||||
/// }));
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
||||
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||
/// <see cref="AdvancedRobot.RemoveCustomEvent(Condition)"/>
|
||||
/// <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
||||
/// </summary>
|
||||
public class Condition
|
||||
{
|
||||
private readonly ConditionTest test;
|
||||
|
||||
/// <summary>
|
||||
/// The priority of this condition. Defaults to 80.
|
||||
/// </summary>
|
||||
public int priority = 80;
|
||||
|
||||
/// <summary>
|
||||
/// The name of this condition.
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||
/// </summary>
|
||||
public Condition(string name, int priority, ConditionTest test)
|
||||
: this(name, priority)
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||
/// </summary>
|
||||
public Condition(string name, ConditionTest test)
|
||||
: this(name)
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||
/// </summary>
|
||||
public Condition(ConditionTest test)
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new, unnamed Condition with the default priority, which is 80.
|
||||
/// </summary>
|
||||
protected Condition()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Condition with the specified name, and default priority, which is 80.
|
||||
/// </summary>
|
||||
/// <param name="name">The name for the new Condition</param>
|
||||
protected Condition(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Condition with the specified name and priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="name">The name for the new condition</param>
|
||||
/// <param name="priority">The priority of the new condition</param>
|
||||
protected Condition(string name, int priority)
|
||||
{
|
||||
this.name = name;
|
||||
if (priority < 0)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 0.");
|
||||
priority = 0;
|
||||
}
|
||||
else if (priority > 99)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 99.");
|
||||
priority = 99;
|
||||
}
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this condition.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name ?? GetType().Name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the priority of this condition.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// </summary>
|
||||
public int Priority
|
||||
{
|
||||
get { return priority; }
|
||||
set { priority=value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overriding the Test() method is the point of a Condition.
|
||||
/// The game will call your Test() function, and take action if it returns true.
|
||||
/// This is valid for both <see cref="AdvancedRobot.WaitFor"/> and
|
||||
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||
/// <p/>
|
||||
/// You may not take any actions inside of Test().
|
||||
/// </summary>
|
||||
public virtual bool Test()
|
||||
{
|
||||
if (test != null)
|
||||
{
|
||||
return test(this);
|
||||
}
|
||||
throw new NotImplementedException("You should inherit from Condition class and override Test() method or pass delegate into constructor");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method signature for Test method of <see cref="Condition"/>
|
||||
/// </summary>
|
||||
public delegate bool ConditionTest(Condition condition);
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.io;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition is used to define custom <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
||||
/// and custom events for an AdvancedRobot. The code below is taken from the sample robot
|
||||
/// named samplecs.Target. See the samplecs/Target.cs for details.
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// AddCustomEvent(
|
||||
/// new Condition("triggerhit", (c) =>
|
||||
/// {
|
||||
/// return Energy <= trigger;
|
||||
/// }));
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
||||
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||
/// <see cref="AdvancedRobot.RemoveCustomEvent(Condition)"/>
|
||||
/// <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
||||
/// </summary>
|
||||
public class Condition
|
||||
{
|
||||
private readonly ConditionTest test;
|
||||
|
||||
/// <summary>
|
||||
/// The priority of this condition. Defaults to 80.
|
||||
/// </summary>
|
||||
public int priority = 80;
|
||||
|
||||
/// <summary>
|
||||
/// The name of this condition.
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||
/// </summary>
|
||||
public Condition(string name, int priority, ConditionTest test)
|
||||
: this(name, priority)
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||
/// </summary>
|
||||
public Condition(string name, ConditionTest test)
|
||||
: this(name)
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||
/// </summary>
|
||||
public Condition(ConditionTest test)
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new, unnamed Condition with the default priority, which is 80.
|
||||
/// </summary>
|
||||
protected Condition()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Condition with the specified name, and default priority, which is 80.
|
||||
/// </summary>
|
||||
/// <param name="name">The name for the new Condition</param>
|
||||
protected Condition(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Condition with the specified name and priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="name">The name for the new condition</param>
|
||||
/// <param name="priority">The priority of the new condition</param>
|
||||
protected Condition(string name, int priority)
|
||||
{
|
||||
this.name = name;
|
||||
if (priority < 0)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 0.");
|
||||
priority = 0;
|
||||
}
|
||||
else if (priority > 99)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 99.");
|
||||
priority = 99;
|
||||
}
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this condition.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name ?? GetType().Name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the priority of this condition.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// </summary>
|
||||
public int Priority
|
||||
{
|
||||
get { return priority; }
|
||||
set { priority=value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overriding the Test() method is the point of a Condition.
|
||||
/// The game will call your Test() function, and take action if it returns true.
|
||||
/// This is valid for both <see cref="AdvancedRobot.WaitFor"/> and
|
||||
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||
/// <p/>
|
||||
/// You may not take any actions inside of Test().
|
||||
/// </summary>
|
||||
public virtual bool Test()
|
||||
{
|
||||
if (test != null)
|
||||
{
|
||||
return test(this);
|
||||
}
|
||||
throw new NotImplementedException("You should inherit from Condition class and override Test() method or pass delegate into constructor");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method signature for Test method of <see cref="Condition"/>
|
||||
/// </summary>
|
||||
public delegate bool ConditionTest(Condition condition);
|
||||
}
|
||||
//doc
|
|
@ -1,123 +1,123 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event is sent to <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
||||
/// when a custom condition is met. Be sure to reset or remove the custom condition to avoid
|
||||
/// having it recurring repeatedly (see the example for the <see cref="Condition"/> method.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CustomEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 80;
|
||||
|
||||
private readonly Condition condition;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new CustomEvent when a condition is met.
|
||||
/// </summary>
|
||||
public CustomEvent(Condition condition)
|
||||
{
|
||||
this.condition = condition;
|
||||
if (condition != null)
|
||||
{
|
||||
Priority = condition.Priority;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new CustomEvent when a condition is met.
|
||||
/// The event will have the given priority.
|
||||
/// An event priority is a value from 0 - 99. The higher value, the higher
|
||||
/// priority. The default priority is 80.
|
||||
/// <p/>
|
||||
/// This is equivalent to calling <see cref="Robocode.Condition.Priority"/> on the
|
||||
/// Condition.
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition that must be met</param>
|
||||
/// <param name="priority">The priority of the condition</param>
|
||||
public CustomEvent(Condition condition, int priority)
|
||||
{
|
||||
this.condition = condition;
|
||||
Priority = priority;
|
||||
if (condition != null)
|
||||
{
|
||||
condition.Priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the condition that fired, causing this event to be generated.
|
||||
/// Use this to determine which condition fired, and to remove the custom event.
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// public void OnCustomEvent(CustomEvent evnt)
|
||||
/// {
|
||||
/// if (event.Condition.Name == "mycondition")
|
||||
/// {
|
||||
/// RemoveCustomEvent(event.Condition);
|
||||
/// // do something else
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// </summary>
|
||||
public Condition Condition
|
||||
{
|
||||
get { return condition; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsAdvancedRobot())
|
||||
{
|
||||
IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnCustomEvent(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sealed to disable overrides
|
||||
public override sealed int CompareTo(Event evnt)
|
||||
{
|
||||
return base.CompareTo(evnt);
|
||||
}
|
||||
|
||||
// sealed to disable overrides
|
||||
internal override bool IsCriticalEvent
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
// sealed to disable overrides
|
||||
public sealed override int Priority
|
||||
{
|
||||
get { return base.Priority; }
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization not supported on this event type"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event is sent to <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
||||
/// when a custom condition is met. Be sure to reset or remove the custom condition to avoid
|
||||
/// having it recurring repeatedly (see the example for the <see cref="Condition"/> method.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CustomEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 80;
|
||||
|
||||
private readonly Condition condition;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new CustomEvent when a condition is met.
|
||||
/// </summary>
|
||||
public CustomEvent(Condition condition)
|
||||
{
|
||||
this.condition = condition;
|
||||
if (condition != null)
|
||||
{
|
||||
Priority = condition.Priority;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new CustomEvent when a condition is met.
|
||||
/// The event will have the given priority.
|
||||
/// An event priority is a value from 0 - 99. The higher value, the higher
|
||||
/// priority. The default priority is 80.
|
||||
/// <p/>
|
||||
/// This is equivalent to calling <see cref="Robocode.Condition.Priority"/> on the
|
||||
/// Condition.
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition that must be met</param>
|
||||
/// <param name="priority">The priority of the condition</param>
|
||||
public CustomEvent(Condition condition, int priority)
|
||||
{
|
||||
this.condition = condition;
|
||||
Priority = priority;
|
||||
if (condition != null)
|
||||
{
|
||||
condition.Priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the condition that fired, causing this event to be generated.
|
||||
/// Use this to determine which condition fired, and to remove the custom event.
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// public void OnCustomEvent(CustomEvent evnt)
|
||||
/// {
|
||||
/// if (event.Condition.Name == "mycondition")
|
||||
/// {
|
||||
/// RemoveCustomEvent(event.Condition);
|
||||
/// // do something else
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// </summary>
|
||||
public Condition Condition
|
||||
{
|
||||
get { return condition; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsAdvancedRobot())
|
||||
{
|
||||
IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnCustomEvent(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sealed to disable overrides
|
||||
public override sealed int CompareTo(Event evnt)
|
||||
{
|
||||
return base.CompareTo(evnt);
|
||||
}
|
||||
|
||||
// sealed to disable overrides
|
||||
internal override bool IsCriticalEvent
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
// sealed to disable overrides
|
||||
public sealed override int Priority
|
||||
{
|
||||
get { return base.Priority; }
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization not supported on this event type"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,78 +1,78 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event is sent to <see cref="Robot.OnDeath(DeathEvent)"/> when your robot dies.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class DeathEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = -1; // System event -> cannot be changed!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Priority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnDeath(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool IsCriticalEvent
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.DeathEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
return new DeathEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event is sent to <see cref="Robot.OnDeath(DeathEvent)"/> when your robot dies.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class DeathEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = -1; // System event -> cannot be changed!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Priority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnDeath(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool IsCriticalEvent
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.DeathEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
return new DeathEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,279 +1,279 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.io;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.security;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// The superclass of all Robocode events.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class Event : IComparable<Event>
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 80;
|
||||
|
||||
private long time;
|
||||
private int priority;
|
||||
|
||||
// time is valid only after adding to event manager on proxy side, we do not update it on battle side
|
||||
private volatile bool addedToQueue;
|
||||
|
||||
/// <summary>
|
||||
/// Compares this event to another event regarding precedence.
|
||||
/// <para>
|
||||
/// The event precedence is first and foremost determined by the event time,
|
||||
/// secondly the event priority, and lastly specific event information.</para>
|
||||
/// <para>
|
||||
/// This method will first compare the time of each event. If the event time
|
||||
/// is the same for both events, then this method compared the priority of
|
||||
/// each event. If the event priorities are equals, then this method will
|
||||
/// compare the two events based on specific event information.</para>
|
||||
/// <para>
|
||||
/// This method is called by the game in order to sort the event queue of a
|
||||
/// robot to make sure the events are listed in chronological order.</para>
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="evnt">the event to compare to this event.</param>
|
||||
/// <returns>
|
||||
/// Returns a negative value if this event has higher precedence, i.e. must
|
||||
/// be listed before the specified event. A positive value if this event
|
||||
/// has a lower precedence, i.e. must be listed after the specified event.
|
||||
/// 0 means that the precedence of the two events are equal.
|
||||
/// </returns>
|
||||
public virtual int CompareTo(Event evnt)
|
||||
{
|
||||
// Compare the time difference which has precedence over priority.
|
||||
var timeDiff = (int) (time - evnt.time);
|
||||
|
||||
if (timeDiff != 0)
|
||||
{
|
||||
return timeDiff; // Time differ
|
||||
}
|
||||
|
||||
// Same time -> Compare the difference in priority
|
||||
int priorityDiff = evnt.Priority - Priority;
|
||||
|
||||
if (priorityDiff != 0)
|
||||
{
|
||||
return priorityDiff; // Priority differ
|
||||
}
|
||||
|
||||
// Same time and priority -> Compare specific event types
|
||||
// look at overrides in ScannedRobotEvent and HitRobotEvent
|
||||
|
||||
// No difference found
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The time when this event occurred.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that the time is equal to the turn of a battle round.
|
||||
/// <para>
|
||||
/// This method is intended for letting robot developers create their own event types.
|
||||
/// It is not possible to change the time of an event after it has been added to the event
|
||||
/// queue of the robot.</para>
|
||||
/// </remarks>
|
||||
public long Time
|
||||
{
|
||||
get { return time; }
|
||||
set
|
||||
{
|
||||
if (addedToQueue)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: The time of an event cannot be changed after it has been added the event queue.");
|
||||
}
|
||||
else
|
||||
{
|
||||
time = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The priority of this event.
|
||||
/// <para>
|
||||
/// An event priority is a value from 0 - 99. The higher value, the higher priority.</para>
|
||||
/// <para>
|
||||
/// The default priority is 80, but varies depending on the type of event.</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is intended for letting robot developers create their own event types.
|
||||
/// <para>
|
||||
/// It is not possible to change the priority of an event after it has been added to the event
|
||||
/// queue of the robot.</para>
|
||||
/// </remarks>
|
||||
/// <seealso cref="SetEventPriority(string, int)"/>
|
||||
public virtual int Priority
|
||||
{
|
||||
get { return priority; }
|
||||
set
|
||||
{
|
||||
if (addedToQueue)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: The priority of an event cannot be changed after it has been added the event queue.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPriorityHidden(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hidden method for setting the exact time when this event occurred.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is called by the game engine only.
|
||||
/// </remarks>
|
||||
/// <param name="time">the time when this event occurred.</param>
|
||||
// This method must be invisible on Robot API
|
||||
private void SetTimeHidden(long time)
|
||||
{
|
||||
// we do not replace time which is set by robot to the future
|
||||
if (this.time < time)
|
||||
{
|
||||
this.time = time;
|
||||
}
|
||||
// when this flag is set, robots are not allowed to change the time or priority of the event anymore
|
||||
addedToQueue = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hidden method for setting the priority from the game engine without checking for the 'addedToQueue' flag.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is called by the game engine only.
|
||||
/// </remarks>
|
||||
/// <param name="newPriority">the new priority of this event.</param>
|
||||
// This method must be invisible on Robot API
|
||||
private void SetPriorityHidden(int newPriority)
|
||||
{
|
||||
if (newPriority < 0)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 0");
|
||||
newPriority = 0;
|
||||
}
|
||||
else if (newPriority > 99)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 99");
|
||||
newPriority = 99;
|
||||
}
|
||||
priority = newPriority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatch this event for a robot, it's statistics, and graphics context.
|
||||
/// </summary>
|
||||
/// <param name="robot">the robot to dispatch to.</param>
|
||||
/// <param name="statics">the robot to statistics to.</param>
|
||||
/// <param name="graphics">the robot to graphics to.</param>
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default priority of this event class.
|
||||
/// </summary>
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this event must be delivered even after timeout.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> when this event must be delivered even after timeout;
|
||||
/// <c>false</c> otherwise.
|
||||
/// </returns>
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual bool IsCriticalEvent
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization not supported on this event type"); }
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hidden event helper for accessing hidden methods on this object.
|
||||
/// </summary>
|
||||
// This method must be invisible on Robot API
|
||||
private static IHiddenEventHelper createHiddenHelper()
|
||||
{
|
||||
return new HiddenEventHelper();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hidden event helper implementation for accessing the internal methods of an event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is used internally by the game engine.
|
||||
/// </remarks>
|
||||
// This method must be invisible on Robot API
|
||||
private class HiddenEventHelper : IHiddenEventHelper
|
||||
{
|
||||
public void SetTime(Event evnt, long newTime)
|
||||
{
|
||||
evnt.SetTimeHidden(newTime);
|
||||
}
|
||||
|
||||
public void SetDefaultPriority(Event evnt)
|
||||
{
|
||||
evnt.Priority = evnt.DefaultPriority;
|
||||
}
|
||||
|
||||
public void SetPriority(Event evnt, int newPriority)
|
||||
{
|
||||
evnt.SetPriorityHidden(newPriority);
|
||||
}
|
||||
|
||||
public bool IsCriticalEvent(Event evnt)
|
||||
{
|
||||
return evnt.IsCriticalEvent;
|
||||
}
|
||||
|
||||
public void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
evnt.Dispatch(robot, statics, graphics);
|
||||
}
|
||||
|
||||
public byte GetSerializationType(Event evnt)
|
||||
{
|
||||
return evnt.SerializationType;
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
public void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
evnt.UpdateBullets(bullets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using net.sf.robocode.io;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.security;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// The superclass of all Robocode events.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class Event : IComparable<Event>
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 80;
|
||||
|
||||
private long time;
|
||||
private int priority;
|
||||
|
||||
// time is valid only after adding to event manager on proxy side, we do not update it on battle side
|
||||
private volatile bool addedToQueue;
|
||||
|
||||
/// <summary>
|
||||
/// Compares this event to another event regarding precedence.
|
||||
/// <para>
|
||||
/// The event precedence is first and foremost determined by the event time,
|
||||
/// secondly the event priority, and lastly specific event information.</para>
|
||||
/// <para>
|
||||
/// This method will first compare the time of each event. If the event time
|
||||
/// is the same for both events, then this method compared the priority of
|
||||
/// each event. If the event priorities are equals, then this method will
|
||||
/// compare the two events based on specific event information.</para>
|
||||
/// <para>
|
||||
/// This method is called by the game in order to sort the event queue of a
|
||||
/// robot to make sure the events are listed in chronological order.</para>
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="evnt">the event to compare to this event.</param>
|
||||
/// <returns>
|
||||
/// Returns a negative value if this event has higher precedence, i.e. must
|
||||
/// be listed before the specified event. A positive value if this event
|
||||
/// has a lower precedence, i.e. must be listed after the specified event.
|
||||
/// 0 means that the precedence of the two events are equal.
|
||||
/// </returns>
|
||||
public virtual int CompareTo(Event evnt)
|
||||
{
|
||||
// Compare the time difference which has precedence over priority.
|
||||
var timeDiff = (int) (time - evnt.time);
|
||||
|
||||
if (timeDiff != 0)
|
||||
{
|
||||
return timeDiff; // Time differ
|
||||
}
|
||||
|
||||
// Same time -> Compare the difference in priority
|
||||
int priorityDiff = evnt.Priority - Priority;
|
||||
|
||||
if (priorityDiff != 0)
|
||||
{
|
||||
return priorityDiff; // Priority differ
|
||||
}
|
||||
|
||||
// Same time and priority -> Compare specific event types
|
||||
// look at overrides in ScannedRobotEvent and HitRobotEvent
|
||||
|
||||
// No difference found
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The time when this event occurred.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that the time is equal to the turn of a battle round.
|
||||
/// <para>
|
||||
/// This method is intended for letting robot developers create their own event types.
|
||||
/// It is not possible to change the time of an event after it has been added to the event
|
||||
/// queue of the robot.</para>
|
||||
/// </remarks>
|
||||
public long Time
|
||||
{
|
||||
get { return time; }
|
||||
set
|
||||
{
|
||||
if (addedToQueue)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: The time of an event cannot be changed after it has been added the event queue.");
|
||||
}
|
||||
else
|
||||
{
|
||||
time = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The priority of this event.
|
||||
/// <para>
|
||||
/// An event priority is a value from 0 - 99. The higher value, the higher priority.</para>
|
||||
/// <para>
|
||||
/// The default priority is 80, but varies depending on the type of event.</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is intended for letting robot developers create their own event types.
|
||||
/// <para>
|
||||
/// It is not possible to change the priority of an event after it has been added to the event
|
||||
/// queue of the robot.</para>
|
||||
/// </remarks>
|
||||
/// <seealso cref="SetEventPriority(string, int)"/>
|
||||
public virtual int Priority
|
||||
{
|
||||
get { return priority; }
|
||||
set
|
||||
{
|
||||
if (addedToQueue)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: The priority of an event cannot be changed after it has been added the event queue.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPriorityHidden(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hidden method for setting the exact time when this event occurred.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is called by the game engine only.
|
||||
/// </remarks>
|
||||
/// <param name="time">the time when this event occurred.</param>
|
||||
// This method must be invisible on Robot API
|
||||
private void SetTimeHidden(long time)
|
||||
{
|
||||
// we do not replace time which is set by robot to the future
|
||||
if (this.time < time)
|
||||
{
|
||||
this.time = time;
|
||||
}
|
||||
// when this flag is set, robots are not allowed to change the time or priority of the event anymore
|
||||
addedToQueue = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hidden method for setting the priority from the game engine without checking for the 'addedToQueue' flag.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is called by the game engine only.
|
||||
/// </remarks>
|
||||
/// <param name="newPriority">the new priority of this event.</param>
|
||||
// This method must be invisible on Robot API
|
||||
private void SetPriorityHidden(int newPriority)
|
||||
{
|
||||
if (newPriority < 0)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 0");
|
||||
newPriority = 0;
|
||||
}
|
||||
else if (newPriority > 99)
|
||||
{
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 99");
|
||||
newPriority = 99;
|
||||
}
|
||||
priority = newPriority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatch this event for a robot, it's statistics, and graphics context.
|
||||
/// </summary>
|
||||
/// <param name="robot">the robot to dispatch to.</param>
|
||||
/// <param name="statics">the robot to statistics to.</param>
|
||||
/// <param name="graphics">the robot to graphics to.</param>
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default priority of this event class.
|
||||
/// </summary>
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this event must be delivered even after timeout.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> when this event must be delivered even after timeout;
|
||||
/// <c>false</c> otherwise.
|
||||
/// </returns>
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual bool IsCriticalEvent
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization not supported on this event type"); }
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
// This method must be invisible on Robot API
|
||||
internal virtual void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hidden event helper for accessing hidden methods on this object.
|
||||
/// </summary>
|
||||
// This method must be invisible on Robot API
|
||||
private static IHiddenEventHelper createHiddenHelper()
|
||||
{
|
||||
return new HiddenEventHelper();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hidden event helper implementation for accessing the internal methods of an event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is used internally by the game engine.
|
||||
/// </remarks>
|
||||
// This method must be invisible on Robot API
|
||||
private class HiddenEventHelper : IHiddenEventHelper
|
||||
{
|
||||
public void SetTime(Event evnt, long newTime)
|
||||
{
|
||||
evnt.SetTimeHidden(newTime);
|
||||
}
|
||||
|
||||
public void SetDefaultPriority(Event evnt)
|
||||
{
|
||||
evnt.Priority = evnt.DefaultPriority;
|
||||
}
|
||||
|
||||
public void SetPriority(Event evnt, int newPriority)
|
||||
{
|
||||
evnt.SetPriorityHidden(newPriority);
|
||||
}
|
||||
|
||||
public bool IsCriticalEvent(Event evnt)
|
||||
{
|
||||
return evnt.IsCriticalEvent;
|
||||
}
|
||||
|
||||
public void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
evnt.Dispatch(robot, statics, graphics);
|
||||
}
|
||||
|
||||
public byte GetSerializationType(Event evnt)
|
||||
{
|
||||
return evnt.SerializationType;
|
||||
}
|
||||
|
||||
// Needed for .NET version
|
||||
public void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets)
|
||||
{
|
||||
evnt.UpdateBullets(bullets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,52 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A prebuilt condition you can use that indicates your gun has finished turning.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
public class GunTurnCompleteCondition : Condition
|
||||
{
|
||||
private readonly AdvancedRobot robot;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new GunTurnCompleteCondition with default priority.
|
||||
/// The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||
public GunTurnCompleteCondition(AdvancedRobot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new GunTurnCompleteCondition with a specific priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// <seealso cref="Condition.Priority"/>
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||
/// <param name="priority">The priority of this condition</param>
|
||||
public GunTurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||
{
|
||||
this.robot = robot;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the gun has stopped turning.
|
||||
/// Returns true if the gun has stopped turning
|
||||
/// </summary>
|
||||
public override bool Test()
|
||||
{
|
||||
return (robot.GunTurnRemaining == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A prebuilt condition you can use that indicates your gun has finished turning.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
public class GunTurnCompleteCondition : Condition
|
||||
{
|
||||
private readonly AdvancedRobot robot;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new GunTurnCompleteCondition with default priority.
|
||||
/// The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||
public GunTurnCompleteCondition(AdvancedRobot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new GunTurnCompleteCondition with a specific priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// <seealso cref="Condition.Priority"/>
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||
/// <param name="priority">The priority of this condition</param>
|
||||
public GunTurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||
{
|
||||
this.robot = robot;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the gun has stopped turning.
|
||||
/// Returns true if the gun has stopped turning
|
||||
/// </summary>
|
||||
public override bool Test()
|
||||
{
|
||||
return (robot.GunTurnRemaining == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,177 +1,177 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitByBulletEvent is sent to <see cref="Robot.OnHitByBullet(HitByBulletEvent)"/>
|
||||
/// when your robot has been hit by a bullet.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class HitByBulletEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 20;
|
||||
|
||||
private readonly double bearing;
|
||||
private readonly Bullet bullet;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new HitByBulletEvent.
|
||||
/// </summary>
|
||||
public HitByBulletEvent(double bearing, Bullet bullet)
|
||||
{
|
||||
this.bearing = bearing;
|
||||
this.bullet = bullet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the bullet, relative to your robot's heading,
|
||||
/// in degrees (-180 < getBearing() <= 180).
|
||||
/// <p/>
|
||||
/// If you were to TurnRight(event.Bearing), you would be facing the
|
||||
/// direction the bullet came from. The calculation used here is:
|
||||
/// (bullet's heading in degrees + 180) - (your heading in degrees)
|
||||
/// </summary>
|
||||
public double Bearing
|
||||
{
|
||||
get { return bearing*180.0/Math.PI; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the bullet, relative to your robot's heading,
|
||||
/// in radians (-Math.PI < getBearingRadians() <= Math.PI).
|
||||
/// <p/>
|
||||
/// If you were to TurnRightRadians(event.BearingRadians), you would be
|
||||
/// facing the direction the bullet came from. The calculation used here is:
|
||||
/// (bullet's heading in radians + Math.PI) - (your heading in radians)
|
||||
/// </summary>
|
||||
public double BearingRadians
|
||||
{
|
||||
get { return bearing; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bullet that hit your robot.
|
||||
/// </summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the heading of the bullet when it hit you, in degrees
|
||||
/// (0 <= getHeading() < 360).
|
||||
/// <p/>
|
||||
/// Note: This is not relative to the direction you are facing. The robot
|
||||
/// that fired the bullet was in the opposite direction of getHeading() when
|
||||
/// it fired the bullet.
|
||||
/// </summary>
|
||||
public double Heading
|
||||
{
|
||||
get { return bullet.Heading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the heading of the bullet when it hit you, in radians
|
||||
/// (0 <= getHeadingRadians() < 2 * PI).
|
||||
/// <p/>
|
||||
/// Note: This is not relative to the direction you are facing. The robot
|
||||
/// that fired the bullet was in the opposite direction of
|
||||
/// getHeadingRadians() when it fired the bullet.
|
||||
/// </summary>
|
||||
public double HeadingRadians
|
||||
{
|
||||
get { return bullet.HeadingRadians; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the robot that fired the bullet.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return bullet.Name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the power of this bullet. The damage you take (in fact, already
|
||||
/// took) is 4 * power, plus 2 * (power-1) if power > 1. The robot that fired
|
||||
/// the bullet receives 3 * power back.
|
||||
/// </summary>
|
||||
public double Power
|
||||
{
|
||||
get { return bullet.Power; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the velocity of this bullet.
|
||||
/// </summary>
|
||||
public double Velocity
|
||||
{
|
||||
get { return bullet.Velocity; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnHitByBullet(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.HitByBulletEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (HitByBulletEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.bullet)
|
||||
+ RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (HitByBulletEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.bullet);
|
||||
serializer.serialize(buffer, obj.bearing);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = (Bullet) serializer.deserializeAny(buffer);
|
||||
double bearing = buffer.getDouble();
|
||||
|
||||
return new HitByBulletEvent(bearing, bullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitByBulletEvent is sent to <see cref="Robot.OnHitByBullet(HitByBulletEvent)"/>
|
||||
/// when your robot has been hit by a bullet.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class HitByBulletEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 20;
|
||||
|
||||
private readonly double bearing;
|
||||
private readonly Bullet bullet;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new HitByBulletEvent.
|
||||
/// </summary>
|
||||
public HitByBulletEvent(double bearing, Bullet bullet)
|
||||
{
|
||||
this.bearing = bearing;
|
||||
this.bullet = bullet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the bullet, relative to your robot's heading,
|
||||
/// in degrees (-180 < getBearing() <= 180).
|
||||
/// <p/>
|
||||
/// If you were to TurnRight(event.Bearing), you would be facing the
|
||||
/// direction the bullet came from. The calculation used here is:
|
||||
/// (bullet's heading in degrees + 180) - (your heading in degrees)
|
||||
/// </summary>
|
||||
public double Bearing
|
||||
{
|
||||
get { return bearing*180.0/Math.PI; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the bullet, relative to your robot's heading,
|
||||
/// in radians (-Math.PI < getBearingRadians() <= Math.PI).
|
||||
/// <p/>
|
||||
/// If you were to TurnRightRadians(event.BearingRadians), you would be
|
||||
/// facing the direction the bullet came from. The calculation used here is:
|
||||
/// (bullet's heading in radians + Math.PI) - (your heading in radians)
|
||||
/// </summary>
|
||||
public double BearingRadians
|
||||
{
|
||||
get { return bearing; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bullet that hit your robot.
|
||||
/// </summary>
|
||||
public Bullet Bullet
|
||||
{
|
||||
get { return bullet; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the heading of the bullet when it hit you, in degrees
|
||||
/// (0 <= getHeading() < 360).
|
||||
/// <p/>
|
||||
/// Note: This is not relative to the direction you are facing. The robot
|
||||
/// that fired the bullet was in the opposite direction of getHeading() when
|
||||
/// it fired the bullet.
|
||||
/// </summary>
|
||||
public double Heading
|
||||
{
|
||||
get { return bullet.Heading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the heading of the bullet when it hit you, in radians
|
||||
/// (0 <= getHeadingRadians() < 2 * PI).
|
||||
/// <p/>
|
||||
/// Note: This is not relative to the direction you are facing. The robot
|
||||
/// that fired the bullet was in the opposite direction of
|
||||
/// getHeadingRadians() when it fired the bullet.
|
||||
/// </summary>
|
||||
public double HeadingRadians
|
||||
{
|
||||
get { return bullet.HeadingRadians; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the robot that fired the bullet.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return bullet.Name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the power of this bullet. The damage you take (in fact, already
|
||||
/// took) is 4 * power, plus 2 * (power-1) if power > 1. The robot that fired
|
||||
/// the bullet receives 3 * power back.
|
||||
/// </summary>
|
||||
public double Power
|
||||
{
|
||||
get { return bullet.Power; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the velocity of this bullet.
|
||||
/// </summary>
|
||||
public double Velocity
|
||||
{
|
||||
get { return bullet.Velocity; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnHitByBullet(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.HitByBulletEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (HitByBulletEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.bullet)
|
||||
+ RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (HitByBulletEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.bullet);
|
||||
serializer.serialize(buffer, obj.bearing);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
var bullet = (Bullet) serializer.deserializeAny(buffer);
|
||||
double bearing = buffer.getDouble();
|
||||
|
||||
return new HitByBulletEvent(bearing, bullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,172 +1,172 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitRobotEvent is sent to <see cref="Robot.OnHitRobot(HitRobotEvent)"/>
|
||||
/// when your robot collides with another robot.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class HitRobotEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 40;
|
||||
|
||||
private readonly string name;
|
||||
private readonly double bearing;
|
||||
private readonly double energy;
|
||||
private readonly bool atFault;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new HitRobotEvent.
|
||||
/// </summary>
|
||||
public HitRobotEvent(string name, double bearing, double energy, bool atFault)
|
||||
{
|
||||
this.name = name;
|
||||
this.bearing = bearing;
|
||||
this.energy = energy;
|
||||
this.atFault = atFault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the robot you hit, relative to your robot's
|
||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||
/// </summary>
|
||||
public double Bearing
|
||||
{
|
||||
get { return bearing*180.0/Math.PI; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the robot you hit, relative to your robot's
|
||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||
/// </summary>
|
||||
public double BearingRadians
|
||||
{
|
||||
get { return bearing; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of energy of the robot you hit.
|
||||
/// </summary>
|
||||
public double Energy
|
||||
{
|
||||
get { return energy; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the robot you hit.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if your robot was moving towards the robot that was hit.
|
||||
/// <p/>
|
||||
/// If <see cref="IsMyFault"/> returns true then your robot's movement (including
|
||||
/// turning) will have stopped and been marked complete.
|
||||
/// <p/>
|
||||
/// Note: If two robots are moving toward each other and collide, they will
|
||||
/// each receive two HitRobotEvents. The first will be the one if isMyFault()
|
||||
/// returns true.
|
||||
/// </summary>
|
||||
public bool IsMyFault
|
||||
{
|
||||
get { return atFault; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int CompareTo(Event evnt)
|
||||
{
|
||||
int res = base.CompareTo(evnt);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
// Compare the IsMyFault, if the events are HitRobotEvents
|
||||
// The isMyFault has higher priority when it is set compared to when it is not set
|
||||
if (evnt is HitRobotEvent)
|
||||
{
|
||||
int compare1 = (this).IsMyFault ? -1 : 0;
|
||||
int compare2 = ((HitRobotEvent) evnt).IsMyFault ? -1 : 0;
|
||||
|
||||
return compare1 - compare2;
|
||||
}
|
||||
|
||||
// No difference found
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnHitRobot(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.HitRobotEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (HitRobotEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 2*RbSerializerN.SIZEOF_DOUBLE
|
||||
+ RbSerializerN.SIZEOF_BOOL;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (HitRobotEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.name);
|
||||
serializer.serialize(buffer, obj.bearing);
|
||||
serializer.serialize(buffer, obj.energy);
|
||||
serializer.serialize(buffer, obj.atFault);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
string robotName = serializer.deserializeString(buffer);
|
||||
double bearing = buffer.getDouble();
|
||||
double energy = buffer.getDouble();
|
||||
bool atFault = serializer.deserializeBoolean(buffer);
|
||||
|
||||
return new HitRobotEvent(robotName, bearing, energy, atFault);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitRobotEvent is sent to <see cref="Robot.OnHitRobot(HitRobotEvent)"/>
|
||||
/// when your robot collides with another robot.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class HitRobotEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 40;
|
||||
|
||||
private readonly string name;
|
||||
private readonly double bearing;
|
||||
private readonly double energy;
|
||||
private readonly bool atFault;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new HitRobotEvent.
|
||||
/// </summary>
|
||||
public HitRobotEvent(string name, double bearing, double energy, bool atFault)
|
||||
{
|
||||
this.name = name;
|
||||
this.bearing = bearing;
|
||||
this.energy = energy;
|
||||
this.atFault = atFault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the robot you hit, relative to your robot's
|
||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||
/// </summary>
|
||||
public double Bearing
|
||||
{
|
||||
get { return bearing*180.0/Math.PI; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the robot you hit, relative to your robot's
|
||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||
/// </summary>
|
||||
public double BearingRadians
|
||||
{
|
||||
get { return bearing; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of energy of the robot you hit.
|
||||
/// </summary>
|
||||
public double Energy
|
||||
{
|
||||
get { return energy; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the robot you hit.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if your robot was moving towards the robot that was hit.
|
||||
/// <p/>
|
||||
/// If <see cref="IsMyFault"/> returns true then your robot's movement (including
|
||||
/// turning) will have stopped and been marked complete.
|
||||
/// <p/>
|
||||
/// Note: If two robots are moving toward each other and collide, they will
|
||||
/// each receive two HitRobotEvents. The first will be the one if isMyFault()
|
||||
/// returns true.
|
||||
/// </summary>
|
||||
public bool IsMyFault
|
||||
{
|
||||
get { return atFault; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int CompareTo(Event evnt)
|
||||
{
|
||||
int res = base.CompareTo(evnt);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
// Compare the IsMyFault, if the events are HitRobotEvents
|
||||
// The isMyFault has higher priority when it is set compared to when it is not set
|
||||
if (evnt is HitRobotEvent)
|
||||
{
|
||||
int compare1 = (this).IsMyFault ? -1 : 0;
|
||||
int compare2 = ((HitRobotEvent) evnt).IsMyFault ? -1 : 0;
|
||||
|
||||
return compare1 - compare2;
|
||||
}
|
||||
|
||||
// No difference found
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnHitRobot(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.HitRobotEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (HitRobotEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 2*RbSerializerN.SIZEOF_DOUBLE
|
||||
+ RbSerializerN.SIZEOF_BOOL;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (HitRobotEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.name);
|
||||
serializer.serialize(buffer, obj.bearing);
|
||||
serializer.serialize(buffer, obj.energy);
|
||||
serializer.serialize(buffer, obj.atFault);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
string robotName = serializer.deserializeString(buffer);
|
||||
double bearing = buffer.getDouble();
|
||||
double energy = buffer.getDouble();
|
||||
bool atFault = serializer.deserializeBoolean(buffer);
|
||||
|
||||
return new HitRobotEvent(robotName, bearing, energy, atFault);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,103 +1,103 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitWallEvent is sent to <see cref="Robot.OnHitWall(HitWallEvent)"/>
|
||||
/// when you collide a wall.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class HitWallEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 30;
|
||||
|
||||
private readonly double bearing;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new HitWallEvent.
|
||||
/// </summary>
|
||||
public HitWallEvent(double bearing)
|
||||
{
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the wall you hit, relative to your robot's
|
||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||
/// </summary>
|
||||
public double Bearing
|
||||
{
|
||||
get { return bearing*180.0/Math.PI; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the wall you hit, relative to your robot's
|
||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||
/// </summary>
|
||||
public double BearingRadians
|
||||
{
|
||||
get { return bearing; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnHitWall(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.HitWallEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (HitWallEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.bearing);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
double bearing = buffer.getDouble();
|
||||
|
||||
return new HitWallEvent(bearing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitWallEvent is sent to <see cref="Robot.OnHitWall(HitWallEvent)"/>
|
||||
/// when you collide a wall.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class HitWallEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 30;
|
||||
|
||||
private readonly double bearing;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new HitWallEvent.
|
||||
/// </summary>
|
||||
public HitWallEvent(double bearing)
|
||||
{
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the wall you hit, relative to your robot's
|
||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||
/// </summary>
|
||||
public double Bearing
|
||||
{
|
||||
get { return bearing*180.0/Math.PI; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bearing to the wall you hit, relative to your robot's
|
||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||
/// </summary>
|
||||
public double BearingRadians
|
||||
{
|
||||
get { return bearing; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnHitWall(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.HitWallEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_DOUBLE;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (HitWallEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.bearing);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
double bearing = buffer.getDouble();
|
||||
|
||||
return new HitWallEvent(bearing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,32 +1,32 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A robot that implement IBorderSentry is a robot type used for keeping other robots away from the borders,
|
||||
/// i.e. guarding the borders in order to prevent "wall crawlers".<br/>
|
||||
/// Robots that implement IBorderSentry have 400 extra life/energy (500 in total), but is placed at the border
|
||||
/// of the battlefield when the game is started.<br/>
|
||||
/// Border sentry robots cannot move away from the border area, and they can only make damage to robots that
|
||||
/// are moving into the border area. The size of the border area is determined by the
|
||||
/// <see cref="BattleRules.SentryBorderSize">battle rules</see>.<br/>
|
||||
/// This type of robot is intended for use in battles where robots should be forced away from the borders in
|
||||
/// order to prevent "wall crawlers".<br/>
|
||||
/// Border sentry robots does not get scores, and will not occur in the battle results or rankings.
|
||||
/// </summary>
|
||||
/// <seealso cref="BattleRules.SentryBorderSize"/>
|
||||
/// <seealso cref="JuniorRobot"/>
|
||||
/// <seealso cref="Robot"/>
|
||||
/// <seealso cref="AdvancedRobot"/>
|
||||
/// <seealso cref="TeamRobot"/>
|
||||
/// <seealso cref="RateControlRobot"/>
|
||||
/// <seealso cref="IDroid"/>
|
||||
public interface IBorderSentry
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A robot that implement IBorderSentry is a robot type used for keeping other robots away from the borders,
|
||||
/// i.e. guarding the borders in order to prevent "wall crawlers".<br/>
|
||||
/// Robots that implement IBorderSentry have 400 extra life/energy (500 in total), but is placed at the border
|
||||
/// of the battlefield when the game is started.<br/>
|
||||
/// Border sentry robots cannot move away from the border area, and they can only make damage to robots that
|
||||
/// are moving into the border area. The size of the border area is determined by the
|
||||
/// <see cref="BattleRules.SentryBorderSize">battle rules</see>.<br/>
|
||||
/// This type of robot is intended for use in battles where robots should be forced away from the borders in
|
||||
/// order to prevent "wall crawlers".<br/>
|
||||
/// Border sentry robots does not get scores, and will not occur in the battle results or rankings.
|
||||
/// </summary>
|
||||
/// <seealso cref="BattleRules.SentryBorderSize"/>
|
||||
/// <seealso cref="JuniorRobot"/>
|
||||
/// <seealso cref="Robot"/>
|
||||
/// <seealso cref="AdvancedRobot"/>
|
||||
/// <seealso cref="TeamRobot"/>
|
||||
/// <seealso cref="RateControlRobot"/>
|
||||
/// <seealso cref="IDroid"/>
|
||||
public interface IBorderSentry
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Robots that implement IDroid have no scanner, but an extra 20 life/energy.
|
||||
/// This class is intended for use in teams.
|
||||
/// <seealso cref="JuniorRobot"/>
|
||||
/// <seealso cref="Robot"/>
|
||||
/// <seealso cref="AdvancedRobot"/>
|
||||
/// <seealso cref="TeamRobot"/>
|
||||
/// <seealso cref="RateControlRobot"/>
|
||||
/// <seealso cref="IBorderSentry"/>
|
||||
/// </summary>
|
||||
public interface IDroid
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Robots that implement IDroid have no scanner, but an extra 20 life/energy.
|
||||
/// This class is intended for use in teams.
|
||||
/// <seealso cref="JuniorRobot"/>
|
||||
/// <seealso cref="Robot"/>
|
||||
/// <seealso cref="AdvancedRobot"/>
|
||||
/// <seealso cref="TeamRobot"/>
|
||||
/// <seealso cref="RateControlRobot"/>
|
||||
/// <seealso cref="IBorderSentry"/>
|
||||
/// </summary>
|
||||
public interface IDroid
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,160 +1,160 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System.Drawing;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="Graphics"/>
|
||||
/// </summary>
|
||||
public interface IGraphics
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
//TODO xml doc
|
||||
void DrawLine(Pen pen, float x1, float y1, float x2, float y2);
|
||||
void DrawLine(Pen pen, PointF pt1, PointF pt2);
|
||||
void DrawLine(Pen pen, int x1, int y1, int x2, int y2);
|
||||
void DrawLine(Pen pen, Point pt1, Point pt2);
|
||||
void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
|
||||
void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle);
|
||||
void DrawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||
void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
|
||||
void DrawRectangle(Pen pen, RectangleF rect);
|
||||
void DrawRectangle(Pen pen, Rectangle rect);
|
||||
void DrawRectangle(Pen pen, float x, float y, float width, float height);
|
||||
void DrawRectangle(Pen pen, int x, int y, int width, int height);
|
||||
void DrawEllipse(Pen pen, RectangleF rect);
|
||||
void DrawEllipse(Pen pen, float x, float y, float width, float height);
|
||||
void DrawEllipse(Pen pen, Rectangle rect);
|
||||
void DrawEllipse(Pen pen, int x, int y, int width, int height);
|
||||
void DrawPie(Pen pen, RectangleF rect, float startAngle, float sweepAngle);
|
||||
void DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
|
||||
void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
|
||||
void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||
void DrawPolygon(Pen pen, PointF[] points);
|
||||
void DrawPolygon(Pen pen, Point[] points);
|
||||
void FillRectangle(Brush brush, RectangleF rect);
|
||||
void FillRectangle(Brush brush, float x, float y, float width, float height);
|
||||
void FillRectangle(Brush brush, Rectangle rect);
|
||||
void FillRectangle(Brush brush, int x, int y, int width, int height);
|
||||
void FillPolygon(Brush brush, PointF[] points);
|
||||
void FillPolygon(Brush brush, Point[] points);
|
||||
void FillEllipse(Brush brush, RectangleF rect);
|
||||
void FillEllipse(Brush brush, float x, float y, float width, float height);
|
||||
void FillEllipse(Brush brush, Rectangle rect);
|
||||
void FillEllipse(Brush brush, int x, int y, int width, int height);
|
||||
void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle);
|
||||
void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
|
||||
void FillPie(Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||
void DrawString(string s, Font font, Brush brush, int x, int y);
|
||||
void DrawString(string s, Font font, Brush brush, float x, float y);
|
||||
void DrawString(string s, Font font, Brush brush, PointF point);
|
||||
void DrawString(string s, Font font, Brush brush, Point point);
|
||||
|
||||
/*
|
||||
void DrawLines(Pen pen, PointF[] points);
|
||||
void DrawLines(Pen pen, Point[] points);
|
||||
void DrawRectangles(Pen pen, RectangleF[] rects);
|
||||
void DrawRectangles(Pen pen, Rectangle[] rects);
|
||||
void DrawPath(Pen pen, GraphicsPath path);
|
||||
void DrawCurve(Pen pen, PointF[] points);
|
||||
void DrawCurve(Pen pen, PointF[] points, float tension);
|
||||
void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments);
|
||||
void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension);
|
||||
void DrawCurve(Pen pen, Point[] points);
|
||||
void DrawCurve(Pen pen, Point[] points, float tension);
|
||||
void DrawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, float tension);
|
||||
void DrawClosedCurve(Pen pen, PointF[] points);
|
||||
void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode);
|
||||
void DrawClosedCurve(Pen pen, Point[] points);
|
||||
void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode);
|
||||
void FillPolygon(Brush brush, PointF[] points, FillMode fillMode);
|
||||
void FillPolygon(Brush brush, Point[] points, FillMode fillMode);
|
||||
void FillRectangles(Brush brush, RectangleF[] rects);
|
||||
void FillRectangles(Brush brush, Rectangle[] rects);
|
||||
void FillClosedCurve(Brush brush, PointF[] points);
|
||||
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode);
|
||||
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension);
|
||||
void FillClosedCurve(Brush brush, Point[] points);
|
||||
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode);
|
||||
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension);
|
||||
void FillRegion(Brush brush, Region region);
|
||||
void FillPath(Brush brush, GraphicsPath path);
|
||||
void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format);
|
||||
void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format);
|
||||
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle);
|
||||
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format);
|
||||
|
||||
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat,
|
||||
out int charactersFitted, out int linesFilled);
|
||||
|
||||
SizeF MeasureString(string text, Font font, PointF origin, StringFormat stringFormat);
|
||||
SizeF MeasureString(string text, Font font, SizeF layoutArea);
|
||||
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat);
|
||||
SizeF MeasureString(string text, Font font);
|
||||
SizeF MeasureString(string text, Font font, int width);
|
||||
SizeF MeasureString(string text, Font font, int width, StringFormat format);
|
||||
Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat);
|
||||
|
||||
void ResetTransform();
|
||||
void MultiplyTransform(Matrix matrix);
|
||||
void MultiplyTransform(Matrix matrix, MatrixOrder order);
|
||||
void TranslateTransform(float dx, float dy);
|
||||
void TranslateTransform(float dx, float dy, MatrixOrder order);
|
||||
void ScaleTransform(float sx, float sy);
|
||||
void ScaleTransform(float sx, float sy, MatrixOrder order);
|
||||
void RotateTransform(float angle);
|
||||
void RotateTransform(float angle, MatrixOrder order);
|
||||
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts);
|
||||
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts);
|
||||
void SetClip(Graphics g);
|
||||
void SetClip(Graphics g, CombineMode combineMode);
|
||||
void SetClip(Rectangle rect);
|
||||
void SetClip(Rectangle rect, CombineMode combineMode);
|
||||
void SetClip(RectangleF rect);
|
||||
void SetClip(RectangleF rect, CombineMode combineMode);
|
||||
void SetClip(GraphicsPath path);
|
||||
void SetClip(GraphicsPath path, CombineMode combineMode);
|
||||
void SetClip(Region region, CombineMode combineMode);
|
||||
void IntersectClip(Rectangle rect);
|
||||
void IntersectClip(RectangleF rect);
|
||||
void IntersectClip(Region region);
|
||||
void ExcludeClip(Rectangle rect);
|
||||
void ExcludeClip(Region region);
|
||||
void ResetClip();
|
||||
void TranslateClip(float dx, float dy);
|
||||
void TranslateClip(int dx, int dy);
|
||||
bool IsVisible(int x, int y);
|
||||
bool IsVisible(Point point);
|
||||
bool IsVisible(float x, float y);
|
||||
bool IsVisible(PointF point);
|
||||
bool IsVisible(int x, int y, int width, int height);
|
||||
bool IsVisible(Rectangle rect);
|
||||
bool IsVisible(float x, float y, float width, float height);
|
||||
bool IsVisible(RectangleF rect);
|
||||
CompositingMode CompositingMode { get; set; }
|
||||
Point RenderingOrigin { get; set; }
|
||||
CompositingQuality CompositingQuality { get; set; }
|
||||
TextRenderingHint TextRenderingHint { get; set; }
|
||||
int TextContrast { get; set; }
|
||||
SmoothingMode SmoothingMode { get; set; }
|
||||
PixelOffsetMode PixelOffsetMode { get; set; }
|
||||
InterpolationMode InterpolationMode { get; set; }
|
||||
Matrix Transform { get; set; }
|
||||
GraphicsUnit PageUnit { get; set; }
|
||||
float PageScale { get; set; }
|
||||
float DpiX { get; }
|
||||
float DpiY { get; }
|
||||
Region Clip { get; set; }
|
||||
RectangleF ClipBounds { get; }
|
||||
bool IsClipEmpty { get; }
|
||||
RectangleF VisibleClipBounds { get; }
|
||||
bool IsVisibleClipEmpty { get; }
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System.Drawing;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="Graphics"/>
|
||||
/// </summary>
|
||||
public interface IGraphics
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
//TODO xml doc
|
||||
void DrawLine(Pen pen, float x1, float y1, float x2, float y2);
|
||||
void DrawLine(Pen pen, PointF pt1, PointF pt2);
|
||||
void DrawLine(Pen pen, int x1, int y1, int x2, int y2);
|
||||
void DrawLine(Pen pen, Point pt1, Point pt2);
|
||||
void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
|
||||
void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle);
|
||||
void DrawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||
void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
|
||||
void DrawRectangle(Pen pen, RectangleF rect);
|
||||
void DrawRectangle(Pen pen, Rectangle rect);
|
||||
void DrawRectangle(Pen pen, float x, float y, float width, float height);
|
||||
void DrawRectangle(Pen pen, int x, int y, int width, int height);
|
||||
void DrawEllipse(Pen pen, RectangleF rect);
|
||||
void DrawEllipse(Pen pen, float x, float y, float width, float height);
|
||||
void DrawEllipse(Pen pen, Rectangle rect);
|
||||
void DrawEllipse(Pen pen, int x, int y, int width, int height);
|
||||
void DrawPie(Pen pen, RectangleF rect, float startAngle, float sweepAngle);
|
||||
void DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
|
||||
void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
|
||||
void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||
void DrawPolygon(Pen pen, PointF[] points);
|
||||
void DrawPolygon(Pen pen, Point[] points);
|
||||
void FillRectangle(Brush brush, RectangleF rect);
|
||||
void FillRectangle(Brush brush, float x, float y, float width, float height);
|
||||
void FillRectangle(Brush brush, Rectangle rect);
|
||||
void FillRectangle(Brush brush, int x, int y, int width, int height);
|
||||
void FillPolygon(Brush brush, PointF[] points);
|
||||
void FillPolygon(Brush brush, Point[] points);
|
||||
void FillEllipse(Brush brush, RectangleF rect);
|
||||
void FillEllipse(Brush brush, float x, float y, float width, float height);
|
||||
void FillEllipse(Brush brush, Rectangle rect);
|
||||
void FillEllipse(Brush brush, int x, int y, int width, int height);
|
||||
void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle);
|
||||
void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
|
||||
void FillPie(Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||
void DrawString(string s, Font font, Brush brush, int x, int y);
|
||||
void DrawString(string s, Font font, Brush brush, float x, float y);
|
||||
void DrawString(string s, Font font, Brush brush, PointF point);
|
||||
void DrawString(string s, Font font, Brush brush, Point point);
|
||||
|
||||
/*
|
||||
void DrawLines(Pen pen, PointF[] points);
|
||||
void DrawLines(Pen pen, Point[] points);
|
||||
void DrawRectangles(Pen pen, RectangleF[] rects);
|
||||
void DrawRectangles(Pen pen, Rectangle[] rects);
|
||||
void DrawPath(Pen pen, GraphicsPath path);
|
||||
void DrawCurve(Pen pen, PointF[] points);
|
||||
void DrawCurve(Pen pen, PointF[] points, float tension);
|
||||
void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments);
|
||||
void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension);
|
||||
void DrawCurve(Pen pen, Point[] points);
|
||||
void DrawCurve(Pen pen, Point[] points, float tension);
|
||||
void DrawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, float tension);
|
||||
void DrawClosedCurve(Pen pen, PointF[] points);
|
||||
void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode);
|
||||
void DrawClosedCurve(Pen pen, Point[] points);
|
||||
void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode);
|
||||
void FillPolygon(Brush brush, PointF[] points, FillMode fillMode);
|
||||
void FillPolygon(Brush brush, Point[] points, FillMode fillMode);
|
||||
void FillRectangles(Brush brush, RectangleF[] rects);
|
||||
void FillRectangles(Brush brush, Rectangle[] rects);
|
||||
void FillClosedCurve(Brush brush, PointF[] points);
|
||||
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode);
|
||||
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension);
|
||||
void FillClosedCurve(Brush brush, Point[] points);
|
||||
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode);
|
||||
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension);
|
||||
void FillRegion(Brush brush, Region region);
|
||||
void FillPath(Brush brush, GraphicsPath path);
|
||||
void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format);
|
||||
void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format);
|
||||
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle);
|
||||
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format);
|
||||
|
||||
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat,
|
||||
out int charactersFitted, out int linesFilled);
|
||||
|
||||
SizeF MeasureString(string text, Font font, PointF origin, StringFormat stringFormat);
|
||||
SizeF MeasureString(string text, Font font, SizeF layoutArea);
|
||||
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat);
|
||||
SizeF MeasureString(string text, Font font);
|
||||
SizeF MeasureString(string text, Font font, int width);
|
||||
SizeF MeasureString(string text, Font font, int width, StringFormat format);
|
||||
Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat);
|
||||
|
||||
void ResetTransform();
|
||||
void MultiplyTransform(Matrix matrix);
|
||||
void MultiplyTransform(Matrix matrix, MatrixOrder order);
|
||||
void TranslateTransform(float dx, float dy);
|
||||
void TranslateTransform(float dx, float dy, MatrixOrder order);
|
||||
void ScaleTransform(float sx, float sy);
|
||||
void ScaleTransform(float sx, float sy, MatrixOrder order);
|
||||
void RotateTransform(float angle);
|
||||
void RotateTransform(float angle, MatrixOrder order);
|
||||
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts);
|
||||
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts);
|
||||
void SetClip(Graphics g);
|
||||
void SetClip(Graphics g, CombineMode combineMode);
|
||||
void SetClip(Rectangle rect);
|
||||
void SetClip(Rectangle rect, CombineMode combineMode);
|
||||
void SetClip(RectangleF rect);
|
||||
void SetClip(RectangleF rect, CombineMode combineMode);
|
||||
void SetClip(GraphicsPath path);
|
||||
void SetClip(GraphicsPath path, CombineMode combineMode);
|
||||
void SetClip(Region region, CombineMode combineMode);
|
||||
void IntersectClip(Rectangle rect);
|
||||
void IntersectClip(RectangleF rect);
|
||||
void IntersectClip(Region region);
|
||||
void ExcludeClip(Rectangle rect);
|
||||
void ExcludeClip(Region region);
|
||||
void ResetClip();
|
||||
void TranslateClip(float dx, float dy);
|
||||
void TranslateClip(int dx, int dy);
|
||||
bool IsVisible(int x, int y);
|
||||
bool IsVisible(Point point);
|
||||
bool IsVisible(float x, float y);
|
||||
bool IsVisible(PointF point);
|
||||
bool IsVisible(int x, int y, int width, int height);
|
||||
bool IsVisible(Rectangle rect);
|
||||
bool IsVisible(float x, float y, float width, float height);
|
||||
bool IsVisible(RectangleF rect);
|
||||
CompositingMode CompositingMode { get; set; }
|
||||
Point RenderingOrigin { get; set; }
|
||||
CompositingQuality CompositingQuality { get; set; }
|
||||
TextRenderingHint TextRenderingHint { get; set; }
|
||||
int TextContrast { get; set; }
|
||||
SmoothingMode SmoothingMode { get; set; }
|
||||
PixelOffsetMode PixelOffsetMode { get; set; }
|
||||
InterpolationMode InterpolationMode { get; set; }
|
||||
Matrix Transform { get; set; }
|
||||
GraphicsUnit PageUnit { get; set; }
|
||||
float PageScale { get; set; }
|
||||
float DpiX { get; }
|
||||
float DpiY { get; }
|
||||
Region Clip { get; set; }
|
||||
RectangleF ClipBounds { get; }
|
||||
bool IsClipEmpty { get; }
|
||||
RectangleF VisibleClipBounds { get; }
|
||||
bool IsVisibleClipEmpty { get; }
|
||||
*/
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,78 +1,78 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Super class of all events that originates from the keyboard.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class KeyEvent : Event
|
||||
{
|
||||
private readonly char keyChar;
|
||||
private readonly int keyCode;
|
||||
private readonly int keyLocation;
|
||||
private readonly int id;
|
||||
private readonly int modifiersEx;
|
||||
private readonly long when;
|
||||
|
||||
/// <summary>
|
||||
/// Called by game
|
||||
/// </summary>
|
||||
protected KeyEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
{
|
||||
this.keyChar = keyChar;
|
||||
this.keyCode = keyCode;
|
||||
this.keyLocation = keyLocation;
|
||||
this.id = id;
|
||||
this.modifiersEx = modifiersEx;
|
||||
this.when = when;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Char of they key pressed
|
||||
/// </summary>
|
||||
public char KeyChar
|
||||
{
|
||||
get { return keyChar; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Keys"/>
|
||||
/// </summary>
|
||||
public int KeyCode
|
||||
{
|
||||
get { return keyCode; }
|
||||
}
|
||||
|
||||
internal int KeyLocation
|
||||
{
|
||||
get { return keyLocation; }
|
||||
}
|
||||
|
||||
internal int ID
|
||||
{
|
||||
get { return id; }
|
||||
}
|
||||
|
||||
internal int ModifiersEx
|
||||
{
|
||||
get { return modifiersEx; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Age of the event
|
||||
/// </summary>
|
||||
public long When
|
||||
{
|
||||
get { return when; }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Super class of all events that originates from the keyboard.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class KeyEvent : Event
|
||||
{
|
||||
private readonly char keyChar;
|
||||
private readonly int keyCode;
|
||||
private readonly int keyLocation;
|
||||
private readonly int id;
|
||||
private readonly int modifiersEx;
|
||||
private readonly long when;
|
||||
|
||||
/// <summary>
|
||||
/// Called by game
|
||||
/// </summary>
|
||||
protected KeyEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
{
|
||||
this.keyChar = keyChar;
|
||||
this.keyCode = keyCode;
|
||||
this.keyLocation = keyLocation;
|
||||
this.id = id;
|
||||
this.modifiersEx = modifiersEx;
|
||||
this.when = when;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Char of they key pressed
|
||||
/// </summary>
|
||||
public char KeyChar
|
||||
{
|
||||
get { return keyChar; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Keys"/>
|
||||
/// </summary>
|
||||
public int KeyCode
|
||||
{
|
||||
get { return keyCode; }
|
||||
}
|
||||
|
||||
internal int KeyLocation
|
||||
{
|
||||
get { return keyLocation; }
|
||||
}
|
||||
|
||||
internal int ID
|
||||
{
|
||||
get { return id; }
|
||||
}
|
||||
|
||||
internal int ModifiersEx
|
||||
{
|
||||
get { return modifiersEx; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Age of the event
|
||||
/// </summary>
|
||||
public long When
|
||||
{
|
||||
get { return when; }
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,96 +1,96 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A KeyPressedEvent is sent to <see cref="Robot.OnKeyPressed(KeyEvent)"/>
|
||||
/// when a key has been pressed on the keyboard.
|
||||
/// <seealso cref="KeyReleasedEvent"/>
|
||||
/// <seealso cref="KeyTypedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class KeyPressedEvent : KeyEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new KeyPressedEvent.
|
||||
/// </summary>
|
||||
public KeyPressedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnKeyPressed(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.KeyPressedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||
RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (KeyPressedEvent) objec;
|
||||
serializer.serialize(buffer, obj.KeyChar);
|
||||
serializer.serialize(buffer, obj.KeyCode);
|
||||
serializer.serialize(buffer, obj.KeyLocation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
char keyChar = buffer.getChar();
|
||||
int keyCode = buffer.getInt();
|
||||
int keyLocation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
return new KeyPressedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A KeyPressedEvent is sent to <see cref="Robot.OnKeyPressed(KeyEvent)"/>
|
||||
/// when a key has been pressed on the keyboard.
|
||||
/// <seealso cref="KeyReleasedEvent"/>
|
||||
/// <seealso cref="KeyTypedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class KeyPressedEvent : KeyEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new KeyPressedEvent.
|
||||
/// </summary>
|
||||
public KeyPressedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnKeyPressed(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.KeyPressedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||
RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (KeyPressedEvent) objec;
|
||||
serializer.serialize(buffer, obj.KeyChar);
|
||||
serializer.serialize(buffer, obj.KeyCode);
|
||||
serializer.serialize(buffer, obj.KeyLocation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
char keyChar = buffer.getChar();
|
||||
int keyCode = buffer.getInt();
|
||||
int keyLocation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
return new KeyPressedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,98 +1,98 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A KeyReleasedEvent is sent to <see cref="Robot.OnKeyReleased(KeyEvent)"/>
|
||||
/// when a key has been released on the keyboard.
|
||||
/// <seealso cref="KeyPressedEvent"/>
|
||||
/// <seealso cref="KeyTypedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class KeyReleasedEvent : KeyEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new KeyReleasedEvent.
|
||||
/// </summary>
|
||||
public KeyReleasedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnKeyReleased(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.KeyReleasedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||
RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (KeyReleasedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.KeyChar);
|
||||
serializer.serialize(buffer, obj.KeyCode);
|
||||
serializer.serialize(buffer, obj.KeyLocation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
char keyChar = buffer.getChar();
|
||||
int keyCode = buffer.getInt();
|
||||
int keyLocation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new KeyReleasedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A KeyReleasedEvent is sent to <see cref="Robot.OnKeyReleased(KeyEvent)"/>
|
||||
/// when a key has been released on the keyboard.
|
||||
/// <seealso cref="KeyPressedEvent"/>
|
||||
/// <seealso cref="KeyTypedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class KeyReleasedEvent : KeyEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new KeyReleasedEvent.
|
||||
/// </summary>
|
||||
public KeyReleasedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnKeyReleased(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.KeyReleasedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||
RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (KeyReleasedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.KeyChar);
|
||||
serializer.serialize(buffer, obj.KeyCode);
|
||||
serializer.serialize(buffer, obj.KeyLocation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
char keyChar = buffer.getChar();
|
||||
int keyCode = buffer.getInt();
|
||||
int keyLocation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new KeyReleasedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,98 +1,98 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A KeyTypedEvent is sent to <see cref="Robot.OnKeyTyped(KeyEvent)"/>
|
||||
/// when a key has been typed (pressed and released) on the keyboard.
|
||||
/// <seealso cref="KeyPressedEvent"/>
|
||||
/// <seealso cref="KeyReleasedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class KeyTypedEvent : KeyEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new KeyTypedEvent.
|
||||
/// </summary>
|
||||
public KeyTypedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnKeyTyped(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.KeyTypedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||
RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (KeyTypedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.KeyChar);
|
||||
serializer.serialize(buffer, obj.KeyCode);
|
||||
serializer.serialize(buffer, obj.KeyLocation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
char keyChar = buffer.getChar();
|
||||
int keyCode = buffer.getInt();
|
||||
int keyLocation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new KeyTypedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A KeyTypedEvent is sent to <see cref="Robot.OnKeyTyped(KeyEvent)"/>
|
||||
/// when a key has been typed (pressed and released) on the keyboard.
|
||||
/// <seealso cref="KeyPressedEvent"/>
|
||||
/// <seealso cref="KeyReleasedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class KeyTypedEvent : KeyEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new KeyTypedEvent.
|
||||
/// </summary>
|
||||
public KeyTypedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnKeyTyped(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.KeyTypedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||
RbSerializerN.SIZEOF_INT;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (KeyTypedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.KeyChar);
|
||||
serializer.serialize(buffer, obj.KeyCode);
|
||||
serializer.serialize(buffer, obj.KeyLocation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
char keyChar = buffer.getChar();
|
||||
int keyCode = buffer.getInt();
|
||||
int keyLocation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new KeyTypedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,292 +1,292 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
// This class is based on the source code from Sun's Java 1.5.0 API for java.awt.event.KeyEvent, but
|
||||
// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode.
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public static class Keys
|
||||
{
|
||||
public const int KEY_FIRST = 400;
|
||||
|
||||
public const int KEY_LAST = 402;
|
||||
|
||||
public const int KEY_TYPED = KEY_FIRST;
|
||||
|
||||
public const int KEY_PRESSED = 1 + KEY_FIRST;
|
||||
|
||||
public const int KEY_RELEASED = 2 + KEY_FIRST;
|
||||
|
||||
public const int VK_ENTER = 0x0A;
|
||||
public const int VK_BACK_SPACE = 0x20;
|
||||
public const int VK_TAB = 0x08;
|
||||
public const int VK_CANCEL = 0x03;
|
||||
public const int VK_CLEAR = 0x0C;
|
||||
public const int VK_SHIFT = 0x10;
|
||||
public const int VK_CONTROL = 0x11;
|
||||
public const int VK_ALT = 0x12;
|
||||
public const int VK_PAUSE = 0x13;
|
||||
public const int VK_CAPS_LOCK = 0x14;
|
||||
public const int VK_ESCAPE = 0x1B;
|
||||
public const int VK_SPACE = 0x20;
|
||||
public const int VK_PAGE_UP = 0x21;
|
||||
public const int VK_PAGE_DOWN = 0x22;
|
||||
public const int VK_END = 0x23;
|
||||
public const int VK_HOME = 0x24;
|
||||
|
||||
public const int VK_LEFT = 0x25;
|
||||
|
||||
public const int VK_UP = 0x26;
|
||||
|
||||
public const int VK_RIGHT = 0x27;
|
||||
|
||||
public const int VK_DOWN = 0x28;
|
||||
|
||||
public const int VK_COMMA = 0x2C;
|
||||
|
||||
public const int VK_MINUS = 0x2D;
|
||||
|
||||
public const int VK_PERIOD = 0x2E;
|
||||
|
||||
public const int VK_SLASH = 0x2F;
|
||||
|
||||
public const int VK_0 = 0x30;
|
||||
public const int VK_1 = 0x31;
|
||||
public const int VK_2 = 0x32;
|
||||
public const int VK_3 = 0x33;
|
||||
public const int VK_4 = 0x34;
|
||||
public const int VK_5 = 0x35;
|
||||
public const int VK_6 = 0x36;
|
||||
public const int VK_7 = 0x37;
|
||||
public const int VK_8 = 0x38;
|
||||
public const int VK_9 = 0x39;
|
||||
|
||||
public const int VK_SEMICOLON = 0x3B;
|
||||
|
||||
public const int VK_EQUALS = 0x3D;
|
||||
|
||||
public const int VK_A = 0x41;
|
||||
public const int VK_B = 0x42;
|
||||
public const int VK_C = 0x43;
|
||||
public const int VK_D = 0x44;
|
||||
public const int VK_E = 0x45;
|
||||
public const int VK_F = 0x46;
|
||||
public const int VK_G = 0x47;
|
||||
public const int VK_H = 0x48;
|
||||
public const int VK_I = 0x49;
|
||||
public const int VK_J = 0x4A;
|
||||
public const int VK_K = 0x4B;
|
||||
public const int VK_L = 0x4C;
|
||||
public const int VK_M = 0x4D;
|
||||
public const int VK_N = 0x4E;
|
||||
public const int VK_O = 0x4F;
|
||||
public const int VK_P = 0x50;
|
||||
public const int VK_Q = 0x51;
|
||||
public const int VK_R = 0x52;
|
||||
public const int VK_S = 0x53;
|
||||
public const int VK_T = 0x54;
|
||||
public const int VK_U = 0x55;
|
||||
public const int VK_V = 0x56;
|
||||
public const int VK_W = 0x57;
|
||||
public const int VK_X = 0x58;
|
||||
public const int VK_Y = 0x59;
|
||||
public const int VK_Z = 0x5A;
|
||||
|
||||
public const int VK_OPEN_BRACKET = 0x5B;
|
||||
|
||||
public const int VK_BACK_SLASH = 0x5C;
|
||||
|
||||
public const int VK_CLOSE_BRACKET = 0x5D;
|
||||
|
||||
public const int VK_NUMPAD0 = 0x60;
|
||||
public const int VK_NUMPAD1 = 0x61;
|
||||
public const int VK_NUMPAD2 = 0x62;
|
||||
public const int VK_NUMPAD3 = 0x63;
|
||||
public const int VK_NUMPAD4 = 0x64;
|
||||
public const int VK_NUMPAD5 = 0x65;
|
||||
public const int VK_NUMPAD6 = 0x66;
|
||||
public const int VK_NUMPAD7 = 0x67;
|
||||
public const int VK_NUMPAD8 = 0x68;
|
||||
public const int VK_NUMPAD9 = 0x69;
|
||||
public const int VK_MULTIPLY = 0x6A;
|
||||
public const int VK_ADD = 0x6B;
|
||||
|
||||
public const int VK_SEPARATER = 0x6C;
|
||||
|
||||
public const int VK_SEPARATOR = VK_SEPARATER;
|
||||
|
||||
public const int VK_SUBTRACT = 0x6D;
|
||||
public const int VK_DECIMAL = 0x6E;
|
||||
public const int VK_DIVIDE = 0x6F;
|
||||
public const int VK_DELETE = 0x7F;
|
||||
public const int VK_NUM_LOCK = 0x90;
|
||||
public const int VK_SCROLL_LOCK = 0x91;
|
||||
|
||||
public const int VK_F1 = 0x70;
|
||||
|
||||
public const int VK_F2 = 0x71;
|
||||
|
||||
public const int VK_F3 = 0x72;
|
||||
|
||||
public const int VK_F4 = 0x73;
|
||||
|
||||
public const int VK_F5 = 0x74;
|
||||
|
||||
public const int VK_F6 = 0x75;
|
||||
|
||||
public const int VK_F7 = 0x76;
|
||||
|
||||
public const int VK_F8 = 0x77;
|
||||
|
||||
public const int VK_F9 = 0x78;
|
||||
|
||||
public const int VK_F10 = 0x79;
|
||||
|
||||
public const int VK_F11 = 0x7A;
|
||||
|
||||
public const int VK_F12 = 0x7B;
|
||||
|
||||
public const int VK_F13 = 0xF000;
|
||||
|
||||
public const int VK_F14 = 0xF001;
|
||||
|
||||
public const int VK_F15 = 0xF002;
|
||||
|
||||
public const int VK_F16 = 0xF003;
|
||||
|
||||
public const int VK_F17 = 0xF004;
|
||||
|
||||
public const int VK_F18 = 0xF005;
|
||||
|
||||
public const int VK_F19 = 0xF006;
|
||||
|
||||
public const int VK_F20 = 0xF007;
|
||||
|
||||
public const int VK_F21 = 0xF008;
|
||||
|
||||
public const int VK_F22 = 0xF009;
|
||||
|
||||
public const int VK_F23 = 0xF00A;
|
||||
|
||||
public const int VK_F24 = 0xF00B;
|
||||
|
||||
public const int VK_PRINTSCREEN = 0x9A;
|
||||
public const int VK_INSERT = 0x9B;
|
||||
public const int VK_HELP = 0x9C;
|
||||
public const int VK_META = 0x9D;
|
||||
|
||||
public const int VK_BACK_QUOTE = 0xC0;
|
||||
public const int VK_QUOTE = 0xDE;
|
||||
|
||||
public const int VK_KP_UP = 0xE0;
|
||||
|
||||
public const int VK_KP_DOWN = 0xE1;
|
||||
|
||||
public const int VK_KP_LEFT = 0xE2;
|
||||
|
||||
public const int VK_KP_RIGHT = 0xE3;
|
||||
|
||||
public const int VK_DEAD_GRAVE = 0x80;
|
||||
public const int VK_DEAD_ACUTE = 0x81;
|
||||
public const int VK_DEAD_CIRCUMFLEX = 0x82;
|
||||
public const int VK_DEAD_TILDE = 0x83;
|
||||
public const int VK_DEAD_MACRON = 0x84;
|
||||
public const int VK_DEAD_BREVE = 0x85;
|
||||
public const int VK_DEAD_ABOVEDOT = 0x86;
|
||||
public const int VK_DEAD_DIAERESIS = 0x87;
|
||||
public const int VK_DEAD_ABOVERING = 0x88;
|
||||
public const int VK_DEAD_DOUBLEACUTE = 0x89;
|
||||
public const int VK_DEAD_CARON = 0x8a;
|
||||
public const int VK_DEAD_CEDILLA = 0x8b;
|
||||
public const int VK_DEAD_OGONEK = 0x8c;
|
||||
public const int VK_DEAD_IOTA = 0x8d;
|
||||
public const int VK_DEAD_VOICED_SOUND = 0x8e;
|
||||
public const int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
|
||||
|
||||
public const int VK_AMPERSAND = 0x96;
|
||||
public const int VK_ASTERISK = 0x97;
|
||||
public const int VK_QUOTEDBL = 0x98;
|
||||
public const int VK_LESS = 0x99;
|
||||
public const int VK_GREATER = 0xa0;
|
||||
public const int VK_BRACELEFT = 0xa1;
|
||||
public const int VK_BRACERIGHT = 0xa2;
|
||||
|
||||
public const int VK_AT = 0x0200;
|
||||
public const int VK_COLON = 0x0201;
|
||||
public const int VK_CIRCUMFLEX = 0x0202;
|
||||
public const int VK_DOLLAR = 0x0203;
|
||||
public const int VK_EURO_SIGN = 0x0204;
|
||||
|
||||
public const int VK_EXCLAMATION_MARK = 0x0205;
|
||||
public const int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
|
||||
public const int VK_LEFT_PARENTHESIS = 0x0207;
|
||||
public const int VK_NUMBER_SIGN = 0x0208;
|
||||
public const int VK_PLUS = 0x0209;
|
||||
public const int VK_RIGHT_PARENTHESIS = 0x020A;
|
||||
public const int VK_UNDERSCORE = 0x020B;
|
||||
public const int VK_WINDOWS = 0x020C;
|
||||
public const int VK_CONTEXT_MENU = 0x020D;
|
||||
public const int VK_const = 0x0018;
|
||||
public const int VK_CONVERT = 0x001C;
|
||||
public const int VK_NONCONVERT = 0x001D;
|
||||
public const int VK_ACCEPT = 0x001E;
|
||||
public const int VK_MODECHANGE = 0x001F;
|
||||
public const int VK_KANA = 0x0015;
|
||||
public const int VK_KANJI = 0x0019;
|
||||
public const int VK_ALPHANUMERIC = 0x00F0;
|
||||
public const int VK_KATAKANA = 0x00F1;
|
||||
public const int VK_HIRAGANA = 0x00F2;
|
||||
public const int VK_FULL_WIDTH = 0x00F3;
|
||||
public const int VK_HALF_WIDTH = 0x00F4;
|
||||
public const int VK_ROMAN_CHARACTERS = 0x00F5;
|
||||
public const int VK_ALL_CANDIDATES = 0x0100;
|
||||
public const int VK_PREVIOUS_CANDIDATE = 0x0101;
|
||||
public const int VK_CODE_INPUT = 0x0102;
|
||||
public const int VK_JAPANESE_KATAKANA = 0x0103;
|
||||
public const int VK_JAPANESE_HIRAGANA = 0x0104;
|
||||
public const int VK_JAPANESE_ROMAN = 0x0105;
|
||||
public const int VK_KANA_LOCK = 0x0106;
|
||||
public const int VK_INPUT_METHOD_ON_OFF = 0x0107;
|
||||
public const int VK_CUT = 0xFFD1;
|
||||
public const int VK_COPY = 0xFFCD;
|
||||
public const int VK_PASTE = 0xFFCF;
|
||||
public const int VK_UNDO = 0xFFCB;
|
||||
public const int VK_AGAIN = 0xFFC9;
|
||||
public const int VK_FIND = 0xFFD0;
|
||||
public const int VK_PROPS = 0xFFCA;
|
||||
public const int VK_STOP = 0xFFC8;
|
||||
public const int VK_COMPOSE = 0xFF20;
|
||||
public const int VK_ALT_GRAPH = 0xFF7E;
|
||||
public const int VK_BEGIN = 0xFF58;
|
||||
public const int VK_UNDEFINED = 0x0;
|
||||
public const int KEY_LOCATION_UNKNOWN = 0;
|
||||
public const int KEY_LOCATION_STANDARD = 1;
|
||||
public const int KEY_LOCATION_LEFT = 2;
|
||||
public const int KEY_LOCATION_RIGHT = 3;
|
||||
public const int KEY_LOCATION_NUMPAD = 4;
|
||||
public static readonly char CHAR_UNDEFINED = (char) 0xFFFF;
|
||||
public const int MOUSE_FIRST = 500;
|
||||
public const int MOUSE_LAST = 507;
|
||||
public const int MOUSE_CLICKED = MOUSE_FIRST;
|
||||
public const int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN
|
||||
public const int MOUSE_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP
|
||||
public const int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE
|
||||
public const int MOUSE_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER
|
||||
public const int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT
|
||||
public const int MOUSE_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG
|
||||
public const int MOUSE_WHEEL = 7 + MOUSE_FIRST;
|
||||
public const int NOBUTTON = 0;
|
||||
public const int BUTTON1 = 1;
|
||||
public const int BUTTON2 = 2;
|
||||
public const int BUTTON3 = 3;
|
||||
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
// This class is based on the source code from Sun's Java 1.5.0 API for java.awt.event.KeyEvent, but
|
||||
// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode.
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <exclude/>
|
||||
public static class Keys
|
||||
{
|
||||
public const int KEY_FIRST = 400;
|
||||
|
||||
public const int KEY_LAST = 402;
|
||||
|
||||
public const int KEY_TYPED = KEY_FIRST;
|
||||
|
||||
public const int KEY_PRESSED = 1 + KEY_FIRST;
|
||||
|
||||
public const int KEY_RELEASED = 2 + KEY_FIRST;
|
||||
|
||||
public const int VK_ENTER = 0x0A;
|
||||
public const int VK_BACK_SPACE = 0x20;
|
||||
public const int VK_TAB = 0x08;
|
||||
public const int VK_CANCEL = 0x03;
|
||||
public const int VK_CLEAR = 0x0C;
|
||||
public const int VK_SHIFT = 0x10;
|
||||
public const int VK_CONTROL = 0x11;
|
||||
public const int VK_ALT = 0x12;
|
||||
public const int VK_PAUSE = 0x13;
|
||||
public const int VK_CAPS_LOCK = 0x14;
|
||||
public const int VK_ESCAPE = 0x1B;
|
||||
public const int VK_SPACE = 0x20;
|
||||
public const int VK_PAGE_UP = 0x21;
|
||||
public const int VK_PAGE_DOWN = 0x22;
|
||||
public const int VK_END = 0x23;
|
||||
public const int VK_HOME = 0x24;
|
||||
|
||||
public const int VK_LEFT = 0x25;
|
||||
|
||||
public const int VK_UP = 0x26;
|
||||
|
||||
public const int VK_RIGHT = 0x27;
|
||||
|
||||
public const int VK_DOWN = 0x28;
|
||||
|
||||
public const int VK_COMMA = 0x2C;
|
||||
|
||||
public const int VK_MINUS = 0x2D;
|
||||
|
||||
public const int VK_PERIOD = 0x2E;
|
||||
|
||||
public const int VK_SLASH = 0x2F;
|
||||
|
||||
public const int VK_0 = 0x30;
|
||||
public const int VK_1 = 0x31;
|
||||
public const int VK_2 = 0x32;
|
||||
public const int VK_3 = 0x33;
|
||||
public const int VK_4 = 0x34;
|
||||
public const int VK_5 = 0x35;
|
||||
public const int VK_6 = 0x36;
|
||||
public const int VK_7 = 0x37;
|
||||
public const int VK_8 = 0x38;
|
||||
public const int VK_9 = 0x39;
|
||||
|
||||
public const int VK_SEMICOLON = 0x3B;
|
||||
|
||||
public const int VK_EQUALS = 0x3D;
|
||||
|
||||
public const int VK_A = 0x41;
|
||||
public const int VK_B = 0x42;
|
||||
public const int VK_C = 0x43;
|
||||
public const int VK_D = 0x44;
|
||||
public const int VK_E = 0x45;
|
||||
public const int VK_F = 0x46;
|
||||
public const int VK_G = 0x47;
|
||||
public const int VK_H = 0x48;
|
||||
public const int VK_I = 0x49;
|
||||
public const int VK_J = 0x4A;
|
||||
public const int VK_K = 0x4B;
|
||||
public const int VK_L = 0x4C;
|
||||
public const int VK_M = 0x4D;
|
||||
public const int VK_N = 0x4E;
|
||||
public const int VK_O = 0x4F;
|
||||
public const int VK_P = 0x50;
|
||||
public const int VK_Q = 0x51;
|
||||
public const int VK_R = 0x52;
|
||||
public const int VK_S = 0x53;
|
||||
public const int VK_T = 0x54;
|
||||
public const int VK_U = 0x55;
|
||||
public const int VK_V = 0x56;
|
||||
public const int VK_W = 0x57;
|
||||
public const int VK_X = 0x58;
|
||||
public const int VK_Y = 0x59;
|
||||
public const int VK_Z = 0x5A;
|
||||
|
||||
public const int VK_OPEN_BRACKET = 0x5B;
|
||||
|
||||
public const int VK_BACK_SLASH = 0x5C;
|
||||
|
||||
public const int VK_CLOSE_BRACKET = 0x5D;
|
||||
|
||||
public const int VK_NUMPAD0 = 0x60;
|
||||
public const int VK_NUMPAD1 = 0x61;
|
||||
public const int VK_NUMPAD2 = 0x62;
|
||||
public const int VK_NUMPAD3 = 0x63;
|
||||
public const int VK_NUMPAD4 = 0x64;
|
||||
public const int VK_NUMPAD5 = 0x65;
|
||||
public const int VK_NUMPAD6 = 0x66;
|
||||
public const int VK_NUMPAD7 = 0x67;
|
||||
public const int VK_NUMPAD8 = 0x68;
|
||||
public const int VK_NUMPAD9 = 0x69;
|
||||
public const int VK_MULTIPLY = 0x6A;
|
||||
public const int VK_ADD = 0x6B;
|
||||
|
||||
public const int VK_SEPARATER = 0x6C;
|
||||
|
||||
public const int VK_SEPARATOR = VK_SEPARATER;
|
||||
|
||||
public const int VK_SUBTRACT = 0x6D;
|
||||
public const int VK_DECIMAL = 0x6E;
|
||||
public const int VK_DIVIDE = 0x6F;
|
||||
public const int VK_DELETE = 0x7F;
|
||||
public const int VK_NUM_LOCK = 0x90;
|
||||
public const int VK_SCROLL_LOCK = 0x91;
|
||||
|
||||
public const int VK_F1 = 0x70;
|
||||
|
||||
public const int VK_F2 = 0x71;
|
||||
|
||||
public const int VK_F3 = 0x72;
|
||||
|
||||
public const int VK_F4 = 0x73;
|
||||
|
||||
public const int VK_F5 = 0x74;
|
||||
|
||||
public const int VK_F6 = 0x75;
|
||||
|
||||
public const int VK_F7 = 0x76;
|
||||
|
||||
public const int VK_F8 = 0x77;
|
||||
|
||||
public const int VK_F9 = 0x78;
|
||||
|
||||
public const int VK_F10 = 0x79;
|
||||
|
||||
public const int VK_F11 = 0x7A;
|
||||
|
||||
public const int VK_F12 = 0x7B;
|
||||
|
||||
public const int VK_F13 = 0xF000;
|
||||
|
||||
public const int VK_F14 = 0xF001;
|
||||
|
||||
public const int VK_F15 = 0xF002;
|
||||
|
||||
public const int VK_F16 = 0xF003;
|
||||
|
||||
public const int VK_F17 = 0xF004;
|
||||
|
||||
public const int VK_F18 = 0xF005;
|
||||
|
||||
public const int VK_F19 = 0xF006;
|
||||
|
||||
public const int VK_F20 = 0xF007;
|
||||
|
||||
public const int VK_F21 = 0xF008;
|
||||
|
||||
public const int VK_F22 = 0xF009;
|
||||
|
||||
public const int VK_F23 = 0xF00A;
|
||||
|
||||
public const int VK_F24 = 0xF00B;
|
||||
|
||||
public const int VK_PRINTSCREEN = 0x9A;
|
||||
public const int VK_INSERT = 0x9B;
|
||||
public const int VK_HELP = 0x9C;
|
||||
public const int VK_META = 0x9D;
|
||||
|
||||
public const int VK_BACK_QUOTE = 0xC0;
|
||||
public const int VK_QUOTE = 0xDE;
|
||||
|
||||
public const int VK_KP_UP = 0xE0;
|
||||
|
||||
public const int VK_KP_DOWN = 0xE1;
|
||||
|
||||
public const int VK_KP_LEFT = 0xE2;
|
||||
|
||||
public const int VK_KP_RIGHT = 0xE3;
|
||||
|
||||
public const int VK_DEAD_GRAVE = 0x80;
|
||||
public const int VK_DEAD_ACUTE = 0x81;
|
||||
public const int VK_DEAD_CIRCUMFLEX = 0x82;
|
||||
public const int VK_DEAD_TILDE = 0x83;
|
||||
public const int VK_DEAD_MACRON = 0x84;
|
||||
public const int VK_DEAD_BREVE = 0x85;
|
||||
public const int VK_DEAD_ABOVEDOT = 0x86;
|
||||
public const int VK_DEAD_DIAERESIS = 0x87;
|
||||
public const int VK_DEAD_ABOVERING = 0x88;
|
||||
public const int VK_DEAD_DOUBLEACUTE = 0x89;
|
||||
public const int VK_DEAD_CARON = 0x8a;
|
||||
public const int VK_DEAD_CEDILLA = 0x8b;
|
||||
public const int VK_DEAD_OGONEK = 0x8c;
|
||||
public const int VK_DEAD_IOTA = 0x8d;
|
||||
public const int VK_DEAD_VOICED_SOUND = 0x8e;
|
||||
public const int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
|
||||
|
||||
public const int VK_AMPERSAND = 0x96;
|
||||
public const int VK_ASTERISK = 0x97;
|
||||
public const int VK_QUOTEDBL = 0x98;
|
||||
public const int VK_LESS = 0x99;
|
||||
public const int VK_GREATER = 0xa0;
|
||||
public const int VK_BRACELEFT = 0xa1;
|
||||
public const int VK_BRACERIGHT = 0xa2;
|
||||
|
||||
public const int VK_AT = 0x0200;
|
||||
public const int VK_COLON = 0x0201;
|
||||
public const int VK_CIRCUMFLEX = 0x0202;
|
||||
public const int VK_DOLLAR = 0x0203;
|
||||
public const int VK_EURO_SIGN = 0x0204;
|
||||
|
||||
public const int VK_EXCLAMATION_MARK = 0x0205;
|
||||
public const int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
|
||||
public const int VK_LEFT_PARENTHESIS = 0x0207;
|
||||
public const int VK_NUMBER_SIGN = 0x0208;
|
||||
public const int VK_PLUS = 0x0209;
|
||||
public const int VK_RIGHT_PARENTHESIS = 0x020A;
|
||||
public const int VK_UNDERSCORE = 0x020B;
|
||||
public const int VK_WINDOWS = 0x020C;
|
||||
public const int VK_CONTEXT_MENU = 0x020D;
|
||||
public const int VK_const = 0x0018;
|
||||
public const int VK_CONVERT = 0x001C;
|
||||
public const int VK_NONCONVERT = 0x001D;
|
||||
public const int VK_ACCEPT = 0x001E;
|
||||
public const int VK_MODECHANGE = 0x001F;
|
||||
public const int VK_KANA = 0x0015;
|
||||
public const int VK_KANJI = 0x0019;
|
||||
public const int VK_ALPHANUMERIC = 0x00F0;
|
||||
public const int VK_KATAKANA = 0x00F1;
|
||||
public const int VK_HIRAGANA = 0x00F2;
|
||||
public const int VK_FULL_WIDTH = 0x00F3;
|
||||
public const int VK_HALF_WIDTH = 0x00F4;
|
||||
public const int VK_ROMAN_CHARACTERS = 0x00F5;
|
||||
public const int VK_ALL_CANDIDATES = 0x0100;
|
||||
public const int VK_PREVIOUS_CANDIDATE = 0x0101;
|
||||
public const int VK_CODE_INPUT = 0x0102;
|
||||
public const int VK_JAPANESE_KATAKANA = 0x0103;
|
||||
public const int VK_JAPANESE_HIRAGANA = 0x0104;
|
||||
public const int VK_JAPANESE_ROMAN = 0x0105;
|
||||
public const int VK_KANA_LOCK = 0x0106;
|
||||
public const int VK_INPUT_METHOD_ON_OFF = 0x0107;
|
||||
public const int VK_CUT = 0xFFD1;
|
||||
public const int VK_COPY = 0xFFCD;
|
||||
public const int VK_PASTE = 0xFFCF;
|
||||
public const int VK_UNDO = 0xFFCB;
|
||||
public const int VK_AGAIN = 0xFFC9;
|
||||
public const int VK_FIND = 0xFFD0;
|
||||
public const int VK_PROPS = 0xFFCA;
|
||||
public const int VK_STOP = 0xFFC8;
|
||||
public const int VK_COMPOSE = 0xFF20;
|
||||
public const int VK_ALT_GRAPH = 0xFF7E;
|
||||
public const int VK_BEGIN = 0xFF58;
|
||||
public const int VK_UNDEFINED = 0x0;
|
||||
public const int KEY_LOCATION_UNKNOWN = 0;
|
||||
public const int KEY_LOCATION_STANDARD = 1;
|
||||
public const int KEY_LOCATION_LEFT = 2;
|
||||
public const int KEY_LOCATION_RIGHT = 3;
|
||||
public const int KEY_LOCATION_NUMPAD = 4;
|
||||
public static readonly char CHAR_UNDEFINED = (char) 0xFFFF;
|
||||
public const int MOUSE_FIRST = 500;
|
||||
public const int MOUSE_LAST = 507;
|
||||
public const int MOUSE_CLICKED = MOUSE_FIRST;
|
||||
public const int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN
|
||||
public const int MOUSE_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP
|
||||
public const int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE
|
||||
public const int MOUSE_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER
|
||||
public const int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT
|
||||
public const int MOUSE_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG
|
||||
public const int MOUSE_WHEEL = 7 + MOUSE_FIRST;
|
||||
public const int NOBUTTON = 0;
|
||||
public const int BUTTON1 = 1;
|
||||
public const int BUTTON2 = 2;
|
||||
public const int BUTTON3 = 3;
|
||||
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
|
@ -1,77 +1,77 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MessageEvent is sent to <see cref="TeamRobot.OnMessageReceived(MessageEvent)"/>
|
||||
/// when a teammate sends a message to your robot.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MessageEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 75;
|
||||
|
||||
private readonly string sender;
|
||||
[NonSerialized]
|
||||
private readonly object message;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MessageEvent.
|
||||
/// </summary>
|
||||
public MessageEvent(string sender, object message)
|
||||
{
|
||||
this.sender = sender;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the sending robot.
|
||||
/// </summary>
|
||||
public string Sender
|
||||
{
|
||||
get { return sender; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the message itself.
|
||||
/// </summary>
|
||||
public object Message
|
||||
{
|
||||
get { return message; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsTeamRobot())
|
||||
{
|
||||
ITeamEvents listener = ((ITeamRobot) robot).GetTeamEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMessageReceived(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization of event type not supported"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MessageEvent is sent to <see cref="TeamRobot.OnMessageReceived(MessageEvent)"/>
|
||||
/// when a teammate sends a message to your robot.
|
||||
/// You can use the information contained in this event to determine what to do.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MessageEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 75;
|
||||
|
||||
private readonly string sender;
|
||||
[NonSerialized]
|
||||
private readonly object message;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MessageEvent.
|
||||
/// </summary>
|
||||
public MessageEvent(string sender, object message)
|
||||
{
|
||||
this.sender = sender;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the sending robot.
|
||||
/// </summary>
|
||||
public string Sender
|
||||
{
|
||||
get { return sender; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the message itself.
|
||||
/// </summary>
|
||||
public object Message
|
||||
{
|
||||
get { return message; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsTeamRobot())
|
||||
{
|
||||
ITeamEvents listener = ((ITeamRobot) robot).GetTeamEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMessageReceived(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization of event type not supported"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,103 +1,103 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseClickedEvent is sent to <see cref="Robot.OnMouseClicked(MouseEvent)"/>
|
||||
/// when the mouse is clicked inside the battle view.
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseClickedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseClickedEvent.
|
||||
/// </summary>
|
||||
public MouseClickedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseClicked(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseClickedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseClickedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseClickedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseClickedEvent is sent to <see cref="Robot.OnMouseClicked(MouseEvent)"/>
|
||||
/// when the mouse is clicked inside the battle view.
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseClickedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseClickedEvent.
|
||||
/// </summary>
|
||||
public MouseClickedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseClicked(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseClickedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseClickedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseClickedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,103 +1,103 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseDraggedEvent is sent to <see cref="Robot.OnMouseDragged(MouseEvent)"/>
|
||||
/// when the mouse is dragged inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseDraggedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseDraggedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseDragged(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseDraggedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseDraggedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseDraggedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseDraggedEvent is sent to <see cref="Robot.OnMouseDragged(MouseEvent)"/>
|
||||
/// when the mouse is dragged inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseDraggedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseDraggedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseDragged(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseDraggedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseDraggedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseDraggedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,104 +1,104 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseEnteredEvent is sent to <see cref="Robot.OnMouseEntered(MouseEvent)"/>
|
||||
/// when the mouse has entered the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseEnteredEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseEnteredEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseEntered(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseEnteredEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseEnteredEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseEnteredEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseEnteredEvent is sent to <see cref="Robot.OnMouseEntered(MouseEvent)"/>
|
||||
/// when the mouse has entered the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseEnteredEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseEnteredEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseEntered(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseEnteredEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseEnteredEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseEnteredEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
|
@ -1,91 +1,91 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Super class of all events that originates from the mouse.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class MouseEvent : Event
|
||||
{
|
||||
private readonly int button;
|
||||
private readonly int clickCount;
|
||||
private readonly int x;
|
||||
private readonly int y;
|
||||
private readonly int id;
|
||||
private readonly int modifiersEx;
|
||||
private readonly long when;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseEvent.
|
||||
/// </summary>
|
||||
protected MouseEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
{
|
||||
this.button = button;
|
||||
this.clickCount = clickCount;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
this.modifiersEx = modifiersEx;
|
||||
this.when = when;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of the button
|
||||
/// </summary>
|
||||
public int Button
|
||||
{
|
||||
get { return button; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Click count
|
||||
/// </summary>
|
||||
public int ClickCount
|
||||
{
|
||||
get { return clickCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cursor coordinates
|
||||
/// </summary>
|
||||
public int X
|
||||
{
|
||||
get { return x; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cursor coordinates
|
||||
/// </summary>
|
||||
public int Y
|
||||
{
|
||||
get { return y; }
|
||||
}
|
||||
|
||||
internal int ID
|
||||
{
|
||||
get { return id; }
|
||||
}
|
||||
|
||||
internal int ModifiersEx
|
||||
{
|
||||
get { return modifiersEx; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Age of the event
|
||||
/// </summary>
|
||||
public long When
|
||||
{
|
||||
get { return when; }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Super class of all events that originates from the mouse.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class MouseEvent : Event
|
||||
{
|
||||
private readonly int button;
|
||||
private readonly int clickCount;
|
||||
private readonly int x;
|
||||
private readonly int y;
|
||||
private readonly int id;
|
||||
private readonly int modifiersEx;
|
||||
private readonly long when;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseEvent.
|
||||
/// </summary>
|
||||
protected MouseEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
{
|
||||
this.button = button;
|
||||
this.clickCount = clickCount;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
this.modifiersEx = modifiersEx;
|
||||
this.when = when;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of the button
|
||||
/// </summary>
|
||||
public int Button
|
||||
{
|
||||
get { return button; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Click count
|
||||
/// </summary>
|
||||
public int ClickCount
|
||||
{
|
||||
get { return clickCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cursor coordinates
|
||||
/// </summary>
|
||||
public int X
|
||||
{
|
||||
get { return x; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cursor coordinates
|
||||
/// </summary>
|
||||
public int Y
|
||||
{
|
||||
get { return y; }
|
||||
}
|
||||
|
||||
internal int ID
|
||||
{
|
||||
get { return id; }
|
||||
}
|
||||
|
||||
internal int ModifiersEx
|
||||
{
|
||||
get { return modifiersEx; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Age of the event
|
||||
/// </summary>
|
||||
public long When
|
||||
{
|
||||
get { return when; }
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,103 +1,103 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseExitedEvent is sent to <see cref="Robot.OnMouseExited(MouseEvent)"/>
|
||||
/// when the mouse has exited the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseExitedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseExitedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseExited(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseExitedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseExitedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseExitedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseExitedEvent is sent to <see cref="Robot.OnMouseExited(MouseEvent)"/>
|
||||
/// when the mouse has exited the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseExitedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseExitedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseExited(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseExitedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseExitedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseExitedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,104 +1,104 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseMovedEvent is sent to <see cref="Robot.OnMouseMoved(MouseEvent)"/>
|
||||
/// when the mouse has moved inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseMovedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseMovedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseMoved(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseMovedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseMovedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseMovedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseMovedEvent is sent to <see cref="Robot.OnMouseMoved(MouseEvent)"/>
|
||||
/// when the mouse has moved inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseMovedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseMovedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseMoved(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseMovedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseMovedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseMovedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,105 +1,105 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MousePressedEvent is sent to <see cref="Robot.OnMousePressed(MouseEvent)"/>
|
||||
/// when the mouse is pressed inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MousePressedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MousePressedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMousePressed(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MousePressedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MousePressedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MousePressedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MousePressedEvent is sent to <see cref="Robot.OnMousePressed(MouseEvent)"/>
|
||||
/// when the mouse is pressed inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MousePressedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MousePressedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMousePressed(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MousePressedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MousePressedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MousePressedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
|
@ -1,104 +1,104 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseReleasedEvent is sent to <see cref="Robot.OnMouseReleased(MouseEvent)"/>
|
||||
/// when the mouse is released inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseReleasedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseReleasedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseReleased(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseReleasedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseReleasedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseReleasedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseReleasedEvent is sent to <see cref="Robot.OnMouseReleased(MouseEvent)"/>
|
||||
/// when the mouse is released inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseReleasedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseDraggedEvent.
|
||||
/// </summary>
|
||||
public MouseReleasedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseReleased(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseReleasedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseReleasedEvent)objec;
|
||||
|
||||
serializer.serialize(buffer, obj.Button);
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int button = buffer.getInt();
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseReleasedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
|
@ -1,134 +1,134 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseWheelMovedEvent is sent to <see cref="Robot.OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||
/// when the mouse wheel is rotated inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseWheelMovedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
private readonly int scrollType;
|
||||
private readonly int scrollAmount;
|
||||
private readonly int wheelRotation;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseWheelMovedEvent.
|
||||
/// </summary>
|
||||
public MouseWheelMovedEvent(int clickCount, int x, int y, int scrollType, int scrollAmount, int wheelRotation,
|
||||
int id, int modifiersEx, long when)
|
||||
: base(-1, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
this.scrollType = scrollType;
|
||||
this.scrollAmount = scrollAmount;
|
||||
this.wheelRotation = wheelRotation;
|
||||
}
|
||||
|
||||
internal int ScrollType
|
||||
{
|
||||
get { return scrollType; }
|
||||
}
|
||||
|
||||
internal int ScrollAmount
|
||||
{
|
||||
get { return scrollAmount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates how far the mouse wheel was rotated.
|
||||
/// </summary>
|
||||
public int WheelRotation
|
||||
{
|
||||
get { return wheelRotation; }
|
||||
}
|
||||
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseWheelMoved(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseWheelMovedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 8*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseWheelMovedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ScrollType);
|
||||
serializer.serialize(buffer, obj.ScrollAmount);
|
||||
serializer.serialize(buffer, obj.WheelRotation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int scrollType = buffer.getInt();
|
||||
int scrollAmount = buffer.getInt();
|
||||
int wheelRotation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseWheelMovedEvent(clickCount, x, y, scrollType, scrollAmount, wheelRotation, id,
|
||||
modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A MouseWheelMovedEvent is sent to <see cref="Robot.OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||
/// when the mouse wheel is rotated inside the battle view.
|
||||
/// <seealso cref="MouseClickedEvent"/>
|
||||
/// <seealso cref="MousePressedEvent"/>
|
||||
/// <seealso cref="MouseReleasedEvent"/>
|
||||
/// <seealso cref="MouseEnteredEvent"/>
|
||||
/// <seealso cref="MouseExitedEvent"/>
|
||||
/// <seealso cref="MouseMovedEvent"/>
|
||||
/// <seealso cref="MouseDraggedEvent"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class MouseWheelMovedEvent : MouseEvent
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 98;
|
||||
private readonly int scrollType;
|
||||
private readonly int scrollAmount;
|
||||
private readonly int wheelRotation;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new MouseWheelMovedEvent.
|
||||
/// </summary>
|
||||
public MouseWheelMovedEvent(int clickCount, int x, int y, int scrollType, int scrollAmount, int wheelRotation,
|
||||
int id, int modifiersEx, long when)
|
||||
: base(-1, clickCount, x, y, id, modifiersEx, when)
|
||||
{
|
||||
this.scrollType = scrollType;
|
||||
this.scrollAmount = scrollAmount;
|
||||
this.wheelRotation = wheelRotation;
|
||||
}
|
||||
|
||||
internal int ScrollType
|
||||
{
|
||||
get { return scrollType; }
|
||||
}
|
||||
|
||||
internal int ScrollAmount
|
||||
{
|
||||
get { return scrollAmount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates how far the mouse wheel was rotated.
|
||||
/// </summary>
|
||||
public int WheelRotation
|
||||
{
|
||||
get { return wheelRotation; }
|
||||
}
|
||||
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsInteractiveRobot())
|
||||
{
|
||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnMouseWheelMoved(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.MouseWheelMovedEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 8*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (MouseWheelMovedEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.ClickCount);
|
||||
serializer.serialize(buffer, obj.X);
|
||||
serializer.serialize(buffer, obj.Y);
|
||||
serializer.serialize(buffer, obj.ScrollType);
|
||||
serializer.serialize(buffer, obj.ScrollAmount);
|
||||
serializer.serialize(buffer, obj.WheelRotation);
|
||||
serializer.serialize(buffer, obj.ID);
|
||||
serializer.serialize(buffer, obj.ModifiersEx);
|
||||
serializer.serialize(buffer, obj.When);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
int clickCount = buffer.getInt();
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
int scrollType = buffer.getInt();
|
||||
int scrollAmount = buffer.getInt();
|
||||
int wheelRotation = buffer.getInt();
|
||||
int id = buffer.getInt();
|
||||
int modifiersEx = buffer.getInt();
|
||||
long when = buffer.getLong();
|
||||
|
||||
return new MouseWheelMovedEvent(clickCount, x, y, scrollType, scrollAmount, wheelRotation, id,
|
||||
modifiersEx, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,52 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A prebuilt condition you can use that indicates your robot has finished moving.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
public class MoveCompleteCondition : Condition
|
||||
{
|
||||
private readonly AdvancedRobot robot;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new MoveCompleteCondition with default priority.
|
||||
/// The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
public MoveCompleteCondition(AdvancedRobot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new MoveCompleteCondition with the specified priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// <seealso cref="Condition.Priority"/>
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
/// <param name="priority">The priority of this condition</param>
|
||||
public MoveCompleteCondition(AdvancedRobot robot, int priority)
|
||||
{
|
||||
this.robot = robot;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the robot has stopped moving.
|
||||
/// Returns true if the robot has stopped moving
|
||||
/// </summary>
|
||||
public override bool Test()
|
||||
{
|
||||
return (robot.DistanceRemaining == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A prebuilt condition you can use that indicates your robot has finished moving.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
public class MoveCompleteCondition : Condition
|
||||
{
|
||||
private readonly AdvancedRobot robot;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new MoveCompleteCondition with default priority.
|
||||
/// The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
public MoveCompleteCondition(AdvancedRobot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new MoveCompleteCondition with the specified priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// <seealso cref="Condition.Priority"/>
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
/// <param name="priority">The priority of this condition</param>
|
||||
public MoveCompleteCondition(AdvancedRobot robot, int priority)
|
||||
{
|
||||
this.robot = robot;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the robot has stopped moving.
|
||||
/// Returns true if the robot has stopped moving
|
||||
/// </summary>
|
||||
public override bool Test()
|
||||
{
|
||||
return (robot.DistanceRemaining == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,50 +1,50 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event occurs when your robot should paint, where the
|
||||
/// <see cref="Robot.OnPaint(IGraphics)"/> is called on your robot.
|
||||
/// <p/>
|
||||
/// You can use this event for setting the event priority by calling
|
||||
/// <see cref="AdvancedRobot.SetEventPriority(string, int)"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class PaintEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 5;
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsPaintRobot())
|
||||
{
|
||||
IPaintEvents listener = ((IPaintRobot) robot).GetPaintEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnPaint(graphics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization of this type is not supported"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.peer;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event occurs when your robot should paint, where the
|
||||
/// <see cref="Robot.OnPaint(IGraphics)"/> is called on your robot.
|
||||
/// <p/>
|
||||
/// You can use this event for setting the event priority by calling
|
||||
/// <see cref="AdvancedRobot.SetEventPriority(string, int)"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class PaintEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 5;
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
if (statics.IsPaintRobot())
|
||||
{
|
||||
IPaintEvents listener = ((IPaintRobot) robot).GetPaintEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnPaint(graphics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { throw new System.Exception("Serialization of this type is not supported"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,52 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A prebuilt condition you can use that indicates your radar has finished turning.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
public class RadarTurnCompleteCondition : Condition
|
||||
{
|
||||
private readonly AdvancedRobot robot;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new RadarTurnCompleteCondition with default priority.
|
||||
/// The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
public RadarTurnCompleteCondition(AdvancedRobot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new RadarTurnCompleteCondition with the specified priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// <seealso cref="Condition.Priority"/>
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
/// <param name="priority">The priority of this condition</param>
|
||||
public RadarTurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||
{
|
||||
this.robot = robot;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the radar has stopped turning.
|
||||
/// Returns true if the radar has stopped turning; false otherwise
|
||||
/// </summary>
|
||||
public override bool Test()
|
||||
{
|
||||
return (robot.RadarTurnRemaining == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// A prebuilt condition you can use that indicates your radar has finished turning.
|
||||
/// <seealso cref="Condition"/>
|
||||
/// </summary>
|
||||
public class RadarTurnCompleteCondition : Condition
|
||||
{
|
||||
private readonly AdvancedRobot robot;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new RadarTurnCompleteCondition with default priority.
|
||||
/// The default priority is 80.
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
public RadarTurnCompleteCondition(AdvancedRobot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new RadarTurnCompleteCondition with the specified priority.
|
||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||
/// higher priority. The default priority is 80.
|
||||
/// <seealso cref="Condition.Priority"/>
|
||||
/// </summary>
|
||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||
/// <param name="priority">The priority of this condition</param>
|
||||
public RadarTurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||
{
|
||||
this.robot = robot;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the radar has stopped turning.
|
||||
/// Returns true if the radar has stopped turning; false otherwise
|
||||
/// </summary>
|
||||
public override bool Test()
|
||||
{
|
||||
return (robot.RadarTurnRemaining == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,364 +1,364 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using Robocode.Util;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This advanced robot type allows you to set a rate for each of the robot's movements.
|
||||
/// <p />
|
||||
/// You can set the rate for:
|
||||
/// <ul>
|
||||
/// <li>velocity - pixels per turn</li>
|
||||
/// <li>robot turn - radians per turn</li>
|
||||
/// <li>gun rotation - radians per turn</li>
|
||||
/// <li>radar rotation - radians per turn</li>
|
||||
/// </ul>
|
||||
/// When you set a rate for one of the above movements, the movement will continue the move by
|
||||
/// specified rate for ever, until the rate is changed. In order to move ahead or right, the
|
||||
/// rate must be set to a positive value. If a negative value is used instead, the movement
|
||||
/// will go back or to the left. In order to stop the movement, the rate must be
|
||||
/// set to 0.
|
||||
/// <para />
|
||||
/// Note: When calling <see cref="VelocityRate" />, <see cref="TurnRate" />,
|
||||
/// <see cref="GunRotationRate" />, <see cref="RadarRotationRate" /> and variants,
|
||||
/// any previous calls to "movement" functions outside of <see cref="RateControlRobot" />,
|
||||
/// such as <see cref="AdvancedRobot.SetAhead(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnRadarRightRadians(double)" /> and similar will be
|
||||
/// overridden when calling the <see cref="Execute()" /> on this robot class.
|
||||
/// <p />
|
||||
/// Look into the source code for the samplecs.VelociRobot in order to see how to use this
|
||||
/// robot type.
|
||||
/// <seealso cref="JuniorRobot"/>
|
||||
/// <seealso cref="Robot"/>
|
||||
/// <seealso cref="AdvancedRobot"/>
|
||||
/// <seealso cref="TeamRobot"/>
|
||||
/// <seealso cref="IDroid"/>
|
||||
/// <seealso cref="IBorderSentry"/>
|
||||
/// </summary>
|
||||
public abstract class RateControlRobot : TeamRobot
|
||||
{
|
||||
private double velocityRate; // Pixels per turn
|
||||
private double turnRate; // Radians per turn
|
||||
private double gunRotationRate; // Radians per turn
|
||||
private double radarRotationRate; // Radians per turn
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// The speed the robot will move (forward), in pixels per turn.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the robot will move backwards
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the robot to move forward 2 pixels per turn
|
||||
/// VelocityRate = 2;
|
||||
///
|
||||
/// // Set the robot to move backwards 8 pixels per turn
|
||||
/// // (overrides the previous order)
|
||||
/// VelocityRate = -8;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last VelocityRate
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// Note: This method overrules <see cref="AdvancedRobot.SetAhead(double)" /> and
|
||||
/// <see cref="AdvancedRobot.SetBack(double)" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="RadarRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetAhead(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetBack(double)" />
|
||||
///</summary>
|
||||
public double VelocityRate
|
||||
{
|
||||
get { return velocityRate; }
|
||||
set { velocityRate = value; }
|
||||
}
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// The robot's clockwise (right) rotation per turn, in degrees.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the robot turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the robot to turn right 10 degrees per turn
|
||||
/// TurnRate = 10;
|
||||
///
|
||||
/// // Set the robot to turn left 4 degrees per turn
|
||||
/// // (overrides the previous order)
|
||||
/// TurnRate = -5;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last TurnRate
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="RadarRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRight(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnLeft(double)" />
|
||||
///</summary>
|
||||
public double TurnRate
|
||||
{
|
||||
get { return Utils.ToRadians(turnRate); }
|
||||
set { turnRate = Utils.ToRadians(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The robot's clockwise (right) rotation per turn, in radians.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the robot turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the robot to turn right pi / 32 radians per turn
|
||||
/// TurnRateRadians = Math.PI / 32;
|
||||
///
|
||||
/// // Set the robot to turn left pi / 20 radians per turn
|
||||
/// // (overrides the previous order)
|
||||
/// TurnRateRadians = -Math.PI / 20;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last TurnRateRadians
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <seealso cref="TurnRateRadians" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="GunRotationRateRadians" />
|
||||
/// <seealso cref="RadarRotationRateRadians" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRightRadians(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnLeftRadians(double)" />
|
||||
/// </summary>
|
||||
public double TurnRateRadians
|
||||
{
|
||||
get { return turnRate; }
|
||||
set { turnRate = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gun's clockwise (right) rotation per turn, in degrees.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the gun turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the gun to turn right 15 degrees per turn
|
||||
/// GunRotationRate = 15;
|
||||
///
|
||||
/// // Set the gun to turn left 9 degrees per turn
|
||||
/// // (overrides the previous order)
|
||||
/// GunRotationRate = -9;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last GunRotationRate()
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="RadarRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunRight(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunLeft(double)" />
|
||||
/// </summary>
|
||||
public double GunRotationRate
|
||||
{
|
||||
get { return Utils.ToDegrees(gunRotationRate); }
|
||||
set { gunRotationRate = Utils.ToRadians(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gun's clockwise (right) rotation per turn, in radians.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the gun turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the gun to turn right pi / 16 radians per turn
|
||||
/// GunRotationRateRadians = Math.PI / 16;
|
||||
///
|
||||
/// // Set the gun to turn left pi / 12 radians per turn
|
||||
/// // (overrides the previous order)
|
||||
/// GunRotationRateRadians = -Math.PI / 12;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last GunRotationRateRadians
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="GunRotationRateRadians()" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRateRadians" />
|
||||
/// <seealso cref="RadarRotationRateRadians" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunRightRadians(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunLeftRadians(double)" />
|
||||
/// </summary>
|
||||
public double GunRotationRateRadians
|
||||
{
|
||||
get { return gunRotationRate; }
|
||||
set { gunRotationRate = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radar's clockwise (right) rotation per turn, in degrees.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the radar turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the radar to turn right 45 degrees per turn
|
||||
/// RadarRotationRate = 45;
|
||||
///
|
||||
/// // Set the radar to turn left 15 degrees per turn
|
||||
/// // (overrides the previous order)
|
||||
/// RadarRotationRate = -15;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last RadarRotationRate
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="RadarRotationRate()" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarRight(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarLeft(double)" />
|
||||
/// </summary>
|
||||
public double RadarRotationRate
|
||||
{
|
||||
get { return Utils.ToDegrees(radarRotationRate); }
|
||||
set { radarRotationRate = Utils.ToRadians(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radar's clockwise (right) rotation per turn, in radians.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the radar turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the radar to turn right pi / 4 radians per turn
|
||||
/// RadarRotationRateRadians = Math.PI / 4;
|
||||
///
|
||||
/// // Set the radar to turn left pi / 8 radians per turn
|
||||
/// // (overrides the previous order)
|
||||
/// RadarRotationRateRadians = -Math.PI / 8;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last RadarRotationRateRadians
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="RadarRotationRateRadians" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRateRadians" />
|
||||
/// <seealso cref="GunRotationRateRadians" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarRightRadians(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
||||
/// </summary>
|
||||
public double RadarRotationRateRadians
|
||||
{
|
||||
get { return radarRotationRate; }
|
||||
set { radarRotationRate = value; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Executes any pending actions, or continues executing actions that are
|
||||
/// in process. This call returns after the actions have been started.
|
||||
/// <p />
|
||||
/// Note that advanced robots <em>must</em> call this function in order to
|
||||
/// Execute pending set* calls like e.g. <see cref="VelocityRate" />,
|
||||
/// <see cref="AdvancedRobot.SetFire(double)" />, <see cref="TurnRate" />
|
||||
/// etc. Otherwise, these calls will never get executed.
|
||||
/// <p />
|
||||
/// Any previous calls to "movement" functions outside of
|
||||
/// <see cref="RateControlRobot" />, such as
|
||||
/// <see cref="AdvancedRobot.SetAhead(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
||||
/// etc. will be overridden when this method is called on this robot class.
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// In this example the robot will move while turning:
|
||||
/// <code>
|
||||
/// VelocityRate = 6;
|
||||
/// TurnRate = 7;
|
||||
///
|
||||
/// while (true)
|
||||
/// {
|
||||
/// Execute();
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
///</summary>
|
||||
public override void Execute()
|
||||
{
|
||||
MaxVelocity = velocityRate;
|
||||
if (velocityRate > 0)
|
||||
{
|
||||
SetAhead(Double.PositiveInfinity);
|
||||
}
|
||||
else if (velocityRate < 0)
|
||||
{
|
||||
SetBack(Double.PositiveInfinity);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAhead(0);
|
||||
}
|
||||
|
||||
SetTurnGunRightRadians(gunRotationRate);
|
||||
SetTurnRadarRightRadians(radarRotationRate);
|
||||
SetTurnRightRadians(turnRate);
|
||||
|
||||
base.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using Robocode.Util;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This advanced robot type allows you to set a rate for each of the robot's movements.
|
||||
/// <p />
|
||||
/// You can set the rate for:
|
||||
/// <ul>
|
||||
/// <li>velocity - pixels per turn</li>
|
||||
/// <li>robot turn - radians per turn</li>
|
||||
/// <li>gun rotation - radians per turn</li>
|
||||
/// <li>radar rotation - radians per turn</li>
|
||||
/// </ul>
|
||||
/// When you set a rate for one of the above movements, the movement will continue the move by
|
||||
/// specified rate for ever, until the rate is changed. In order to move ahead or right, the
|
||||
/// rate must be set to a positive value. If a negative value is used instead, the movement
|
||||
/// will go back or to the left. In order to stop the movement, the rate must be
|
||||
/// set to 0.
|
||||
/// <para />
|
||||
/// Note: When calling <see cref="VelocityRate" />, <see cref="TurnRate" />,
|
||||
/// <see cref="GunRotationRate" />, <see cref="RadarRotationRate" /> and variants,
|
||||
/// any previous calls to "movement" functions outside of <see cref="RateControlRobot" />,
|
||||
/// such as <see cref="AdvancedRobot.SetAhead(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnRadarRightRadians(double)" /> and similar will be
|
||||
/// overridden when calling the <see cref="Execute()" /> on this robot class.
|
||||
/// <p />
|
||||
/// Look into the source code for the samplecs.VelociRobot in order to see how to use this
|
||||
/// robot type.
|
||||
/// <seealso cref="JuniorRobot"/>
|
||||
/// <seealso cref="Robot"/>
|
||||
/// <seealso cref="AdvancedRobot"/>
|
||||
/// <seealso cref="TeamRobot"/>
|
||||
/// <seealso cref="IDroid"/>
|
||||
/// <seealso cref="IBorderSentry"/>
|
||||
/// </summary>
|
||||
public abstract class RateControlRobot : TeamRobot
|
||||
{
|
||||
private double velocityRate; // Pixels per turn
|
||||
private double turnRate; // Radians per turn
|
||||
private double gunRotationRate; // Radians per turn
|
||||
private double radarRotationRate; // Radians per turn
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// The speed the robot will move (forward), in pixels per turn.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the robot will move backwards
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the robot to move forward 2 pixels per turn
|
||||
/// VelocityRate = 2;
|
||||
///
|
||||
/// // Set the robot to move backwards 8 pixels per turn
|
||||
/// // (overrides the previous order)
|
||||
/// VelocityRate = -8;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last VelocityRate
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// Note: This method overrules <see cref="AdvancedRobot.SetAhead(double)" /> and
|
||||
/// <see cref="AdvancedRobot.SetBack(double)" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="RadarRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetAhead(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetBack(double)" />
|
||||
///</summary>
|
||||
public double VelocityRate
|
||||
{
|
||||
get { return velocityRate; }
|
||||
set { velocityRate = value; }
|
||||
}
|
||||
|
||||
///
|
||||
///<summary>
|
||||
/// The robot's clockwise (right) rotation per turn, in degrees.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the robot turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the robot to turn right 10 degrees per turn
|
||||
/// TurnRate = 10;
|
||||
///
|
||||
/// // Set the robot to turn left 4 degrees per turn
|
||||
/// // (overrides the previous order)
|
||||
/// TurnRate = -5;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last TurnRate
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="RadarRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRight(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnLeft(double)" />
|
||||
///</summary>
|
||||
public double TurnRate
|
||||
{
|
||||
get { return Utils.ToRadians(turnRate); }
|
||||
set { turnRate = Utils.ToRadians(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The robot's clockwise (right) rotation per turn, in radians.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the robot turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the robot to turn right pi / 32 radians per turn
|
||||
/// TurnRateRadians = Math.PI / 32;
|
||||
///
|
||||
/// // Set the robot to turn left pi / 20 radians per turn
|
||||
/// // (overrides the previous order)
|
||||
/// TurnRateRadians = -Math.PI / 20;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last TurnRateRadians
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <seealso cref="TurnRateRadians" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="GunRotationRateRadians" />
|
||||
/// <seealso cref="RadarRotationRateRadians" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRightRadians(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnLeftRadians(double)" />
|
||||
/// </summary>
|
||||
public double TurnRateRadians
|
||||
{
|
||||
get { return turnRate; }
|
||||
set { turnRate = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gun's clockwise (right) rotation per turn, in degrees.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the gun turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the gun to turn right 15 degrees per turn
|
||||
/// GunRotationRate = 15;
|
||||
///
|
||||
/// // Set the gun to turn left 9 degrees per turn
|
||||
/// // (overrides the previous order)
|
||||
/// GunRotationRate = -9;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last GunRotationRate()
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="RadarRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunRight(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunLeft(double)" />
|
||||
/// </summary>
|
||||
public double GunRotationRate
|
||||
{
|
||||
get { return Utils.ToDegrees(gunRotationRate); }
|
||||
set { gunRotationRate = Utils.ToRadians(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gun's clockwise (right) rotation per turn, in radians.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the gun turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the gun to turn right pi / 16 radians per turn
|
||||
/// GunRotationRateRadians = Math.PI / 16;
|
||||
///
|
||||
/// // Set the gun to turn left pi / 12 radians per turn
|
||||
/// // (overrides the previous order)
|
||||
/// GunRotationRateRadians = -Math.PI / 12;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last GunRotationRateRadians
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="GunRotationRateRadians()" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRateRadians" />
|
||||
/// <seealso cref="RadarRotationRateRadians" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunRightRadians(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnGunLeftRadians(double)" />
|
||||
/// </summary>
|
||||
public double GunRotationRateRadians
|
||||
{
|
||||
get { return gunRotationRate; }
|
||||
set { gunRotationRate = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radar's clockwise (right) rotation per turn, in degrees.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the radar turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the radar to turn right 45 degrees per turn
|
||||
/// RadarRotationRate = 45;
|
||||
///
|
||||
/// // Set the radar to turn left 15 degrees per turn
|
||||
/// // (overrides the previous order)
|
||||
/// RadarRotationRate = -15;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last RadarRotationRate
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="RadarRotationRate()" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRate" />
|
||||
/// <seealso cref="GunRotationRate" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarRight(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarLeft(double)" />
|
||||
/// </summary>
|
||||
public double RadarRotationRate
|
||||
{
|
||||
get { return Utils.ToDegrees(radarRotationRate); }
|
||||
set { radarRotationRate = Utils.ToRadians(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radar's clockwise (right) rotation per turn, in radians.
|
||||
/// <p />
|
||||
/// This call returns immediately, and will not execute until you call
|
||||
/// Execute() or take an action that executes.
|
||||
/// <p />
|
||||
/// Note that both positive and negative values can be given as input,
|
||||
/// where negative values means that the radar turns counterclockwise (left)
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // Set the radar to turn right pi / 4 radians per turn
|
||||
/// RadarRotationRateRadians = Math.PI / 4;
|
||||
///
|
||||
/// // Set the radar to turn left pi / 8 radians per turn
|
||||
/// // (overrides the previous order)
|
||||
/// RadarRotationRateRadians = -Math.PI / 8;
|
||||
///
|
||||
/// ...
|
||||
/// // Executes the last RadarRotationRateRadians
|
||||
/// Execute();
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <seealso cref="RadarRotationRateRadians" />
|
||||
/// <seealso cref="VelocityRate" />
|
||||
/// <seealso cref="TurnRateRadians" />
|
||||
/// <seealso cref="GunRotationRateRadians" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarRightRadians(double)" />
|
||||
/// <seealso cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
||||
/// </summary>
|
||||
public double RadarRotationRateRadians
|
||||
{
|
||||
get { return radarRotationRate; }
|
||||
set { radarRotationRate = value; }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Executes any pending actions, or continues executing actions that are
|
||||
/// in process. This call returns after the actions have been started.
|
||||
/// <p />
|
||||
/// Note that advanced robots <em>must</em> call this function in order to
|
||||
/// Execute pending set* calls like e.g. <see cref="VelocityRate" />,
|
||||
/// <see cref="AdvancedRobot.SetFire(double)" />, <see cref="TurnRate" />
|
||||
/// etc. Otherwise, these calls will never get executed.
|
||||
/// <p />
|
||||
/// Any previous calls to "movement" functions outside of
|
||||
/// <see cref="RateControlRobot" />, such as
|
||||
/// <see cref="AdvancedRobot.SetAhead(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
||||
/// <see cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
||||
/// etc. will be overridden when this method is called on this robot class.
|
||||
/// <p />
|
||||
/// <example>
|
||||
/// In this example the robot will move while turning:
|
||||
/// <code>
|
||||
/// VelocityRate = 6;
|
||||
/// TurnRate = 7;
|
||||
///
|
||||
/// while (true)
|
||||
/// {
|
||||
/// Execute();
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
///</summary>
|
||||
public override void Execute()
|
||||
{
|
||||
MaxVelocity = velocityRate;
|
||||
if (velocityRate > 0)
|
||||
{
|
||||
SetAhead(Double.PositiveInfinity);
|
||||
}
|
||||
else if (velocityRate < 0)
|
||||
{
|
||||
SetBack(Double.PositiveInfinity);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAhead(0);
|
||||
}
|
||||
|
||||
SetTurnGunRightRadians(gunRotationRate);
|
||||
SetTurnRadarRightRadians(radarRotationRate);
|
||||
SetTurnRightRadians(turnRate);
|
||||
|
||||
base.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//doc
|
File diff suppressed because it is too large
Load Diff
|
@ -1,95 +1,95 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event is sent to <see cref="Robot.OnRobotDeath(RobotDeathEvent)"/>
|
||||
/// when another robot (not your robot) dies.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class RobotDeathEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 70;
|
||||
|
||||
private readonly string robotName;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new RobotDeathEvent.
|
||||
/// </summary>
|
||||
/// <param name="robotName">the name of the robot that died</param>
|
||||
public RobotDeathEvent(string robotName)
|
||||
{
|
||||
this.robotName = robotName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the robot that died.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return robotName; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnRobotDeath(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.RobotDeathEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (RobotDeathEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName);
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (RobotDeathEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.robotName);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
string name = serializer.deserializeString(buffer);
|
||||
|
||||
return new RobotDeathEvent(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.peer;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.RobotInterfaces;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// This event is sent to <see cref="Robot.OnRobotDeath(RobotDeathEvent)"/>
|
||||
/// when another robot (not your robot) dies.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class RobotDeathEvent : Event
|
||||
{
|
||||
private const int DEFAULT_PRIORITY = 70;
|
||||
|
||||
private readonly string robotName;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the game to create a new RobotDeathEvent.
|
||||
/// </summary>
|
||||
/// <param name="robotName">the name of the robot that died</param>
|
||||
public RobotDeathEvent(string robotName)
|
||||
{
|
||||
this.robotName = robotName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the robot that died.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return robotName; }
|
||||
}
|
||||
|
||||
internal override int DefaultPriority
|
||||
{
|
||||
get { return DEFAULT_PRIORITY; }
|
||||
}
|
||||
|
||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||
{
|
||||
IBasicEvents listener = robot.GetBasicEventListener();
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.OnRobotDeath(this);
|
||||
}
|
||||
}
|
||||
|
||||
internal override byte SerializationType
|
||||
{
|
||||
get { return RbSerializerN.RobotDeathEvent_TYPE; }
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
var obj = (RobotDeathEvent) objec;
|
||||
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName);
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (RobotDeathEvent) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.robotName);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
string name = serializer.deserializeString(buffer);
|
||||
|
||||
return new RobotDeathEvent(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
|
@ -1,401 +1,401 @@
|
|||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.security;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.Util;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the status of a robot for a specific time/turn returned by
|
||||
/// <see cref="StatusEvent.Status"/>.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class RobotStatus
|
||||
{
|
||||
private readonly double energy;
|
||||
private readonly double x;
|
||||
private readonly double y;
|
||||
private readonly double bodyHeading;
|
||||
private readonly double gunHeading;
|
||||
private readonly double radarHeading;
|
||||
private readonly double velocity;
|
||||
private readonly double bodyTurnRemaining;
|
||||
private readonly double radarTurnRemaining;
|
||||
private readonly double gunTurnRemaining;
|
||||
private readonly double distanceRemaining;
|
||||
private readonly double gunHeat;
|
||||
private readonly int others;
|
||||
private readonly int numSentries;
|
||||
private readonly int roundNum;
|
||||
private readonly int numRounds;
|
||||
private readonly long time;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the robot's current energy.
|
||||
/// </summary>
|
||||
public double Energy
|
||||
{
|
||||
get { return energy; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the X position of the robot. (0,0) is at the bottom left of the
|
||||
/// battlefield.
|
||||
/// </summary>
|
||||
/// <seealso cref="Y"/>
|
||||
public double X
|
||||
{
|
||||
get { return x; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Y position of the robot. (0,0) is at the bottom left of the
|
||||
/// battlefield.
|
||||
/// <seealso cref="X"/>
|
||||
/// </summary>
|
||||
public double Y
|
||||
{
|
||||
get { return y; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's body is facing, in radians.
|
||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||
/// </summary>
|
||||
public double HeadingRadians
|
||||
{
|
||||
get { return bodyHeading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's body is facing, in degrees.
|
||||
/// The value returned will be between 0 and 360 (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// 90 means East, 180 means South, and 270 means West.
|
||||
/// </summary>
|
||||
public double Heading
|
||||
{
|
||||
get { return Utils.ToDegrees(bodyHeading); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's gun is facing, in radians.
|
||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||
/// </summary>
|
||||
public double GunHeadingRadians
|
||||
{
|
||||
get { return gunHeading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's gun is facing, in degrees.
|
||||
/// The value returned will be between 0 and 360 (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// 90 means East, 180 means South, and 270 means West.
|
||||
/// </summary>
|
||||
public double GunHeading
|
||||
{
|
||||
get { return Utils.ToDegrees(gunHeading); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's radar is facing, in radians.
|
||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||
/// </summary>
|
||||
public double RadarHeadingRadians
|
||||
{
|
||||
get { return radarHeading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's radar is facing, in degrees.
|
||||
/// The value returned will be between 0 and 360 (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// 90 means East, 180 means South, and 270 means West.
|
||||
/// </summary>
|
||||
public double RadarHeading
|
||||
{
|
||||
get { return Utils.ToDegrees(radarHeading); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the velocity of the robot measured in pixels/turn.
|
||||
/// <p/>
|
||||
/// The maximum velocity of a robot is defined by <see cref="Rules.MAX_VELOCITY"/>
|
||||
/// (8 pixels / turn).
|
||||
/// <seealso cref="Rules.MAX_VELOCITY"/>
|
||||
/// </summary>
|
||||
public double Velocity
|
||||
{
|
||||
get { return velocity; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the robots's turn, in radians.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the robot is currently turning to the right.
|
||||
/// Negative values means that the robot is currently turning to the left.
|
||||
/// </summary>
|
||||
public double TurnRemainingRadians
|
||||
{
|
||||
get { return bodyTurnRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the robots's turn, in degrees.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the robot is currently turning to the right.
|
||||
/// Negative values means that the robot is currently turning to the left.
|
||||
/// </summary>
|
||||
public double TurnRemaining
|
||||
{
|
||||
get { return Utils.ToDegrees(bodyTurnRemaining); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the radar's turn, in radians.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the radar is currently turning to the right.
|
||||
/// Negative values means that the radar is currently turning to the left.
|
||||
/// </summary>
|
||||
public double RadarTurnRemainingRadians
|
||||
{
|
||||
get { return radarTurnRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the radar's turn, in degrees.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the radar is currently turning to the right.
|
||||
/// Negative values means that the radar is currently turning to the left.
|
||||
/// </summary>
|
||||
public double RadarTurnRemaining
|
||||
{
|
||||
get { return Utils.ToDegrees(radarTurnRemaining); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the gun's turn, in radians.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the gun is currently turning to the right.
|
||||
/// Negative values means that the gun is currently turning to the left.
|
||||
/// </summary>
|
||||
public double GunTurnRemainingRadians
|
||||
{
|
||||
get { return gunTurnRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the gun's turn, in degrees.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the gun is currently turning to the right.
|
||||
/// Negative values means that the gun is currently turning to the left.
|
||||
/// </summary>
|
||||
public double GunTurnRemaining
|
||||
{
|
||||
get { return Utils.ToDegrees(gunTurnRemaining); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the distance remaining in the robot's current move measured in
|
||||
/// pixels.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the robot is currently moving forwards.
|
||||
/// Negative values means that the robot is currently moving backwards.
|
||||
/// </summary>
|
||||
public double DistanceRemaining
|
||||
{
|
||||
get { return distanceRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current heat of the gun. The gun cannot Fire unless this is
|
||||
/// 0. (Calls to Fire will succeed, but will not actually Fire unless
|
||||
/// GetGunHeat() == 0).
|
||||
/// <p/>
|
||||
/// The amount of gun heat generated when the gun is fired is
|
||||
/// 1 + (firePower / 5). Each turn the gun heat drops by the amount returned
|
||||
/// by <see cref="Robot.GunCoolingRate"/>, which is a battle setup.
|
||||
/// <p/>
|
||||
/// Note that all guns are "hot" at the start of each round, where the gun
|
||||
/// heat is 3.
|
||||
/// </summary>
|
||||
/// <seealso cref="Robot.GunCoolingRate"/>
|
||||
/// <seealso cref="Robot.Fire(double)"/>
|
||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||
public double GunHeat
|
||||
{
|
||||
get { return gunHeat; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns how many opponents that are left in the current round.
|
||||
/// </summary>
|
||||
public int Others
|
||||
{
|
||||
get { return others; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns how many sentry robots that are left in the current round.
|
||||
/// </summary>
|
||||
public int NumSentries
|
||||
{
|
||||
get { return numSentries; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of rounds in the current battle.
|
||||
/// </summary>
|
||||
/// <seealso cref="RoundNum"/>
|
||||
public int NumRounds
|
||||
{
|
||||
get { return numRounds; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current round number (0 to <see cref="NumRounds"/> - 1) of
|
||||
/// the battle.
|
||||
/// </summary>
|
||||
/// <seealso cref="NumRounds"/>
|
||||
public int RoundNum
|
||||
{
|
||||
get { return roundNum; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the game time of the round, where the time is equal to the current turn in the round.
|
||||
/// </summary>
|
||||
public long Time
|
||||
{
|
||||
get { return time; }
|
||||
}
|
||||
|
||||
private RobotStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading,
|
||||
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
||||
double gunTurnRemaining,
|
||||
double distanceRemaining, double gunHeat,
|
||||
int others, int numSentries,
|
||||
int roundNum, int numRounds, long time)
|
||||
{
|
||||
this.energy = energy;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.bodyHeading = bodyHeading;
|
||||
this.gunHeading = gunHeading;
|
||||
this.radarHeading = radarHeading;
|
||||
this.bodyTurnRemaining = bodyTurnRemaining;
|
||||
this.velocity = velocity;
|
||||
this.radarTurnRemaining = radarTurnRemaining;
|
||||
this.gunTurnRemaining = gunTurnRemaining;
|
||||
this.distanceRemaining = distanceRemaining;
|
||||
this.gunHeat = gunHeat;
|
||||
this.others = others;
|
||||
this.numSentries = numSentries;
|
||||
this.roundNum = roundNum;
|
||||
this.numRounds = numRounds;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN, IHiddenStatusHelper
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 4*RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (RobotStatus) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.energy);
|
||||
serializer.serialize(buffer, obj.x);
|
||||
serializer.serialize(buffer, obj.y);
|
||||
serializer.serialize(buffer, obj.bodyHeading);
|
||||
serializer.serialize(buffer, obj.gunHeading);
|
||||
serializer.serialize(buffer, obj.radarHeading);
|
||||
serializer.serialize(buffer, obj.velocity);
|
||||
serializer.serialize(buffer, obj.bodyTurnRemaining);
|
||||
serializer.serialize(buffer, obj.radarTurnRemaining);
|
||||
serializer.serialize(buffer, obj.gunTurnRemaining);
|
||||
serializer.serialize(buffer, obj.distanceRemaining);
|
||||
serializer.serialize(buffer, obj.gunHeat);
|
||||
serializer.serialize(buffer, obj.others);
|
||||
serializer.serialize(buffer, obj.numSentries);
|
||||
serializer.serialize(buffer, obj.roundNum);
|
||||
serializer.serialize(buffer, obj.numRounds);
|
||||
serializer.serialize(buffer, obj.time);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
double energy = buffer.getDouble();
|
||||
double x = buffer.getDouble();
|
||||
double y = buffer.getDouble();
|
||||
double bodyHeading = buffer.getDouble();
|
||||
double gunHeading = buffer.getDouble();
|
||||
double radarHeading = buffer.getDouble();
|
||||
double velocity = buffer.getDouble();
|
||||
double bodyTurnRemaining = buffer.getDouble();
|
||||
double radarTurnRemaining = buffer.getDouble();
|
||||
double gunTurnRemaining = buffer.getDouble();
|
||||
double distanceRemaining = buffer.getDouble();
|
||||
double gunHeat = buffer.getDouble();
|
||||
int others = buffer.getInt();
|
||||
int numSentries = buffer.getInt();
|
||||
int roundNum = buffer.getInt();
|
||||
int numRounds = buffer.getInt();
|
||||
long time = buffer.getLong();
|
||||
|
||||
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
||||
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
||||
roundNum, numRounds, time);
|
||||
}
|
||||
|
||||
public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading, double velocity, double bodyTurnRemaining,
|
||||
double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining,
|
||||
double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time)
|
||||
{
|
||||
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
||||
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
||||
roundNum, numRounds, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*/
|
||||
using System;
|
||||
using net.sf.robocode.nio;
|
||||
using net.sf.robocode.security;
|
||||
using net.sf.robocode.serialization;
|
||||
using Robocode.Util;
|
||||
|
||||
namespace Robocode
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the status of a robot for a specific time/turn returned by
|
||||
/// <see cref="StatusEvent.Status"/>.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class RobotStatus
|
||||
{
|
||||
private readonly double energy;
|
||||
private readonly double x;
|
||||
private readonly double y;
|
||||
private readonly double bodyHeading;
|
||||
private readonly double gunHeading;
|
||||
private readonly double radarHeading;
|
||||
private readonly double velocity;
|
||||
private readonly double bodyTurnRemaining;
|
||||
private readonly double radarTurnRemaining;
|
||||
private readonly double gunTurnRemaining;
|
||||
private readonly double distanceRemaining;
|
||||
private readonly double gunHeat;
|
||||
private readonly int others;
|
||||
private readonly int numSentries;
|
||||
private readonly int roundNum;
|
||||
private readonly int numRounds;
|
||||
private readonly long time;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the robot's current energy.
|
||||
/// </summary>
|
||||
public double Energy
|
||||
{
|
||||
get { return energy; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the X position of the robot. (0,0) is at the bottom left of the
|
||||
/// battlefield.
|
||||
/// </summary>
|
||||
/// <seealso cref="Y"/>
|
||||
public double X
|
||||
{
|
||||
get { return x; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Y position of the robot. (0,0) is at the bottom left of the
|
||||
/// battlefield.
|
||||
/// <seealso cref="X"/>
|
||||
/// </summary>
|
||||
public double Y
|
||||
{
|
||||
get { return y; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's body is facing, in radians.
|
||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||
/// </summary>
|
||||
public double HeadingRadians
|
||||
{
|
||||
get { return bodyHeading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's body is facing, in degrees.
|
||||
/// The value returned will be between 0 and 360 (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// 90 means East, 180 means South, and 270 means West.
|
||||
/// </summary>
|
||||
public double Heading
|
||||
{
|
||||
get { return Utils.ToDegrees(bodyHeading); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's gun is facing, in radians.
|
||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||
/// </summary>
|
||||
public double GunHeadingRadians
|
||||
{
|
||||
get { return gunHeading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's gun is facing, in degrees.
|
||||
/// The value returned will be between 0 and 360 (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// 90 means East, 180 means South, and 270 means West.
|
||||
/// </summary>
|
||||
public double GunHeading
|
||||
{
|
||||
get { return Utils.ToDegrees(gunHeading); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's radar is facing, in radians.
|
||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||
/// </summary>
|
||||
public double RadarHeadingRadians
|
||||
{
|
||||
get { return radarHeading; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the direction that the robot's radar is facing, in degrees.
|
||||
/// The value returned will be between 0 and 360 (is excluded).
|
||||
/// <p/>
|
||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||
/// 90 means East, 180 means South, and 270 means West.
|
||||
/// </summary>
|
||||
public double RadarHeading
|
||||
{
|
||||
get { return Utils.ToDegrees(radarHeading); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the velocity of the robot measured in pixels/turn.
|
||||
/// <p/>
|
||||
/// The maximum velocity of a robot is defined by <see cref="Rules.MAX_VELOCITY"/>
|
||||
/// (8 pixels / turn).
|
||||
/// <seealso cref="Rules.MAX_VELOCITY"/>
|
||||
/// </summary>
|
||||
public double Velocity
|
||||
{
|
||||
get { return velocity; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the robots's turn, in radians.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the robot is currently turning to the right.
|
||||
/// Negative values means that the robot is currently turning to the left.
|
||||
/// </summary>
|
||||
public double TurnRemainingRadians
|
||||
{
|
||||
get { return bodyTurnRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the robots's turn, in degrees.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the robot is currently turning to the right.
|
||||
/// Negative values means that the robot is currently turning to the left.
|
||||
/// </summary>
|
||||
public double TurnRemaining
|
||||
{
|
||||
get { return Utils.ToDegrees(bodyTurnRemaining); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the radar's turn, in radians.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the radar is currently turning to the right.
|
||||
/// Negative values means that the radar is currently turning to the left.
|
||||
/// </summary>
|
||||
public double RadarTurnRemainingRadians
|
||||
{
|
||||
get { return radarTurnRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the radar's turn, in degrees.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the radar is currently turning to the right.
|
||||
/// Negative values means that the radar is currently turning to the left.
|
||||
/// </summary>
|
||||
public double RadarTurnRemaining
|
||||
{
|
||||
get { return Utils.ToDegrees(radarTurnRemaining); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the gun's turn, in radians.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the gun is currently turning to the right.
|
||||
/// Negative values means that the gun is currently turning to the left.
|
||||
/// </summary>
|
||||
public double GunTurnRemainingRadians
|
||||
{
|
||||
get { return gunTurnRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle remaining in the gun's turn, in degrees.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the gun is currently turning to the right.
|
||||
/// Negative values means that the gun is currently turning to the left.
|
||||
/// </summary>
|
||||
public double GunTurnRemaining
|
||||
{
|
||||
get { return Utils.ToDegrees(gunTurnRemaining); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the distance remaining in the robot's current move measured in
|
||||
/// pixels.
|
||||
/// <p/>
|
||||
/// This call returns both positive and negative values.
|
||||
/// Positive values means that the robot is currently moving forwards.
|
||||
/// Negative values means that the robot is currently moving backwards.
|
||||
/// </summary>
|
||||
public double DistanceRemaining
|
||||
{
|
||||
get { return distanceRemaining; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current heat of the gun. The gun cannot Fire unless this is
|
||||
/// 0. (Calls to Fire will succeed, but will not actually Fire unless
|
||||
/// GetGunHeat() == 0).
|
||||
/// <p/>
|
||||
/// The amount of gun heat generated when the gun is fired is
|
||||
/// 1 + (firePower / 5). Each turn the gun heat drops by the amount returned
|
||||
/// by <see cref="Robot.GunCoolingRate"/>, which is a battle setup.
|
||||
/// <p/>
|
||||
/// Note that all guns are "hot" at the start of each round, where the gun
|
||||
/// heat is 3.
|
||||
/// </summary>
|
||||
/// <seealso cref="Robot.GunCoolingRate"/>
|
||||
/// <seealso cref="Robot.Fire(double)"/>
|
||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||
public double GunHeat
|
||||
{
|
||||
get { return gunHeat; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns how many opponents that are left in the current round.
|
||||
/// </summary>
|
||||
public int Others
|
||||
{
|
||||
get { return others; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns how many sentry robots that are left in the current round.
|
||||
/// </summary>
|
||||
public int NumSentries
|
||||
{
|
||||
get { return numSentries; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of rounds in the current battle.
|
||||
/// </summary>
|
||||
/// <seealso cref="RoundNum"/>
|
||||
public int NumRounds
|
||||
{
|
||||
get { return numRounds; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current round number (0 to <see cref="NumRounds"/> - 1) of
|
||||
/// the battle.
|
||||
/// </summary>
|
||||
/// <seealso cref="NumRounds"/>
|
||||
public int RoundNum
|
||||
{
|
||||
get { return roundNum; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the game time of the round, where the time is equal to the current turn in the round.
|
||||
/// </summary>
|
||||
public long Time
|
||||
{
|
||||
get { return time; }
|
||||
}
|
||||
|
||||
private RobotStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading,
|
||||
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
||||
double gunTurnRemaining,
|
||||
double distanceRemaining, double gunHeat,
|
||||
int others, int numSentries,
|
||||
int roundNum, int numRounds, long time)
|
||||
{
|
||||
this.energy = energy;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.bodyHeading = bodyHeading;
|
||||
this.gunHeading = gunHeading;
|
||||
this.radarHeading = radarHeading;
|
||||
this.bodyTurnRemaining = bodyTurnRemaining;
|
||||
this.velocity = velocity;
|
||||
this.radarTurnRemaining = radarTurnRemaining;
|
||||
this.gunTurnRemaining = gunTurnRemaining;
|
||||
this.distanceRemaining = distanceRemaining;
|
||||
this.gunHeat = gunHeat;
|
||||
this.others = others;
|
||||
this.numSentries = numSentries;
|
||||
this.roundNum = roundNum;
|
||||
this.numRounds = numRounds;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
private static ISerializableHelperN createHiddenSerializer()
|
||||
{
|
||||
return new SerializableHelper();
|
||||
}
|
||||
|
||||
private class SerializableHelper : ISerializableHelperN, IHiddenStatusHelper
|
||||
{
|
||||
public int sizeOf(RbSerializerN serializer, object objec)
|
||||
{
|
||||
return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 4*RbSerializerN.SIZEOF_INT
|
||||
+ RbSerializerN.SIZEOF_LONG;
|
||||
}
|
||||
|
||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||
{
|
||||
var obj = (RobotStatus) objec;
|
||||
|
||||
serializer.serialize(buffer, obj.energy);
|
||||
serializer.serialize(buffer, obj.x);
|
||||
serializer.serialize(buffer, obj.y);
|
||||
serializer.serialize(buffer, obj.bodyHeading);
|
||||
serializer.serialize(buffer, obj.gunHeading);
|
||||
serializer.serialize(buffer, obj.radarHeading);
|
||||
serializer.serialize(buffer, obj.velocity);
|
||||
serializer.serialize(buffer, obj.bodyTurnRemaining);
|
||||
serializer.serialize(buffer, obj.radarTurnRemaining);
|
||||
serializer.serialize(buffer, obj.gunTurnRemaining);
|
||||
serializer.serialize(buffer, obj.distanceRemaining);
|
||||
serializer.serialize(buffer, obj.gunHeat);
|
||||
serializer.serialize(buffer, obj.others);
|
||||
serializer.serialize(buffer, obj.numSentries);
|
||||
serializer.serialize(buffer, obj.roundNum);
|
||||
serializer.serialize(buffer, obj.numRounds);
|
||||
serializer.serialize(buffer, obj.time);
|
||||
}
|
||||
|
||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||
{
|
||||
double energy = buffer.getDouble();
|
||||
double x = buffer.getDouble();
|
||||
double y = buffer.getDouble();
|
||||
double bodyHeading = buffer.getDouble();
|
||||
double gunHeading = buffer.getDouble();
|
||||
double radarHeading = buffer.getDouble();
|
||||
double velocity = buffer.getDouble();
|
||||
double bodyTurnRemaining = buffer.getDouble();
|
||||
double radarTurnRemaining = buffer.getDouble();
|
||||
double gunTurnRemaining = buffer.getDouble();
|
||||
double distanceRemaining = buffer.getDouble();
|
||||
double gunHeat = buffer.getDouble();
|
||||
int others = buffer.getInt();
|
||||
int numSentries = buffer.getInt();
|
||||
int roundNum = buffer.getInt();
|
||||
int numRounds = buffer.getInt();
|
||||
long time = buffer.getLong();
|
||||
|
||||
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
||||
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
||||
roundNum, numRounds, time);
|
||||
}
|
||||
|
||||
public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||
double radarHeading, double velocity, double bodyTurnRemaining,
|
||||
double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining,
|
||||
double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time)
|
||||
{
|
||||
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
||||
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
||||
roundNum, numRounds, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//doc
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue