Compare commits
15 Commits
master
...
liangshawn
Author | SHA1 | Date |
---|---|---|
ALEX11 | e3c8608f8a | |
ALEX11 | 19f4b31af9 | |
ALEX11 | daa5c52067 | |
ALEX11 | 4572bed23a | |
ALEX11 | 71f1486770 | |
ALEX11 | 93d851621a | |
ALEX11 | a41e1a90da | |
ALEX11 | 3f8a739940 | |
ALEX11 | 6cb9c7742c | |
ALEX11 | 5d5ddd74f8 | |
ALEX11 | 766372dd49 | |
ALEX11 | d4d3c55d50 | |
ALEX11 | 713ddd21e0 | |
ALEX11 | cafc732331 | |
ALEX11 | 15a43e3140 |
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,149 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,9 @@ target
|
||||||
build.xml
|
build.xml
|
||||||
maven-build.xml
|
maven-build.xml
|
||||||
maven-build.properties
|
maven-build.properties
|
||||||
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.sln
|
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.sln
|
||||||
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.suo
|
/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.suo
|
||||||
ucdetector_reports
|
ucdetector_reports
|
||||||
/plugins/dotnet/*.suo
|
/plugins/dotnet/*.suo
|
||||||
*.class
|
*.class
|
||||||
.recommenders
|
.recommenders
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
@REM
|
@REM
|
||||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
@REM All rights reserved. This program and the accompanying materials
|
@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 are made available under the terms of the Eclipse Public License v1.0
|
||||||
@REM which accompanies this distribution, and is available at
|
@REM which accompanies this distribution, and is available at
|
||||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
|
|
||||||
@rem NOTE: Here we expect jacobe.exe to be installed on system PATH
|
@rem NOTE: Here we expect jacobe.exe to be installed on system PATH
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
if exist "%~dp0\tools\lib\jacobe.jar" goto jacobe
|
if exist "%~dp0\tools\lib\jacobe.jar" goto jacobe
|
||||||
call "%~dp0\tools\loadTools.cmd"
|
call "%~dp0\tools\loadTools.cmd"
|
||||||
|
|
||||||
:jacobe
|
:jacobe
|
||||||
call "%~dp0\tools\bin\ant.bat" -buildfile "%~dp0\tools\jacobe\build.xml"
|
call "%~dp0\tools\bin\ant.bat" -buildfile "%~dp0\tools\jacobe\build.xml"
|
|
@ -1,15 +1,15 @@
|
||||||
@REM
|
@REM
|
||||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
@REM All rights reserved. This program and the accompanying materials
|
@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 are made available under the terms of the Eclipse Public License v1.0
|
||||||
@REM which accompanies this distribution, and is available at
|
@REM which accompanies this distribution, and is available at
|
||||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
if not exist "%~dp0\tools\lib\maven-*-uber.jar" (
|
if not exist "%~dp0\tools\lib\maven-*-uber.jar" (
|
||||||
call "%~dp0\tools\loadTools.cmd"
|
call "%~dp0\tools\loadTools.cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
call "%~dp0\tools\bin\mvn.bat" %*
|
call "%~dp0\tools\bin\mvn.bat" %*
|
|
@ -1,12 +1,12 @@
|
||||||
@REM
|
@REM
|
||||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
@REM All rights reserved. This program and the accompanying materials
|
@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 are made available under the terms of the Eclipse Public License v1.0
|
||||||
@REM which accompanies this distribution, and is available at
|
@REM which accompanies this distribution, and is available at
|
||||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
mvn clean install ant:ant -DskipTests=false %*
|
mvn clean install ant:ant -DskipTests=false %*
|
||||||
rem mvn eclipse:eclipse
|
rem mvn eclipse:eclipse
|
|
@ -1,11 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>plugins</name>
|
<name>plugins</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
@REM
|
@REM
|
||||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
@REM All rights reserved. This program and the accompanying materials
|
@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 are made available under the terms of the Eclipse Public License v1.0
|
||||||
@REM which accompanies this distribution, and is available at
|
@REM which accompanies this distribution, and is available at
|
||||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
rem set JAVA_HOME=%JDK6_HOME%
|
rem set JAVA_HOME=%JDK6_HOME%
|
||||||
rem set PATH=%JAVA_HOME%\bin;%PATH%
|
rem set PATH=%JAVA_HOME%\bin;%PATH%
|
||||||
|
|
||||||
set NET_FRAMEWORK_HOME=C:\Windows\Microsoft.NET\Framework\v3.5
|
set NET_FRAMEWORK_HOME=C:\Windows\Microsoft.NET\Framework\v3.5
|
||||||
set PATH=%NET_FRAMEWORK_HOME%;%PATH%
|
set PATH=%NET_FRAMEWORK_HOME%;%PATH%
|
||||||
|
|
||||||
if exist "%~dp0\tools\lib\proxygen.exe" goto gen
|
if exist "%~dp0\tools\lib\proxygen.exe" goto gen
|
||||||
call "%~dp0\tools\loadTools.cmd"
|
call "%~dp0\tools\loadTools.cmd"
|
||||||
|
|
||||||
:gen
|
:gen
|
||||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.control.proxygen.xml
|
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.control.proxygen.xml
|
||||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.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
|
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
|
echo cat't find robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll, please compile it
|
||||||
goto end
|
goto end
|
||||||
|
|
||||||
:gen1
|
:gen1
|
||||||
if exist "%~dp0\tools\lib\robocode.dll" goto gen3
|
if exist "%~dp0\tools\lib\robocode.dll" goto gen3
|
||||||
if exist "%~dp0\robocode.dotnet.api\target\robocode.dll" goto gen2
|
if exist "%~dp0\robocode.dotnet.api\target\robocode.dll" goto gen2
|
||||||
echo cat't find \robocode.dotnet.api\target\robocode.dll, please compile it
|
echo cat't find \robocode.dotnet.api\target\robocode.dll, please compile it
|
||||||
goto end
|
goto end
|
||||||
|
|
||||||
:gen2
|
:gen2
|
||||||
|
|
||||||
copy "%~dp0\robocode.dotnet.api\target\robocode.dll" "%~dp0\tools\lib"
|
copy "%~dp0\robocode.dotnet.api\target\robocode.dll" "%~dp0\tools\lib"
|
||||||
|
|
||||||
:gen3
|
:gen3
|
||||||
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.net.xml
|
"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.net.xml
|
||||||
|
|
||||||
:end
|
:end
|
|
@ -1,20 +1,20 @@
|
||||||
@REM
|
@REM
|
||||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
@REM All rights reserved. This program and the accompanying materials
|
@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 are made available under the terms of the Eclipse Public License v1.0
|
||||||
@REM which accompanies this distribution, and is available at
|
@REM which accompanies this distribution, and is available at
|
||||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
if not exist "%~dp0\tools\lib" (
|
if not exist "%~dp0\tools\lib" (
|
||||||
mkdir "%~dp0\tools\lib"
|
mkdir "%~dp0\tools\lib"
|
||||||
call "%~dp0\tools\loadTools.cmd"
|
call "%~dp0\tools\loadTools.cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not exist "%~dp0\..\..\tools\lib\maven-*-uber.jar" (
|
if not exist "%~dp0\..\..\tools\lib\maven-*-uber.jar" (
|
||||||
call "%~dp0\..\..\tools\loadTools.cmd"
|
call "%~dp0\..\..\tools\loadTools.cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
call "%~dp0\..\..\mvn" %*
|
call "%~dp0\..\..\mvn" %*
|
|
@ -1,12 +1,12 @@
|
||||||
@REM
|
@REM
|
||||||
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
@REM All rights reserved. This program and the accompanying materials
|
@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 are made available under the terms of the Eclipse Public License v1.0
|
||||||
@REM which accompanies this distribution, and is available at
|
@REM which accompanies this distribution, and is available at
|
||||||
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
@REM http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
mvn clean install ant:ant -DskipTests=false %*
|
mvn clean install ant:ant -DskipTests=false %*
|
||||||
rem mvn eclipse:eclipse
|
rem mvn eclipse:eclipse
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>robocode.dotnet.api</name>
|
<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>
|
<comment>.NET Robot API for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||||
<projects/>
|
<projects/>
|
||||||
<buildSpec/>
|
<buildSpec/>
|
||||||
<natures/>
|
<natures/>
|
||||||
</projectDescription>
|
</projectDescription>
|
|
@ -1,10 +1,10 @@
|
||||||
#Tue Nov 27 22:34:10 CET 2012
|
#Tue Nov 27 22:34:10 CET 2012
|
||||||
encoding/src/test/java=8859_1
|
encoding/src/test/java=8859_1
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
encoding/src/main/resources=8859_1
|
encoding/src/main/resources=8859_1
|
||||||
encoding/src/main/java=8859_1
|
encoding/src/main/java=8859_1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
encoding/src/test/resources=8859_1
|
encoding/src/test/resources=8859_1
|
||||||
encoding/src=8859_1
|
encoding/src=8859_1
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
org.eclipse.jdt.core.compiler.source=1.6
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- The configuration and platform will be used to determine which
|
<!-- The configuration and platform will be used to determine which
|
||||||
assemblies to include from solution and project documentation
|
assemblies to include from solution and project documentation
|
||||||
sources -->
|
sources -->
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{90f0d09b-f58d-4f2e-ac8a-164d89979ef1}</ProjectGuid>
|
<ProjectGuid>{90f0d09b-f58d-4f2e-ac8a-164d89979ef1}</ProjectGuid>
|
||||||
<SHFBSchemaVersion>1.9.5.0</SHFBSchemaVersion>
|
<SHFBSchemaVersion>1.9.5.0</SHFBSchemaVersion>
|
||||||
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
|
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
|
||||||
Studio adds them anyway -->
|
Studio adds them anyway -->
|
||||||
<AssemblyName>Documentation</AssemblyName>
|
<AssemblyName>Documentation</AssemblyName>
|
||||||
<RootNamespace>Documentation</RootNamespace>
|
<RootNamespace>Documentation</RootNamespace>
|
||||||
<Name>Documentation</Name>
|
<Name>Documentation</Name>
|
||||||
<!-- SHFB properties -->
|
<!-- SHFB properties -->
|
||||||
<OutputPath>.\target\Help\</OutputPath>
|
<OutputPath>.\target\Help\</OutputPath>
|
||||||
<HtmlHelpName>RobotAPI</HtmlHelpName>
|
<HtmlHelpName>RobotAPI</HtmlHelpName>
|
||||||
<DocumentationSources>
|
<DocumentationSources>
|
||||||
<DocumentationSource sourceFile="target\robocode.dll" xmlns="" />
|
<DocumentationSource sourceFile="target\robocode.dll" xmlns="" />
|
||||||
<DocumentationSource sourceFile="target\robocode.xml" xmlns="" />
|
<DocumentationSource sourceFile="target\robocode.xml" xmlns="" />
|
||||||
</DocumentationSources>
|
</DocumentationSources>
|
||||||
<MissingTags>AutoDocumentCtors, AutoDocumentDispose</MissingTags>
|
<MissingTags>AutoDocumentCtors, AutoDocumentDispose</MissingTags>
|
||||||
<HelpTitle>Robocode Robot API for .NET</HelpTitle>
|
<HelpTitle>Robocode Robot API for .NET</HelpTitle>
|
||||||
<FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
|
<FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
|
||||||
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
|
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
|
||||||
<ApiFilter>
|
<ApiFilter>
|
||||||
<Filter entryType="Namespace" fullName="net.sf.robocode.io" isExposed="False" />
|
<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.nio" isExposed="False" />
|
||||||
<Filter entryType="Namespace" fullName="net.sf.robocode.peer" 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.security" isExposed="False" />
|
||||||
<Filter entryType="Namespace" fullName="net.sf.robocode.serialization" isExposed="False" />
|
<Filter entryType="Namespace" fullName="net.sf.robocode.serialization" isExposed="False" />
|
||||||
<Filter entryType="Namespace" fullName="robocode" isExposed="True">
|
<Filter entryType="Namespace" fullName="robocode" isExposed="True">
|
||||||
<Filter entryType="Class" fullName="robocode.Keys" filterName="Keys" isExposed="False" />
|
<Filter entryType="Class" fullName="robocode.Keys" filterName="Keys" isExposed="False" />
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter entryType="Namespace" fullName="robocode.exception" isExposed="True">
|
<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.EventInterruptedException" filterName="EventInterruptedException" isExposed="False" />
|
||||||
<Filter entryType="Class" fullName="robocode.exception.RobotException" filterName="RobotException" isExposed="False" />
|
<Filter entryType="Class" fullName="robocode.exception.RobotException" filterName="RobotException" isExposed="False" />
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter entryType="Namespace" fullName="System" isExposed="True">
|
<Filter entryType="Namespace" fullName="System" isExposed="True">
|
||||||
<Filter entryType="Class" fullName="System.Attribute" filterName="Attribute" isExposed="False" />
|
<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.Exception" filterName="Exception" isExposed="False" />
|
||||||
<Filter entryType="Class" fullName="System.Object" filterName="Object" isExposed="False" />
|
<Filter entryType="Class" fullName="System.Object" filterName="Object" isExposed="False" />
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter entryType="Namespace" fullName="System.Security" isExposed="True">
|
<Filter entryType="Namespace" fullName="System.Security" isExposed="True">
|
||||||
<Filter entryType="Class" fullName="System.Security.CodeAccessPermission" filterName="CodeAccessPermission" isExposed="False" />
|
<Filter entryType="Class" fullName="System.Security.CodeAccessPermission" filterName="CodeAccessPermission" isExposed="False" />
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter entryType="Namespace" fullName="System.Security.Permissions" isExposed="True">
|
<Filter entryType="Namespace" fullName="System.Security.Permissions" isExposed="True">
|
||||||
<Filter entryType="Class" fullName="System.Security.Permissions.SecurityAttribute" filterName="SecurityAttribute" isExposed="False" />
|
<Filter entryType="Class" fullName="System.Security.Permissions.SecurityAttribute" filterName="SecurityAttribute" isExposed="False" />
|
||||||
</Filter>
|
</Filter>
|
||||||
</ApiFilter>
|
</ApiFilter>
|
||||||
<VisibleItems>InheritedMembers, Protected, SealedProtected</VisibleItems>
|
<VisibleItems>InheritedMembers, Protected, SealedProtected</VisibleItems>
|
||||||
<NamespaceSummaries>
|
<NamespaceSummaries>
|
||||||
<NamespaceSummaryItem name="robocode" isDocumented="True" xmlns="">Robot API used for writing robots for Robocode</NamespaceSummaryItem>
|
<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" 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.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>
|
<NamespaceSummaryItem name="robocode.util" isDocumented="True" xmlns="">Utility classes that can be used when writing robots. Kept for compatibility with legacy robots.</NamespaceSummaryItem>
|
||||||
</NamespaceSummaries>
|
</NamespaceSummaries>
|
||||||
<ProjectSummary>Robocode Robot API for .NET</ProjectSummary>
|
<ProjectSummary>Robocode Robot API for .NET</ProjectSummary>
|
||||||
<CopyrightText>Copyright %28c%29 2001-2016 Mathew A. Nelson and Robocode contributors</CopyrightText>
|
<CopyrightText>Copyright %28c%29 2001-2016 Mathew A. Nelson and Robocode contributors</CopyrightText>
|
||||||
<FeedbackEMailAddress>fnl%40users.sourceforge.net</FeedbackEMailAddress>
|
<FeedbackEMailAddress>fnl%40users.sourceforge.net</FeedbackEMailAddress>
|
||||||
<FeedbackEMailLinkText>administator and maintainer of Robocode</FeedbackEMailLinkText>
|
<FeedbackEMailLinkText>administator and maintainer of Robocode</FeedbackEMailLinkText>
|
||||||
<PresentationStyle>vs2010</PresentationStyle>
|
<PresentationStyle>vs2010</PresentationStyle>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- There are no properties for these groups. AnyCPU needs to appear in
|
<!-- There are no properties for these groups. AnyCPU needs to appear in
|
||||||
order for Visual Studio to perform the build. The others are optional
|
order for Visual Studio to perform the build. The others are optional
|
||||||
common platform types that may appear. -->
|
common platform types that may appear. -->
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- Import the SHFB build targets -->
|
<!-- Import the SHFB build targets -->
|
||||||
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
|
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -1,3 +1,3 @@
|
||||||
/obj
|
/obj
|
||||||
/robocode.dotnet.api.sln
|
/robocode.dotnet.api.sln
|
||||||
/robocode.dotnet.api.suo
|
/robocode.dotnet.api.suo
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System.Security;
|
using System.Security;
|
||||||
|
|
||||||
[assembly: AllowPartiallyTrustedCallers]
|
[assembly: AllowPartiallyTrustedCallers]
|
|
@ -1,132 +1,132 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using net.sf.robocode.security;
|
using net.sf.robocode.security;
|
||||||
|
|
||||||
namespace net.sf.robocode.io
|
namespace net.sf.robocode.io
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
///<summary>
|
///<summary>
|
||||||
/// This is a class used for logging.
|
/// This is a class used for logging.
|
||||||
///</summary>
|
///</summary>
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
||||||
public class LoggerN
|
public class LoggerN
|
||||||
{
|
{
|
||||||
public static TextWriter realOut = Console.Out;
|
public static TextWriter realOut = Console.Out;
|
||||||
public static TextWriter realErr = Console.Error;
|
public static TextWriter realErr = Console.Error;
|
||||||
public static TextWriter robotOut = Console.Out;
|
public static TextWriter robotOut = Console.Out;
|
||||||
|
|
||||||
private static ILoggerN logListener;
|
private static ILoggerN logListener;
|
||||||
private static readonly StringBuilder logBuffer = new StringBuilder();
|
private static readonly StringBuilder logBuffer = new StringBuilder();
|
||||||
[ThreadStatic] public static bool IsSafeThread;
|
[ThreadStatic] public static bool IsSafeThread;
|
||||||
|
|
||||||
public static void setLogListener(ILoggerN logListener)
|
public static void setLogListener(ILoggerN logListener)
|
||||||
{
|
{
|
||||||
LoggerN.logListener = logListener;
|
LoggerN.logListener = logListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logMessage(string s)
|
public static void logMessage(string s)
|
||||||
{
|
{
|
||||||
logMessage(s, true);
|
logMessage(s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logMessage(Exception e)
|
public static void logMessage(Exception e)
|
||||||
{
|
{
|
||||||
logMessage(e.StackTrace);
|
logMessage(e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logMessage(string message, Exception t)
|
public static void logMessage(string message, Exception t)
|
||||||
{
|
{
|
||||||
logMessage(message + ":\n" + t.StackTrace);
|
logMessage(message + ":\n" + t.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logError(string message, Exception t)
|
public static void logError(string message, Exception t)
|
||||||
{
|
{
|
||||||
logError(message + ":\n" + t.StackTrace);
|
logError(message + ":\n" + t.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logError(Exception t)
|
public static void logError(Exception t)
|
||||||
{
|
{
|
||||||
logError(t.StackTrace);
|
logError(t.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logMessage(string s, bool newline)
|
public static void logMessage(string s, bool newline)
|
||||||
{
|
{
|
||||||
if (logListener == null)
|
if (logListener == null)
|
||||||
{
|
{
|
||||||
if (newline)
|
if (newline)
|
||||||
{
|
{
|
||||||
realOut.WriteLine(s);
|
realOut.WriteLine(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
realOut.Write(s);
|
realOut.Write(s);
|
||||||
realOut.Flush();
|
realOut.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lock (logBuffer)
|
lock (logBuffer)
|
||||||
{
|
{
|
||||||
if (!IsSafeThread)
|
if (!IsSafeThread)
|
||||||
{
|
{
|
||||||
// we just queue it, to not let unsafe thread travel thru system
|
// we just queue it, to not let unsafe thread travel thru system
|
||||||
logBuffer.Append(s);
|
logBuffer.Append(s);
|
||||||
logBuffer.Append("\n");
|
logBuffer.Append("\n");
|
||||||
}
|
}
|
||||||
else if (newline)
|
else if (newline)
|
||||||
{
|
{
|
||||||
logMessage(logBuffer + s, true);
|
logMessage(logBuffer + s, true);
|
||||||
logBuffer.Length = 0;
|
logBuffer.Length = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logBuffer.Append(s);
|
logBuffer.Append(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logError(string s)
|
public static void logError(string s)
|
||||||
{
|
{
|
||||||
if (logListener == null)
|
if (logListener == null)
|
||||||
{
|
{
|
||||||
realErr.WriteLine(s);
|
realErr.WriteLine(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logListener.logError(s);
|
logListener.logError(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteLineToRobotsConsole(string s)
|
public static void WriteLineToRobotsConsole(string s)
|
||||||
{
|
{
|
||||||
if (robotOut != null)
|
if (robotOut != null)
|
||||||
{
|
{
|
||||||
robotOut.WriteLine(s);
|
robotOut.WriteLine(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logMessage(s);
|
logMessage(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface ILoggerN
|
public interface ILoggerN
|
||||||
{
|
{
|
||||||
void logMessage(string s, bool newline);
|
void logMessage(string s, bool newline);
|
||||||
void logError(string s);
|
void logError(string s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//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
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* 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
|
// 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.
|
// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
namespace net.sf.robocode.nio
|
namespace net.sf.robocode.nio
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A read/write HeapByteBuffer.
|
/// A read/write HeapByteBuffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
internal class HeapByteBuffer : ByteBuffer
|
internal class HeapByteBuffer : ByteBuffer
|
||||||
{
|
{
|
||||||
internal HeapByteBuffer(int cap, int lim)
|
internal HeapByteBuffer(int cap, int lim)
|
||||||
: base(-1, 0, lim, cap, new byte[cap], 0)
|
: base(-1, 0, lim, cap, new byte[cap], 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal HeapByteBuffer(byte[] buf, int off, int len)
|
internal HeapByteBuffer(byte[] buf, int off, int len)
|
||||||
: base(-1, off, off + len, buf.Length, buf, 0)
|
: base(-1, off, off + len, buf.Length, buf, 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HeapByteBuffer(byte[] buf,
|
protected HeapByteBuffer(byte[] buf,
|
||||||
int mark, int pos, int lim, int cap,
|
int mark, int pos, int lim, int cap,
|
||||||
int off)
|
int off)
|
||||||
: base(mark, pos, lim, cap, buf, off)
|
: base(mark, pos, lim, cap, buf, off)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer slice()
|
public override ByteBuffer slice()
|
||||||
{
|
{
|
||||||
return new HeapByteBuffer(hb,
|
return new HeapByteBuffer(hb,
|
||||||
-1,
|
-1,
|
||||||
0,
|
0,
|
||||||
remaining(),
|
remaining(),
|
||||||
remaining(),
|
remaining(),
|
||||||
position() + _offset);
|
position() + _offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer duplicate()
|
public override ByteBuffer duplicate()
|
||||||
{
|
{
|
||||||
return new HeapByteBuffer(hb,
|
return new HeapByteBuffer(hb,
|
||||||
markValue(),
|
markValue(),
|
||||||
position(),
|
position(),
|
||||||
limit(),
|
limit(),
|
||||||
capacity(),
|
capacity(),
|
||||||
_offset);
|
_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer asReadOnlyBuffer()
|
public override ByteBuffer asReadOnlyBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected int ix(int i)
|
protected int ix(int i)
|
||||||
{
|
{
|
||||||
return i + _offset;
|
return i + _offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte get()
|
public override byte get()
|
||||||
{
|
{
|
||||||
return hb[ix(nextGetIndex())];
|
return hb[ix(nextGetIndex())];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte get(int i)
|
public override byte get(int i)
|
||||||
{
|
{
|
||||||
return hb[ix(checkIndex(i))];
|
return hb[ix(checkIndex(i))];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer get(byte[] dst, int offset, int length)
|
public override ByteBuffer get(byte[] dst, int offset, int length)
|
||||||
{
|
{
|
||||||
checkBounds(offset, length, dst.Length);
|
checkBounds(offset, length, dst.Length);
|
||||||
if (length > remaining())
|
if (length > remaining())
|
||||||
throw new BufferUnderflowException();
|
throw new BufferUnderflowException();
|
||||||
Array.Copy(hb, ix(position()), dst, offset, length);
|
Array.Copy(hb, ix(position()), dst, offset, length);
|
||||||
position(position() + length);
|
position(position() + length);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool isDirect()
|
public override bool isDirect()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool isReadOnly()
|
public override bool isReadOnly()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer put(byte x)
|
public override ByteBuffer put(byte x)
|
||||||
{
|
{
|
||||||
hb[ix(nextPutIndex())] = x;
|
hb[ix(nextPutIndex())] = x;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer put(int i, byte x)
|
public override ByteBuffer put(int i, byte x)
|
||||||
{
|
{
|
||||||
hb[ix(checkIndex(i))] = x;
|
hb[ix(checkIndex(i))] = x;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer put(byte[] src, int offset, int length)
|
public override ByteBuffer put(byte[] src, int offset, int length)
|
||||||
{
|
{
|
||||||
checkBounds(offset, length, src.Length);
|
checkBounds(offset, length, src.Length);
|
||||||
if (length > remaining())
|
if (length > remaining())
|
||||||
throw new BufferOverflowException();
|
throw new BufferOverflowException();
|
||||||
Array.Copy(src, offset, hb, ix(position()), length);
|
Array.Copy(src, offset, hb, ix(position()), length);
|
||||||
position(position() + length);
|
position(position() + length);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer put(ByteBuffer src)
|
public override ByteBuffer put(ByteBuffer src)
|
||||||
{
|
{
|
||||||
if (src is HeapByteBuffer)
|
if (src is HeapByteBuffer)
|
||||||
{
|
{
|
||||||
if (src == this)
|
if (src == this)
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
var sb = (HeapByteBuffer) src;
|
var sb = (HeapByteBuffer) src;
|
||||||
int n = sb.remaining();
|
int n = sb.remaining();
|
||||||
if (n > remaining())
|
if (n > remaining())
|
||||||
throw new BufferOverflowException();
|
throw new BufferOverflowException();
|
||||||
Array.Copy(sb.hb, sb.ix(sb.position()),
|
Array.Copy(sb.hb, sb.ix(sb.position()),
|
||||||
hb, ix(position()), n);
|
hb, ix(position()), n);
|
||||||
sb.position(sb.position() + n);
|
sb.position(sb.position() + n);
|
||||||
position(position() + n);
|
position(position() + n);
|
||||||
}
|
}
|
||||||
else if (src.isDirect())
|
else if (src.isDirect())
|
||||||
{
|
{
|
||||||
int n = src.remaining();
|
int n = src.remaining();
|
||||||
if (n > remaining())
|
if (n > remaining())
|
||||||
throw new BufferOverflowException();
|
throw new BufferOverflowException();
|
||||||
src.get(hb, ix(position()), n);
|
src.get(hb, ix(position()), n);
|
||||||
position(position() + n);
|
position(position() + n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base.put(src);
|
base.put(src);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer compact()
|
public override ByteBuffer compact()
|
||||||
{
|
{
|
||||||
Array.Copy(hb, ix(position()), hb, ix(0), remaining());
|
Array.Copy(hb, ix(position()), hb, ix(0), remaining());
|
||||||
position(remaining());
|
position(remaining());
|
||||||
limit(capacity());
|
limit(capacity());
|
||||||
discardMark();
|
discardMark();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal override byte _get(int i)
|
internal override byte _get(int i)
|
||||||
{
|
{
|
||||||
return hb[i];
|
return hb[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void _put(int i, byte b)
|
internal override void _put(int i, byte b)
|
||||||
{
|
{
|
||||||
hb[i] = b;
|
hb[i] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override char getChar()
|
public override char getChar()
|
||||||
{
|
{
|
||||||
return BitConverter.ToChar(hb, ix(nextGetIndex(2)));
|
return BitConverter.ToChar(hb, ix(nextGetIndex(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override char getChar(int i)
|
public override char getChar(int i)
|
||||||
{
|
{
|
||||||
return BitConverter.ToChar(hb, ix(checkIndex(i, 2)));
|
return BitConverter.ToChar(hb, ix(checkIndex(i, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ByteBuffer putChar(char x)
|
public override ByteBuffer putChar(char x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(nextPutIndex(2));
|
int index = ix(nextPutIndex(2));
|
||||||
Array.Copy(bytes, 0, hb, index, 2);
|
Array.Copy(bytes, 0, hb, index, 2);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer putChar(int i, char x)
|
public override ByteBuffer putChar(int i, char x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(checkIndex(i, 2));
|
int index = ix(checkIndex(i, 2));
|
||||||
Array.Copy(bytes, 0, hb, index, 2);
|
Array.Copy(bytes, 0, hb, index, 2);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Buffer asCharBuffer()
|
public override Buffer asCharBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override short getShort()
|
public override short getShort()
|
||||||
{
|
{
|
||||||
return BitConverter.ToInt16(hb, ix(nextGetIndex(2)));
|
return BitConverter.ToInt16(hb, ix(nextGetIndex(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override short getShort(int i)
|
public override short getShort(int i)
|
||||||
{
|
{
|
||||||
return BitConverter.ToInt16(hb, ix(checkIndex(i, 2)));
|
return BitConverter.ToInt16(hb, ix(checkIndex(i, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ByteBuffer putShort(short x)
|
public override ByteBuffer putShort(short x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(nextPutIndex(2));
|
int index = ix(nextPutIndex(2));
|
||||||
Array.Copy(bytes, 0, hb, index, 2);
|
Array.Copy(bytes, 0, hb, index, 2);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer putShort(int i, short x)
|
public override ByteBuffer putShort(int i, short x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(checkIndex(i, 2));
|
int index = ix(checkIndex(i, 2));
|
||||||
Array.Copy(bytes, 0, hb, index, 2);
|
Array.Copy(bytes, 0, hb, index, 2);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Buffer asShortBuffer()
|
public override Buffer asShortBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int getInt()
|
public override int getInt()
|
||||||
{
|
{
|
||||||
return BitConverter.ToInt32(hb, ix(nextGetIndex(4)));
|
return BitConverter.ToInt32(hb, ix(nextGetIndex(4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int getInt(int i)
|
public override int getInt(int i)
|
||||||
{
|
{
|
||||||
return BitConverter.ToInt32(hb, ix(checkIndex(i, 4)));
|
return BitConverter.ToInt32(hb, ix(checkIndex(i, 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ByteBuffer putInt(int x)
|
public override ByteBuffer putInt(int x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(nextPutIndex(4));
|
int index = ix(nextPutIndex(4));
|
||||||
Array.Copy(bytes, 0, hb, index, 4);
|
Array.Copy(bytes, 0, hb, index, 4);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer putInt(int i, int x)
|
public override ByteBuffer putInt(int i, int x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(checkIndex(i, 4));
|
int index = ix(checkIndex(i, 4));
|
||||||
Array.Copy(bytes, 0, hb, index, 4);
|
Array.Copy(bytes, 0, hb, index, 4);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Buffer asIntBuffer()
|
public override Buffer asIntBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// long
|
// long
|
||||||
|
|
||||||
|
|
||||||
public override long getLong()
|
public override long getLong()
|
||||||
{
|
{
|
||||||
return BitConverter.ToInt64(hb, ix(nextGetIndex(8)));
|
return BitConverter.ToInt64(hb, ix(nextGetIndex(8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long getLong(int i)
|
public override long getLong(int i)
|
||||||
{
|
{
|
||||||
return BitConverter.ToInt64(hb, ix(checkIndex(i, 8)));
|
return BitConverter.ToInt64(hb, ix(checkIndex(i, 8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ByteBuffer putLong(long x)
|
public override ByteBuffer putLong(long x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(nextPutIndex(8));
|
int index = ix(nextPutIndex(8));
|
||||||
Array.Copy(bytes, 0, hb, index, 8);
|
Array.Copy(bytes, 0, hb, index, 8);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer putLong(int i, long x)
|
public override ByteBuffer putLong(int i, long x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(checkIndex(i, 8));
|
int index = ix(checkIndex(i, 8));
|
||||||
Array.Copy(bytes, 0, hb, index, 8);
|
Array.Copy(bytes, 0, hb, index, 8);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Buffer asLongBuffer()
|
public override Buffer asLongBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// float
|
// float
|
||||||
|
|
||||||
|
|
||||||
public override float getFloat()
|
public override float getFloat()
|
||||||
{
|
{
|
||||||
return BitConverter.ToSingle(hb, ix(nextGetIndex(4)));
|
return BitConverter.ToSingle(hb, ix(nextGetIndex(4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float getFloat(int i)
|
public override float getFloat(int i)
|
||||||
{
|
{
|
||||||
return BitConverter.ToSingle(hb, ix(checkIndex(i, 4)));
|
return BitConverter.ToSingle(hb, ix(checkIndex(i, 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ByteBuffer putFloat(float x)
|
public override ByteBuffer putFloat(float x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(nextPutIndex(4));
|
int index = ix(nextPutIndex(4));
|
||||||
Array.Copy(bytes, 0, hb, index, 4);
|
Array.Copy(bytes, 0, hb, index, 4);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer putFloat(int i, float x)
|
public override ByteBuffer putFloat(int i, float x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(checkIndex(i, 4));
|
int index = ix(checkIndex(i, 4));
|
||||||
Array.Copy(bytes, 0, hb, index, 4);
|
Array.Copy(bytes, 0, hb, index, 4);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Buffer asFloatBuffer()
|
public override Buffer asFloatBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// double
|
// double
|
||||||
|
|
||||||
|
|
||||||
public override double getDouble()
|
public override double getDouble()
|
||||||
{
|
{
|
||||||
return BitConverter.ToDouble(hb, ix(nextGetIndex(8)));
|
return BitConverter.ToDouble(hb, ix(nextGetIndex(8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override double getDouble(int i)
|
public override double getDouble(int i)
|
||||||
{
|
{
|
||||||
return BitConverter.ToDouble(hb, ix(checkIndex(i, 8)));
|
return BitConverter.ToDouble(hb, ix(checkIndex(i, 8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ByteBuffer putDouble(double x)
|
public override ByteBuffer putDouble(double x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(nextPutIndex(8));
|
int index = ix(nextPutIndex(8));
|
||||||
Array.Copy(bytes, 0, hb, index, 8);
|
Array.Copy(bytes, 0, hb, index, 8);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ByteBuffer putDouble(int i, double x)
|
public override ByteBuffer putDouble(int i, double x)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(x);
|
byte[] bytes = BitConverter.GetBytes(x);
|
||||||
int index = ix(checkIndex(i, 8));
|
int index = ix(checkIndex(i, 8));
|
||||||
Array.Copy(bytes, 0, hb, index, 8);
|
Array.Copy(bytes, 0, hb, index, 8);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Buffer asDoubleBuffer()
|
public override Buffer asDoubleBuffer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,116 +1,116 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace net.sf.robocode.nio
|
namespace net.sf.robocode.nio
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class InvalidMarkException : Exception
|
public class InvalidMarkException : Exception
|
||||||
{
|
{
|
||||||
public InvalidMarkException()
|
public InvalidMarkException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidMarkException(string message)
|
public InvalidMarkException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidMarkException(string message, Exception inner)
|
public InvalidMarkException(string message, Exception inner)
|
||||||
: base(message, inner)
|
: base(message, inner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InvalidMarkException(SerializationInfo info,
|
protected InvalidMarkException(SerializationInfo info,
|
||||||
StreamingContext context)
|
StreamingContext context)
|
||||||
: base(info, context)
|
: base(info, context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BufferUnderflowException : Exception
|
public class BufferUnderflowException : Exception
|
||||||
{
|
{
|
||||||
public BufferUnderflowException()
|
public BufferUnderflowException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferUnderflowException(string message)
|
public BufferUnderflowException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferUnderflowException(string message, Exception inner)
|
public BufferUnderflowException(string message, Exception inner)
|
||||||
: base(message, inner)
|
: base(message, inner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BufferUnderflowException(SerializationInfo info,
|
protected BufferUnderflowException(SerializationInfo info,
|
||||||
StreamingContext context)
|
StreamingContext context)
|
||||||
: base(info, context)
|
: base(info, context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BufferOverflowException : Exception
|
public class BufferOverflowException : Exception
|
||||||
{
|
{
|
||||||
public BufferOverflowException()
|
public BufferOverflowException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferOverflowException(string message)
|
public BufferOverflowException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferOverflowException(string message, Exception inner)
|
public BufferOverflowException(string message, Exception inner)
|
||||||
: base(message, inner)
|
: base(message, inner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BufferOverflowException(SerializationInfo info,
|
protected BufferOverflowException(SerializationInfo info,
|
||||||
StreamingContext context)
|
StreamingContext context)
|
||||||
: base(info, context)
|
: base(info, context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReadOnlyBufferException : Exception
|
public class ReadOnlyBufferException : Exception
|
||||||
{
|
{
|
||||||
public ReadOnlyBufferException()
|
public ReadOnlyBufferException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyBufferException(string message)
|
public ReadOnlyBufferException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyBufferException(string message, Exception inner)
|
public ReadOnlyBufferException(string message, Exception inner)
|
||||||
: base(message, inner)
|
: base(message, inner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReadOnlyBufferException(SerializationInfo info,
|
protected ReadOnlyBufferException(SerializationInfo info,
|
||||||
StreamingContext context)
|
StreamingContext context)
|
||||||
: base(info, context)
|
: base(info, context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace net.sf.robocode.peer
|
namespace net.sf.robocode.peer
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface IRobotStaticsN
|
public interface IRobotStaticsN
|
||||||
{
|
{
|
||||||
bool IsInteractiveRobot();
|
bool IsInteractiveRobot();
|
||||||
|
|
||||||
bool IsPaintRobot();
|
bool IsPaintRobot();
|
||||||
|
|
||||||
bool IsAdvancedRobot();
|
bool IsAdvancedRobot();
|
||||||
|
|
||||||
bool IsTeamRobot();
|
bool IsTeamRobot();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,131 +1,131 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
using net.sf.robocode.io;
|
using net.sf.robocode.io;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using Robocode;
|
using Robocode;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
[RobocodeInternalPermission(SecurityAction.LinkDemand)]
|
||||||
public class HiddenAccessN
|
public class HiddenAccessN
|
||||||
{
|
{
|
||||||
private static IHiddenEventHelper eventHelper;
|
private static IHiddenEventHelper eventHelper;
|
||||||
private static IHiddenBulletHelper bulletHelper;
|
private static IHiddenBulletHelper bulletHelper;
|
||||||
private static IHiddenStatusHelper statusHelper;
|
private static IHiddenStatusHelper statusHelper;
|
||||||
private static IHiddenRulesHelper rulesHelper;
|
private static IHiddenRulesHelper rulesHelper;
|
||||||
private static bool initialized;
|
private static bool initialized;
|
||||||
public static IHiddenRandomHelper randomHelper;
|
public static IHiddenRandomHelper randomHelper;
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
if (initialized)
|
if (initialized)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MethodInfo method;
|
MethodInfo method;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
method = typeof (Event).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
method = typeof (Event).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
eventHelper = (IHiddenEventHelper) method.Invoke(null, null);
|
eventHelper = (IHiddenEventHelper) method.Invoke(null, null);
|
||||||
|
|
||||||
method = typeof (Bullet).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
method = typeof (Bullet).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
bulletHelper = (IHiddenBulletHelper) method.Invoke(null, null);
|
bulletHelper = (IHiddenBulletHelper) method.Invoke(null, null);
|
||||||
|
|
||||||
method = typeof (RobotStatus).GetMethod("createHiddenSerializer",
|
method = typeof (RobotStatus).GetMethod("createHiddenSerializer",
|
||||||
BindingFlags.Static | BindingFlags.NonPublic);
|
BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
statusHelper = (IHiddenStatusHelper) method.Invoke(null, null);
|
statusHelper = (IHiddenStatusHelper) method.Invoke(null, null);
|
||||||
|
|
||||||
method = typeof (BattleRules).GetMethod("createHiddenHelper",
|
method = typeof (BattleRules).GetMethod("createHiddenHelper",
|
||||||
BindingFlags.Static | BindingFlags.NonPublic);
|
BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
rulesHelper = (IHiddenRulesHelper) method.Invoke(null, null);
|
rulesHelper = (IHiddenRulesHelper) method.Invoke(null, null);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LoggerN.logError(e);
|
LoggerN.logError(e);
|
||||||
Environment.Exit(-1);
|
Environment.Exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsCriticalEvent(Event e)
|
public static bool IsCriticalEvent(Event e)
|
||||||
{
|
{
|
||||||
return eventHelper.IsCriticalEvent(e);
|
return eventHelper.IsCriticalEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetEventTime(Event e, long newTime)
|
public static void SetEventTime(Event e, long newTime)
|
||||||
{
|
{
|
||||||
eventHelper.SetTime(e, newTime);
|
eventHelper.SetTime(e, newTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetEventPriority(Event e, int newPriority)
|
public static void SetEventPriority(Event e, int newPriority)
|
||||||
{
|
{
|
||||||
eventHelper.SetPriority(e, newPriority);
|
eventHelper.SetPriority(e, newPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
eventHelper.Dispatch(evnt, robot, statics, graphics);
|
eventHelper.Dispatch(evnt, robot, statics, graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetDefaultPriority(Event e)
|
public static void SetDefaultPriority(Event e)
|
||||||
{
|
{
|
||||||
eventHelper.SetDefaultPriority(e);
|
eventHelper.SetDefaultPriority(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte GetSerializationType(Event e)
|
public static byte GetSerializationType(Event e)
|
||||||
{
|
{
|
||||||
return eventHelper.GetSerializationType(e);
|
return eventHelper.GetSerializationType(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for .NET version
|
// Needed for .NET version
|
||||||
public static void UpdateBullets(Event e, Dictionary<int, Bullet> bullets)
|
public static void UpdateBullets(Event e, Dictionary<int, Bullet> bullets)
|
||||||
{
|
{
|
||||||
eventHelper.UpdateBullets(e, bullets);
|
eventHelper.UpdateBullets(e, bullets);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
||||||
{
|
{
|
||||||
bulletHelper.update(bullet, x, y, victimName, isActive);
|
bulletHelper.update(bullet, x, y, victimName, isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||||
double radarHeading, double velocity, double bodyTurnRemaining,
|
double radarHeading, double velocity, double bodyTurnRemaining,
|
||||||
double radarTurnRemaining, double gunTurnRemaining,
|
double radarTurnRemaining, double gunTurnRemaining,
|
||||||
double distanceRemaining, double gunHeat, int others, int numSentries,
|
double distanceRemaining, double gunHeat, int others, int numSentries,
|
||||||
int roundNum, int numRounds, long time)
|
int roundNum, int numRounds, long time)
|
||||||
{
|
{
|
||||||
return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity,
|
return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity,
|
||||||
bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining,
|
bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining,
|
||||||
gunHeat, others, numSentries, roundNum, numRounds, time);
|
gunHeat, others, numSentries, roundNum, numRounds, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||||
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
||||||
{
|
{
|
||||||
return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetRobotName()
|
public static string GetRobotName()
|
||||||
{
|
{
|
||||||
string name = (string)AppDomain.CurrentDomain.GetData("robotName");
|
string name = (string)AppDomain.CurrentDomain.GetData("robotName");
|
||||||
return name ?? "";
|
return name ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//happy
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface IHiddenBulletHelper
|
public interface IHiddenBulletHelper
|
||||||
{
|
{
|
||||||
void update(Bullet bullet, double x, double y, string victimName, bool isActive);
|
void update(Bullet bullet, double x, double y, string victimName, bool isActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//happy
|
|
@ -1,29 +1,29 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using Robocode;
|
using Robocode;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface IHiddenEventHelper
|
public interface IHiddenEventHelper
|
||||||
{
|
{
|
||||||
void SetDefaultPriority(Event evnt);
|
void SetDefaultPriority(Event evnt);
|
||||||
void SetPriority(Event evnt, int newPriority);
|
void SetPriority(Event evnt, int newPriority);
|
||||||
void SetTime(Event evnt, long newTime);
|
void SetTime(Event evnt, long newTime);
|
||||||
bool IsCriticalEvent(Event evnt);
|
bool IsCriticalEvent(Event evnt);
|
||||||
void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics);
|
void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics);
|
||||||
byte GetSerializationType(Event evnt);
|
byte GetSerializationType(Event evnt);
|
||||||
void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets); // Needed for .NET version
|
void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets); // Needed for .NET version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//happy
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface IHiddenRandomHelper
|
public interface IHiddenRandomHelper
|
||||||
{
|
{
|
||||||
Random GetRandom();
|
Random GetRandom();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,21 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface IHiddenRulesHelper
|
public interface IHiddenRulesHelper
|
||||||
{
|
{
|
||||||
BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||||
bool hideEnemyNames, int borderSentryRobotAttackRange);
|
bool hideEnemyNames, int borderSentryRobotAttackRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//happy
|
|
@ -1,25 +1,25 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface IHiddenStatusHelper
|
public interface IHiddenStatusHelper
|
||||||
{
|
{
|
||||||
RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||||
double radarHeading,
|
double radarHeading,
|
||||||
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
||||||
double gunTurnRemaining,
|
double gunTurnRemaining,
|
||||||
double distanceRemaining, double gunHeat, int others, int numSentries,
|
double distanceRemaining, double gunHeat, int others, int numSentries,
|
||||||
int roundNum, int numRounds, long time);
|
int roundNum, int numRounds, long time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//happy
|
|
@ -1,151 +1,151 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace net.sf.robocode.security
|
namespace net.sf.robocode.security
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class RobocodeInternalPermission : CodeAccessPermission, IUnrestrictedPermission
|
public sealed class RobocodeInternalPermission : CodeAccessPermission, IUnrestrictedPermission
|
||||||
{
|
{
|
||||||
private bool unrestricted;
|
private bool unrestricted;
|
||||||
|
|
||||||
public RobocodeInternalPermission(PermissionState state)
|
public RobocodeInternalPermission(PermissionState state)
|
||||||
{
|
{
|
||||||
unrestricted = state == PermissionState.Unrestricted;
|
unrestricted = state == PermissionState.Unrestricted;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IUnrestrictedPermission Members
|
#region IUnrestrictedPermission Members
|
||||||
|
|
||||||
public bool IsUnrestricted()
|
public bool IsUnrestricted()
|
||||||
{
|
{
|
||||||
return unrestricted;
|
return unrestricted;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override IPermission Copy()
|
public override IPermission Copy()
|
||||||
{
|
{
|
||||||
//Create a new instance of RobocodeInternalPermission with the current
|
//Create a new instance of RobocodeInternalPermission with the current
|
||||||
//value of unrestricted.
|
//value of unrestricted.
|
||||||
var copy = new RobocodeInternalPermission(PermissionState.None);
|
var copy = new RobocodeInternalPermission(PermissionState.None);
|
||||||
|
|
||||||
copy.unrestricted = IsUnrestricted();
|
copy.unrestricted = IsUnrestricted();
|
||||||
//Return the copy.
|
//Return the copy.
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IPermission Intersect(IPermission target)
|
public override IPermission Intersect(IPermission target)
|
||||||
{
|
{
|
||||||
//If nothing was passed, return null.
|
//If nothing was passed, return null.
|
||||||
if (null == target)
|
if (null == target)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Create a new instance of RobocodeInternalPermission from the passed object.
|
//Create a new instance of RobocodeInternalPermission from the passed object.
|
||||||
var PassedPermission = (RobocodeInternalPermission) target;
|
var PassedPermission = (RobocodeInternalPermission) target;
|
||||||
|
|
||||||
//If one class has an unrestricted value of false, then the
|
//If one class has an unrestricted value of false, then the
|
||||||
//intersection will have an unrestricted value of false.
|
//intersection will have an unrestricted value of false.
|
||||||
//Return the passed class with the unrestricted value of false.
|
//Return the passed class with the unrestricted value of false.
|
||||||
if (!PassedPermission.unrestricted)
|
if (!PassedPermission.unrestricted)
|
||||||
{
|
{
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
//Return a copy of the current class if the passed one has
|
//Return a copy of the current class if the passed one has
|
||||||
//an unrestricted value of true.
|
//an unrestricted value of true.
|
||||||
return Copy();
|
return Copy();
|
||||||
}
|
}
|
||||||
//Catch an InvalidCastException.
|
//Catch an InvalidCastException.
|
||||||
//Throw ArgumentException to notify the user.
|
//Throw ArgumentException to notify the user.
|
||||||
catch (InvalidCastException)
|
catch (InvalidCastException)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsSubsetOf(IPermission target)
|
public override bool IsSubsetOf(IPermission target)
|
||||||
{
|
{
|
||||||
//If nothing was passed and unrestricted is false,
|
//If nothing was passed and unrestricted is false,
|
||||||
//then return true.
|
//then return true.
|
||||||
if (null == target)
|
if (null == target)
|
||||||
{
|
{
|
||||||
return !unrestricted;
|
return !unrestricted;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Create a new instance of RobocodeInternalPermission from the passed object.
|
//Create a new instance of RobocodeInternalPermission from the passed object.
|
||||||
var passedpermission = (RobocodeInternalPermission) target;
|
var passedpermission = (RobocodeInternalPermission) target;
|
||||||
|
|
||||||
//If unrestricted has the same value in both objects, then
|
//If unrestricted has the same value in both objects, then
|
||||||
//one is the subset of the other.
|
//one is the subset of the other.
|
||||||
return unrestricted == passedpermission.unrestricted;
|
return unrestricted == passedpermission.unrestricted;
|
||||||
}
|
}
|
||||||
//Catch an InvalidCastException.
|
//Catch an InvalidCastException.
|
||||||
//Throw ArgumentException to notify the user.
|
//Throw ArgumentException to notify the user.
|
||||||
catch (InvalidCastException)
|
catch (InvalidCastException)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
throw new ArgumentException("Argument_WrongType", GetType().FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FromXml(SecurityElement PassedElement)
|
public override void FromXml(SecurityElement PassedElement)
|
||||||
{
|
{
|
||||||
//Get the unrestricted value from the XML and initialize
|
//Get the unrestricted value from the XML and initialize
|
||||||
//the current instance of unrestricted to that value.
|
//the current instance of unrestricted to that value.
|
||||||
string element = PassedElement.Attribute("Unrestricted");
|
string element = PassedElement.Attribute("Unrestricted");
|
||||||
|
|
||||||
if (null != element)
|
if (null != element)
|
||||||
{
|
{
|
||||||
unrestricted = Convert.ToBoolean(element);
|
unrestricted = Convert.ToBoolean(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SecurityElement ToXml()
|
public override SecurityElement ToXml()
|
||||||
{
|
{
|
||||||
//Encode the current permission to XML using the
|
//Encode the current permission to XML using the
|
||||||
//SecurityElement class.
|
//SecurityElement class.
|
||||||
var element = new SecurityElement("IPermission");
|
var element = new SecurityElement("IPermission");
|
||||||
Type type = GetType();
|
Type type = GetType();
|
||||||
var AssemblyName = new StringBuilder(type.Assembly.ToString());
|
var AssemblyName = new StringBuilder(type.Assembly.ToString());
|
||||||
AssemblyName.Replace('\"', '\'');
|
AssemblyName.Replace('\"', '\'');
|
||||||
element.AddAttribute("class", type.FullName + ", " + AssemblyName);
|
element.AddAttribute("class", type.FullName + ", " + AssemblyName);
|
||||||
element.AddAttribute("version", "1");
|
element.AddAttribute("version", "1");
|
||||||
element.AddAttribute("Unrestricted", unrestricted.ToString());
|
element.AddAttribute("Unrestricted", unrestricted.ToString());
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)]
|
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)]
|
||||||
public class RobocodeInternalPermissionAttribute : CodeAccessSecurityAttribute
|
public class RobocodeInternalPermissionAttribute : CodeAccessSecurityAttribute
|
||||||
{
|
{
|
||||||
public RobocodeInternalPermissionAttribute(SecurityAction action)
|
public RobocodeInternalPermissionAttribute(SecurityAction action)
|
||||||
: base(action)
|
: base(action)
|
||||||
{
|
{
|
||||||
Unrestricted = false;
|
Unrestricted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IPermission CreatePermission()
|
public override IPermission CreatePermission()
|
||||||
{
|
{
|
||||||
return Unrestricted
|
return Unrestricted
|
||||||
? new RobocodeInternalPermission(PermissionState.Unrestricted)
|
? new RobocodeInternalPermission(PermissionState.Unrestricted)
|
||||||
: new RobocodeInternalPermission(PermissionState.None);
|
: new RobocodeInternalPermission(PermissionState.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
}
|
}
|
|
@ -1,22 +1,22 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
|
|
||||||
namespace net.sf.robocode.serialization
|
namespace net.sf.robocode.serialization
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public interface ISerializableHelperN
|
public interface ISerializableHelperN
|
||||||
{
|
{
|
||||||
int sizeOf(RbSerializerN serializer, object obj);
|
int sizeOf(RbSerializerN serializer, object obj);
|
||||||
void serialize(RbSerializerN serializer, ByteBuffer buffer, object obj);
|
void serialize(RbSerializerN serializer, ByteBuffer buffer, object obj);
|
||||||
object deserialize(RbSerializerN serializer, ByteBuffer buffer);
|
object deserialize(RbSerializerN serializer, ByteBuffer buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//happy
|
//happy
|
File diff suppressed because it is too large
Load Diff
|
@ -1,164 +1,164 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProductVersion>9.0.30729</ProductVersion>
|
<ProductVersion>9.0.30729</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{7E0900D3-6E8F-48EB-86DB-AA767AA90B84}</ProjectGuid>
|
<ProjectGuid>{7E0900D3-6E8F-48EB-86DB-AA767AA90B84}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>robocode</RootNamespace>
|
<RootNamespace>robocode</RootNamespace>
|
||||||
<AssemblyName>robocode</AssemblyName>
|
<AssemblyName>robocode</AssemblyName>
|
||||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>..\..\tools\keys\robocode.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>..\..\tools\keys\robocode.snk</AssemblyOriginatorKeyFile>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
<OldToolsVersion>3.5</OldToolsVersion>
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
<UpgradeBackupLocation />
|
<UpgradeBackupLocation />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>..\target\</OutputPath>
|
<OutputPath>..\target\</OutputPath>
|
||||||
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<DocumentationFile>..\target\robocode.xml</DocumentationFile>
|
<DocumentationFile>..\target\robocode.xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>..\target\</OutputPath>
|
<OutputPath>..\target\</OutputPath>
|
||||||
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
<IntermediateOutputPath>..\target\obj\</IntermediateOutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\target\build-sources\generated-sources\META-INF\AssemblyInfo.cs">
|
<Compile Include="..\target\build-sources\generated-sources\META-INF\AssemblyInfo.cs">
|
||||||
<Link>AssemblyInfo.cs</Link>
|
<Link>AssemblyInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="AssemblyInf.cs" />
|
<Compile Include="AssemblyInf.cs" />
|
||||||
<Compile Include="net\sf\robocode\io\LoggerN.cs" />
|
<Compile Include="net\sf\robocode\io\LoggerN.cs" />
|
||||||
<Compile Include="net\sf\robocode\peer\IRobotStaticsN.cs" />
|
<Compile Include="net\sf\robocode\peer\IRobotStaticsN.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\HiddenAccessN.cs" />
|
<Compile Include="net\sf\robocode\security\HiddenAccessN.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\IHiddenBulletHelper.cs" />
|
<Compile Include="net\sf\robocode\security\IHiddenBulletHelper.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\IHiddenEventHelper.cs" />
|
<Compile Include="net\sf\robocode\security\IHiddenEventHelper.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\IHiddenRandomHelper.cs" />
|
<Compile Include="net\sf\robocode\security\IHiddenRandomHelper.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\IHiddenRulesHelper.cs" />
|
<Compile Include="net\sf\robocode\security\IHiddenRulesHelper.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\IHiddenStatusHelper.cs" />
|
<Compile Include="net\sf\robocode\security\IHiddenStatusHelper.cs" />
|
||||||
<Compile Include="net\sf\robocode\security\RobocodeInternalPermission.cs" />
|
<Compile Include="net\sf\robocode\security\RobocodeInternalPermission.cs" />
|
||||||
<Compile Include="net\sf\robocode\serialization\ISerializableHelperN.cs" />
|
<Compile Include="net\sf\robocode\serialization\ISerializableHelperN.cs" />
|
||||||
<Compile Include="net\sf\robocode\serialization\RbSerializerN.cs" />
|
<Compile Include="net\sf\robocode\serialization\RbSerializerN.cs" />
|
||||||
<Compile Include="net\sf\robocode\nio\Buffer.cs" />
|
<Compile Include="net\sf\robocode\nio\Buffer.cs" />
|
||||||
<Compile Include="net\sf\robocode\nio\ByteBuffer.cs" />
|
<Compile Include="net\sf\robocode\nio\ByteBuffer.cs" />
|
||||||
<Compile Include="net\sf\robocode\nio\HeapByteBuffer.cs" />
|
<Compile Include="net\sf\robocode\nio\HeapByteBuffer.cs" />
|
||||||
<Compile Include="net\sf\robocode\nio\InvalidMarkException.cs" />
|
<Compile Include="net\sf\robocode\nio\InvalidMarkException.cs" />
|
||||||
<Compile Include="robocode\AdvancedRobot.cs" />
|
<Compile Include="robocode\AdvancedRobot.cs" />
|
||||||
<Compile Include="robocode\BattleEndedEvent.cs" />
|
<Compile Include="robocode\BattleEndedEvent.cs" />
|
||||||
<Compile Include="robocode\BattleResults.cs" />
|
<Compile Include="robocode\BattleResults.cs" />
|
||||||
<Compile Include="robocode\BattleRules.cs" />
|
<Compile Include="robocode\BattleRules.cs" />
|
||||||
<Compile Include="robocode\Bullet.cs" />
|
<Compile Include="robocode\Bullet.cs" />
|
||||||
<Compile Include="robocode\BulletHitBulletEvent.cs" />
|
<Compile Include="robocode\BulletHitBulletEvent.cs" />
|
||||||
<Compile Include="robocode\BulletHitEvent.cs" />
|
<Compile Include="robocode\BulletHitEvent.cs" />
|
||||||
<Compile Include="robocode\BulletMissedEvent.cs" />
|
<Compile Include="robocode\BulletMissedEvent.cs" />
|
||||||
<Compile Include="robocode\Condition.cs" />
|
<Compile Include="robocode\Condition.cs" />
|
||||||
<Compile Include="robocode\IBorderSentry.cs" />
|
<Compile Include="robocode\IBorderSentry.cs" />
|
||||||
<Compile Include="robocode\CustomEvent.cs" />
|
<Compile Include="robocode\CustomEvent.cs" />
|
||||||
<Compile Include="robocode\DeathEvent.cs" />
|
<Compile Include="robocode\DeathEvent.cs" />
|
||||||
<Compile Include="robocode\IDroid.cs" />
|
<Compile Include="robocode\IDroid.cs" />
|
||||||
<Compile Include="robocode\Event.cs" />
|
<Compile Include="robocode\Event.cs" />
|
||||||
<Compile Include="robocode\exception\EventInterruptedException.cs">
|
<Compile Include="robocode\exception\EventInterruptedException.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="robocode\exception\RobotException.cs">
|
<Compile Include="robocode\exception\RobotException.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="robocode\IGraphics.cs" />
|
<Compile Include="robocode\IGraphics.cs" />
|
||||||
<Compile Include="robocode\GunTurnCompleteCondition.cs" />
|
<Compile Include="robocode\GunTurnCompleteCondition.cs" />
|
||||||
<Compile Include="robocode\HitByBulletEvent.cs" />
|
<Compile Include="robocode\HitByBulletEvent.cs" />
|
||||||
<Compile Include="robocode\HitRobotEvent.cs" />
|
<Compile Include="robocode\HitRobotEvent.cs" />
|
||||||
<Compile Include="robocode\HitWallEvent.cs" />
|
<Compile Include="robocode\HitWallEvent.cs" />
|
||||||
<Compile Include="robocode\JuniorRobot.cs" />
|
<Compile Include="robocode\JuniorRobot.cs" />
|
||||||
<Compile Include="robocode\KeyEvent.cs" />
|
<Compile Include="robocode\KeyEvent.cs" />
|
||||||
<Compile Include="robocode\KeyPressedEvent.cs" />
|
<Compile Include="robocode\KeyPressedEvent.cs" />
|
||||||
<Compile Include="robocode\KeyReleasedEvent.cs" />
|
<Compile Include="robocode\KeyReleasedEvent.cs" />
|
||||||
<Compile Include="robocode\Keys.cs" />
|
<Compile Include="robocode\Keys.cs" />
|
||||||
<Compile Include="robocode\KeyTypedEvent.cs" />
|
<Compile Include="robocode\KeyTypedEvent.cs" />
|
||||||
<Compile Include="robocode\MessageEvent.cs" />
|
<Compile Include="robocode\MessageEvent.cs" />
|
||||||
<Compile Include="robocode\MouseClickedEvent.cs" />
|
<Compile Include="robocode\MouseClickedEvent.cs" />
|
||||||
<Compile Include="robocode\MouseDraggedEvent.cs" />
|
<Compile Include="robocode\MouseDraggedEvent.cs" />
|
||||||
<Compile Include="robocode\MouseEnteredEvent.cs" />
|
<Compile Include="robocode\MouseEnteredEvent.cs" />
|
||||||
<Compile Include="robocode\MouseEvent.cs" />
|
<Compile Include="robocode\MouseEvent.cs" />
|
||||||
<Compile Include="robocode\MouseExitedEvent.cs" />
|
<Compile Include="robocode\MouseExitedEvent.cs" />
|
||||||
<Compile Include="robocode\MouseMovedEvent.cs" />
|
<Compile Include="robocode\MouseMovedEvent.cs" />
|
||||||
<Compile Include="robocode\MousePressedEvent.cs" />
|
<Compile Include="robocode\MousePressedEvent.cs" />
|
||||||
<Compile Include="robocode\MouseReleasedEvent.cs" />
|
<Compile Include="robocode\MouseReleasedEvent.cs" />
|
||||||
<Compile Include="robocode\MouseWheelMovedEvent.cs" />
|
<Compile Include="robocode\MouseWheelMovedEvent.cs" />
|
||||||
<Compile Include="robocode\MoveCompleteCondition.cs" />
|
<Compile Include="robocode\MoveCompleteCondition.cs" />
|
||||||
<Compile Include="robocode\PaintEvent.cs" />
|
<Compile Include="robocode\PaintEvent.cs" />
|
||||||
<Compile Include="robocode\RadarTurnCompleteCondition.cs" />
|
<Compile Include="robocode\RadarTurnCompleteCondition.cs" />
|
||||||
<Compile Include="robocode\RateControlRobot.cs" />
|
<Compile Include="robocode\RateControlRobot.cs" />
|
||||||
<Compile Include="robocode\Robot.cs" />
|
<Compile Include="robocode\Robot.cs" />
|
||||||
<Compile Include="robocode\RobotDeathEvent.cs" />
|
<Compile Include="robocode\RobotDeathEvent.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IAdvancedEvents.cs" />
|
<Compile Include="robocode\robotinterfaces\IAdvancedEvents.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IAdvancedRobot.cs" />
|
<Compile Include="robocode\robotinterfaces\IAdvancedRobot.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IBasicEvents.cs" />
|
<Compile Include="robocode\robotinterfaces\IBasicEvents.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IBasicEvents2.cs" />
|
<Compile Include="robocode\robotinterfaces\IBasicEvents2.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IBasicEvents3.cs" />
|
<Compile Include="robocode\robotinterfaces\IBasicEvents3.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IBasicRobot.cs" />
|
<Compile Include="robocode\robotinterfaces\IBasicRobot.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IInteractiveEvents.cs" />
|
<Compile Include="robocode\robotinterfaces\IInteractiveEvents.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IInteractiveRobot.cs" />
|
<Compile Include="robocode\robotinterfaces\IInteractiveRobot.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IJuniorRobot.cs" />
|
<Compile Include="robocode\robotinterfaces\IJuniorRobot.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IPaintEvents.cs" />
|
<Compile Include="robocode\robotinterfaces\IPaintEvents.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IPaintRobot.cs" />
|
<Compile Include="robocode\robotinterfaces\IPaintRobot.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\ITeamEvents.cs" />
|
<Compile Include="robocode\robotinterfaces\ITeamEvents.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\ITeamRobot.cs" />
|
<Compile Include="robocode\robotinterfaces\ITeamRobot.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\peer\IAdvancedRobotPeer.cs" />
|
<Compile Include="robocode\robotinterfaces\peer\IAdvancedRobotPeer.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\peer\IBasicRobotPeer.cs" />
|
<Compile Include="robocode\robotinterfaces\peer\IBasicRobotPeer.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\peer\IJuniorRobotPeer.cs" />
|
<Compile Include="robocode\robotinterfaces\peer\IJuniorRobotPeer.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\peer\IStandardRobotPeer.cs" />
|
<Compile Include="robocode\robotinterfaces\peer\IStandardRobotPeer.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\peer\ITeamRobotPeer.cs" />
|
<Compile Include="robocode\robotinterfaces\peer\ITeamRobotPeer.cs" />
|
||||||
<Compile Include="robocode\robotinterfaces\IRunnable.cs" />
|
<Compile Include="robocode\robotinterfaces\IRunnable.cs" />
|
||||||
<Compile Include="robocode\RobotStatus.cs" />
|
<Compile Include="robocode\RobotStatus.cs" />
|
||||||
<Compile Include="robocode\RoundEndedEvent.cs" />
|
<Compile Include="robocode\RoundEndedEvent.cs" />
|
||||||
<Compile Include="robocode\Rules.cs" />
|
<Compile Include="robocode\Rules.cs" />
|
||||||
<Compile Include="robocode\Thread.cs" />
|
<Compile Include="robocode\Thread.cs" />
|
||||||
<Compile Include="robocode\ScannedRobotEvent.cs" />
|
<Compile Include="robocode\ScannedRobotEvent.cs" />
|
||||||
<Compile Include="robocode\SkippedTurnEvent.cs" />
|
<Compile Include="robocode\SkippedTurnEvent.cs" />
|
||||||
<Compile Include="robocode\StatusEvent.cs" />
|
<Compile Include="robocode\StatusEvent.cs" />
|
||||||
<Compile Include="robocode\TeamRobot.cs" />
|
<Compile Include="robocode\TeamRobot.cs" />
|
||||||
<Compile Include="robocode\TurnCompleteCondition.cs" />
|
<Compile Include="robocode\TurnCompleteCondition.cs" />
|
||||||
<Compile Include="robocode\util\Utils.cs" />
|
<Compile Include="robocode\util\Utils.cs" />
|
||||||
<Compile Include="robocode\WinEvent.cs" />
|
<Compile Include="robocode\WinEvent.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
</Target>
|
</Target>
|
||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target"</PostBuildEvent>
|
<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\
|
<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
|
echo [assembly: System.Reflection.AssemblyVersion("1.9.2.4")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</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
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// A BattleEndedEvent is sent to <see cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
/// A BattleEndedEvent is sent to <see cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||||
/// when the battle is ended.
|
/// when the battle is ended.
|
||||||
/// You can use the information contained in this event to determine if the
|
/// You can use the information contained in this event to determine if the
|
||||||
/// battle was aborted and also get the results of the battle.
|
/// battle was aborted and also get the results of the battle.
|
||||||
/// <seealso cref="BattleResults"/>
|
/// <seealso cref="BattleResults"/>
|
||||||
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class BattleEndedEvent : Event
|
public sealed class BattleEndedEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
||||||
|
|
||||||
private readonly bool aborted;
|
private readonly bool aborted;
|
||||||
private readonly BattleResults results;
|
private readonly BattleResults results;
|
||||||
|
|
||||||
///
|
///
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Called by the game to create a new BattleEndedEvent.
|
/// Called by the game to create a new BattleEndedEvent.
|
||||||
///</summary>
|
///</summary>
|
||||||
public BattleEndedEvent(bool aborted, BattleResults results)
|
public BattleEndedEvent(bool aborted, BattleResults results)
|
||||||
{
|
{
|
||||||
this.aborted = aborted;
|
this.aborted = aborted;
|
||||||
this.results = results;
|
this.results = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Checks if this battle was aborted.
|
/// Checks if this battle was aborted.
|
||||||
/// Returns true if the battle was aborted
|
/// Returns true if the battle was aborted
|
||||||
///</summary>
|
///</summary>
|
||||||
public bool IsAborted
|
public bool IsAborted
|
||||||
{
|
{
|
||||||
get { return aborted; }
|
get { return aborted; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the battle results.
|
/// Returns the battle results.
|
||||||
///</summary>
|
///</summary>
|
||||||
public BattleResults Results
|
public BattleResults Results
|
||||||
{
|
{
|
||||||
get { return results; }
|
get { return results; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int Priority
|
public override int Priority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (robot != null)
|
if (robot != null)
|
||||||
{
|
{
|
||||||
var listener = robot.GetBasicEventListener() as IBasicEvents2;
|
var listener = robot.GetBasicEventListener() as IBasicEvents2;
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnBattleEnded(this);
|
listener.OnBattleEnded(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override bool IsCriticalEvent
|
internal override bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.BattleEndedEvent_TYPE; }
|
get { return RbSerializerN.BattleEndedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BattleEndedEvent) objec;
|
var obj = (BattleEndedEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_BOOL
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_BOOL
|
||||||
+ serializer.sizeOf(RbSerializerN.BattleResults_TYPE, obj.results);
|
+ serializer.sizeOf(RbSerializerN.BattleResults_TYPE, obj.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BattleEndedEvent) objec;
|
var obj = (BattleEndedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.aborted);
|
serializer.serialize(buffer, obj.aborted);
|
||||||
serializer.serialize(buffer, RbSerializerN.BattleResults_TYPE, obj.results);
|
serializer.serialize(buffer, RbSerializerN.BattleResults_TYPE, obj.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
bool aborted = serializer.deserializeBoolean(buffer);
|
bool aborted = serializer.deserializeBoolean(buffer);
|
||||||
var results = (BattleResults) serializer.deserializeAny(buffer);
|
var results = (BattleResults) serializer.deserializeAny(buffer);
|
||||||
|
|
||||||
return new BattleEndedEvent(aborted, results);
|
return new BattleEndedEvent(aborted, results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//docl
|
//docl
|
|
@ -1,225 +1,225 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Contains the battle results returned by <see cref="BattleEndedEvent.Results"/>
|
/// Contains the battle results returned by <see cref="BattleEndedEvent.Results"/>
|
||||||
/// when a battle has ended.
|
/// when a battle has ended.
|
||||||
/// <seealso cref="BattleEndedEvent.Results"/>
|
/// <seealso cref="BattleEndedEvent.Results"/>
|
||||||
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
/// <seealso cref="Robot.OnBattleEnded(BattleEndedEvent)"/>
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BattleResults : IComparable<BattleResults>
|
public class BattleResults : IComparable<BattleResults>
|
||||||
{
|
{
|
||||||
internal string teamLeaderName;
|
internal string teamLeaderName;
|
||||||
internal int rank;
|
internal int rank;
|
||||||
internal double score;
|
internal double score;
|
||||||
internal double survival;
|
internal double survival;
|
||||||
internal double lastSurvivorBonus;
|
internal double lastSurvivorBonus;
|
||||||
internal double bulletDamage;
|
internal double bulletDamage;
|
||||||
internal double bulletDamageBonus;
|
internal double bulletDamageBonus;
|
||||||
internal double ramDamage;
|
internal double ramDamage;
|
||||||
internal double ramDamageBonus;
|
internal double ramDamageBonus;
|
||||||
internal int firsts;
|
internal int firsts;
|
||||||
internal int seconds;
|
internal int seconds;
|
||||||
internal int thirds;
|
internal int thirds;
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Constructs this BattleResults object.
|
/// Constructs this BattleResults object.
|
||||||
///</summary>
|
///</summary>
|
||||||
public BattleResults(
|
public BattleResults(
|
||||||
string teamLeaderName,
|
string teamLeaderName,
|
||||||
int rank,
|
int rank,
|
||||||
double score,
|
double score,
|
||||||
double survival,
|
double survival,
|
||||||
double lastSurvivorBonus,
|
double lastSurvivorBonus,
|
||||||
double bulletDamage,
|
double bulletDamage,
|
||||||
double bulletDamageBonus,
|
double bulletDamageBonus,
|
||||||
double ramDamage,
|
double ramDamage,
|
||||||
double ramDamageBonus,
|
double ramDamageBonus,
|
||||||
int firsts,
|
int firsts,
|
||||||
int seconds,
|
int seconds,
|
||||||
int thirds
|
int thirds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.teamLeaderName = teamLeaderName;
|
this.teamLeaderName = teamLeaderName;
|
||||||
this.rank = rank;
|
this.rank = rank;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.survival = survival;
|
this.survival = survival;
|
||||||
this.lastSurvivorBonus = lastSurvivorBonus;
|
this.lastSurvivorBonus = lastSurvivorBonus;
|
||||||
this.bulletDamage = bulletDamage;
|
this.bulletDamage = bulletDamage;
|
||||||
this.bulletDamageBonus = bulletDamageBonus;
|
this.bulletDamageBonus = bulletDamageBonus;
|
||||||
this.ramDamage = ramDamage;
|
this.ramDamage = ramDamage;
|
||||||
this.ramDamageBonus = ramDamageBonus;
|
this.ramDamageBonus = ramDamageBonus;
|
||||||
this.firsts = firsts;
|
this.firsts = firsts;
|
||||||
this.seconds = seconds;
|
this.seconds = seconds;
|
||||||
this.thirds = thirds;
|
this.thirds = thirds;
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the name of the team leader in the team or the name of the
|
/// 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.
|
/// robot if the robot is not participating in a team.
|
||||||
///</summary>
|
///</summary>
|
||||||
public string TeamLeaderName
|
public string TeamLeaderName
|
||||||
{
|
{
|
||||||
get { return teamLeaderName; }
|
get { return teamLeaderName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the rank of this robot in the battle results.
|
/// Returns the rank of this robot in the battle results.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int Rank
|
public int Rank
|
||||||
{
|
{
|
||||||
get { return rank; }
|
get { return rank; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the total score of this robot in the battle.
|
/// Returns the total score of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int Score
|
public int Score
|
||||||
{
|
{
|
||||||
get { return (int) (score + 0.5); }
|
get { return (int) (score + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the survival score of this robot in the battle.
|
/// Returns the survival score of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int Survival
|
public int Survival
|
||||||
{
|
{
|
||||||
get { return (int) (survival + 0.5); }
|
get { return (int) (survival + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the last survivor score of this robot in the battle.
|
/// Returns the last survivor score of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int LastSurvivorBonus
|
public int LastSurvivorBonus
|
||||||
{
|
{
|
||||||
get { return (int) (lastSurvivorBonus + 0.5); }
|
get { return (int) (lastSurvivorBonus + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the bullet damage score of this robot in the battle.
|
/// Returns the bullet damage score of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int BulletDamage
|
public int BulletDamage
|
||||||
{
|
{
|
||||||
get { return (int) (bulletDamage + 0.5); }
|
get { return (int) (bulletDamage + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the bullet damage bonus of this robot in the battle.
|
/// Returns the bullet damage bonus of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int BulletDamageBonus
|
public int BulletDamageBonus
|
||||||
{
|
{
|
||||||
get { return (int) (bulletDamageBonus + 0.5); }
|
get { return (int) (bulletDamageBonus + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the ram damage score of this robot in the battle.
|
/// Returns the ram damage score of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int RamDamage
|
public int RamDamage
|
||||||
{
|
{
|
||||||
get { return (int) (ramDamage + 0.5); }
|
get { return (int) (ramDamage + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the ram damage bonus of this robot in the battle.
|
/// Returns the ram damage bonus of this robot in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int RamDamageBonus
|
public int RamDamageBonus
|
||||||
{
|
{
|
||||||
get { return (int) (ramDamageBonus + 0.5); }
|
get { return (int) (ramDamageBonus + 0.5); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the number of rounds this robot placed first in the battle.
|
/// Returns the number of rounds this robot placed first in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int Firsts
|
public int Firsts
|
||||||
{
|
{
|
||||||
get { return firsts; }
|
get { return firsts; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the number of rounds this robot placed second in the battle.
|
/// Returns the number of rounds this robot placed second in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int Seconds
|
public int Seconds
|
||||||
{
|
{
|
||||||
get { return seconds; }
|
get { return seconds; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the number of rounds this robot placed third in the battle.
|
/// Returns the number of rounds this robot placed third in the battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int Thirds
|
public int Thirds
|
||||||
{
|
{
|
||||||
get { return thirds; }
|
get { return thirds; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CompareTo(BattleResults o)
|
public int CompareTo(BattleResults o)
|
||||||
{
|
{
|
||||||
return score.CompareTo(o.score);
|
return score.CompareTo(o.score);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BattleResults) objec;
|
var obj = (BattleResults) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.teamLeaderName) +
|
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.teamLeaderName) +
|
||||||
4*RbSerializerN.SIZEOF_INT
|
4*RbSerializerN.SIZEOF_INT
|
||||||
+ 7*RbSerializerN.SIZEOF_DOUBLE;
|
+ 7*RbSerializerN.SIZEOF_DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BattleResults) objec;
|
var obj = (BattleResults) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.teamLeaderName);
|
serializer.serialize(buffer, obj.teamLeaderName);
|
||||||
serializer.serialize(buffer, obj.rank);
|
serializer.serialize(buffer, obj.rank);
|
||||||
serializer.serialize(buffer, obj.score);
|
serializer.serialize(buffer, obj.score);
|
||||||
serializer.serialize(buffer, obj.survival);
|
serializer.serialize(buffer, obj.survival);
|
||||||
serializer.serialize(buffer, obj.lastSurvivorBonus);
|
serializer.serialize(buffer, obj.lastSurvivorBonus);
|
||||||
serializer.serialize(buffer, obj.bulletDamage);
|
serializer.serialize(buffer, obj.bulletDamage);
|
||||||
serializer.serialize(buffer, obj.bulletDamageBonus);
|
serializer.serialize(buffer, obj.bulletDamageBonus);
|
||||||
serializer.serialize(buffer, obj.ramDamage);
|
serializer.serialize(buffer, obj.ramDamage);
|
||||||
serializer.serialize(buffer, obj.ramDamageBonus);
|
serializer.serialize(buffer, obj.ramDamageBonus);
|
||||||
serializer.serialize(buffer, obj.firsts);
|
serializer.serialize(buffer, obj.firsts);
|
||||||
serializer.serialize(buffer, obj.seconds);
|
serializer.serialize(buffer, obj.seconds);
|
||||||
serializer.serialize(buffer, obj.thirds);
|
serializer.serialize(buffer, obj.thirds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
string teamLeaderName = serializer.deserializeString(buffer);
|
string teamLeaderName = serializer.deserializeString(buffer);
|
||||||
int rank = buffer.getInt();
|
int rank = buffer.getInt();
|
||||||
double score = buffer.getDouble();
|
double score = buffer.getDouble();
|
||||||
double survival = buffer.getDouble();
|
double survival = buffer.getDouble();
|
||||||
double lastSurvivorBonus = buffer.getDouble();
|
double lastSurvivorBonus = buffer.getDouble();
|
||||||
double bulletDamage = buffer.getDouble();
|
double bulletDamage = buffer.getDouble();
|
||||||
double bulletDamageBonus = buffer.getDouble();
|
double bulletDamageBonus = buffer.getDouble();
|
||||||
double ramDamage = buffer.getDouble();
|
double ramDamage = buffer.getDouble();
|
||||||
double ramDamageBonus = buffer.getDouble();
|
double ramDamageBonus = buffer.getDouble();
|
||||||
int firsts = buffer.getInt();
|
int firsts = buffer.getInt();
|
||||||
int seconds = buffer.getInt();
|
int seconds = buffer.getInt();
|
||||||
int thirds = buffer.getInt();
|
int thirds = buffer.getInt();
|
||||||
|
|
||||||
return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage,
|
return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage,
|
||||||
bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds);
|
bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,137 +1,137 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.security;
|
using net.sf.robocode.security;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains the battle rules returned by <see cref="Robocode.Control.Events.BattleStartedEvent.BattleRules">BattleStartedEvent.BattleRules</see>
|
/// 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 started and <see cref="Robocode.Control.Events.BattleCompletedEvent.BattleRules">BattleCompletedEvent.BattleRules</see>
|
||||||
/// when a battle is completed.
|
/// when a battle is completed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="Robocode.Control.Events.BattleStartedEvent">BattleStartedEvent</seealso>
|
/// <seealso cref="Robocode.Control.Events.BattleStartedEvent">BattleStartedEvent</seealso>
|
||||||
/// <seealso cref="Robocode.Control.Events.BattleCompletedEvent">BattleCompletedEvent</seealso>
|
/// <seealso cref="Robocode.Control.Events.BattleCompletedEvent">BattleCompletedEvent</seealso>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class BattleRules
|
public sealed class BattleRules
|
||||||
{
|
{
|
||||||
private readonly int battlefieldWidth;
|
private readonly int battlefieldWidth;
|
||||||
private readonly int battlefieldHeight;
|
private readonly int battlefieldHeight;
|
||||||
private readonly int numRounds;
|
private readonly int numRounds;
|
||||||
private readonly double gunCoolingRate;
|
private readonly double gunCoolingRate;
|
||||||
private readonly long inactivityTime;
|
private readonly long inactivityTime;
|
||||||
private readonly bool hideEnemyNames;
|
private readonly bool hideEnemyNames;
|
||||||
private readonly int sentryBorderSize;
|
private readonly int sentryBorderSize;
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the battlefield width.
|
/// Returns the battlefield width.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int BattlefieldWidth
|
public int BattlefieldWidth
|
||||||
{
|
{
|
||||||
get { return battlefieldWidth; }
|
get { return battlefieldWidth; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the battlefield height.
|
/// Returns the battlefield height.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int BattlefieldHeight
|
public int BattlefieldHeight
|
||||||
{
|
{
|
||||||
get { return battlefieldHeight; }
|
get { return battlefieldHeight; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the number of rounds.
|
/// Returns the number of rounds.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int NumRounds
|
public int NumRounds
|
||||||
{
|
{
|
||||||
get { return numRounds; }
|
get { return numRounds; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn.
|
/// Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// The gun cooling rate is default 0.1 per turn, but can be changed by the battle setup.
|
/// 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!
|
/// So don't count on the cooling rate being 0.1!
|
||||||
/// <seealso cref="Robot.GunHeat"/>
|
/// <seealso cref="Robot.GunHeat"/>
|
||||||
/// <seealso cref="Robot.Fire(double)"/>
|
/// <seealso cref="Robot.Fire(double)"/>
|
||||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||||
///</summary>
|
///</summary>
|
||||||
public double GunCoolingRate
|
public double GunCoolingRate
|
||||||
{
|
{
|
||||||
get { return gunCoolingRate; }
|
get { return gunCoolingRate; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped.
|
/// 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
|
/// 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.
|
/// action before being punished by the game by zapping.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// When a robot is zapped by the game, it will loose 0.1 energy points per turn. Eventually the robot will be
|
/// 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
|
/// killed by zapping until the robot takes action. When the robot takes action, the inactivity time counter is
|
||||||
/// reset.
|
/// reset.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// The allowed inactivity time is per default 450 turns, but can be changed by the battle setup.
|
/// 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!
|
/// So don't count on the inactivity time being 450 turns!
|
||||||
/// <seealso cref="Robot.DoNothing()"/>
|
/// <seealso cref="Robot.DoNothing()"/>
|
||||||
/// <seealso cref="AdvancedRobot.Execute()"/>
|
/// <seealso cref="AdvancedRobot.Execute()"/>
|
||||||
///</summary>
|
///</summary>
|
||||||
public long InactivityTime
|
public long InactivityTime
|
||||||
{
|
{
|
||||||
get { return inactivityTime; }
|
get { return inactivityTime; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns true if the enemy names are hidden, i.e. anonymous; false otherwise.
|
/// Returns true if the enemy names are hidden, i.e. anonymous; false otherwise.
|
||||||
///</summary>
|
///</summary>
|
||||||
public bool HideEnemyNames
|
public bool HideEnemyNames
|
||||||
{
|
{
|
||||||
get { return hideEnemyNames; }
|
get { return hideEnemyNames; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the sentry border size for a <see cref="Robocode.BorderSentry">BorderSentry</see> that defines the how
|
/// 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/>
|
/// 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
|
/// 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
|
/// 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
|
/// distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this
|
||||||
/// border area.
|
/// border area.
|
||||||
///</summary>
|
///</summary>
|
||||||
public int SentryBorderSize
|
public int SentryBorderSize
|
||||||
{
|
{
|
||||||
get { return sentryBorderSize; }
|
get { return sentryBorderSize; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private BattleRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
private BattleRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||||
bool hideEnemyNames, int sentryBorderSize)
|
bool hideEnemyNames, int sentryBorderSize)
|
||||||
{
|
{
|
||||||
this.battlefieldWidth = battlefieldWidth;
|
this.battlefieldWidth = battlefieldWidth;
|
||||||
this.battlefieldHeight = battlefieldHeight;
|
this.battlefieldHeight = battlefieldHeight;
|
||||||
this.numRounds = numRounds;
|
this.numRounds = numRounds;
|
||||||
this.gunCoolingRate = gunCoolingRate;
|
this.gunCoolingRate = gunCoolingRate;
|
||||||
this.inactivityTime = inactivityTime;
|
this.inactivityTime = inactivityTime;
|
||||||
this.hideEnemyNames = hideEnemyNames;
|
this.hideEnemyNames = hideEnemyNames;
|
||||||
this.sentryBorderSize = sentryBorderSize;
|
this.sentryBorderSize = sentryBorderSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IHiddenRulesHelper createHiddenHelper()
|
private static IHiddenRulesHelper createHiddenHelper()
|
||||||
{
|
{
|
||||||
return new HiddenHelper();
|
return new HiddenHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HiddenHelper : IHiddenRulesHelper
|
private class HiddenHelper : IHiddenRulesHelper
|
||||||
{
|
{
|
||||||
public BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
public BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
|
||||||
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
bool hideEnemyNames, int borderSentryRobotAttackRange)
|
||||||
{
|
{
|
||||||
return new BattleRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
return new BattleRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,217 +1,217 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.security;
|
using net.sf.robocode.security;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.Util;
|
using Robocode.Util;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Represents a bullet. This is returned from <see cref="Robot.FireBullet(double)"/>
|
/// Represents a bullet. This is returned from <see cref="Robot.FireBullet(double)"/>
|
||||||
/// and <see cref="AdvancedRobot.SetFireBullet(double)"/>, and all the bullet-related
|
/// and <see cref="AdvancedRobot.SetFireBullet(double)"/>, and all the bullet-related
|
||||||
/// events.
|
/// events.
|
||||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||||
/// <seealso cref="AdvancedRobot.SetFireBullet(double)"/>
|
/// <seealso cref="AdvancedRobot.SetFireBullet(double)"/>
|
||||||
/// <seealso cref="BulletHitEvent"/>
|
/// <seealso cref="BulletHitEvent"/>
|
||||||
/// <seealso cref="BulletMissedEvent"/>
|
/// <seealso cref="BulletMissedEvent"/>
|
||||||
/// <seealso cref="BulletHitBulletEvent"/>
|
/// <seealso cref="BulletHitBulletEvent"/>
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Bullet
|
public class Bullet
|
||||||
{
|
{
|
||||||
private readonly double headingRadians;
|
private readonly double headingRadians;
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
private readonly double power;
|
private readonly double power;
|
||||||
private readonly string ownerName;
|
private readonly string ownerName;
|
||||||
private string victimName;
|
private string victimName;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private readonly int bulletId;
|
private readonly int bulletId;
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Called by the game to create a new Bullet object
|
/// Called by the game to create a new Bullet object
|
||||||
///</summary>
|
///</summary>
|
||||||
public Bullet(double heading, double x, double y, double power, string ownerName, string victimName,
|
public Bullet(double heading, double x, double y, double power, string ownerName, string victimName,
|
||||||
bool isActive, int bulletId)
|
bool isActive, int bulletId)
|
||||||
{
|
{
|
||||||
headingRadians = heading;
|
headingRadians = heading;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.ownerName = ownerName;
|
this.ownerName = ownerName;
|
||||||
this.victimName = victimName;
|
this.victimName = victimName;
|
||||||
_isActive = isActive;
|
_isActive = isActive;
|
||||||
this.bulletId = bulletId;
|
this.bulletId = bulletId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(Object obj)
|
public override bool Equals(Object obj)
|
||||||
{
|
{
|
||||||
if (obj is Bullet)
|
if (obj is Bullet)
|
||||||
{
|
{
|
||||||
Bullet bullet = (Bullet)obj;
|
Bullet bullet = (Bullet)obj;
|
||||||
return bullet.bulletId == bulletId;
|
return bullet.bulletId == bulletId;
|
||||||
}
|
}
|
||||||
return Equals(obj);
|
return Equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the direction the bullet is/was heading, in degrees
|
/// Returns the direction the bullet is/was heading, in degrees
|
||||||
/// (0 <= getHeading() < 360). This is not relative to the direction you are facing.
|
/// (0 <= getHeading() < 360). This is not relative to the direction you are facing.
|
||||||
///</summary>
|
///</summary>
|
||||||
public double Heading
|
public double Heading
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(headingRadians); }
|
get { return Utils.ToDegrees(headingRadians); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the direction the bullet is/was heading, in radians
|
/// 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.
|
/// (0 <= getHeadingRadians() < 2 * Math.PI). This is not relative to the direction you are facing.
|
||||||
///</summary>
|
///</summary>
|
||||||
public double HeadingRadians
|
public double HeadingRadians
|
||||||
{
|
{
|
||||||
get { return headingRadians; }
|
get { return headingRadians; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the name of the robot that fired this bullet.
|
/// Returns the name of the robot that fired this bullet.
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return ownerName; }
|
get { return ownerName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the power of this bullet.
|
/// Returns the power of this bullet.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// The bullet will do (4 * power) damage if it hits another robot.
|
/// 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)
|
/// 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.
|
/// damage. You will get (3 * power) back if you hit the other robot.
|
||||||
///</summary>
|
///</summary>
|
||||||
public double Power
|
public double Power
|
||||||
{
|
{
|
||||||
get { return power; }
|
get { return power; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the velocity of this bullet. The velocity of the bullet is
|
/// Returns the velocity of this bullet. The velocity of the bullet is
|
||||||
/// constant once it has been fired.
|
/// constant once it has been fired.
|
||||||
///</summary>
|
///</summary>
|
||||||
public double Velocity
|
public double Velocity
|
||||||
{
|
{
|
||||||
get { return Rules.GetBulletSpeed(power); }
|
get { return Rules.GetBulletSpeed(power); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the name of the robot that this bullet hit, or null if
|
/// Returns the name of the robot that this bullet hit, or null if
|
||||||
/// the bullet has not hit a robot.
|
/// the bullet has not hit a robot.
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Victim
|
public string Victim
|
||||||
{
|
{
|
||||||
get { return victimName; }
|
get { return victimName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the X position of the bullet.
|
/// Returns the X position of the bullet.
|
||||||
///</summary>
|
///</summary>
|
||||||
public double X
|
public double X
|
||||||
{
|
{
|
||||||
get { return x; }
|
get { return x; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the Y position of the bullet.
|
/// Returns the Y position of the bullet.
|
||||||
///</summary>
|
///</summary>
|
||||||
public double Y
|
public double Y
|
||||||
{
|
{
|
||||||
get { return y; }
|
get { return y; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Checks if this bullet is still active on the battlefield.
|
/// Checks if this bullet is still active on the battlefield.
|
||||||
///</summary>
|
///</summary>
|
||||||
public bool IsActive
|
public bool IsActive
|
||||||
{
|
{
|
||||||
get { return _isActive; }
|
get { return _isActive; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Updates this bullet based on the specified bullet status.
|
/// Updates this bullet based on the specified bullet status.
|
||||||
///</summary>
|
///</summary>
|
||||||
// this method is invisible on RobotAPI
|
// this method is invisible on RobotAPI
|
||||||
private void update(double x, double y, string victimName, bool isActive)
|
private void update(double x, double y, string victimName, bool isActive)
|
||||||
{
|
{
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.victimName = victimName;
|
this.victimName = victimName;
|
||||||
_isActive = isActive;
|
_isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int getBulletId()
|
internal int getBulletId()
|
||||||
{
|
{
|
||||||
return bulletId;
|
return bulletId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IHiddenBulletHelper createHiddenHelper()
|
private static IHiddenBulletHelper createHiddenHelper()
|
||||||
{
|
{
|
||||||
return new HiddenBulletHelper();
|
return new HiddenBulletHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new HiddenBulletHelper();
|
return new HiddenBulletHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HiddenBulletHelper : IHiddenBulletHelper, ISerializableHelperN
|
private class HiddenBulletHelper : IHiddenBulletHelper, ISerializableHelperN
|
||||||
{
|
{
|
||||||
public void update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
public void update(Bullet bullet, double x, double y, string victimName, bool isActive)
|
||||||
{
|
{
|
||||||
bullet.update(x, y, victimName, isActive);
|
bullet.update(x, y, victimName, isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (Bullet)objec;
|
var obj = (Bullet)objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 4 * RbSerializerN.SIZEOF_DOUBLE + serializer.sizeOf(obj.ownerName)
|
return RbSerializerN.SIZEOF_TYPEINFO + 4 * RbSerializerN.SIZEOF_DOUBLE + serializer.sizeOf(obj.ownerName)
|
||||||
+ serializer.sizeOf(obj.victimName) + RbSerializerN.SIZEOF_BOOL + RbSerializerN.SIZEOF_INT;
|
+ serializer.sizeOf(obj.victimName) + RbSerializerN.SIZEOF_BOOL + RbSerializerN.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (Bullet)objec;
|
var obj = (Bullet)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.headingRadians);
|
serializer.serialize(buffer, obj.headingRadians);
|
||||||
serializer.serialize(buffer, obj.x);
|
serializer.serialize(buffer, obj.x);
|
||||||
serializer.serialize(buffer, obj.y);
|
serializer.serialize(buffer, obj.y);
|
||||||
serializer.serialize(buffer, obj.power);
|
serializer.serialize(buffer, obj.power);
|
||||||
serializer.serialize(buffer, obj.ownerName);
|
serializer.serialize(buffer, obj.ownerName);
|
||||||
serializer.serialize(buffer, obj.victimName);
|
serializer.serialize(buffer, obj.victimName);
|
||||||
serializer.serialize(buffer, obj._isActive);
|
serializer.serialize(buffer, obj._isActive);
|
||||||
serializer.serialize(buffer, obj.bulletId);
|
serializer.serialize(buffer, obj.bulletId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
double headingRadians = buffer.getDouble();
|
double headingRadians = buffer.getDouble();
|
||||||
double x = buffer.getDouble();
|
double x = buffer.getDouble();
|
||||||
double y = buffer.getDouble();
|
double y = buffer.getDouble();
|
||||||
double power = buffer.getDouble();
|
double power = buffer.getDouble();
|
||||||
string ownerName = serializer.deserializeString(buffer);
|
string ownerName = serializer.deserializeString(buffer);
|
||||||
string victimName = serializer.deserializeString(buffer);
|
string victimName = serializer.deserializeString(buffer);
|
||||||
bool isActive = serializer.deserializeBoolean(buffer);
|
bool isActive = serializer.deserializeBoolean(buffer);
|
||||||
int bulletId = serializer.deserializeInt(buffer);
|
int bulletId = serializer.deserializeInt(buffer);
|
||||||
|
|
||||||
return new Bullet(headingRadians, x, y, power, ownerName, victimName, isActive, bulletId);
|
return new Bullet(headingRadians, x, y, power, ownerName, victimName, isActive, bulletId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,116 +1,116 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// This event is sent to <see cref="Robot.OnBulletHitBullet(BulletHitBulletEvent)"/>
|
/// This event is sent to <see cref="Robot.OnBulletHitBullet(BulletHitBulletEvent)"/>
|
||||||
/// when one of your bullets has hit another bullet.
|
/// when one of your bullets has hit another bullet.
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class BulletHitBulletEvent : Event
|
public sealed class BulletHitBulletEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 55;
|
private const int DEFAULT_PRIORITY = 55;
|
||||||
|
|
||||||
private Bullet bullet;
|
private Bullet bullet;
|
||||||
private readonly Bullet hitBullet;
|
private readonly Bullet hitBullet;
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Called by the game to create a new BulletHitEvent.
|
/// Called by the game to create a new BulletHitEvent.
|
||||||
///</summary>
|
///</summary>
|
||||||
public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet)
|
public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet)
|
||||||
{
|
{
|
||||||
this.bullet = bullet;
|
this.bullet = bullet;
|
||||||
this.hitBullet = hitBullet;
|
this.hitBullet = hitBullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns your bullet that hit another bullet.
|
/// Returns your bullet that hit another bullet.
|
||||||
///</summary>
|
///</summary>
|
||||||
public Bullet Bullet
|
public Bullet Bullet
|
||||||
{
|
{
|
||||||
get { return bullet; }
|
get { return bullet; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the bullet that was hit by your bullet.
|
/// Returns the bullet that was hit by your bullet.
|
||||||
///</summary>
|
///</summary>
|
||||||
public Bullet HitBullet
|
public Bullet HitBullet
|
||||||
{
|
{
|
||||||
get { return hitBullet; }
|
get { return hitBullet; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnBulletHitBullet(this);
|
listener.OnBulletHitBullet(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for .NET version
|
// Needed for .NET version
|
||||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||||
{
|
{
|
||||||
// we need to pass same instance
|
// we need to pass same instance
|
||||||
bullet = bullets[bullet.getBulletId()];
|
bullet = bullets[bullet.getBulletId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.BulletHitBulletEvent_TYPE; }
|
get { return RbSerializerN.BulletHitBulletEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BulletHitBulletEvent) objec;
|
var obj = (BulletHitBulletEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT
|
||||||
+ serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
+ serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BulletHitBulletEvent) objec;
|
var obj = (BulletHitBulletEvent) objec;
|
||||||
|
|
||||||
// no need to transmit whole bullet, rest of it is already known to proxy side
|
// no need to transmit whole bullet, rest of it is already known to proxy side
|
||||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||||
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.hitBullet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||||
var hitBullet = (Bullet) serializer.deserializeAny(buffer);
|
var hitBullet = (Bullet) serializer.deserializeAny(buffer);
|
||||||
|
|
||||||
return new BulletHitBulletEvent(bullet, hitBullet);
|
return new BulletHitBulletEvent(bullet, hitBullet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
||||||
|
|
|
@ -1,128 +1,128 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// This event is sent to <see cref="Robot.OnBulletHit(BulletHitEvent)"/>
|
/// This event is sent to <see cref="Robot.OnBulletHit(BulletHitEvent)"/>
|
||||||
/// when one of your bullets has hit another robot.
|
/// when one of your bullets has hit another robot.
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class BulletHitEvent : Event
|
public sealed class BulletHitEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 50;
|
private const int DEFAULT_PRIORITY = 50;
|
||||||
|
|
||||||
private readonly string name;
|
private readonly string name;
|
||||||
private readonly double energy;
|
private readonly double energy;
|
||||||
private Bullet bullet;
|
private Bullet bullet;
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Called by the game to create a new BulletHitEvent.
|
/// Called by the game to create a new BulletHitEvent.
|
||||||
///</summary>
|
///</summary>
|
||||||
public BulletHitEvent(string name, double energy, Bullet bullet)
|
public BulletHitEvent(string name, double energy, Bullet bullet)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.energy = energy;
|
this.energy = energy;
|
||||||
this.bullet = bullet;
|
this.bullet = bullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the bullet of yours that hit the robot.
|
/// Returns the bullet of yours that hit the robot.
|
||||||
///</summary>
|
///</summary>
|
||||||
public Bullet Bullet
|
public Bullet Bullet
|
||||||
{
|
{
|
||||||
get { return bullet; }
|
get { return bullet; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the remaining energy of the robot your bullet has hit (after the
|
/// Returns the remaining energy of the robot your bullet has hit (after the
|
||||||
/// damage done by your bullet).
|
/// damage done by your bullet).
|
||||||
///</summary>
|
///</summary>
|
||||||
public double VictimEnergy
|
public double VictimEnergy
|
||||||
{
|
{
|
||||||
get { return energy; }
|
get { return energy; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the name of the robot your bullet hit.
|
/// Returns the name of the robot your bullet hit.
|
||||||
///</summary>
|
///</summary>
|
||||||
public string VictimName
|
public string VictimName
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnBulletHit(this);
|
listener.OnBulletHit(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for .NET version
|
// Needed for .NET version
|
||||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||||
{
|
{
|
||||||
// we need to pass same instance
|
// we need to pass same instance
|
||||||
bullet = bullets[bullet.getBulletId()];
|
bullet = bullets[bullet.getBulletId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.BulletHitEvent_TYPE; }
|
get { return RbSerializerN.BulletHitEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BulletHitEvent) objec;
|
var obj = (BulletHitEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT + serializer.sizeOf(obj.name)
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT + serializer.sizeOf(obj.name)
|
||||||
+ RbSerializerN.SIZEOF_DOUBLE;
|
+ RbSerializerN.SIZEOF_DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BulletHitEvent) objec;
|
var obj = (BulletHitEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||||
serializer.serialize(buffer, obj.name);
|
serializer.serialize(buffer, obj.name);
|
||||||
serializer.serialize(buffer, obj.energy);
|
serializer.serialize(buffer, obj.energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||||
string name = serializer.deserializeString(buffer);
|
string name = serializer.deserializeString(buffer);
|
||||||
double energy = buffer.getDouble();
|
double energy = buffer.getDouble();
|
||||||
|
|
||||||
return new BulletHitEvent(name, energy, bullet);
|
return new BulletHitEvent(name, energy, bullet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
||||||
|
|
|
@ -1,102 +1,102 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// This event is sent to <see cref="Robot.OnBulletMissed(BulletMissedEvent)"/>
|
/// This event is sent to <see cref="Robot.OnBulletMissed(BulletMissedEvent)"/>
|
||||||
/// when one of your bullets has missed, i.e. when the bullet has
|
/// when one of your bullets has missed, i.e. when the bullet has
|
||||||
/// reached the border of the battlefield.
|
/// reached the border of the battlefield.
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class BulletMissedEvent : Event
|
public sealed class BulletMissedEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 60;
|
private const int DEFAULT_PRIORITY = 60;
|
||||||
|
|
||||||
private Bullet bullet;
|
private Bullet bullet;
|
||||||
|
|
||||||
///
|
///
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Called by the game to create a new BulletMissedEvent.
|
/// Called by the game to create a new BulletMissedEvent.
|
||||||
///</summary>
|
///</summary>
|
||||||
public BulletMissedEvent(Bullet bullet)
|
public BulletMissedEvent(Bullet bullet)
|
||||||
{
|
{
|
||||||
this.bullet = bullet;
|
this.bullet = bullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Returns the bullet that missed.
|
/// Returns the bullet that missed.
|
||||||
///</summary>
|
///</summary>
|
||||||
public Bullet Bullet
|
public Bullet Bullet
|
||||||
{
|
{
|
||||||
get { return bullet; }
|
get { return bullet; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnBulletMissed(this);
|
listener.OnBulletMissed(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for .NET version
|
// Needed for .NET version
|
||||||
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||||
{
|
{
|
||||||
// we need to pass same instance
|
// we need to pass same instance
|
||||||
bullet = bullets[bullet.getBulletId()];
|
bullet = bullets[bullet.getBulletId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.BulletMissedEvent_TYPE; }
|
get { return RbSerializerN.BulletMissedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT;
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (BulletMissedEvent) objec;
|
var obj = (BulletMissedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.bullet.getBulletId());
|
serializer.serialize(buffer, obj.bullet.getBulletId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
|
||||||
|
|
||||||
return new BulletMissedEvent(bullet);
|
return new BulletMissedEvent(bullet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
||||||
|
|
|
@ -1,155 +1,155 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.io;
|
using net.sf.robocode.io;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Condition is used to define custom <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
/// 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
|
/// 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.
|
/// named samplecs.Target. See the samplecs/Target.cs for details.
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// AddCustomEvent(
|
/// AddCustomEvent(
|
||||||
/// new Condition("triggerhit", (c) =>
|
/// new Condition("triggerhit", (c) =>
|
||||||
/// {
|
/// {
|
||||||
/// return Energy <= trigger;
|
/// return Energy <= trigger;
|
||||||
/// }));
|
/// }));
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
/// <see cref="AdvancedRobot.WaitFor(Condition)"/>
|
||||||
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||||
/// <see cref="AdvancedRobot.RemoveCustomEvent(Condition)"/>
|
/// <see cref="AdvancedRobot.RemoveCustomEvent(Condition)"/>
|
||||||
/// <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
/// <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Condition
|
public class Condition
|
||||||
{
|
{
|
||||||
private readonly ConditionTest test;
|
private readonly ConditionTest test;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The priority of this condition. Defaults to 80.
|
/// The priority of this condition. Defaults to 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int priority = 80;
|
public int priority = 80;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of this condition.
|
/// The name of this condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string name;
|
public string name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Condition(string name, int priority, ConditionTest test)
|
public Condition(string name, int priority, ConditionTest test)
|
||||||
: this(name, priority)
|
: this(name, priority)
|
||||||
{
|
{
|
||||||
this.test = test;
|
this.test = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Condition(string name, ConditionTest test)
|
public Condition(string name, ConditionTest test)
|
||||||
: this(name)
|
: this(name)
|
||||||
{
|
{
|
||||||
this.test = test;
|
this.test = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
/// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Condition(ConditionTest test)
|
public Condition(ConditionTest test)
|
||||||
{
|
{
|
||||||
this.test = test;
|
this.test = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new, unnamed Condition with the default priority, which is 80.
|
/// Creates a new, unnamed Condition with the default priority, which is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Condition()
|
protected Condition()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new Condition with the specified name, and default priority, which is 80.
|
/// Creates a new Condition with the specified name, and default priority, which is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name for the new Condition</param>
|
/// <param name="name">The name for the new Condition</param>
|
||||||
protected Condition(string name)
|
protected Condition(string name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new Condition with the specified name and priority.
|
/// Creates a new Condition with the specified name and priority.
|
||||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||||
/// higher priority. The default priority is 80.
|
/// higher priority. The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name for the new condition</param>
|
/// <param name="name">The name for the new condition</param>
|
||||||
/// <param name="priority">The priority of the new condition</param>
|
/// <param name="priority">The priority of the new condition</param>
|
||||||
protected Condition(string name, int priority)
|
protected Condition(string name, int priority)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (priority < 0)
|
if (priority < 0)
|
||||||
{
|
{
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 0.");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 0.");
|
||||||
priority = 0;
|
priority = 0;
|
||||||
}
|
}
|
||||||
else if (priority > 99)
|
else if (priority > 99)
|
||||||
{
|
{
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99.");
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 99.");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 99.");
|
||||||
priority = 99;
|
priority = 99;
|
||||||
}
|
}
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of this condition.
|
/// Returns the name of this condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name ?? GetType().Name; }
|
get { return name ?? GetType().Name; }
|
||||||
set { name = value; }
|
set { name = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the priority of this condition.
|
/// Returns the priority of this condition.
|
||||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||||
/// higher priority. The default priority is 80.
|
/// higher priority. The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Priority
|
public int Priority
|
||||||
{
|
{
|
||||||
get { return priority; }
|
get { return priority; }
|
||||||
set { priority=value; }
|
set { priority=value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overriding the Test() method is the point of a Condition.
|
/// Overriding the Test() method is the point of a Condition.
|
||||||
/// The game will call your Test() function, and take action if it returns true.
|
/// The game will call your Test() function, and take action if it returns true.
|
||||||
/// This is valid for both <see cref="AdvancedRobot.WaitFor"/> and
|
/// This is valid for both <see cref="AdvancedRobot.WaitFor"/> and
|
||||||
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
/// <see cref="AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// You may not take any actions inside of Test().
|
/// You may not take any actions inside of Test().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool Test()
|
public virtual bool Test()
|
||||||
{
|
{
|
||||||
if (test != null)
|
if (test != null)
|
||||||
{
|
{
|
||||||
return test(this);
|
return test(this);
|
||||||
}
|
}
|
||||||
throw new NotImplementedException("You should inherit from Condition class and override Test() method or pass delegate into constructor");
|
throw new NotImplementedException("You should inherit from Condition class and override Test() method or pass delegate into constructor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Method signature for Test method of <see cref="Condition"/>
|
/// Method signature for Test method of <see cref="Condition"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate bool ConditionTest(Condition condition);
|
public delegate bool ConditionTest(Condition condition);
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,123 +1,123 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event is sent to <see cref="AdvancedRobot.OnCustomEvent(CustomEvent)"/>
|
/// 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
|
/// 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.
|
/// having it recurring repeatedly (see the example for the <see cref="Condition"/> method.
|
||||||
/// <seealso cref="Condition"/>
|
/// <seealso cref="Condition"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CustomEvent : Event
|
public class CustomEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 80;
|
private const int DEFAULT_PRIORITY = 80;
|
||||||
|
|
||||||
private readonly Condition condition;
|
private readonly Condition condition;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new CustomEvent when a condition is met.
|
/// Called by the game to create a new CustomEvent when a condition is met.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CustomEvent(Condition condition)
|
public CustomEvent(Condition condition)
|
||||||
{
|
{
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
if (condition != null)
|
if (condition != null)
|
||||||
{
|
{
|
||||||
Priority = condition.Priority;
|
Priority = condition.Priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new CustomEvent when a condition is met.
|
/// Called by the game to create a new CustomEvent when a condition is met.
|
||||||
/// The event will have the given priority.
|
/// The event will have the given priority.
|
||||||
/// An event priority is a value from 0 - 99. The higher value, the higher
|
/// An event priority is a value from 0 - 99. The higher value, the higher
|
||||||
/// priority. The default priority is 80.
|
/// priority. The default priority is 80.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This is equivalent to calling <see cref="Robocode.Condition.Priority"/> on the
|
/// This is equivalent to calling <see cref="Robocode.Condition.Priority"/> on the
|
||||||
/// Condition.
|
/// Condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="condition">The condition that must be met</param>
|
/// <param name="condition">The condition that must be met</param>
|
||||||
/// <param name="priority">The priority of the condition</param>
|
/// <param name="priority">The priority of the condition</param>
|
||||||
public CustomEvent(Condition condition, int priority)
|
public CustomEvent(Condition condition, int priority)
|
||||||
{
|
{
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
Priority = priority;
|
Priority = priority;
|
||||||
if (condition != null)
|
if (condition != null)
|
||||||
{
|
{
|
||||||
condition.Priority = priority;
|
condition.Priority = priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the condition that fired, causing this event to be generated.
|
/// Returns the condition that fired, causing this event to be generated.
|
||||||
/// Use this to determine which condition fired, and to remove the custom event.
|
/// Use this to determine which condition fired, and to remove the custom event.
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnCustomEvent(CustomEvent evnt)
|
/// public void OnCustomEvent(CustomEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// if (event.Condition.Name == "mycondition")
|
/// if (event.Condition.Name == "mycondition")
|
||||||
/// {
|
/// {
|
||||||
/// RemoveCustomEvent(event.Condition);
|
/// RemoveCustomEvent(event.Condition);
|
||||||
/// // do something else
|
/// // do something else
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Condition Condition
|
public Condition Condition
|
||||||
{
|
{
|
||||||
get { return condition; }
|
get { return condition; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsAdvancedRobot())
|
if (statics.IsAdvancedRobot())
|
||||||
{
|
{
|
||||||
IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();
|
IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnCustomEvent(this);
|
listener.OnCustomEvent(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sealed to disable overrides
|
// sealed to disable overrides
|
||||||
public override sealed int CompareTo(Event evnt)
|
public override sealed int CompareTo(Event evnt)
|
||||||
{
|
{
|
||||||
return base.CompareTo(evnt);
|
return base.CompareTo(evnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sealed to disable overrides
|
// sealed to disable overrides
|
||||||
internal override bool IsCriticalEvent
|
internal override bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// sealed to disable overrides
|
// sealed to disable overrides
|
||||||
public sealed override int Priority
|
public sealed override int Priority
|
||||||
{
|
{
|
||||||
get { return base.Priority; }
|
get { return base.Priority; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { throw new System.Exception("Serialization not supported on this event type"); }
|
get { throw new System.Exception("Serialization not supported on this event type"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,78 +1,78 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event is sent to <see cref="Robot.OnDeath(DeathEvent)"/> when your robot dies.
|
/// This event is sent to <see cref="Robot.OnDeath(DeathEvent)"/> when your robot dies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class DeathEvent : Event
|
public sealed class DeathEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = -1; // System event -> cannot be changed!;
|
private const int DEFAULT_PRIORITY = -1; // System event -> cannot be changed!;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int Priority
|
public override int Priority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnDeath(this);
|
listener.OnDeath(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override bool IsCriticalEvent
|
internal override bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.DeathEvent_TYPE; }
|
get { return RbSerializerN.DeathEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO;
|
return RbSerializerN.SIZEOF_TYPEINFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
return new DeathEvent();
|
return new DeathEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,279 +1,279 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using net.sf.robocode.io;
|
using net.sf.robocode.io;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.security;
|
using net.sf.robocode.security;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The superclass of all Robocode events.
|
/// The superclass of all Robocode events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public abstract class Event : IComparable<Event>
|
public abstract class Event : IComparable<Event>
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 80;
|
private const int DEFAULT_PRIORITY = 80;
|
||||||
|
|
||||||
private long time;
|
private long time;
|
||||||
private int priority;
|
private int priority;
|
||||||
|
|
||||||
// time is valid only after adding to event manager on proxy side, we do not update it on battle side
|
// time is valid only after adding to event manager on proxy side, we do not update it on battle side
|
||||||
private volatile bool addedToQueue;
|
private volatile bool addedToQueue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compares this event to another event regarding precedence.
|
/// Compares this event to another event regarding precedence.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The event precedence is first and foremost determined by the event time,
|
/// The event precedence is first and foremost determined by the event time,
|
||||||
/// secondly the event priority, and lastly specific event information.</para>
|
/// secondly the event priority, and lastly specific event information.</para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This method will first compare the time of each event. If the event time
|
/// 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
|
/// 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
|
/// each event. If the event priorities are equals, then this method will
|
||||||
/// compare the two events based on specific event information.</para>
|
/// compare the two events based on specific event information.</para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This method is called by the game in order to sort the event queue of a
|
/// 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>
|
/// robot to make sure the events are listed in chronological order.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
///
|
||||||
/// <param name="evnt">the event to compare to this event.</param>
|
/// <param name="evnt">the event to compare to this event.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// Returns a negative value if this event has higher precedence, i.e. must
|
/// 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
|
/// 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.
|
/// has a lower precedence, i.e. must be listed after the specified event.
|
||||||
/// 0 means that the precedence of the two events are equal.
|
/// 0 means that the precedence of the two events are equal.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public virtual int CompareTo(Event evnt)
|
public virtual int CompareTo(Event evnt)
|
||||||
{
|
{
|
||||||
// Compare the time difference which has precedence over priority.
|
// Compare the time difference which has precedence over priority.
|
||||||
var timeDiff = (int) (time - evnt.time);
|
var timeDiff = (int) (time - evnt.time);
|
||||||
|
|
||||||
if (timeDiff != 0)
|
if (timeDiff != 0)
|
||||||
{
|
{
|
||||||
return timeDiff; // Time differ
|
return timeDiff; // Time differ
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same time -> Compare the difference in priority
|
// Same time -> Compare the difference in priority
|
||||||
int priorityDiff = evnt.Priority - Priority;
|
int priorityDiff = evnt.Priority - Priority;
|
||||||
|
|
||||||
if (priorityDiff != 0)
|
if (priorityDiff != 0)
|
||||||
{
|
{
|
||||||
return priorityDiff; // Priority differ
|
return priorityDiff; // Priority differ
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same time and priority -> Compare specific event types
|
// Same time and priority -> Compare specific event types
|
||||||
// look at overrides in ScannedRobotEvent and HitRobotEvent
|
// look at overrides in ScannedRobotEvent and HitRobotEvent
|
||||||
|
|
||||||
// No difference found
|
// No difference found
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time when this event occurred.
|
/// The time when this event occurred.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Note that the time is equal to the turn of a battle round.
|
/// Note that the time is equal to the turn of a battle round.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This method is intended for letting robot developers create their own event types.
|
/// 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
|
/// It is not possible to change the time of an event after it has been added to the event
|
||||||
/// queue of the robot.</para>
|
/// queue of the robot.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public long Time
|
public long Time
|
||||||
{
|
{
|
||||||
get { return time; }
|
get { return time; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (addedToQueue)
|
if (addedToQueue)
|
||||||
{
|
{
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: The time of an event cannot be changed after it has been added the event queue.");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: The time of an event cannot be changed after it has been added the event queue.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
time = value;
|
time = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The priority of this event.
|
/// The priority of this event.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// An event priority is a value from 0 - 99. The higher value, the higher priority.</para>
|
/// An event priority is a value from 0 - 99. The higher value, the higher priority.</para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The default priority is 80, but varies depending on the type of event.</para>
|
/// The default priority is 80, but varies depending on the type of event.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method is intended for letting robot developers create their own event types.
|
/// This method is intended for letting robot developers create their own event types.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// It is not possible to change the priority of an event after it has been added to the event
|
/// It is not possible to change the priority of an event after it has been added to the event
|
||||||
/// queue of the robot.</para>
|
/// queue of the robot.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <seealso cref="SetEventPriority(string, int)"/>
|
/// <seealso cref="SetEventPriority(string, int)"/>
|
||||||
public virtual int Priority
|
public virtual int Priority
|
||||||
{
|
{
|
||||||
get { return priority; }
|
get { return priority; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (addedToQueue)
|
if (addedToQueue)
|
||||||
{
|
{
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: The priority of an event cannot be changed after it has been added the event queue.");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: The priority of an event cannot be changed after it has been added the event queue.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetPriorityHidden(value);
|
SetPriorityHidden(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hidden method for setting the exact time when this event occurred.
|
/// Hidden method for setting the exact time when this event occurred.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method is called by the game engine only.
|
/// This method is called by the game engine only.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="time">the time when this event occurred.</param>
|
/// <param name="time">the time when this event occurred.</param>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
private void SetTimeHidden(long time)
|
private void SetTimeHidden(long time)
|
||||||
{
|
{
|
||||||
// we do not replace time which is set by robot to the future
|
// we do not replace time which is set by robot to the future
|
||||||
if (this.time < time)
|
if (this.time < time)
|
||||||
{
|
{
|
||||||
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
|
// when this flag is set, robots are not allowed to change the time or priority of the event anymore
|
||||||
addedToQueue = true;
|
addedToQueue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hidden method for setting the priority from the game engine without checking for the 'addedToQueue' flag.
|
/// Hidden method for setting the priority from the game engine without checking for the 'addedToQueue' flag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method is called by the game engine only.
|
/// This method is called by the game engine only.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="newPriority">the new priority of this event.</param>
|
/// <param name="newPriority">the new priority of this event.</param>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
private void SetPriorityHidden(int newPriority)
|
private void SetPriorityHidden(int newPriority)
|
||||||
{
|
{
|
||||||
if (newPriority < 0)
|
if (newPriority < 0)
|
||||||
{
|
{
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 0");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 0");
|
||||||
newPriority = 0;
|
newPriority = 0;
|
||||||
}
|
}
|
||||||
else if (newPriority > 99)
|
else if (newPriority > 99)
|
||||||
{
|
{
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99");
|
||||||
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 99");
|
LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 99");
|
||||||
newPriority = 99;
|
newPriority = 99;
|
||||||
}
|
}
|
||||||
priority = newPriority;
|
priority = newPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispatch this event for a robot, it's statistics, and graphics context.
|
/// Dispatch this event for a robot, it's statistics, and graphics context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">the robot to dispatch to.</param>
|
/// <param name="robot">the robot to dispatch to.</param>
|
||||||
/// <param name="statics">the robot to statistics to.</param>
|
/// <param name="statics">the robot to statistics to.</param>
|
||||||
/// <param name="graphics">the robot to graphics to.</param>
|
/// <param name="graphics">the robot to graphics to.</param>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default priority of this event class.
|
/// The default priority of this event class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
internal virtual int DefaultPriority
|
internal virtual int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if this event must be delivered even after timeout.
|
/// Checks if this event must be delivered even after timeout.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <c>true</c> when this event must be delivered even after timeout;
|
/// <c>true</c> when this event must be delivered even after timeout;
|
||||||
/// <c>false</c> otherwise.
|
/// <c>false</c> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
internal virtual bool IsCriticalEvent
|
internal virtual bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
internal virtual byte SerializationType
|
internal virtual byte SerializationType
|
||||||
{
|
{
|
||||||
get { throw new System.Exception("Serialization not supported on this event type"); }
|
get { throw new System.Exception("Serialization not supported on this event type"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for .NET version
|
// Needed for .NET version
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
internal virtual void UpdateBullets(Dictionary<int, Bullet> bullets)
|
internal virtual void UpdateBullets(Dictionary<int, Bullet> bullets)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a hidden event helper for accessing hidden methods on this object.
|
/// Returns a hidden event helper for accessing hidden methods on this object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
private static IHiddenEventHelper createHiddenHelper()
|
private static IHiddenEventHelper createHiddenHelper()
|
||||||
{
|
{
|
||||||
return new HiddenEventHelper();
|
return new HiddenEventHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hidden event helper implementation for accessing the internal methods of an event.
|
/// Hidden event helper implementation for accessing the internal methods of an event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This class is used internally by the game engine.
|
/// This class is used internally by the game engine.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
// This method must be invisible on Robot API
|
// This method must be invisible on Robot API
|
||||||
private class HiddenEventHelper : IHiddenEventHelper
|
private class HiddenEventHelper : IHiddenEventHelper
|
||||||
{
|
{
|
||||||
public void SetTime(Event evnt, long newTime)
|
public void SetTime(Event evnt, long newTime)
|
||||||
{
|
{
|
||||||
evnt.SetTimeHidden(newTime);
|
evnt.SetTimeHidden(newTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDefaultPriority(Event evnt)
|
public void SetDefaultPriority(Event evnt)
|
||||||
{
|
{
|
||||||
evnt.Priority = evnt.DefaultPriority;
|
evnt.Priority = evnt.DefaultPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPriority(Event evnt, int newPriority)
|
public void SetPriority(Event evnt, int newPriority)
|
||||||
{
|
{
|
||||||
evnt.SetPriorityHidden(newPriority);
|
evnt.SetPriorityHidden(newPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCriticalEvent(Event evnt)
|
public bool IsCriticalEvent(Event evnt)
|
||||||
{
|
{
|
||||||
return evnt.IsCriticalEvent;
|
return evnt.IsCriticalEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
public void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
evnt.Dispatch(robot, statics, graphics);
|
evnt.Dispatch(robot, statics, graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte GetSerializationType(Event evnt)
|
public byte GetSerializationType(Event evnt)
|
||||||
{
|
{
|
||||||
return evnt.SerializationType;
|
return evnt.SerializationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for .NET version
|
// Needed for .NET version
|
||||||
public void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets)
|
public void UpdateBullets(Event evnt, Dictionary<int, Bullet> bullets)
|
||||||
{
|
{
|
||||||
evnt.UpdateBullets(bullets);
|
evnt.UpdateBullets(bullets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A prebuilt condition you can use that indicates your gun has finished turning.
|
/// A prebuilt condition you can use that indicates your gun has finished turning.
|
||||||
/// <seealso cref="Condition"/>
|
/// <seealso cref="Condition"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GunTurnCompleteCondition : Condition
|
public class GunTurnCompleteCondition : Condition
|
||||||
{
|
{
|
||||||
private readonly AdvancedRobot robot;
|
private readonly AdvancedRobot robot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new GunTurnCompleteCondition with default priority.
|
/// Creates a new GunTurnCompleteCondition with default priority.
|
||||||
/// The default priority is 80.
|
/// The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||||
public GunTurnCompleteCondition(AdvancedRobot robot)
|
public GunTurnCompleteCondition(AdvancedRobot robot)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new GunTurnCompleteCondition with a specific priority.
|
/// Creates a new GunTurnCompleteCondition with a specific priority.
|
||||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||||
/// higher priority. The default priority is 80.
|
/// higher priority. The default priority is 80.
|
||||||
/// <seealso cref="Condition.Priority"/>
|
/// <seealso cref="Condition.Priority"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||||
/// <param name="priority">The priority of this condition</param>
|
/// <param name="priority">The priority of this condition</param>
|
||||||
public GunTurnCompleteCondition(AdvancedRobot robot, int priority)
|
public GunTurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests if the gun has stopped turning.
|
/// Tests if the gun has stopped turning.
|
||||||
/// Returns true if the gun has stopped turning
|
/// Returns true if the gun has stopped turning
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Test()
|
public override bool Test()
|
||||||
{
|
{
|
||||||
return (robot.GunTurnRemaining == 0);
|
return (robot.GunTurnRemaining == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,177 +1,177 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A HitByBulletEvent is sent to <see cref="Robot.OnHitByBullet(HitByBulletEvent)"/>
|
/// A HitByBulletEvent is sent to <see cref="Robot.OnHitByBullet(HitByBulletEvent)"/>
|
||||||
/// when your robot has been hit by a bullet.
|
/// when your robot has been hit by a bullet.
|
||||||
/// You can use the information contained in this event to determine what to do.
|
/// You can use the information contained in this event to determine what to do.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class HitByBulletEvent : Event
|
public sealed class HitByBulletEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 20;
|
private const int DEFAULT_PRIORITY = 20;
|
||||||
|
|
||||||
private readonly double bearing;
|
private readonly double bearing;
|
||||||
private readonly Bullet bullet;
|
private readonly Bullet bullet;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new HitByBulletEvent.
|
/// Called by the game to create a new HitByBulletEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitByBulletEvent(double bearing, Bullet bullet)
|
public HitByBulletEvent(double bearing, Bullet bullet)
|
||||||
{
|
{
|
||||||
this.bearing = bearing;
|
this.bearing = bearing;
|
||||||
this.bullet = bullet;
|
this.bullet = bullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the bullet, relative to your robot's heading,
|
/// Returns the bearing to the bullet, relative to your robot's heading,
|
||||||
/// in degrees (-180 < getBearing() <= 180).
|
/// in degrees (-180 < getBearing() <= 180).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// If you were to TurnRight(event.Bearing), you would be facing the
|
/// If you were to TurnRight(event.Bearing), you would be facing the
|
||||||
/// direction the bullet came from. The calculation used here is:
|
/// direction the bullet came from. The calculation used here is:
|
||||||
/// (bullet's heading in degrees + 180) - (your heading in degrees)
|
/// (bullet's heading in degrees + 180) - (your heading in degrees)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Bearing
|
public double Bearing
|
||||||
{
|
{
|
||||||
get { return bearing*180.0/Math.PI; }
|
get { return bearing*180.0/Math.PI; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the bullet, relative to your robot's heading,
|
/// Returns the bearing to the bullet, relative to your robot's heading,
|
||||||
/// in radians (-Math.PI < getBearingRadians() <= Math.PI).
|
/// in radians (-Math.PI < getBearingRadians() <= Math.PI).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// If you were to TurnRightRadians(event.BearingRadians), you would be
|
/// If you were to TurnRightRadians(event.BearingRadians), you would be
|
||||||
/// facing the direction the bullet came from. The calculation used here is:
|
/// facing the direction the bullet came from. The calculation used here is:
|
||||||
/// (bullet's heading in radians + Math.PI) - (your heading in radians)
|
/// (bullet's heading in radians + Math.PI) - (your heading in radians)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double BearingRadians
|
public double BearingRadians
|
||||||
{
|
{
|
||||||
get { return bearing; }
|
get { return bearing; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bullet that hit your robot.
|
/// Returns the bullet that hit your robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Bullet Bullet
|
public Bullet Bullet
|
||||||
{
|
{
|
||||||
get { return bullet; }
|
get { return bullet; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the heading of the bullet when it hit you, in degrees
|
/// Returns the heading of the bullet when it hit you, in degrees
|
||||||
/// (0 <= getHeading() < 360).
|
/// (0 <= getHeading() < 360).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note: This is not relative to the direction you are facing. The robot
|
/// 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
|
/// that fired the bullet was in the opposite direction of getHeading() when
|
||||||
/// it fired the bullet.
|
/// it fired the bullet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Heading
|
public double Heading
|
||||||
{
|
{
|
||||||
get { return bullet.Heading; }
|
get { return bullet.Heading; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the heading of the bullet when it hit you, in radians
|
/// Returns the heading of the bullet when it hit you, in radians
|
||||||
/// (0 <= getHeadingRadians() < 2 * PI).
|
/// (0 <= getHeadingRadians() < 2 * PI).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note: This is not relative to the direction you are facing. The robot
|
/// Note: This is not relative to the direction you are facing. The robot
|
||||||
/// that fired the bullet was in the opposite direction of
|
/// that fired the bullet was in the opposite direction of
|
||||||
/// getHeadingRadians() when it fired the bullet.
|
/// getHeadingRadians() when it fired the bullet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double HeadingRadians
|
public double HeadingRadians
|
||||||
{
|
{
|
||||||
get { return bullet.HeadingRadians; }
|
get { return bullet.HeadingRadians; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the robot that fired the bullet.
|
/// Returns the name of the robot that fired the bullet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return bullet.Name; }
|
get { return bullet.Name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the power of this bullet. The damage you take (in fact, already
|
/// 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
|
/// took) is 4 * power, plus 2 * (power-1) if power > 1. The robot that fired
|
||||||
/// the bullet receives 3 * power back.
|
/// the bullet receives 3 * power back.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Power
|
public double Power
|
||||||
{
|
{
|
||||||
get { return bullet.Power; }
|
get { return bullet.Power; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the velocity of this bullet.
|
/// Returns the velocity of this bullet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Velocity
|
public double Velocity
|
||||||
{
|
{
|
||||||
get { return bullet.Velocity; }
|
get { return bullet.Velocity; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnHitByBullet(this);
|
listener.OnHitByBullet(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.HitByBulletEvent_TYPE; }
|
get { return RbSerializerN.HitByBulletEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (HitByBulletEvent) objec;
|
var obj = (HitByBulletEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.bullet)
|
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.bullet)
|
||||||
+ RbSerializerN.SIZEOF_DOUBLE;
|
+ RbSerializerN.SIZEOF_DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (HitByBulletEvent) objec;
|
var obj = (HitByBulletEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.bullet);
|
serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.bullet);
|
||||||
serializer.serialize(buffer, obj.bearing);
|
serializer.serialize(buffer, obj.bearing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
var bullet = (Bullet) serializer.deserializeAny(buffer);
|
var bullet = (Bullet) serializer.deserializeAny(buffer);
|
||||||
double bearing = buffer.getDouble();
|
double bearing = buffer.getDouble();
|
||||||
|
|
||||||
return new HitByBulletEvent(bearing, bullet);
|
return new HitByBulletEvent(bearing, bullet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,172 +1,172 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A HitRobotEvent is sent to <see cref="Robot.OnHitRobot(HitRobotEvent)"/>
|
/// A HitRobotEvent is sent to <see cref="Robot.OnHitRobot(HitRobotEvent)"/>
|
||||||
/// when your robot collides with another robot.
|
/// when your robot collides with another robot.
|
||||||
/// You can use the information contained in this event to determine what to do.
|
/// You can use the information contained in this event to determine what to do.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class HitRobotEvent : Event
|
public sealed class HitRobotEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 40;
|
private const int DEFAULT_PRIORITY = 40;
|
||||||
|
|
||||||
private readonly string name;
|
private readonly string name;
|
||||||
private readonly double bearing;
|
private readonly double bearing;
|
||||||
private readonly double energy;
|
private readonly double energy;
|
||||||
private readonly bool atFault;
|
private readonly bool atFault;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new HitRobotEvent.
|
/// Called by the game to create a new HitRobotEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitRobotEvent(string name, double bearing, double energy, bool atFault)
|
public HitRobotEvent(string name, double bearing, double energy, bool atFault)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.bearing = bearing;
|
this.bearing = bearing;
|
||||||
this.energy = energy;
|
this.energy = energy;
|
||||||
this.atFault = atFault;
|
this.atFault = atFault;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the robot you hit, relative to your robot's
|
/// Returns the bearing to the robot you hit, relative to your robot's
|
||||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Bearing
|
public double Bearing
|
||||||
{
|
{
|
||||||
get { return bearing*180.0/Math.PI; }
|
get { return bearing*180.0/Math.PI; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the robot you hit, relative to your robot's
|
/// Returns the bearing to the robot you hit, relative to your robot's
|
||||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double BearingRadians
|
public double BearingRadians
|
||||||
{
|
{
|
||||||
get { return bearing; }
|
get { return bearing; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the amount of energy of the robot you hit.
|
/// Returns the amount of energy of the robot you hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Energy
|
public double Energy
|
||||||
{
|
{
|
||||||
get { return energy; }
|
get { return energy; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the robot you hit.
|
/// Returns the name of the robot you hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if your robot was moving towards the robot that was hit.
|
/// Checks if your robot was moving towards the robot that was hit.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// If <see cref="IsMyFault"/> returns true then your robot's movement (including
|
/// If <see cref="IsMyFault"/> returns true then your robot's movement (including
|
||||||
/// turning) will have stopped and been marked complete.
|
/// turning) will have stopped and been marked complete.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note: If two robots are moving toward each other and collide, they will
|
/// 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()
|
/// each receive two HitRobotEvents. The first will be the one if isMyFault()
|
||||||
/// returns true.
|
/// returns true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsMyFault
|
public bool IsMyFault
|
||||||
{
|
{
|
||||||
get { return atFault; }
|
get { return atFault; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int CompareTo(Event evnt)
|
public override int CompareTo(Event evnt)
|
||||||
{
|
{
|
||||||
int res = base.CompareTo(evnt);
|
int res = base.CompareTo(evnt);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare the IsMyFault, if the events are HitRobotEvents
|
// Compare the IsMyFault, if the events are HitRobotEvents
|
||||||
// The isMyFault has higher priority when it is set compared to when it is not set
|
// The isMyFault has higher priority when it is set compared to when it is not set
|
||||||
if (evnt is HitRobotEvent)
|
if (evnt is HitRobotEvent)
|
||||||
{
|
{
|
||||||
int compare1 = (this).IsMyFault ? -1 : 0;
|
int compare1 = (this).IsMyFault ? -1 : 0;
|
||||||
int compare2 = ((HitRobotEvent) evnt).IsMyFault ? -1 : 0;
|
int compare2 = ((HitRobotEvent) evnt).IsMyFault ? -1 : 0;
|
||||||
|
|
||||||
return compare1 - compare2;
|
return compare1 - compare2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No difference found
|
// No difference found
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnHitRobot(this);
|
listener.OnHitRobot(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.HitRobotEvent_TYPE; }
|
get { return RbSerializerN.HitRobotEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (HitRobotEvent) objec;
|
var obj = (HitRobotEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 2*RbSerializerN.SIZEOF_DOUBLE
|
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 2*RbSerializerN.SIZEOF_DOUBLE
|
||||||
+ RbSerializerN.SIZEOF_BOOL;
|
+ RbSerializerN.SIZEOF_BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (HitRobotEvent) objec;
|
var obj = (HitRobotEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.name);
|
serializer.serialize(buffer, obj.name);
|
||||||
serializer.serialize(buffer, obj.bearing);
|
serializer.serialize(buffer, obj.bearing);
|
||||||
serializer.serialize(buffer, obj.energy);
|
serializer.serialize(buffer, obj.energy);
|
||||||
serializer.serialize(buffer, obj.atFault);
|
serializer.serialize(buffer, obj.atFault);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
string robotName = serializer.deserializeString(buffer);
|
string robotName = serializer.deserializeString(buffer);
|
||||||
double bearing = buffer.getDouble();
|
double bearing = buffer.getDouble();
|
||||||
double energy = buffer.getDouble();
|
double energy = buffer.getDouble();
|
||||||
bool atFault = serializer.deserializeBoolean(buffer);
|
bool atFault = serializer.deserializeBoolean(buffer);
|
||||||
|
|
||||||
return new HitRobotEvent(robotName, bearing, energy, atFault);
|
return new HitRobotEvent(robotName, bearing, energy, atFault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,103 +1,103 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A HitWallEvent is sent to <see cref="Robot.OnHitWall(HitWallEvent)"/>
|
/// A HitWallEvent is sent to <see cref="Robot.OnHitWall(HitWallEvent)"/>
|
||||||
/// when you collide a wall.
|
/// when you collide a wall.
|
||||||
/// You can use the information contained in this event to determine what to do.
|
/// You can use the information contained in this event to determine what to do.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class HitWallEvent : Event
|
public sealed class HitWallEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 30;
|
private const int DEFAULT_PRIORITY = 30;
|
||||||
|
|
||||||
private readonly double bearing;
|
private readonly double bearing;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new HitWallEvent.
|
/// Called by the game to create a new HitWallEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitWallEvent(double bearing)
|
public HitWallEvent(double bearing)
|
||||||
{
|
{
|
||||||
this.bearing = bearing;
|
this.bearing = bearing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the wall you hit, relative to your robot's
|
/// Returns the bearing to the wall you hit, relative to your robot's
|
||||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Bearing
|
public double Bearing
|
||||||
{
|
{
|
||||||
get { return bearing*180.0/Math.PI; }
|
get { return bearing*180.0/Math.PI; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the wall you hit, relative to your robot's
|
/// Returns the bearing to the wall you hit, relative to your robot's
|
||||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double BearingRadians
|
public double BearingRadians
|
||||||
{
|
{
|
||||||
get { return bearing; }
|
get { return bearing; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnHitWall(this);
|
listener.OnHitWall(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.HitWallEvent_TYPE; }
|
get { return RbSerializerN.HitWallEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_DOUBLE;
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (HitWallEvent) objec;
|
var obj = (HitWallEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.bearing);
|
serializer.serialize(buffer, obj.bearing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
double bearing = buffer.getDouble();
|
double bearing = buffer.getDouble();
|
||||||
|
|
||||||
return new HitWallEvent(bearing);
|
return new HitWallEvent(bearing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,32 +1,32 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot that implement IBorderSentry is a robot type used for keeping other robots away from the borders,
|
/// 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/>
|
/// 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
|
/// 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/>
|
/// 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
|
/// 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
|
/// are moving into the border area. The size of the border area is determined by the
|
||||||
/// <see cref="BattleRules.SentryBorderSize">battle rules</see>.<br/>
|
/// <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
|
/// 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/>
|
/// order to prevent "wall crawlers".<br/>
|
||||||
/// Border sentry robots does not get scores, and will not occur in the battle results or rankings.
|
/// Border sentry robots does not get scores, and will not occur in the battle results or rankings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="BattleRules.SentryBorderSize"/>
|
/// <seealso cref="BattleRules.SentryBorderSize"/>
|
||||||
/// <seealso cref="JuniorRobot"/>
|
/// <seealso cref="JuniorRobot"/>
|
||||||
/// <seealso cref="Robot"/>
|
/// <seealso cref="Robot"/>
|
||||||
/// <seealso cref="AdvancedRobot"/>
|
/// <seealso cref="AdvancedRobot"/>
|
||||||
/// <seealso cref="TeamRobot"/>
|
/// <seealso cref="TeamRobot"/>
|
||||||
/// <seealso cref="RateControlRobot"/>
|
/// <seealso cref="RateControlRobot"/>
|
||||||
/// <seealso cref="IDroid"/>
|
/// <seealso cref="IDroid"/>
|
||||||
public interface IBorderSentry
|
public interface IBorderSentry
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Robots that implement IDroid have no scanner, but an extra 20 life/energy.
|
/// Robots that implement IDroid have no scanner, but an extra 20 life/energy.
|
||||||
/// This class is intended for use in teams.
|
/// This class is intended for use in teams.
|
||||||
/// <seealso cref="JuniorRobot"/>
|
/// <seealso cref="JuniorRobot"/>
|
||||||
/// <seealso cref="Robot"/>
|
/// <seealso cref="Robot"/>
|
||||||
/// <seealso cref="AdvancedRobot"/>
|
/// <seealso cref="AdvancedRobot"/>
|
||||||
/// <seealso cref="TeamRobot"/>
|
/// <seealso cref="TeamRobot"/>
|
||||||
/// <seealso cref="RateControlRobot"/>
|
/// <seealso cref="RateControlRobot"/>
|
||||||
/// <seealso cref="IBorderSentry"/>
|
/// <seealso cref="IBorderSentry"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDroid
|
public interface IDroid
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,160 +1,160 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Graphics"/>
|
/// <see cref="Graphics"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGraphics
|
public interface IGraphics
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
//TODO xml doc
|
//TODO xml doc
|
||||||
void DrawLine(Pen pen, float x1, float y1, float x2, float y2);
|
void DrawLine(Pen pen, float x1, float y1, float x2, float y2);
|
||||||
void DrawLine(Pen pen, PointF pt1, PointF pt2);
|
void DrawLine(Pen pen, PointF pt1, PointF pt2);
|
||||||
void DrawLine(Pen pen, int x1, int y1, int x2, int y2);
|
void DrawLine(Pen pen, int x1, int y1, int x2, int y2);
|
||||||
void DrawLine(Pen pen, Point pt1, Point pt2);
|
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, 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, 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, int x, int y, int width, int height, int startAngle, int sweepAngle);
|
||||||
void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
|
void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
|
||||||
void DrawRectangle(Pen pen, RectangleF rect);
|
void DrawRectangle(Pen pen, RectangleF rect);
|
||||||
void DrawRectangle(Pen pen, Rectangle rect);
|
void DrawRectangle(Pen pen, Rectangle rect);
|
||||||
void DrawRectangle(Pen pen, float x, float y, float width, float height);
|
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 DrawRectangle(Pen pen, int x, int y, int width, int height);
|
||||||
void DrawEllipse(Pen pen, RectangleF rect);
|
void DrawEllipse(Pen pen, RectangleF rect);
|
||||||
void DrawEllipse(Pen pen, float x, float y, float width, float height);
|
void DrawEllipse(Pen pen, float x, float y, float width, float height);
|
||||||
void DrawEllipse(Pen pen, Rectangle rect);
|
void DrawEllipse(Pen pen, Rectangle rect);
|
||||||
void DrawEllipse(Pen pen, int x, int y, int width, int height);
|
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, 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, 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, Rectangle rect, float startAngle, float sweepAngle);
|
||||||
void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle, int 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, PointF[] points);
|
||||||
void DrawPolygon(Pen pen, Point[] points);
|
void DrawPolygon(Pen pen, Point[] points);
|
||||||
void FillRectangle(Brush brush, RectangleF rect);
|
void FillRectangle(Brush brush, RectangleF rect);
|
||||||
void FillRectangle(Brush brush, float x, float y, float width, float height);
|
void FillRectangle(Brush brush, float x, float y, float width, float height);
|
||||||
void FillRectangle(Brush brush, Rectangle rect);
|
void FillRectangle(Brush brush, Rectangle rect);
|
||||||
void FillRectangle(Brush brush, int x, int y, int width, int height);
|
void FillRectangle(Brush brush, int x, int y, int width, int height);
|
||||||
void FillPolygon(Brush brush, PointF[] points);
|
void FillPolygon(Brush brush, PointF[] points);
|
||||||
void FillPolygon(Brush brush, Point[] points);
|
void FillPolygon(Brush brush, Point[] points);
|
||||||
void FillEllipse(Brush brush, RectangleF rect);
|
void FillEllipse(Brush brush, RectangleF rect);
|
||||||
void FillEllipse(Brush brush, float x, float y, float width, float height);
|
void FillEllipse(Brush brush, float x, float y, float width, float height);
|
||||||
void FillEllipse(Brush brush, Rectangle rect);
|
void FillEllipse(Brush brush, Rectangle rect);
|
||||||
void FillEllipse(Brush brush, int x, int y, int width, int height);
|
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, 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, 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 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, int x, int y);
|
||||||
void DrawString(string s, Font font, Brush brush, float x, float 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, PointF point);
|
||||||
void DrawString(string s, Font font, Brush brush, Point point);
|
void DrawString(string s, Font font, Brush brush, Point point);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void DrawLines(Pen pen, PointF[] points);
|
void DrawLines(Pen pen, PointF[] points);
|
||||||
void DrawLines(Pen pen, Point[] points);
|
void DrawLines(Pen pen, Point[] points);
|
||||||
void DrawRectangles(Pen pen, RectangleF[] rects);
|
void DrawRectangles(Pen pen, RectangleF[] rects);
|
||||||
void DrawRectangles(Pen pen, Rectangle[] rects);
|
void DrawRectangles(Pen pen, Rectangle[] rects);
|
||||||
void DrawPath(Pen pen, GraphicsPath path);
|
void DrawPath(Pen pen, GraphicsPath path);
|
||||||
void DrawCurve(Pen pen, PointF[] points);
|
void DrawCurve(Pen pen, PointF[] points);
|
||||||
void DrawCurve(Pen pen, PointF[] points, float tension);
|
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);
|
||||||
void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension);
|
void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension);
|
||||||
void DrawCurve(Pen pen, Point[] points);
|
void DrawCurve(Pen pen, Point[] points);
|
||||||
void DrawCurve(Pen pen, Point[] points, float tension);
|
void DrawCurve(Pen pen, Point[] points, float tension);
|
||||||
void DrawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, 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);
|
||||||
void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode);
|
void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode);
|
||||||
void DrawClosedCurve(Pen pen, Point[] points);
|
void DrawClosedCurve(Pen pen, Point[] points);
|
||||||
void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode);
|
void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode);
|
||||||
void FillPolygon(Brush brush, PointF[] points, FillMode fillMode);
|
void FillPolygon(Brush brush, PointF[] points, FillMode fillMode);
|
||||||
void FillPolygon(Brush brush, Point[] points, FillMode fillMode);
|
void FillPolygon(Brush brush, Point[] points, FillMode fillMode);
|
||||||
void FillRectangles(Brush brush, RectangleF[] rects);
|
void FillRectangles(Brush brush, RectangleF[] rects);
|
||||||
void FillRectangles(Brush brush, Rectangle[] rects);
|
void FillRectangles(Brush brush, Rectangle[] rects);
|
||||||
void FillClosedCurve(Brush brush, PointF[] points);
|
void FillClosedCurve(Brush brush, PointF[] points);
|
||||||
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode);
|
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode);
|
||||||
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension);
|
void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension);
|
||||||
void FillClosedCurve(Brush brush, Point[] points);
|
void FillClosedCurve(Brush brush, Point[] points);
|
||||||
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode);
|
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode);
|
||||||
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension);
|
void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension);
|
||||||
void FillRegion(Brush brush, Region region);
|
void FillRegion(Brush brush, Region region);
|
||||||
void FillPath(Brush brush, GraphicsPath path);
|
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, 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, PointF point, StringFormat format);
|
||||||
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle);
|
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle);
|
||||||
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format);
|
void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format);
|
||||||
|
|
||||||
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat,
|
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat,
|
||||||
out int charactersFitted, out int linesFilled);
|
out int charactersFitted, out int linesFilled);
|
||||||
|
|
||||||
SizeF MeasureString(string text, Font font, PointF origin, StringFormat stringFormat);
|
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);
|
||||||
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat);
|
SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat);
|
||||||
SizeF MeasureString(string text, Font font);
|
SizeF MeasureString(string text, Font font);
|
||||||
SizeF MeasureString(string text, Font font, int width);
|
SizeF MeasureString(string text, Font font, int width);
|
||||||
SizeF MeasureString(string text, Font font, int width, StringFormat format);
|
SizeF MeasureString(string text, Font font, int width, StringFormat format);
|
||||||
Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat);
|
Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat);
|
||||||
|
|
||||||
void ResetTransform();
|
void ResetTransform();
|
||||||
void MultiplyTransform(Matrix matrix);
|
void MultiplyTransform(Matrix matrix);
|
||||||
void MultiplyTransform(Matrix matrix, MatrixOrder order);
|
void MultiplyTransform(Matrix matrix, MatrixOrder order);
|
||||||
void TranslateTransform(float dx, float dy);
|
void TranslateTransform(float dx, float dy);
|
||||||
void TranslateTransform(float dx, float dy, MatrixOrder order);
|
void TranslateTransform(float dx, float dy, MatrixOrder order);
|
||||||
void ScaleTransform(float sx, float sy);
|
void ScaleTransform(float sx, float sy);
|
||||||
void ScaleTransform(float sx, float sy, MatrixOrder order);
|
void ScaleTransform(float sx, float sy, MatrixOrder order);
|
||||||
void RotateTransform(float angle);
|
void RotateTransform(float angle);
|
||||||
void RotateTransform(float angle, MatrixOrder order);
|
void RotateTransform(float angle, MatrixOrder order);
|
||||||
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts);
|
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts);
|
||||||
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts);
|
void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts);
|
||||||
void SetClip(Graphics g);
|
void SetClip(Graphics g);
|
||||||
void SetClip(Graphics g, CombineMode combineMode);
|
void SetClip(Graphics g, CombineMode combineMode);
|
||||||
void SetClip(Rectangle rect);
|
void SetClip(Rectangle rect);
|
||||||
void SetClip(Rectangle rect, CombineMode combineMode);
|
void SetClip(Rectangle rect, CombineMode combineMode);
|
||||||
void SetClip(RectangleF rect);
|
void SetClip(RectangleF rect);
|
||||||
void SetClip(RectangleF rect, CombineMode combineMode);
|
void SetClip(RectangleF rect, CombineMode combineMode);
|
||||||
void SetClip(GraphicsPath path);
|
void SetClip(GraphicsPath path);
|
||||||
void SetClip(GraphicsPath path, CombineMode combineMode);
|
void SetClip(GraphicsPath path, CombineMode combineMode);
|
||||||
void SetClip(Region region, CombineMode combineMode);
|
void SetClip(Region region, CombineMode combineMode);
|
||||||
void IntersectClip(Rectangle rect);
|
void IntersectClip(Rectangle rect);
|
||||||
void IntersectClip(RectangleF rect);
|
void IntersectClip(RectangleF rect);
|
||||||
void IntersectClip(Region region);
|
void IntersectClip(Region region);
|
||||||
void ExcludeClip(Rectangle rect);
|
void ExcludeClip(Rectangle rect);
|
||||||
void ExcludeClip(Region region);
|
void ExcludeClip(Region region);
|
||||||
void ResetClip();
|
void ResetClip();
|
||||||
void TranslateClip(float dx, float dy);
|
void TranslateClip(float dx, float dy);
|
||||||
void TranslateClip(int dx, int dy);
|
void TranslateClip(int dx, int dy);
|
||||||
bool IsVisible(int x, int y);
|
bool IsVisible(int x, int y);
|
||||||
bool IsVisible(Point point);
|
bool IsVisible(Point point);
|
||||||
bool IsVisible(float x, float y);
|
bool IsVisible(float x, float y);
|
||||||
bool IsVisible(PointF point);
|
bool IsVisible(PointF point);
|
||||||
bool IsVisible(int x, int y, int width, int height);
|
bool IsVisible(int x, int y, int width, int height);
|
||||||
bool IsVisible(Rectangle rect);
|
bool IsVisible(Rectangle rect);
|
||||||
bool IsVisible(float x, float y, float width, float height);
|
bool IsVisible(float x, float y, float width, float height);
|
||||||
bool IsVisible(RectangleF rect);
|
bool IsVisible(RectangleF rect);
|
||||||
CompositingMode CompositingMode { get; set; }
|
CompositingMode CompositingMode { get; set; }
|
||||||
Point RenderingOrigin { get; set; }
|
Point RenderingOrigin { get; set; }
|
||||||
CompositingQuality CompositingQuality { get; set; }
|
CompositingQuality CompositingQuality { get; set; }
|
||||||
TextRenderingHint TextRenderingHint { get; set; }
|
TextRenderingHint TextRenderingHint { get; set; }
|
||||||
int TextContrast { get; set; }
|
int TextContrast { get; set; }
|
||||||
SmoothingMode SmoothingMode { get; set; }
|
SmoothingMode SmoothingMode { get; set; }
|
||||||
PixelOffsetMode PixelOffsetMode { get; set; }
|
PixelOffsetMode PixelOffsetMode { get; set; }
|
||||||
InterpolationMode InterpolationMode { get; set; }
|
InterpolationMode InterpolationMode { get; set; }
|
||||||
Matrix Transform { get; set; }
|
Matrix Transform { get; set; }
|
||||||
GraphicsUnit PageUnit { get; set; }
|
GraphicsUnit PageUnit { get; set; }
|
||||||
float PageScale { get; set; }
|
float PageScale { get; set; }
|
||||||
float DpiX { get; }
|
float DpiX { get; }
|
||||||
float DpiY { get; }
|
float DpiY { get; }
|
||||||
Region Clip { get; set; }
|
Region Clip { get; set; }
|
||||||
RectangleF ClipBounds { get; }
|
RectangleF ClipBounds { get; }
|
||||||
bool IsClipEmpty { get; }
|
bool IsClipEmpty { get; }
|
||||||
RectangleF VisibleClipBounds { get; }
|
RectangleF VisibleClipBounds { get; }
|
||||||
bool IsVisibleClipEmpty { 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
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Super class of all events that originates from the keyboard.
|
/// Super class of all events that originates from the keyboard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public abstract class KeyEvent : Event
|
public abstract class KeyEvent : Event
|
||||||
{
|
{
|
||||||
private readonly char keyChar;
|
private readonly char keyChar;
|
||||||
private readonly int keyCode;
|
private readonly int keyCode;
|
||||||
private readonly int keyLocation;
|
private readonly int keyLocation;
|
||||||
private readonly int id;
|
private readonly int id;
|
||||||
private readonly int modifiersEx;
|
private readonly int modifiersEx;
|
||||||
private readonly long when;
|
private readonly long when;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by game
|
/// Called by game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected KeyEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
protected KeyEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||||
{
|
{
|
||||||
this.keyChar = keyChar;
|
this.keyChar = keyChar;
|
||||||
this.keyCode = keyCode;
|
this.keyCode = keyCode;
|
||||||
this.keyLocation = keyLocation;
|
this.keyLocation = keyLocation;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.modifiersEx = modifiersEx;
|
this.modifiersEx = modifiersEx;
|
||||||
this.when = when;
|
this.when = when;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Char of they key pressed
|
/// Char of they key pressed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public char KeyChar
|
public char KeyChar
|
||||||
{
|
{
|
||||||
get { return keyChar; }
|
get { return keyChar; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Keys"/>
|
/// <see cref="Keys"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int KeyCode
|
public int KeyCode
|
||||||
{
|
{
|
||||||
get { return keyCode; }
|
get { return keyCode; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int KeyLocation
|
internal int KeyLocation
|
||||||
{
|
{
|
||||||
get { return keyLocation; }
|
get { return keyLocation; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int ID
|
internal int ID
|
||||||
{
|
{
|
||||||
get { return id; }
|
get { return id; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int ModifiersEx
|
internal int ModifiersEx
|
||||||
{
|
{
|
||||||
get { return modifiersEx; }
|
get { return modifiersEx; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Age of the event
|
/// Age of the event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long When
|
public long When
|
||||||
{
|
{
|
||||||
get { return when; }
|
get { return when; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,96 +1,96 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A KeyPressedEvent is sent to <see cref="Robot.OnKeyPressed(KeyEvent)"/>
|
/// A KeyPressedEvent is sent to <see cref="Robot.OnKeyPressed(KeyEvent)"/>
|
||||||
/// when a key has been pressed on the keyboard.
|
/// when a key has been pressed on the keyboard.
|
||||||
/// <seealso cref="KeyReleasedEvent"/>
|
/// <seealso cref="KeyReleasedEvent"/>
|
||||||
/// <seealso cref="KeyTypedEvent"/>
|
/// <seealso cref="KeyTypedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class KeyPressedEvent : KeyEvent
|
public sealed class KeyPressedEvent : KeyEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new KeyPressedEvent.
|
/// Called by the game to create a new KeyPressedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public KeyPressedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
public KeyPressedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnKeyPressed(this);
|
listener.OnKeyPressed(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.KeyPressedEvent_TYPE; }
|
get { return RbSerializerN.KeyPressedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||||
RbSerializerN.SIZEOF_INT;
|
RbSerializerN.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (KeyPressedEvent) objec;
|
var obj = (KeyPressedEvent) objec;
|
||||||
serializer.serialize(buffer, obj.KeyChar);
|
serializer.serialize(buffer, obj.KeyChar);
|
||||||
serializer.serialize(buffer, obj.KeyCode);
|
serializer.serialize(buffer, obj.KeyCode);
|
||||||
serializer.serialize(buffer, obj.KeyLocation);
|
serializer.serialize(buffer, obj.KeyLocation);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
char keyChar = buffer.getChar();
|
char keyChar = buffer.getChar();
|
||||||
int keyCode = buffer.getInt();
|
int keyCode = buffer.getInt();
|
||||||
int keyLocation = buffer.getInt();
|
int keyLocation = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
return new KeyPressedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
return new KeyPressedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,98 +1,98 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A KeyReleasedEvent is sent to <see cref="Robot.OnKeyReleased(KeyEvent)"/>
|
/// A KeyReleasedEvent is sent to <see cref="Robot.OnKeyReleased(KeyEvent)"/>
|
||||||
/// when a key has been released on the keyboard.
|
/// when a key has been released on the keyboard.
|
||||||
/// <seealso cref="KeyPressedEvent"/>
|
/// <seealso cref="KeyPressedEvent"/>
|
||||||
/// <seealso cref="KeyTypedEvent"/>
|
/// <seealso cref="KeyTypedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class KeyReleasedEvent : KeyEvent
|
public sealed class KeyReleasedEvent : KeyEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new KeyReleasedEvent.
|
/// Called by the game to create a new KeyReleasedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public KeyReleasedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
public KeyReleasedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnKeyReleased(this);
|
listener.OnKeyReleased(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.KeyReleasedEvent_TYPE; }
|
get { return RbSerializerN.KeyReleasedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||||
RbSerializerN.SIZEOF_INT;
|
RbSerializerN.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (KeyReleasedEvent) objec;
|
var obj = (KeyReleasedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.KeyChar);
|
serializer.serialize(buffer, obj.KeyChar);
|
||||||
serializer.serialize(buffer, obj.KeyCode);
|
serializer.serialize(buffer, obj.KeyCode);
|
||||||
serializer.serialize(buffer, obj.KeyLocation);
|
serializer.serialize(buffer, obj.KeyLocation);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
char keyChar = buffer.getChar();
|
char keyChar = buffer.getChar();
|
||||||
int keyCode = buffer.getInt();
|
int keyCode = buffer.getInt();
|
||||||
int keyLocation = buffer.getInt();
|
int keyLocation = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new KeyReleasedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
return new KeyReleasedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,98 +1,98 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A KeyTypedEvent is sent to <see cref="Robot.OnKeyTyped(KeyEvent)"/>
|
/// A KeyTypedEvent is sent to <see cref="Robot.OnKeyTyped(KeyEvent)"/>
|
||||||
/// when a key has been typed (pressed and released) on the keyboard.
|
/// when a key has been typed (pressed and released) on the keyboard.
|
||||||
/// <seealso cref="KeyPressedEvent"/>
|
/// <seealso cref="KeyPressedEvent"/>
|
||||||
/// <seealso cref="KeyReleasedEvent"/>
|
/// <seealso cref="KeyReleasedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class KeyTypedEvent : KeyEvent
|
public sealed class KeyTypedEvent : KeyEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new KeyTypedEvent.
|
/// Called by the game to create a new KeyTypedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public KeyTypedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
public KeyTypedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when)
|
||||||
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
: base(keyChar, keyCode, keyLocation, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnKeyTyped(this);
|
listener.OnKeyTyped(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.KeyTypedEvent_TYPE; }
|
get { return RbSerializerN.KeyTypedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT
|
||||||
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
+ RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT +
|
||||||
RbSerializerN.SIZEOF_INT;
|
RbSerializerN.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (KeyTypedEvent) objec;
|
var obj = (KeyTypedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.KeyChar);
|
serializer.serialize(buffer, obj.KeyChar);
|
||||||
serializer.serialize(buffer, obj.KeyCode);
|
serializer.serialize(buffer, obj.KeyCode);
|
||||||
serializer.serialize(buffer, obj.KeyLocation);
|
serializer.serialize(buffer, obj.KeyLocation);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
char keyChar = buffer.getChar();
|
char keyChar = buffer.getChar();
|
||||||
int keyCode = buffer.getInt();
|
int keyCode = buffer.getInt();
|
||||||
int keyLocation = buffer.getInt();
|
int keyLocation = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new KeyTypedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
return new KeyTypedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,292 +1,292 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* 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
|
// 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.
|
// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode.
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
public static class Keys
|
public static class Keys
|
||||||
{
|
{
|
||||||
public const int KEY_FIRST = 400;
|
public const int KEY_FIRST = 400;
|
||||||
|
|
||||||
public const int KEY_LAST = 402;
|
public const int KEY_LAST = 402;
|
||||||
|
|
||||||
public const int KEY_TYPED = KEY_FIRST;
|
public const int KEY_TYPED = KEY_FIRST;
|
||||||
|
|
||||||
public const int KEY_PRESSED = 1 + KEY_FIRST;
|
public const int KEY_PRESSED = 1 + KEY_FIRST;
|
||||||
|
|
||||||
public const int KEY_RELEASED = 2 + KEY_FIRST;
|
public const int KEY_RELEASED = 2 + KEY_FIRST;
|
||||||
|
|
||||||
public const int VK_ENTER = 0x0A;
|
public const int VK_ENTER = 0x0A;
|
||||||
public const int VK_BACK_SPACE = 0x20;
|
public const int VK_BACK_SPACE = 0x20;
|
||||||
public const int VK_TAB = 0x08;
|
public const int VK_TAB = 0x08;
|
||||||
public const int VK_CANCEL = 0x03;
|
public const int VK_CANCEL = 0x03;
|
||||||
public const int VK_CLEAR = 0x0C;
|
public const int VK_CLEAR = 0x0C;
|
||||||
public const int VK_SHIFT = 0x10;
|
public const int VK_SHIFT = 0x10;
|
||||||
public const int VK_CONTROL = 0x11;
|
public const int VK_CONTROL = 0x11;
|
||||||
public const int VK_ALT = 0x12;
|
public const int VK_ALT = 0x12;
|
||||||
public const int VK_PAUSE = 0x13;
|
public const int VK_PAUSE = 0x13;
|
||||||
public const int VK_CAPS_LOCK = 0x14;
|
public const int VK_CAPS_LOCK = 0x14;
|
||||||
public const int VK_ESCAPE = 0x1B;
|
public const int VK_ESCAPE = 0x1B;
|
||||||
public const int VK_SPACE = 0x20;
|
public const int VK_SPACE = 0x20;
|
||||||
public const int VK_PAGE_UP = 0x21;
|
public const int VK_PAGE_UP = 0x21;
|
||||||
public const int VK_PAGE_DOWN = 0x22;
|
public const int VK_PAGE_DOWN = 0x22;
|
||||||
public const int VK_END = 0x23;
|
public const int VK_END = 0x23;
|
||||||
public const int VK_HOME = 0x24;
|
public const int VK_HOME = 0x24;
|
||||||
|
|
||||||
public const int VK_LEFT = 0x25;
|
public const int VK_LEFT = 0x25;
|
||||||
|
|
||||||
public const int VK_UP = 0x26;
|
public const int VK_UP = 0x26;
|
||||||
|
|
||||||
public const int VK_RIGHT = 0x27;
|
public const int VK_RIGHT = 0x27;
|
||||||
|
|
||||||
public const int VK_DOWN = 0x28;
|
public const int VK_DOWN = 0x28;
|
||||||
|
|
||||||
public const int VK_COMMA = 0x2C;
|
public const int VK_COMMA = 0x2C;
|
||||||
|
|
||||||
public const int VK_MINUS = 0x2D;
|
public const int VK_MINUS = 0x2D;
|
||||||
|
|
||||||
public const int VK_PERIOD = 0x2E;
|
public const int VK_PERIOD = 0x2E;
|
||||||
|
|
||||||
public const int VK_SLASH = 0x2F;
|
public const int VK_SLASH = 0x2F;
|
||||||
|
|
||||||
public const int VK_0 = 0x30;
|
public const int VK_0 = 0x30;
|
||||||
public const int VK_1 = 0x31;
|
public const int VK_1 = 0x31;
|
||||||
public const int VK_2 = 0x32;
|
public const int VK_2 = 0x32;
|
||||||
public const int VK_3 = 0x33;
|
public const int VK_3 = 0x33;
|
||||||
public const int VK_4 = 0x34;
|
public const int VK_4 = 0x34;
|
||||||
public const int VK_5 = 0x35;
|
public const int VK_5 = 0x35;
|
||||||
public const int VK_6 = 0x36;
|
public const int VK_6 = 0x36;
|
||||||
public const int VK_7 = 0x37;
|
public const int VK_7 = 0x37;
|
||||||
public const int VK_8 = 0x38;
|
public const int VK_8 = 0x38;
|
||||||
public const int VK_9 = 0x39;
|
public const int VK_9 = 0x39;
|
||||||
|
|
||||||
public const int VK_SEMICOLON = 0x3B;
|
public const int VK_SEMICOLON = 0x3B;
|
||||||
|
|
||||||
public const int VK_EQUALS = 0x3D;
|
public const int VK_EQUALS = 0x3D;
|
||||||
|
|
||||||
public const int VK_A = 0x41;
|
public const int VK_A = 0x41;
|
||||||
public const int VK_B = 0x42;
|
public const int VK_B = 0x42;
|
||||||
public const int VK_C = 0x43;
|
public const int VK_C = 0x43;
|
||||||
public const int VK_D = 0x44;
|
public const int VK_D = 0x44;
|
||||||
public const int VK_E = 0x45;
|
public const int VK_E = 0x45;
|
||||||
public const int VK_F = 0x46;
|
public const int VK_F = 0x46;
|
||||||
public const int VK_G = 0x47;
|
public const int VK_G = 0x47;
|
||||||
public const int VK_H = 0x48;
|
public const int VK_H = 0x48;
|
||||||
public const int VK_I = 0x49;
|
public const int VK_I = 0x49;
|
||||||
public const int VK_J = 0x4A;
|
public const int VK_J = 0x4A;
|
||||||
public const int VK_K = 0x4B;
|
public const int VK_K = 0x4B;
|
||||||
public const int VK_L = 0x4C;
|
public const int VK_L = 0x4C;
|
||||||
public const int VK_M = 0x4D;
|
public const int VK_M = 0x4D;
|
||||||
public const int VK_N = 0x4E;
|
public const int VK_N = 0x4E;
|
||||||
public const int VK_O = 0x4F;
|
public const int VK_O = 0x4F;
|
||||||
public const int VK_P = 0x50;
|
public const int VK_P = 0x50;
|
||||||
public const int VK_Q = 0x51;
|
public const int VK_Q = 0x51;
|
||||||
public const int VK_R = 0x52;
|
public const int VK_R = 0x52;
|
||||||
public const int VK_S = 0x53;
|
public const int VK_S = 0x53;
|
||||||
public const int VK_T = 0x54;
|
public const int VK_T = 0x54;
|
||||||
public const int VK_U = 0x55;
|
public const int VK_U = 0x55;
|
||||||
public const int VK_V = 0x56;
|
public const int VK_V = 0x56;
|
||||||
public const int VK_W = 0x57;
|
public const int VK_W = 0x57;
|
||||||
public const int VK_X = 0x58;
|
public const int VK_X = 0x58;
|
||||||
public const int VK_Y = 0x59;
|
public const int VK_Y = 0x59;
|
||||||
public const int VK_Z = 0x5A;
|
public const int VK_Z = 0x5A;
|
||||||
|
|
||||||
public const int VK_OPEN_BRACKET = 0x5B;
|
public const int VK_OPEN_BRACKET = 0x5B;
|
||||||
|
|
||||||
public const int VK_BACK_SLASH = 0x5C;
|
public const int VK_BACK_SLASH = 0x5C;
|
||||||
|
|
||||||
public const int VK_CLOSE_BRACKET = 0x5D;
|
public const int VK_CLOSE_BRACKET = 0x5D;
|
||||||
|
|
||||||
public const int VK_NUMPAD0 = 0x60;
|
public const int VK_NUMPAD0 = 0x60;
|
||||||
public const int VK_NUMPAD1 = 0x61;
|
public const int VK_NUMPAD1 = 0x61;
|
||||||
public const int VK_NUMPAD2 = 0x62;
|
public const int VK_NUMPAD2 = 0x62;
|
||||||
public const int VK_NUMPAD3 = 0x63;
|
public const int VK_NUMPAD3 = 0x63;
|
||||||
public const int VK_NUMPAD4 = 0x64;
|
public const int VK_NUMPAD4 = 0x64;
|
||||||
public const int VK_NUMPAD5 = 0x65;
|
public const int VK_NUMPAD5 = 0x65;
|
||||||
public const int VK_NUMPAD6 = 0x66;
|
public const int VK_NUMPAD6 = 0x66;
|
||||||
public const int VK_NUMPAD7 = 0x67;
|
public const int VK_NUMPAD7 = 0x67;
|
||||||
public const int VK_NUMPAD8 = 0x68;
|
public const int VK_NUMPAD8 = 0x68;
|
||||||
public const int VK_NUMPAD9 = 0x69;
|
public const int VK_NUMPAD9 = 0x69;
|
||||||
public const int VK_MULTIPLY = 0x6A;
|
public const int VK_MULTIPLY = 0x6A;
|
||||||
public const int VK_ADD = 0x6B;
|
public const int VK_ADD = 0x6B;
|
||||||
|
|
||||||
public const int VK_SEPARATER = 0x6C;
|
public const int VK_SEPARATER = 0x6C;
|
||||||
|
|
||||||
public const int VK_SEPARATOR = VK_SEPARATER;
|
public const int VK_SEPARATOR = VK_SEPARATER;
|
||||||
|
|
||||||
public const int VK_SUBTRACT = 0x6D;
|
public const int VK_SUBTRACT = 0x6D;
|
||||||
public const int VK_DECIMAL = 0x6E;
|
public const int VK_DECIMAL = 0x6E;
|
||||||
public const int VK_DIVIDE = 0x6F;
|
public const int VK_DIVIDE = 0x6F;
|
||||||
public const int VK_DELETE = 0x7F;
|
public const int VK_DELETE = 0x7F;
|
||||||
public const int VK_NUM_LOCK = 0x90;
|
public const int VK_NUM_LOCK = 0x90;
|
||||||
public const int VK_SCROLL_LOCK = 0x91;
|
public const int VK_SCROLL_LOCK = 0x91;
|
||||||
|
|
||||||
public const int VK_F1 = 0x70;
|
public const int VK_F1 = 0x70;
|
||||||
|
|
||||||
public const int VK_F2 = 0x71;
|
public const int VK_F2 = 0x71;
|
||||||
|
|
||||||
public const int VK_F3 = 0x72;
|
public const int VK_F3 = 0x72;
|
||||||
|
|
||||||
public const int VK_F4 = 0x73;
|
public const int VK_F4 = 0x73;
|
||||||
|
|
||||||
public const int VK_F5 = 0x74;
|
public const int VK_F5 = 0x74;
|
||||||
|
|
||||||
public const int VK_F6 = 0x75;
|
public const int VK_F6 = 0x75;
|
||||||
|
|
||||||
public const int VK_F7 = 0x76;
|
public const int VK_F7 = 0x76;
|
||||||
|
|
||||||
public const int VK_F8 = 0x77;
|
public const int VK_F8 = 0x77;
|
||||||
|
|
||||||
public const int VK_F9 = 0x78;
|
public const int VK_F9 = 0x78;
|
||||||
|
|
||||||
public const int VK_F10 = 0x79;
|
public const int VK_F10 = 0x79;
|
||||||
|
|
||||||
public const int VK_F11 = 0x7A;
|
public const int VK_F11 = 0x7A;
|
||||||
|
|
||||||
public const int VK_F12 = 0x7B;
|
public const int VK_F12 = 0x7B;
|
||||||
|
|
||||||
public const int VK_F13 = 0xF000;
|
public const int VK_F13 = 0xF000;
|
||||||
|
|
||||||
public const int VK_F14 = 0xF001;
|
public const int VK_F14 = 0xF001;
|
||||||
|
|
||||||
public const int VK_F15 = 0xF002;
|
public const int VK_F15 = 0xF002;
|
||||||
|
|
||||||
public const int VK_F16 = 0xF003;
|
public const int VK_F16 = 0xF003;
|
||||||
|
|
||||||
public const int VK_F17 = 0xF004;
|
public const int VK_F17 = 0xF004;
|
||||||
|
|
||||||
public const int VK_F18 = 0xF005;
|
public const int VK_F18 = 0xF005;
|
||||||
|
|
||||||
public const int VK_F19 = 0xF006;
|
public const int VK_F19 = 0xF006;
|
||||||
|
|
||||||
public const int VK_F20 = 0xF007;
|
public const int VK_F20 = 0xF007;
|
||||||
|
|
||||||
public const int VK_F21 = 0xF008;
|
public const int VK_F21 = 0xF008;
|
||||||
|
|
||||||
public const int VK_F22 = 0xF009;
|
public const int VK_F22 = 0xF009;
|
||||||
|
|
||||||
public const int VK_F23 = 0xF00A;
|
public const int VK_F23 = 0xF00A;
|
||||||
|
|
||||||
public const int VK_F24 = 0xF00B;
|
public const int VK_F24 = 0xF00B;
|
||||||
|
|
||||||
public const int VK_PRINTSCREEN = 0x9A;
|
public const int VK_PRINTSCREEN = 0x9A;
|
||||||
public const int VK_INSERT = 0x9B;
|
public const int VK_INSERT = 0x9B;
|
||||||
public const int VK_HELP = 0x9C;
|
public const int VK_HELP = 0x9C;
|
||||||
public const int VK_META = 0x9D;
|
public const int VK_META = 0x9D;
|
||||||
|
|
||||||
public const int VK_BACK_QUOTE = 0xC0;
|
public const int VK_BACK_QUOTE = 0xC0;
|
||||||
public const int VK_QUOTE = 0xDE;
|
public const int VK_QUOTE = 0xDE;
|
||||||
|
|
||||||
public const int VK_KP_UP = 0xE0;
|
public const int VK_KP_UP = 0xE0;
|
||||||
|
|
||||||
public const int VK_KP_DOWN = 0xE1;
|
public const int VK_KP_DOWN = 0xE1;
|
||||||
|
|
||||||
public const int VK_KP_LEFT = 0xE2;
|
public const int VK_KP_LEFT = 0xE2;
|
||||||
|
|
||||||
public const int VK_KP_RIGHT = 0xE3;
|
public const int VK_KP_RIGHT = 0xE3;
|
||||||
|
|
||||||
public const int VK_DEAD_GRAVE = 0x80;
|
public const int VK_DEAD_GRAVE = 0x80;
|
||||||
public const int VK_DEAD_ACUTE = 0x81;
|
public const int VK_DEAD_ACUTE = 0x81;
|
||||||
public const int VK_DEAD_CIRCUMFLEX = 0x82;
|
public const int VK_DEAD_CIRCUMFLEX = 0x82;
|
||||||
public const int VK_DEAD_TILDE = 0x83;
|
public const int VK_DEAD_TILDE = 0x83;
|
||||||
public const int VK_DEAD_MACRON = 0x84;
|
public const int VK_DEAD_MACRON = 0x84;
|
||||||
public const int VK_DEAD_BREVE = 0x85;
|
public const int VK_DEAD_BREVE = 0x85;
|
||||||
public const int VK_DEAD_ABOVEDOT = 0x86;
|
public const int VK_DEAD_ABOVEDOT = 0x86;
|
||||||
public const int VK_DEAD_DIAERESIS = 0x87;
|
public const int VK_DEAD_DIAERESIS = 0x87;
|
||||||
public const int VK_DEAD_ABOVERING = 0x88;
|
public const int VK_DEAD_ABOVERING = 0x88;
|
||||||
public const int VK_DEAD_DOUBLEACUTE = 0x89;
|
public const int VK_DEAD_DOUBLEACUTE = 0x89;
|
||||||
public const int VK_DEAD_CARON = 0x8a;
|
public const int VK_DEAD_CARON = 0x8a;
|
||||||
public const int VK_DEAD_CEDILLA = 0x8b;
|
public const int VK_DEAD_CEDILLA = 0x8b;
|
||||||
public const int VK_DEAD_OGONEK = 0x8c;
|
public const int VK_DEAD_OGONEK = 0x8c;
|
||||||
public const int VK_DEAD_IOTA = 0x8d;
|
public const int VK_DEAD_IOTA = 0x8d;
|
||||||
public const int VK_DEAD_VOICED_SOUND = 0x8e;
|
public const int VK_DEAD_VOICED_SOUND = 0x8e;
|
||||||
public const int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
|
public const int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
|
||||||
|
|
||||||
public const int VK_AMPERSAND = 0x96;
|
public const int VK_AMPERSAND = 0x96;
|
||||||
public const int VK_ASTERISK = 0x97;
|
public const int VK_ASTERISK = 0x97;
|
||||||
public const int VK_QUOTEDBL = 0x98;
|
public const int VK_QUOTEDBL = 0x98;
|
||||||
public const int VK_LESS = 0x99;
|
public const int VK_LESS = 0x99;
|
||||||
public const int VK_GREATER = 0xa0;
|
public const int VK_GREATER = 0xa0;
|
||||||
public const int VK_BRACELEFT = 0xa1;
|
public const int VK_BRACELEFT = 0xa1;
|
||||||
public const int VK_BRACERIGHT = 0xa2;
|
public const int VK_BRACERIGHT = 0xa2;
|
||||||
|
|
||||||
public const int VK_AT = 0x0200;
|
public const int VK_AT = 0x0200;
|
||||||
public const int VK_COLON = 0x0201;
|
public const int VK_COLON = 0x0201;
|
||||||
public const int VK_CIRCUMFLEX = 0x0202;
|
public const int VK_CIRCUMFLEX = 0x0202;
|
||||||
public const int VK_DOLLAR = 0x0203;
|
public const int VK_DOLLAR = 0x0203;
|
||||||
public const int VK_EURO_SIGN = 0x0204;
|
public const int VK_EURO_SIGN = 0x0204;
|
||||||
|
|
||||||
public const int VK_EXCLAMATION_MARK = 0x0205;
|
public const int VK_EXCLAMATION_MARK = 0x0205;
|
||||||
public const int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
|
public const int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
|
||||||
public const int VK_LEFT_PARENTHESIS = 0x0207;
|
public const int VK_LEFT_PARENTHESIS = 0x0207;
|
||||||
public const int VK_NUMBER_SIGN = 0x0208;
|
public const int VK_NUMBER_SIGN = 0x0208;
|
||||||
public const int VK_PLUS = 0x0209;
|
public const int VK_PLUS = 0x0209;
|
||||||
public const int VK_RIGHT_PARENTHESIS = 0x020A;
|
public const int VK_RIGHT_PARENTHESIS = 0x020A;
|
||||||
public const int VK_UNDERSCORE = 0x020B;
|
public const int VK_UNDERSCORE = 0x020B;
|
||||||
public const int VK_WINDOWS = 0x020C;
|
public const int VK_WINDOWS = 0x020C;
|
||||||
public const int VK_CONTEXT_MENU = 0x020D;
|
public const int VK_CONTEXT_MENU = 0x020D;
|
||||||
public const int VK_const = 0x0018;
|
public const int VK_const = 0x0018;
|
||||||
public const int VK_CONVERT = 0x001C;
|
public const int VK_CONVERT = 0x001C;
|
||||||
public const int VK_NONCONVERT = 0x001D;
|
public const int VK_NONCONVERT = 0x001D;
|
||||||
public const int VK_ACCEPT = 0x001E;
|
public const int VK_ACCEPT = 0x001E;
|
||||||
public const int VK_MODECHANGE = 0x001F;
|
public const int VK_MODECHANGE = 0x001F;
|
||||||
public const int VK_KANA = 0x0015;
|
public const int VK_KANA = 0x0015;
|
||||||
public const int VK_KANJI = 0x0019;
|
public const int VK_KANJI = 0x0019;
|
||||||
public const int VK_ALPHANUMERIC = 0x00F0;
|
public const int VK_ALPHANUMERIC = 0x00F0;
|
||||||
public const int VK_KATAKANA = 0x00F1;
|
public const int VK_KATAKANA = 0x00F1;
|
||||||
public const int VK_HIRAGANA = 0x00F2;
|
public const int VK_HIRAGANA = 0x00F2;
|
||||||
public const int VK_FULL_WIDTH = 0x00F3;
|
public const int VK_FULL_WIDTH = 0x00F3;
|
||||||
public const int VK_HALF_WIDTH = 0x00F4;
|
public const int VK_HALF_WIDTH = 0x00F4;
|
||||||
public const int VK_ROMAN_CHARACTERS = 0x00F5;
|
public const int VK_ROMAN_CHARACTERS = 0x00F5;
|
||||||
public const int VK_ALL_CANDIDATES = 0x0100;
|
public const int VK_ALL_CANDIDATES = 0x0100;
|
||||||
public const int VK_PREVIOUS_CANDIDATE = 0x0101;
|
public const int VK_PREVIOUS_CANDIDATE = 0x0101;
|
||||||
public const int VK_CODE_INPUT = 0x0102;
|
public const int VK_CODE_INPUT = 0x0102;
|
||||||
public const int VK_JAPANESE_KATAKANA = 0x0103;
|
public const int VK_JAPANESE_KATAKANA = 0x0103;
|
||||||
public const int VK_JAPANESE_HIRAGANA = 0x0104;
|
public const int VK_JAPANESE_HIRAGANA = 0x0104;
|
||||||
public const int VK_JAPANESE_ROMAN = 0x0105;
|
public const int VK_JAPANESE_ROMAN = 0x0105;
|
||||||
public const int VK_KANA_LOCK = 0x0106;
|
public const int VK_KANA_LOCK = 0x0106;
|
||||||
public const int VK_INPUT_METHOD_ON_OFF = 0x0107;
|
public const int VK_INPUT_METHOD_ON_OFF = 0x0107;
|
||||||
public const int VK_CUT = 0xFFD1;
|
public const int VK_CUT = 0xFFD1;
|
||||||
public const int VK_COPY = 0xFFCD;
|
public const int VK_COPY = 0xFFCD;
|
||||||
public const int VK_PASTE = 0xFFCF;
|
public const int VK_PASTE = 0xFFCF;
|
||||||
public const int VK_UNDO = 0xFFCB;
|
public const int VK_UNDO = 0xFFCB;
|
||||||
public const int VK_AGAIN = 0xFFC9;
|
public const int VK_AGAIN = 0xFFC9;
|
||||||
public const int VK_FIND = 0xFFD0;
|
public const int VK_FIND = 0xFFD0;
|
||||||
public const int VK_PROPS = 0xFFCA;
|
public const int VK_PROPS = 0xFFCA;
|
||||||
public const int VK_STOP = 0xFFC8;
|
public const int VK_STOP = 0xFFC8;
|
||||||
public const int VK_COMPOSE = 0xFF20;
|
public const int VK_COMPOSE = 0xFF20;
|
||||||
public const int VK_ALT_GRAPH = 0xFF7E;
|
public const int VK_ALT_GRAPH = 0xFF7E;
|
||||||
public const int VK_BEGIN = 0xFF58;
|
public const int VK_BEGIN = 0xFF58;
|
||||||
public const int VK_UNDEFINED = 0x0;
|
public const int VK_UNDEFINED = 0x0;
|
||||||
public const int KEY_LOCATION_UNKNOWN = 0;
|
public const int KEY_LOCATION_UNKNOWN = 0;
|
||||||
public const int KEY_LOCATION_STANDARD = 1;
|
public const int KEY_LOCATION_STANDARD = 1;
|
||||||
public const int KEY_LOCATION_LEFT = 2;
|
public const int KEY_LOCATION_LEFT = 2;
|
||||||
public const int KEY_LOCATION_RIGHT = 3;
|
public const int KEY_LOCATION_RIGHT = 3;
|
||||||
public const int KEY_LOCATION_NUMPAD = 4;
|
public const int KEY_LOCATION_NUMPAD = 4;
|
||||||
public static readonly char CHAR_UNDEFINED = (char) 0xFFFF;
|
public static readonly char CHAR_UNDEFINED = (char) 0xFFFF;
|
||||||
public const int MOUSE_FIRST = 500;
|
public const int MOUSE_FIRST = 500;
|
||||||
public const int MOUSE_LAST = 507;
|
public const int MOUSE_LAST = 507;
|
||||||
public const int MOUSE_CLICKED = MOUSE_FIRST;
|
public const int MOUSE_CLICKED = MOUSE_FIRST;
|
||||||
public const int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN
|
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_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP
|
||||||
public const int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE
|
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_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER
|
||||||
public const int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT
|
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_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG
|
||||||
public const int MOUSE_WHEEL = 7 + MOUSE_FIRST;
|
public const int MOUSE_WHEEL = 7 + MOUSE_FIRST;
|
||||||
public const int NOBUTTON = 0;
|
public const int NOBUTTON = 0;
|
||||||
public const int BUTTON1 = 1;
|
public const int BUTTON1 = 1;
|
||||||
public const int BUTTON2 = 2;
|
public const int BUTTON2 = 2;
|
||||||
public const int BUTTON3 = 3;
|
public const int BUTTON3 = 3;
|
||||||
|
|
||||||
}
|
}
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MessageEvent is sent to <see cref="TeamRobot.OnMessageReceived(MessageEvent)"/>
|
/// A MessageEvent is sent to <see cref="TeamRobot.OnMessageReceived(MessageEvent)"/>
|
||||||
/// when a teammate sends a message to your robot.
|
/// when a teammate sends a message to your robot.
|
||||||
/// You can use the information contained in this event to determine what to do.
|
/// You can use the information contained in this event to determine what to do.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MessageEvent : Event
|
public sealed class MessageEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 75;
|
private const int DEFAULT_PRIORITY = 75;
|
||||||
|
|
||||||
private readonly string sender;
|
private readonly string sender;
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private readonly object message;
|
private readonly object message;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MessageEvent.
|
/// Called by the game to create a new MessageEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MessageEvent(string sender, object message)
|
public MessageEvent(string sender, object message)
|
||||||
{
|
{
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the sending robot.
|
/// Returns the name of the sending robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Sender
|
public string Sender
|
||||||
{
|
{
|
||||||
get { return sender; }
|
get { return sender; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the message itself.
|
/// Returns the message itself.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Message
|
public object Message
|
||||||
{
|
{
|
||||||
get { return message; }
|
get { return message; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsTeamRobot())
|
if (statics.IsTeamRobot())
|
||||||
{
|
{
|
||||||
ITeamEvents listener = ((ITeamRobot) robot).GetTeamEventListener();
|
ITeamEvents listener = ((ITeamRobot) robot).GetTeamEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMessageReceived(this);
|
listener.OnMessageReceived(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { throw new System.Exception("Serialization of event type not supported"); }
|
get { throw new System.Exception("Serialization of event type not supported"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,103 +1,103 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseClickedEvent is sent to <see cref="Robot.OnMouseClicked(MouseEvent)"/>
|
/// A MouseClickedEvent is sent to <see cref="Robot.OnMouseClicked(MouseEvent)"/>
|
||||||
/// when the mouse is clicked inside the battle view.
|
/// when the mouse is clicked inside the battle view.
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseClickedEvent : MouseEvent
|
public sealed class MouseClickedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseClickedEvent.
|
/// Called by the game to create a new MouseClickedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseClickedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MouseClickedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseClicked(this);
|
listener.OnMouseClicked(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseClickedEvent_TYPE; }
|
get { return RbSerializerN.MouseClickedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseClickedEvent) objec;
|
var obj = (MouseClickedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseClickedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MouseClickedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,103 +1,103 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseDraggedEvent is sent to <see cref="Robot.OnMouseDragged(MouseEvent)"/>
|
/// A MouseDraggedEvent is sent to <see cref="Robot.OnMouseDragged(MouseEvent)"/>
|
||||||
/// when the mouse is dragged inside the battle view.
|
/// when the mouse is dragged inside the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseDraggedEvent : MouseEvent
|
public sealed class MouseDraggedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseDraggedEvent.
|
/// Called by the game to create a new MouseDraggedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseDraggedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MouseDraggedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseDragged(this);
|
listener.OnMouseDragged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseDraggedEvent_TYPE; }
|
get { return RbSerializerN.MouseDraggedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseDraggedEvent) objec;
|
var obj = (MouseDraggedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseDraggedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MouseDraggedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,104 +1,104 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseEnteredEvent is sent to <see cref="Robot.OnMouseEntered(MouseEvent)"/>
|
/// A MouseEnteredEvent is sent to <see cref="Robot.OnMouseEntered(MouseEvent)"/>
|
||||||
/// when the mouse has entered the battle view.
|
/// when the mouse has entered the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseEnteredEvent : MouseEvent
|
public sealed class MouseEnteredEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseDraggedEvent.
|
/// Called by the game to create a new MouseDraggedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseEnteredEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MouseEnteredEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseEntered(this);
|
listener.OnMouseEntered(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseEnteredEvent_TYPE; }
|
get { return RbSerializerN.MouseEnteredEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseEnteredEvent)objec;
|
var obj = (MouseEnteredEvent)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseEnteredEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MouseEnteredEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,91 +1,91 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Super class of all events that originates from the mouse.
|
/// Super class of all events that originates from the mouse.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public abstract class MouseEvent : Event
|
public abstract class MouseEvent : Event
|
||||||
{
|
{
|
||||||
private readonly int button;
|
private readonly int button;
|
||||||
private readonly int clickCount;
|
private readonly int clickCount;
|
||||||
private readonly int x;
|
private readonly int x;
|
||||||
private readonly int y;
|
private readonly int y;
|
||||||
private readonly int id;
|
private readonly int id;
|
||||||
private readonly int modifiersEx;
|
private readonly int modifiersEx;
|
||||||
private readonly long when;
|
private readonly long when;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseEvent.
|
/// Called by the game to create a new MouseEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected MouseEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
protected MouseEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
{
|
{
|
||||||
this.button = button;
|
this.button = button;
|
||||||
this.clickCount = clickCount;
|
this.clickCount = clickCount;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.modifiersEx = modifiersEx;
|
this.modifiersEx = modifiersEx;
|
||||||
this.when = when;
|
this.when = when;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of the button
|
/// Number of the button
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Button
|
public int Button
|
||||||
{
|
{
|
||||||
get { return button; }
|
get { return button; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Click count
|
/// Click count
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ClickCount
|
public int ClickCount
|
||||||
{
|
{
|
||||||
get { return clickCount; }
|
get { return clickCount; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cursor coordinates
|
/// Cursor coordinates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int X
|
public int X
|
||||||
{
|
{
|
||||||
get { return x; }
|
get { return x; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cursor coordinates
|
/// Cursor coordinates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Y
|
public int Y
|
||||||
{
|
{
|
||||||
get { return y; }
|
get { return y; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int ID
|
internal int ID
|
||||||
{
|
{
|
||||||
get { return id; }
|
get { return id; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int ModifiersEx
|
internal int ModifiersEx
|
||||||
{
|
{
|
||||||
get { return modifiersEx; }
|
get { return modifiersEx; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Age of the event
|
/// Age of the event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long When
|
public long When
|
||||||
{
|
{
|
||||||
get { return when; }
|
get { return when; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,103 +1,103 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseExitedEvent is sent to <see cref="Robot.OnMouseExited(MouseEvent)"/>
|
/// A MouseExitedEvent is sent to <see cref="Robot.OnMouseExited(MouseEvent)"/>
|
||||||
/// when the mouse has exited the battle view.
|
/// when the mouse has exited the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseExitedEvent : MouseEvent
|
public sealed class MouseExitedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseDraggedEvent.
|
/// Called by the game to create a new MouseDraggedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseExitedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MouseExitedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseExited(this);
|
listener.OnMouseExited(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseExitedEvent_TYPE; }
|
get { return RbSerializerN.MouseExitedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseExitedEvent)objec;
|
var obj = (MouseExitedEvent)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseExitedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MouseExitedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,104 +1,104 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseMovedEvent is sent to <see cref="Robot.OnMouseMoved(MouseEvent)"/>
|
/// A MouseMovedEvent is sent to <see cref="Robot.OnMouseMoved(MouseEvent)"/>
|
||||||
/// when the mouse has moved inside the battle view.
|
/// when the mouse has moved inside the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseMovedEvent : MouseEvent
|
public sealed class MouseMovedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseDraggedEvent.
|
/// Called by the game to create a new MouseDraggedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseMovedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MouseMovedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseMoved(this);
|
listener.OnMouseMoved(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseMovedEvent_TYPE; }
|
get { return RbSerializerN.MouseMovedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseMovedEvent)objec;
|
var obj = (MouseMovedEvent)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseMovedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MouseMovedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,105 +1,105 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MousePressedEvent is sent to <see cref="Robot.OnMousePressed(MouseEvent)"/>
|
/// A MousePressedEvent is sent to <see cref="Robot.OnMousePressed(MouseEvent)"/>
|
||||||
/// when the mouse is pressed inside the battle view.
|
/// when the mouse is pressed inside the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MousePressedEvent : MouseEvent
|
public sealed class MousePressedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseDraggedEvent.
|
/// Called by the game to create a new MouseDraggedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MousePressedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MousePressedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMousePressed(this);
|
listener.OnMousePressed(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MousePressedEvent_TYPE; }
|
get { return RbSerializerN.MousePressedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MousePressedEvent)objec;
|
var obj = (MousePressedEvent)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MousePressedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MousePressedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,104 +1,104 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseReleasedEvent is sent to <see cref="Robot.OnMouseReleased(MouseEvent)"/>
|
/// A MouseReleasedEvent is sent to <see cref="Robot.OnMouseReleased(MouseEvent)"/>
|
||||||
/// when the mouse is released inside the battle view.
|
/// when the mouse is released inside the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// <seealso cref="MouseWheelMovedEvent"/>
|
/// <seealso cref="MouseWheelMovedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseReleasedEvent : MouseEvent
|
public sealed class MouseReleasedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseDraggedEvent.
|
/// Called by the game to create a new MouseDraggedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseReleasedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
public MouseReleasedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when)
|
||||||
: base(button, clickCount, x, y, id, modifiersEx, when)
|
: base(button, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseReleased(this);
|
listener.OnMouseReleased(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseReleasedEvent_TYPE; }
|
get { return RbSerializerN.MouseReleasedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseReleasedEvent)objec;
|
var obj = (MouseReleasedEvent)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.Button);
|
serializer.serialize(buffer, obj.Button);
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int button = buffer.getInt();
|
int button = buffer.getInt();
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseReleasedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
return new MouseReleasedEvent(button, clickCount, x, y, id, modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,134 +1,134 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MouseWheelMovedEvent is sent to <see cref="Robot.OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// A MouseWheelMovedEvent is sent to <see cref="Robot.OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// when the mouse wheel is rotated inside the battle view.
|
/// when the mouse wheel is rotated inside the battle view.
|
||||||
/// <seealso cref="MouseClickedEvent"/>
|
/// <seealso cref="MouseClickedEvent"/>
|
||||||
/// <seealso cref="MousePressedEvent"/>
|
/// <seealso cref="MousePressedEvent"/>
|
||||||
/// <seealso cref="MouseReleasedEvent"/>
|
/// <seealso cref="MouseReleasedEvent"/>
|
||||||
/// <seealso cref="MouseEnteredEvent"/>
|
/// <seealso cref="MouseEnteredEvent"/>
|
||||||
/// <seealso cref="MouseExitedEvent"/>
|
/// <seealso cref="MouseExitedEvent"/>
|
||||||
/// <seealso cref="MouseMovedEvent"/>
|
/// <seealso cref="MouseMovedEvent"/>
|
||||||
/// <seealso cref="MouseDraggedEvent"/>
|
/// <seealso cref="MouseDraggedEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class MouseWheelMovedEvent : MouseEvent
|
public sealed class MouseWheelMovedEvent : MouseEvent
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 98;
|
private const int DEFAULT_PRIORITY = 98;
|
||||||
private readonly int scrollType;
|
private readonly int scrollType;
|
||||||
private readonly int scrollAmount;
|
private readonly int scrollAmount;
|
||||||
private readonly int wheelRotation;
|
private readonly int wheelRotation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new MouseWheelMovedEvent.
|
/// Called by the game to create a new MouseWheelMovedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseWheelMovedEvent(int clickCount, int x, int y, int scrollType, int scrollAmount, int wheelRotation,
|
public MouseWheelMovedEvent(int clickCount, int x, int y, int scrollType, int scrollAmount, int wheelRotation,
|
||||||
int id, int modifiersEx, long when)
|
int id, int modifiersEx, long when)
|
||||||
: base(-1, clickCount, x, y, id, modifiersEx, when)
|
: base(-1, clickCount, x, y, id, modifiersEx, when)
|
||||||
{
|
{
|
||||||
this.scrollType = scrollType;
|
this.scrollType = scrollType;
|
||||||
this.scrollAmount = scrollAmount;
|
this.scrollAmount = scrollAmount;
|
||||||
this.wheelRotation = wheelRotation;
|
this.wheelRotation = wheelRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int ScrollType
|
internal int ScrollType
|
||||||
{
|
{
|
||||||
get { return scrollType; }
|
get { return scrollType; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int ScrollAmount
|
internal int ScrollAmount
|
||||||
{
|
{
|
||||||
get { return scrollAmount; }
|
get { return scrollAmount; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates how far the mouse wheel was rotated.
|
/// Indicates how far the mouse wheel was rotated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int WheelRotation
|
public int WheelRotation
|
||||||
{
|
{
|
||||||
get { return wheelRotation; }
|
get { return wheelRotation; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsInteractiveRobot())
|
if (statics.IsInteractiveRobot())
|
||||||
{
|
{
|
||||||
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnMouseWheelMoved(this);
|
listener.OnMouseWheelMoved(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.MouseWheelMovedEvent_TYPE; }
|
get { return RbSerializerN.MouseWheelMovedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 8*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + 8*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (MouseWheelMovedEvent) objec;
|
var obj = (MouseWheelMovedEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.ClickCount);
|
serializer.serialize(buffer, obj.ClickCount);
|
||||||
serializer.serialize(buffer, obj.X);
|
serializer.serialize(buffer, obj.X);
|
||||||
serializer.serialize(buffer, obj.Y);
|
serializer.serialize(buffer, obj.Y);
|
||||||
serializer.serialize(buffer, obj.ScrollType);
|
serializer.serialize(buffer, obj.ScrollType);
|
||||||
serializer.serialize(buffer, obj.ScrollAmount);
|
serializer.serialize(buffer, obj.ScrollAmount);
|
||||||
serializer.serialize(buffer, obj.WheelRotation);
|
serializer.serialize(buffer, obj.WheelRotation);
|
||||||
serializer.serialize(buffer, obj.ID);
|
serializer.serialize(buffer, obj.ID);
|
||||||
serializer.serialize(buffer, obj.ModifiersEx);
|
serializer.serialize(buffer, obj.ModifiersEx);
|
||||||
serializer.serialize(buffer, obj.When);
|
serializer.serialize(buffer, obj.When);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int clickCount = buffer.getInt();
|
int clickCount = buffer.getInt();
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
int scrollType = buffer.getInt();
|
int scrollType = buffer.getInt();
|
||||||
int scrollAmount = buffer.getInt();
|
int scrollAmount = buffer.getInt();
|
||||||
int wheelRotation = buffer.getInt();
|
int wheelRotation = buffer.getInt();
|
||||||
int id = buffer.getInt();
|
int id = buffer.getInt();
|
||||||
int modifiersEx = buffer.getInt();
|
int modifiersEx = buffer.getInt();
|
||||||
long when = buffer.getLong();
|
long when = buffer.getLong();
|
||||||
|
|
||||||
return new MouseWheelMovedEvent(clickCount, x, y, scrollType, scrollAmount, wheelRotation, id,
|
return new MouseWheelMovedEvent(clickCount, x, y, scrollType, scrollAmount, wheelRotation, id,
|
||||||
modifiersEx, when);
|
modifiersEx, when);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,52 +1,52 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A prebuilt condition you can use that indicates your robot has finished moving.
|
/// A prebuilt condition you can use that indicates your robot has finished moving.
|
||||||
/// <seealso cref="Condition"/>
|
/// <seealso cref="Condition"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MoveCompleteCondition : Condition
|
public class MoveCompleteCondition : Condition
|
||||||
{
|
{
|
||||||
private readonly AdvancedRobot robot;
|
private readonly AdvancedRobot robot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new MoveCompleteCondition with default priority.
|
/// Creates a new MoveCompleteCondition with default priority.
|
||||||
/// The default priority is 80.
|
/// The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||||
public MoveCompleteCondition(AdvancedRobot robot)
|
public MoveCompleteCondition(AdvancedRobot robot)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new MoveCompleteCondition with the specified priority.
|
/// Creates a new MoveCompleteCondition with the specified priority.
|
||||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||||
/// higher priority. The default priority is 80.
|
/// higher priority. The default priority is 80.
|
||||||
/// <seealso cref="Condition.Priority"/>
|
/// <seealso cref="Condition.Priority"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||||
/// <param name="priority">The priority of this condition</param>
|
/// <param name="priority">The priority of this condition</param>
|
||||||
public MoveCompleteCondition(AdvancedRobot robot, int priority)
|
public MoveCompleteCondition(AdvancedRobot robot, int priority)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests if the robot has stopped moving.
|
/// Tests if the robot has stopped moving.
|
||||||
/// Returns true if the robot has stopped moving
|
/// Returns true if the robot has stopped moving
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Test()
|
public override bool Test()
|
||||||
{
|
{
|
||||||
return (robot.DistanceRemaining == 0);
|
return (robot.DistanceRemaining == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,50 +1,50 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event occurs when your robot should paint, where the
|
/// This event occurs when your robot should paint, where the
|
||||||
/// <see cref="Robot.OnPaint(IGraphics)"/> is called on your robot.
|
/// <see cref="Robot.OnPaint(IGraphics)"/> is called on your robot.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// You can use this event for setting the event priority by calling
|
/// You can use this event for setting the event priority by calling
|
||||||
/// <see cref="AdvancedRobot.SetEventPriority(string, int)"/>
|
/// <see cref="AdvancedRobot.SetEventPriority(string, int)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class PaintEvent : Event
|
public sealed class PaintEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 5;
|
private const int DEFAULT_PRIORITY = 5;
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsPaintRobot())
|
if (statics.IsPaintRobot())
|
||||||
{
|
{
|
||||||
IPaintEvents listener = ((IPaintRobot) robot).GetPaintEventListener();
|
IPaintEvents listener = ((IPaintRobot) robot).GetPaintEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnPaint(graphics);
|
listener.OnPaint(graphics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { throw new System.Exception("Serialization of this type is not supported"); }
|
get { throw new System.Exception("Serialization of this type is not supported"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,52 +1,52 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A prebuilt condition you can use that indicates your radar has finished turning.
|
/// A prebuilt condition you can use that indicates your radar has finished turning.
|
||||||
/// <seealso cref="Condition"/>
|
/// <seealso cref="Condition"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RadarTurnCompleteCondition : Condition
|
public class RadarTurnCompleteCondition : Condition
|
||||||
{
|
{
|
||||||
private readonly AdvancedRobot robot;
|
private readonly AdvancedRobot robot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new RadarTurnCompleteCondition with default priority.
|
/// Creates a new RadarTurnCompleteCondition with default priority.
|
||||||
/// The default priority is 80.
|
/// The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||||
public RadarTurnCompleteCondition(AdvancedRobot robot)
|
public RadarTurnCompleteCondition(AdvancedRobot robot)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new RadarTurnCompleteCondition with the specified priority.
|
/// Creates a new RadarTurnCompleteCondition with the specified priority.
|
||||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||||
/// higher priority. The default priority is 80.
|
/// higher priority. The default priority is 80.
|
||||||
/// <seealso cref="Condition.Priority"/>
|
/// <seealso cref="Condition.Priority"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be a <see cref="AdvancedRobot"/></param>
|
||||||
/// <param name="priority">The priority of this condition</param>
|
/// <param name="priority">The priority of this condition</param>
|
||||||
public RadarTurnCompleteCondition(AdvancedRobot robot, int priority)
|
public RadarTurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests if the radar has stopped turning.
|
/// Tests if the radar has stopped turning.
|
||||||
/// Returns true if the radar has stopped turning; false otherwise
|
/// Returns true if the radar has stopped turning; false otherwise
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Test()
|
public override bool Test()
|
||||||
{
|
{
|
||||||
return (robot.RadarTurnRemaining == 0);
|
return (robot.RadarTurnRemaining == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,364 +1,364 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using Robocode.Util;
|
using Robocode.Util;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This advanced robot type allows you to set a rate for each of the robot's movements.
|
/// This advanced robot type allows you to set a rate for each of the robot's movements.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// You can set the rate for:
|
/// You can set the rate for:
|
||||||
/// <ul>
|
/// <ul>
|
||||||
/// <li>velocity - pixels per turn</li>
|
/// <li>velocity - pixels per turn</li>
|
||||||
/// <li>robot turn - radians per turn</li>
|
/// <li>robot turn - radians per turn</li>
|
||||||
/// <li>gun rotation - radians per turn</li>
|
/// <li>gun rotation - radians per turn</li>
|
||||||
/// <li>radar rotation - radians per turn</li>
|
/// <li>radar rotation - radians per turn</li>
|
||||||
/// </ul>
|
/// </ul>
|
||||||
/// When you set a rate for one of the above movements, the movement will continue the move by
|
/// 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
|
/// 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
|
/// 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
|
/// will go back or to the left. In order to stop the movement, the rate must be
|
||||||
/// set to 0.
|
/// set to 0.
|
||||||
/// <para />
|
/// <para />
|
||||||
/// Note: When calling <see cref="VelocityRate" />, <see cref="TurnRate" />,
|
/// Note: When calling <see cref="VelocityRate" />, <see cref="TurnRate" />,
|
||||||
/// <see cref="GunRotationRate" />, <see cref="RadarRotationRate" /> and variants,
|
/// <see cref="GunRotationRate" />, <see cref="RadarRotationRate" /> and variants,
|
||||||
/// any previous calls to "movement" functions outside of <see cref="RateControlRobot" />,
|
/// any previous calls to "movement" functions outside of <see cref="RateControlRobot" />,
|
||||||
/// such as <see cref="AdvancedRobot.SetAhead(double)" />,
|
/// such as <see cref="AdvancedRobot.SetAhead(double)" />,
|
||||||
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
||||||
/// <see cref="AdvancedRobot.SetTurnRadarRightRadians(double)" /> and similar will be
|
/// <see cref="AdvancedRobot.SetTurnRadarRightRadians(double)" /> and similar will be
|
||||||
/// overridden when calling the <see cref="Execute()" /> on this robot class.
|
/// overridden when calling the <see cref="Execute()" /> on this robot class.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Look into the source code for the samplecs.VelociRobot in order to see how to use this
|
/// Look into the source code for the samplecs.VelociRobot in order to see how to use this
|
||||||
/// robot type.
|
/// robot type.
|
||||||
/// <seealso cref="JuniorRobot"/>
|
/// <seealso cref="JuniorRobot"/>
|
||||||
/// <seealso cref="Robot"/>
|
/// <seealso cref="Robot"/>
|
||||||
/// <seealso cref="AdvancedRobot"/>
|
/// <seealso cref="AdvancedRobot"/>
|
||||||
/// <seealso cref="TeamRobot"/>
|
/// <seealso cref="TeamRobot"/>
|
||||||
/// <seealso cref="IDroid"/>
|
/// <seealso cref="IDroid"/>
|
||||||
/// <seealso cref="IBorderSentry"/>
|
/// <seealso cref="IBorderSentry"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class RateControlRobot : TeamRobot
|
public abstract class RateControlRobot : TeamRobot
|
||||||
{
|
{
|
||||||
private double velocityRate; // Pixels per turn
|
private double velocityRate; // Pixels per turn
|
||||||
private double turnRate; // Radians per turn
|
private double turnRate; // Radians per turn
|
||||||
private double gunRotationRate; // Radians per turn
|
private double gunRotationRate; // Radians per turn
|
||||||
private double radarRotationRate; // Radians per turn
|
private double radarRotationRate; // Radians per turn
|
||||||
|
|
||||||
///
|
///
|
||||||
///<summary>
|
///<summary>
|
||||||
/// The speed the robot will move (forward), in pixels per turn.
|
/// The speed the robot will move (forward), in pixels per turn.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the robot will move backwards
|
/// where negative values means that the robot will move backwards
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the robot to move forward 2 pixels per turn
|
/// // Set the robot to move forward 2 pixels per turn
|
||||||
/// VelocityRate = 2;
|
/// VelocityRate = 2;
|
||||||
///
|
///
|
||||||
/// // Set the robot to move backwards 8 pixels per turn
|
/// // Set the robot to move backwards 8 pixels per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// VelocityRate = -8;
|
/// VelocityRate = -8;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last VelocityRate
|
/// // Executes the last VelocityRate
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// Note: This method overrules <see cref="AdvancedRobot.SetAhead(double)" /> and
|
/// Note: This method overrules <see cref="AdvancedRobot.SetAhead(double)" /> and
|
||||||
/// <see cref="AdvancedRobot.SetBack(double)" />
|
/// <see cref="AdvancedRobot.SetBack(double)" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="TurnRate" />
|
/// <seealso cref="TurnRate" />
|
||||||
/// <seealso cref="GunRotationRate" />
|
/// <seealso cref="GunRotationRate" />
|
||||||
/// <seealso cref="RadarRotationRate" />
|
/// <seealso cref="RadarRotationRate" />
|
||||||
/// <seealso cref="AdvancedRobot.SetAhead(double)" />
|
/// <seealso cref="AdvancedRobot.SetAhead(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetBack(double)" />
|
/// <seealso cref="AdvancedRobot.SetBack(double)" />
|
||||||
///</summary>
|
///</summary>
|
||||||
public double VelocityRate
|
public double VelocityRate
|
||||||
{
|
{
|
||||||
get { return velocityRate; }
|
get { return velocityRate; }
|
||||||
set { velocityRate = value; }
|
set { velocityRate = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
///<summary>
|
///<summary>
|
||||||
/// The robot's clockwise (right) rotation per turn, in degrees.
|
/// The robot's clockwise (right) rotation per turn, in degrees.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the robot turns counterclockwise (left)
|
/// where negative values means that the robot turns counterclockwise (left)
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the robot to turn right 10 degrees per turn
|
/// // Set the robot to turn right 10 degrees per turn
|
||||||
/// TurnRate = 10;
|
/// TurnRate = 10;
|
||||||
///
|
///
|
||||||
/// // Set the robot to turn left 4 degrees per turn
|
/// // Set the robot to turn left 4 degrees per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// TurnRate = -5;
|
/// TurnRate = -5;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last TurnRate
|
/// // Executes the last TurnRate
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="TurnRate" />
|
/// <seealso cref="TurnRate" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="GunRotationRate" />
|
/// <seealso cref="GunRotationRate" />
|
||||||
/// <seealso cref="RadarRotationRate" />
|
/// <seealso cref="RadarRotationRate" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnRight(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnRight(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnLeft(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnLeft(double)" />
|
||||||
///</summary>
|
///</summary>
|
||||||
public double TurnRate
|
public double TurnRate
|
||||||
{
|
{
|
||||||
get { return Utils.ToRadians(turnRate); }
|
get { return Utils.ToRadians(turnRate); }
|
||||||
set { turnRate = Utils.ToRadians(value); }
|
set { turnRate = Utils.ToRadians(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The robot's clockwise (right) rotation per turn, in radians.
|
/// The robot's clockwise (right) rotation per turn, in radians.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the robot turns counterclockwise (left)
|
/// where negative values means that the robot turns counterclockwise (left)
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the robot to turn right pi / 32 radians per turn
|
/// // Set the robot to turn right pi / 32 radians per turn
|
||||||
/// TurnRateRadians = Math.PI / 32;
|
/// TurnRateRadians = Math.PI / 32;
|
||||||
///
|
///
|
||||||
/// // Set the robot to turn left pi / 20 radians per turn
|
/// // Set the robot to turn left pi / 20 radians per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// TurnRateRadians = -Math.PI / 20;
|
/// TurnRateRadians = -Math.PI / 20;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last TurnRateRadians
|
/// // Executes the last TurnRateRadians
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
///
|
///
|
||||||
/// <seealso cref="TurnRateRadians" />
|
/// <seealso cref="TurnRateRadians" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="GunRotationRateRadians" />
|
/// <seealso cref="GunRotationRateRadians" />
|
||||||
/// <seealso cref="RadarRotationRateRadians" />
|
/// <seealso cref="RadarRotationRateRadians" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnRightRadians(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnRightRadians(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnLeftRadians(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnLeftRadians(double)" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TurnRateRadians
|
public double TurnRateRadians
|
||||||
{
|
{
|
||||||
get { return turnRate; }
|
get { return turnRate; }
|
||||||
set { turnRate = value; }
|
set { turnRate = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The gun's clockwise (right) rotation per turn, in degrees.
|
/// The gun's clockwise (right) rotation per turn, in degrees.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the gun turns counterclockwise (left)
|
/// where negative values means that the gun turns counterclockwise (left)
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the gun to turn right 15 degrees per turn
|
/// // Set the gun to turn right 15 degrees per turn
|
||||||
/// GunRotationRate = 15;
|
/// GunRotationRate = 15;
|
||||||
///
|
///
|
||||||
/// // Set the gun to turn left 9 degrees per turn
|
/// // Set the gun to turn left 9 degrees per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// GunRotationRate = -9;
|
/// GunRotationRate = -9;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last GunRotationRate()
|
/// // Executes the last GunRotationRate()
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="GunRotationRate" />
|
/// <seealso cref="GunRotationRate" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="TurnRate" />
|
/// <seealso cref="TurnRate" />
|
||||||
/// <seealso cref="RadarRotationRate" />
|
/// <seealso cref="RadarRotationRate" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnGunRight(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnGunRight(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnGunLeft(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnGunLeft(double)" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GunRotationRate
|
public double GunRotationRate
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(gunRotationRate); }
|
get { return Utils.ToDegrees(gunRotationRate); }
|
||||||
set { gunRotationRate = Utils.ToRadians(value); }
|
set { gunRotationRate = Utils.ToRadians(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The gun's clockwise (right) rotation per turn, in radians.
|
/// The gun's clockwise (right) rotation per turn, in radians.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the gun turns counterclockwise (left)
|
/// where negative values means that the gun turns counterclockwise (left)
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the gun to turn right pi / 16 radians per turn
|
/// // Set the gun to turn right pi / 16 radians per turn
|
||||||
/// GunRotationRateRadians = Math.PI / 16;
|
/// GunRotationRateRadians = Math.PI / 16;
|
||||||
///
|
///
|
||||||
/// // Set the gun to turn left pi / 12 radians per turn
|
/// // Set the gun to turn left pi / 12 radians per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// GunRotationRateRadians = -Math.PI / 12;
|
/// GunRotationRateRadians = -Math.PI / 12;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last GunRotationRateRadians
|
/// // Executes the last GunRotationRateRadians
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="GunRotationRateRadians()" />
|
/// <seealso cref="GunRotationRateRadians()" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="TurnRateRadians" />
|
/// <seealso cref="TurnRateRadians" />
|
||||||
/// <seealso cref="RadarRotationRateRadians" />
|
/// <seealso cref="RadarRotationRateRadians" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnGunRightRadians(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnGunRightRadians(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnGunLeftRadians(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnGunLeftRadians(double)" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GunRotationRateRadians
|
public double GunRotationRateRadians
|
||||||
{
|
{
|
||||||
get { return gunRotationRate; }
|
get { return gunRotationRate; }
|
||||||
set { gunRotationRate = value; }
|
set { gunRotationRate = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The radar's clockwise (right) rotation per turn, in degrees.
|
/// The radar's clockwise (right) rotation per turn, in degrees.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the radar turns counterclockwise (left)
|
/// where negative values means that the radar turns counterclockwise (left)
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the radar to turn right 45 degrees per turn
|
/// // Set the radar to turn right 45 degrees per turn
|
||||||
/// RadarRotationRate = 45;
|
/// RadarRotationRate = 45;
|
||||||
///
|
///
|
||||||
/// // Set the radar to turn left 15 degrees per turn
|
/// // Set the radar to turn left 15 degrees per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// RadarRotationRate = -15;
|
/// RadarRotationRate = -15;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last RadarRotationRate
|
/// // Executes the last RadarRotationRate
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="RadarRotationRate()" />
|
/// <seealso cref="RadarRotationRate()" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="TurnRate" />
|
/// <seealso cref="TurnRate" />
|
||||||
/// <seealso cref="GunRotationRate" />
|
/// <seealso cref="GunRotationRate" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnRadarRight(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnRadarRight(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnRadarLeft(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnRadarLeft(double)" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RadarRotationRate
|
public double RadarRotationRate
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(radarRotationRate); }
|
get { return Utils.ToDegrees(radarRotationRate); }
|
||||||
set { radarRotationRate = Utils.ToRadians(value); }
|
set { radarRotationRate = Utils.ToRadians(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The radar's clockwise (right) rotation per turn, in radians.
|
/// The radar's clockwise (right) rotation per turn, in radians.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// This call returns immediately, and will not execute until you call
|
/// This call returns immediately, and will not execute until you call
|
||||||
/// Execute() or take an action that executes.
|
/// Execute() or take an action that executes.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that both positive and negative values can be given as input,
|
/// Note that both positive and negative values can be given as input,
|
||||||
/// where negative values means that the radar turns counterclockwise (left)
|
/// where negative values means that the radar turns counterclockwise (left)
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// // Set the radar to turn right pi / 4 radians per turn
|
/// // Set the radar to turn right pi / 4 radians per turn
|
||||||
/// RadarRotationRateRadians = Math.PI / 4;
|
/// RadarRotationRateRadians = Math.PI / 4;
|
||||||
///
|
///
|
||||||
/// // Set the radar to turn left pi / 8 radians per turn
|
/// // Set the radar to turn left pi / 8 radians per turn
|
||||||
/// // (overrides the previous order)
|
/// // (overrides the previous order)
|
||||||
/// RadarRotationRateRadians = -Math.PI / 8;
|
/// RadarRotationRateRadians = -Math.PI / 8;
|
||||||
///
|
///
|
||||||
/// ...
|
/// ...
|
||||||
/// // Executes the last RadarRotationRateRadians
|
/// // Executes the last RadarRotationRateRadians
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="RadarRotationRateRadians" />
|
/// <seealso cref="RadarRotationRateRadians" />
|
||||||
/// <seealso cref="VelocityRate" />
|
/// <seealso cref="VelocityRate" />
|
||||||
/// <seealso cref="TurnRateRadians" />
|
/// <seealso cref="TurnRateRadians" />
|
||||||
/// <seealso cref="GunRotationRateRadians" />
|
/// <seealso cref="GunRotationRateRadians" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnRadarRightRadians(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnRadarRightRadians(double)" />
|
||||||
/// <seealso cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
/// <seealso cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RadarRotationRateRadians
|
public double RadarRotationRateRadians
|
||||||
{
|
{
|
||||||
get { return radarRotationRate; }
|
get { return radarRotationRate; }
|
||||||
set { radarRotationRate = value; }
|
set { radarRotationRate = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Executes any pending actions, or continues executing actions that are
|
/// Executes any pending actions, or continues executing actions that are
|
||||||
/// in process. This call returns after the actions have been started.
|
/// in process. This call returns after the actions have been started.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Note that advanced robots <em>must</em> call this function in order to
|
/// Note that advanced robots <em>must</em> call this function in order to
|
||||||
/// Execute pending set* calls like e.g. <see cref="VelocityRate" />,
|
/// Execute pending set* calls like e.g. <see cref="VelocityRate" />,
|
||||||
/// <see cref="AdvancedRobot.SetFire(double)" />, <see cref="TurnRate" />
|
/// <see cref="AdvancedRobot.SetFire(double)" />, <see cref="TurnRate" />
|
||||||
/// etc. Otherwise, these calls will never get executed.
|
/// etc. Otherwise, these calls will never get executed.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// Any previous calls to "movement" functions outside of
|
/// Any previous calls to "movement" functions outside of
|
||||||
/// <see cref="RateControlRobot" />, such as
|
/// <see cref="RateControlRobot" />, such as
|
||||||
/// <see cref="AdvancedRobot.SetAhead(double)" />,
|
/// <see cref="AdvancedRobot.SetAhead(double)" />,
|
||||||
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
/// <see cref="AdvancedRobot.SetTurnLeft(double)" />,
|
||||||
/// <see cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
/// <see cref="AdvancedRobot.SetTurnRadarLeftRadians(double)" />
|
||||||
/// etc. will be overridden when this method is called on this robot class.
|
/// etc. will be overridden when this method is called on this robot class.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// <example>
|
/// <example>
|
||||||
/// In this example the robot will move while turning:
|
/// In this example the robot will move while turning:
|
||||||
/// <code>
|
/// <code>
|
||||||
/// VelocityRate = 6;
|
/// VelocityRate = 6;
|
||||||
/// TurnRate = 7;
|
/// TurnRate = 7;
|
||||||
///
|
///
|
||||||
/// while (true)
|
/// while (true)
|
||||||
/// {
|
/// {
|
||||||
/// Execute();
|
/// Execute();
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
///</summary>
|
///</summary>
|
||||||
public override void Execute()
|
public override void Execute()
|
||||||
{
|
{
|
||||||
MaxVelocity = velocityRate;
|
MaxVelocity = velocityRate;
|
||||||
if (velocityRate > 0)
|
if (velocityRate > 0)
|
||||||
{
|
{
|
||||||
SetAhead(Double.PositiveInfinity);
|
SetAhead(Double.PositiveInfinity);
|
||||||
}
|
}
|
||||||
else if (velocityRate < 0)
|
else if (velocityRate < 0)
|
||||||
{
|
{
|
||||||
SetBack(Double.PositiveInfinity);
|
SetBack(Double.PositiveInfinity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetAhead(0);
|
SetAhead(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTurnGunRightRadians(gunRotationRate);
|
SetTurnGunRightRadians(gunRotationRate);
|
||||||
SetTurnRadarRightRadians(radarRotationRate);
|
SetTurnRadarRightRadians(radarRotationRate);
|
||||||
SetTurnRightRadians(turnRate);
|
SetTurnRightRadians(turnRate);
|
||||||
|
|
||||||
base.Execute();
|
base.Execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//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
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event is sent to <see cref="Robot.OnRobotDeath(RobotDeathEvent)"/>
|
/// This event is sent to <see cref="Robot.OnRobotDeath(RobotDeathEvent)"/>
|
||||||
/// when another robot (not your robot) dies.
|
/// when another robot (not your robot) dies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class RobotDeathEvent : Event
|
public sealed class RobotDeathEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 70;
|
private const int DEFAULT_PRIORITY = 70;
|
||||||
|
|
||||||
private readonly string robotName;
|
private readonly string robotName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new RobotDeathEvent.
|
/// Called by the game to create a new RobotDeathEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robotName">the name of the robot that died</param>
|
/// <param name="robotName">the name of the robot that died</param>
|
||||||
public RobotDeathEvent(string robotName)
|
public RobotDeathEvent(string robotName)
|
||||||
{
|
{
|
||||||
this.robotName = robotName;
|
this.robotName = robotName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the robot that died.
|
/// Returns the name of the robot that died.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return robotName; }
|
get { return robotName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnRobotDeath(this);
|
listener.OnRobotDeath(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.RobotDeathEvent_TYPE; }
|
get { return RbSerializerN.RobotDeathEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (RobotDeathEvent) objec;
|
var obj = (RobotDeathEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName);
|
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (RobotDeathEvent) objec;
|
var obj = (RobotDeathEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.robotName);
|
serializer.serialize(buffer, obj.robotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
string name = serializer.deserializeString(buffer);
|
string name = serializer.deserializeString(buffer);
|
||||||
|
|
||||||
return new RobotDeathEvent(name);
|
return new RobotDeathEvent(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,401 +1,401 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.security;
|
using net.sf.robocode.security;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.Util;
|
using Robocode.Util;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains the status of a robot for a specific time/turn returned by
|
/// Contains the status of a robot for a specific time/turn returned by
|
||||||
/// <see cref="StatusEvent.Status"/>.
|
/// <see cref="StatusEvent.Status"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class RobotStatus
|
public sealed class RobotStatus
|
||||||
{
|
{
|
||||||
private readonly double energy;
|
private readonly double energy;
|
||||||
private readonly double x;
|
private readonly double x;
|
||||||
private readonly double y;
|
private readonly double y;
|
||||||
private readonly double bodyHeading;
|
private readonly double bodyHeading;
|
||||||
private readonly double gunHeading;
|
private readonly double gunHeading;
|
||||||
private readonly double radarHeading;
|
private readonly double radarHeading;
|
||||||
private readonly double velocity;
|
private readonly double velocity;
|
||||||
private readonly double bodyTurnRemaining;
|
private readonly double bodyTurnRemaining;
|
||||||
private readonly double radarTurnRemaining;
|
private readonly double radarTurnRemaining;
|
||||||
private readonly double gunTurnRemaining;
|
private readonly double gunTurnRemaining;
|
||||||
private readonly double distanceRemaining;
|
private readonly double distanceRemaining;
|
||||||
private readonly double gunHeat;
|
private readonly double gunHeat;
|
||||||
private readonly int others;
|
private readonly int others;
|
||||||
private readonly int numSentries;
|
private readonly int numSentries;
|
||||||
private readonly int roundNum;
|
private readonly int roundNum;
|
||||||
private readonly int numRounds;
|
private readonly int numRounds;
|
||||||
private readonly long time;
|
private readonly long time;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the robot's current energy.
|
/// Returns the robot's current energy.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Energy
|
public double Energy
|
||||||
{
|
{
|
||||||
get { return energy; }
|
get { return energy; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the X position of the robot. (0,0) is at the bottom left of the
|
/// Returns the X position of the robot. (0,0) is at the bottom left of the
|
||||||
/// battlefield.
|
/// battlefield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="Y"/>
|
/// <seealso cref="Y"/>
|
||||||
public double X
|
public double X
|
||||||
{
|
{
|
||||||
get { return x; }
|
get { return x; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the Y position of the robot. (0,0) is at the bottom left of the
|
/// Returns the Y position of the robot. (0,0) is at the bottom left of the
|
||||||
/// battlefield.
|
/// battlefield.
|
||||||
/// <seealso cref="X"/>
|
/// <seealso cref="X"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Y
|
public double Y
|
||||||
{
|
{
|
||||||
get { return y; }
|
get { return y; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the direction that the robot's body is facing, in radians.
|
/// Returns the direction that the robot's body is facing, in radians.
|
||||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
/// 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.
|
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double HeadingRadians
|
public double HeadingRadians
|
||||||
{
|
{
|
||||||
get { return bodyHeading; }
|
get { return bodyHeading; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the direction that the robot's body is facing, in degrees.
|
/// Returns the direction that the robot's body is facing, in degrees.
|
||||||
/// The value returned will be between 0 and 360 (is excluded).
|
/// The value returned will be between 0 and 360 (is excluded).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||||
/// 90 means East, 180 means South, and 270 means West.
|
/// 90 means East, 180 means South, and 270 means West.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Heading
|
public double Heading
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(bodyHeading); }
|
get { return Utils.ToDegrees(bodyHeading); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the direction that the robot's gun is facing, in radians.
|
/// Returns the direction that the robot's gun is facing, in radians.
|
||||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
/// 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.
|
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GunHeadingRadians
|
public double GunHeadingRadians
|
||||||
{
|
{
|
||||||
get { return gunHeading; }
|
get { return gunHeading; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the direction that the robot's gun is facing, in degrees.
|
/// Returns the direction that the robot's gun is facing, in degrees.
|
||||||
/// The value returned will be between 0 and 360 (is excluded).
|
/// The value returned will be between 0 and 360 (is excluded).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||||
/// 90 means East, 180 means South, and 270 means West.
|
/// 90 means East, 180 means South, and 270 means West.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GunHeading
|
public double GunHeading
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(gunHeading); }
|
get { return Utils.ToDegrees(gunHeading); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the direction that the robot's radar is facing, in radians.
|
/// Returns the direction that the robot's radar is facing, in radians.
|
||||||
/// The value returned will be between 0 and 2 * PI (is excluded).
|
/// The value returned will be between 0 and 2 * PI (is excluded).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
/// 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.
|
/// PI / 2 means East, PI means South, and 3 * PI / 2 means West.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RadarHeadingRadians
|
public double RadarHeadingRadians
|
||||||
{
|
{
|
||||||
get { return radarHeading; }
|
get { return radarHeading; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the direction that the robot's radar is facing, in degrees.
|
/// Returns the direction that the robot's radar is facing, in degrees.
|
||||||
/// The value returned will be between 0 and 360 (is excluded).
|
/// The value returned will be between 0 and 360 (is excluded).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
/// Note that the heading in Robocode is like a compass, where 0 means North,
|
||||||
/// 90 means East, 180 means South, and 270 means West.
|
/// 90 means East, 180 means South, and 270 means West.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RadarHeading
|
public double RadarHeading
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(radarHeading); }
|
get { return Utils.ToDegrees(radarHeading); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the velocity of the robot measured in pixels/turn.
|
/// Returns the velocity of the robot measured in pixels/turn.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// The maximum velocity of a robot is defined by <see cref="Rules.MAX_VELOCITY"/>
|
/// The maximum velocity of a robot is defined by <see cref="Rules.MAX_VELOCITY"/>
|
||||||
/// (8 pixels / turn).
|
/// (8 pixels / turn).
|
||||||
/// <seealso cref="Rules.MAX_VELOCITY"/>
|
/// <seealso cref="Rules.MAX_VELOCITY"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Velocity
|
public double Velocity
|
||||||
{
|
{
|
||||||
get { return velocity; }
|
get { return velocity; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the angle remaining in the robots's turn, in radians.
|
/// Returns the angle remaining in the robots's turn, in radians.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the robot is currently turning to the right.
|
/// Positive values means that the robot is currently turning to the right.
|
||||||
/// Negative values means that the robot is currently turning to the left.
|
/// Negative values means that the robot is currently turning to the left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TurnRemainingRadians
|
public double TurnRemainingRadians
|
||||||
{
|
{
|
||||||
get { return bodyTurnRemaining; }
|
get { return bodyTurnRemaining; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the angle remaining in the robots's turn, in degrees.
|
/// Returns the angle remaining in the robots's turn, in degrees.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the robot is currently turning to the right.
|
/// Positive values means that the robot is currently turning to the right.
|
||||||
/// Negative values means that the robot is currently turning to the left.
|
/// Negative values means that the robot is currently turning to the left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TurnRemaining
|
public double TurnRemaining
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(bodyTurnRemaining); }
|
get { return Utils.ToDegrees(bodyTurnRemaining); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the angle remaining in the radar's turn, in radians.
|
/// Returns the angle remaining in the radar's turn, in radians.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the radar is currently turning to the right.
|
/// Positive values means that the radar is currently turning to the right.
|
||||||
/// Negative values means that the radar is currently turning to the left.
|
/// Negative values means that the radar is currently turning to the left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RadarTurnRemainingRadians
|
public double RadarTurnRemainingRadians
|
||||||
{
|
{
|
||||||
get { return radarTurnRemaining; }
|
get { return radarTurnRemaining; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the angle remaining in the radar's turn, in degrees.
|
/// Returns the angle remaining in the radar's turn, in degrees.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the radar is currently turning to the right.
|
/// Positive values means that the radar is currently turning to the right.
|
||||||
/// Negative values means that the radar is currently turning to the left.
|
/// Negative values means that the radar is currently turning to the left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RadarTurnRemaining
|
public double RadarTurnRemaining
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(radarTurnRemaining); }
|
get { return Utils.ToDegrees(radarTurnRemaining); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the angle remaining in the gun's turn, in radians.
|
/// Returns the angle remaining in the gun's turn, in radians.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the gun is currently turning to the right.
|
/// Positive values means that the gun is currently turning to the right.
|
||||||
/// Negative values means that the gun is currently turning to the left.
|
/// Negative values means that the gun is currently turning to the left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GunTurnRemainingRadians
|
public double GunTurnRemainingRadians
|
||||||
{
|
{
|
||||||
get { return gunTurnRemaining; }
|
get { return gunTurnRemaining; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the angle remaining in the gun's turn, in degrees.
|
/// Returns the angle remaining in the gun's turn, in degrees.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the gun is currently turning to the right.
|
/// Positive values means that the gun is currently turning to the right.
|
||||||
/// Negative values means that the gun is currently turning to the left.
|
/// Negative values means that the gun is currently turning to the left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GunTurnRemaining
|
public double GunTurnRemaining
|
||||||
{
|
{
|
||||||
get { return Utils.ToDegrees(gunTurnRemaining); }
|
get { return Utils.ToDegrees(gunTurnRemaining); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the distance remaining in the robot's current move measured in
|
/// Returns the distance remaining in the robot's current move measured in
|
||||||
/// pixels.
|
/// pixels.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This call returns both positive and negative values.
|
/// This call returns both positive and negative values.
|
||||||
/// Positive values means that the robot is currently moving forwards.
|
/// Positive values means that the robot is currently moving forwards.
|
||||||
/// Negative values means that the robot is currently moving backwards.
|
/// Negative values means that the robot is currently moving backwards.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double DistanceRemaining
|
public double DistanceRemaining
|
||||||
{
|
{
|
||||||
get { return distanceRemaining; }
|
get { return distanceRemaining; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the current heat of the gun. The gun cannot Fire unless this is
|
/// 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
|
/// 0. (Calls to Fire will succeed, but will not actually Fire unless
|
||||||
/// GetGunHeat() == 0).
|
/// GetGunHeat() == 0).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// The amount of gun heat generated when the gun is fired is
|
/// 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
|
/// 1 + (firePower / 5). Each turn the gun heat drops by the amount returned
|
||||||
/// by <see cref="Robot.GunCoolingRate"/>, which is a battle setup.
|
/// by <see cref="Robot.GunCoolingRate"/>, which is a battle setup.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that all guns are "hot" at the start of each round, where the gun
|
/// Note that all guns are "hot" at the start of each round, where the gun
|
||||||
/// heat is 3.
|
/// heat is 3.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="Robot.GunCoolingRate"/>
|
/// <seealso cref="Robot.GunCoolingRate"/>
|
||||||
/// <seealso cref="Robot.Fire(double)"/>
|
/// <seealso cref="Robot.Fire(double)"/>
|
||||||
/// <seealso cref="Robot.FireBullet(double)"/>
|
/// <seealso cref="Robot.FireBullet(double)"/>
|
||||||
public double GunHeat
|
public double GunHeat
|
||||||
{
|
{
|
||||||
get { return gunHeat; }
|
get { return gunHeat; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns how many opponents that are left in the current round.
|
/// Returns how many opponents that are left in the current round.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Others
|
public int Others
|
||||||
{
|
{
|
||||||
get { return others; }
|
get { return others; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns how many sentry robots that are left in the current round.
|
/// Returns how many sentry robots that are left in the current round.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int NumSentries
|
public int NumSentries
|
||||||
{
|
{
|
||||||
get { return numSentries; }
|
get { return numSentries; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the number of rounds in the current battle.
|
/// Returns the number of rounds in the current battle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="RoundNum"/>
|
/// <seealso cref="RoundNum"/>
|
||||||
public int NumRounds
|
public int NumRounds
|
||||||
{
|
{
|
||||||
get { return numRounds; }
|
get { return numRounds; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the current round number (0 to <see cref="NumRounds"/> - 1) of
|
/// Returns the current round number (0 to <see cref="NumRounds"/> - 1) of
|
||||||
/// the battle.
|
/// the battle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="NumRounds"/>
|
/// <seealso cref="NumRounds"/>
|
||||||
public int RoundNum
|
public int RoundNum
|
||||||
{
|
{
|
||||||
get { return roundNum; }
|
get { return roundNum; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the game time of the round, where the time is equal to the current turn in the round.
|
/// Returns the game time of the round, where the time is equal to the current turn in the round.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long Time
|
public long Time
|
||||||
{
|
{
|
||||||
get { return time; }
|
get { return time; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private RobotStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
private RobotStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||||
double radarHeading,
|
double radarHeading,
|
||||||
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
|
||||||
double gunTurnRemaining,
|
double gunTurnRemaining,
|
||||||
double distanceRemaining, double gunHeat,
|
double distanceRemaining, double gunHeat,
|
||||||
int others, int numSentries,
|
int others, int numSentries,
|
||||||
int roundNum, int numRounds, long time)
|
int roundNum, int numRounds, long time)
|
||||||
{
|
{
|
||||||
this.energy = energy;
|
this.energy = energy;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.bodyHeading = bodyHeading;
|
this.bodyHeading = bodyHeading;
|
||||||
this.gunHeading = gunHeading;
|
this.gunHeading = gunHeading;
|
||||||
this.radarHeading = radarHeading;
|
this.radarHeading = radarHeading;
|
||||||
this.bodyTurnRemaining = bodyTurnRemaining;
|
this.bodyTurnRemaining = bodyTurnRemaining;
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
this.radarTurnRemaining = radarTurnRemaining;
|
this.radarTurnRemaining = radarTurnRemaining;
|
||||||
this.gunTurnRemaining = gunTurnRemaining;
|
this.gunTurnRemaining = gunTurnRemaining;
|
||||||
this.distanceRemaining = distanceRemaining;
|
this.distanceRemaining = distanceRemaining;
|
||||||
this.gunHeat = gunHeat;
|
this.gunHeat = gunHeat;
|
||||||
this.others = others;
|
this.others = others;
|
||||||
this.numSentries = numSentries;
|
this.numSentries = numSentries;
|
||||||
this.roundNum = roundNum;
|
this.roundNum = roundNum;
|
||||||
this.numRounds = numRounds;
|
this.numRounds = numRounds;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN, IHiddenStatusHelper
|
private class SerializableHelper : ISerializableHelperN, IHiddenStatusHelper
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 4*RbSerializerN.SIZEOF_INT
|
return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 4*RbSerializerN.SIZEOF_INT
|
||||||
+ RbSerializerN.SIZEOF_LONG;
|
+ RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (RobotStatus) objec;
|
var obj = (RobotStatus) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.energy);
|
serializer.serialize(buffer, obj.energy);
|
||||||
serializer.serialize(buffer, obj.x);
|
serializer.serialize(buffer, obj.x);
|
||||||
serializer.serialize(buffer, obj.y);
|
serializer.serialize(buffer, obj.y);
|
||||||
serializer.serialize(buffer, obj.bodyHeading);
|
serializer.serialize(buffer, obj.bodyHeading);
|
||||||
serializer.serialize(buffer, obj.gunHeading);
|
serializer.serialize(buffer, obj.gunHeading);
|
||||||
serializer.serialize(buffer, obj.radarHeading);
|
serializer.serialize(buffer, obj.radarHeading);
|
||||||
serializer.serialize(buffer, obj.velocity);
|
serializer.serialize(buffer, obj.velocity);
|
||||||
serializer.serialize(buffer, obj.bodyTurnRemaining);
|
serializer.serialize(buffer, obj.bodyTurnRemaining);
|
||||||
serializer.serialize(buffer, obj.radarTurnRemaining);
|
serializer.serialize(buffer, obj.radarTurnRemaining);
|
||||||
serializer.serialize(buffer, obj.gunTurnRemaining);
|
serializer.serialize(buffer, obj.gunTurnRemaining);
|
||||||
serializer.serialize(buffer, obj.distanceRemaining);
|
serializer.serialize(buffer, obj.distanceRemaining);
|
||||||
serializer.serialize(buffer, obj.gunHeat);
|
serializer.serialize(buffer, obj.gunHeat);
|
||||||
serializer.serialize(buffer, obj.others);
|
serializer.serialize(buffer, obj.others);
|
||||||
serializer.serialize(buffer, obj.numSentries);
|
serializer.serialize(buffer, obj.numSentries);
|
||||||
serializer.serialize(buffer, obj.roundNum);
|
serializer.serialize(buffer, obj.roundNum);
|
||||||
serializer.serialize(buffer, obj.numRounds);
|
serializer.serialize(buffer, obj.numRounds);
|
||||||
serializer.serialize(buffer, obj.time);
|
serializer.serialize(buffer, obj.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
double energy = buffer.getDouble();
|
double energy = buffer.getDouble();
|
||||||
double x = buffer.getDouble();
|
double x = buffer.getDouble();
|
||||||
double y = buffer.getDouble();
|
double y = buffer.getDouble();
|
||||||
double bodyHeading = buffer.getDouble();
|
double bodyHeading = buffer.getDouble();
|
||||||
double gunHeading = buffer.getDouble();
|
double gunHeading = buffer.getDouble();
|
||||||
double radarHeading = buffer.getDouble();
|
double radarHeading = buffer.getDouble();
|
||||||
double velocity = buffer.getDouble();
|
double velocity = buffer.getDouble();
|
||||||
double bodyTurnRemaining = buffer.getDouble();
|
double bodyTurnRemaining = buffer.getDouble();
|
||||||
double radarTurnRemaining = buffer.getDouble();
|
double radarTurnRemaining = buffer.getDouble();
|
||||||
double gunTurnRemaining = buffer.getDouble();
|
double gunTurnRemaining = buffer.getDouble();
|
||||||
double distanceRemaining = buffer.getDouble();
|
double distanceRemaining = buffer.getDouble();
|
||||||
double gunHeat = buffer.getDouble();
|
double gunHeat = buffer.getDouble();
|
||||||
int others = buffer.getInt();
|
int others = buffer.getInt();
|
||||||
int numSentries = buffer.getInt();
|
int numSentries = buffer.getInt();
|
||||||
int roundNum = buffer.getInt();
|
int roundNum = buffer.getInt();
|
||||||
int numRounds = buffer.getInt();
|
int numRounds = buffer.getInt();
|
||||||
long time = buffer.getLong();
|
long time = buffer.getLong();
|
||||||
|
|
||||||
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
||||||
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
||||||
roundNum, numRounds, time);
|
roundNum, numRounds, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
|
||||||
double radarHeading, double velocity, double bodyTurnRemaining,
|
double radarHeading, double velocity, double bodyTurnRemaining,
|
||||||
double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining,
|
double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining,
|
||||||
double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time)
|
double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time)
|
||||||
{
|
{
|
||||||
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
|
||||||
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
|
||||||
roundNum, numRounds, time);
|
roundNum, numRounds, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,134 +1,134 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A RoundEndedEvent is sent to <see cref="Robot.OnRoundEnded(RoundEndedEvent)"/> when a round has ended.
|
/// A RoundEndedEvent is sent to <see cref="Robot.OnRoundEnded(RoundEndedEvent)"/> when a round has ended.
|
||||||
/// You can use the information contained in this event to determine which round that has ended.
|
/// You can use the information contained in this event to determine which round that has ended.
|
||||||
/// <seealso cref="Robot.OnRoundEnded(RoundEndedEvent)"/>
|
/// <seealso cref="Robot.OnRoundEnded(RoundEndedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoundEndedEvent : Event
|
public class RoundEndedEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 110; // System event -> cannot be changed!
|
private const int DEFAULT_PRIORITY = 110; // System event -> cannot be changed!
|
||||||
|
|
||||||
private readonly int round;
|
private readonly int round;
|
||||||
private readonly int turns;
|
private readonly int turns;
|
||||||
private readonly int totalTurns;
|
private readonly int totalTurns;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new RoundEndedEvent.
|
/// Called by the game to create a new RoundEndedEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="round">The round that has ended (zero-indexed)</param>
|
/// <param name="round">The round that has ended (zero-indexed)</param>
|
||||||
/// <param name="turns">The number of turns that this round reached</param>
|
/// <param name="turns">The number of turns that this round reached</param>
|
||||||
/// <param name="totalTurns">The total number of turns reached in the battle when this round ended</param>
|
/// <param name="totalTurns">The total number of turns reached in the battle when this round ended</param>
|
||||||
public RoundEndedEvent(int round, int turns, int totalTurns)
|
public RoundEndedEvent(int round, int turns, int totalTurns)
|
||||||
{
|
{
|
||||||
this.round = round;
|
this.round = round;
|
||||||
this.turns = turns;
|
this.turns = turns;
|
||||||
this.totalTurns = totalTurns;
|
this.totalTurns = totalTurns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The round that ended (zero-indexed).
|
/// The round that ended (zero-indexed).
|
||||||
/// </value>
|
/// </value>
|
||||||
public int Round
|
public int Round
|
||||||
{
|
{
|
||||||
get { return round; }
|
get { return round; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The number of turns that this round reached.
|
/// The number of turns that this round reached.
|
||||||
/// </value>
|
/// </value>
|
||||||
public int Turns
|
public int Turns
|
||||||
{
|
{
|
||||||
get { return turns; }
|
get { return turns; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The total number of turns reached in the battle when this round ended.
|
/// The total number of turns reached in the battle when this round ended.
|
||||||
/// </value>
|
/// </value>
|
||||||
public int TotalTurns
|
public int TotalTurns
|
||||||
{
|
{
|
||||||
get { return totalTurns; }
|
get { return totalTurns; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override sealed int DefaultPriority
|
internal override sealed int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override sealed int Priority
|
public override sealed int Priority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (robot != null)
|
if (robot != null)
|
||||||
{
|
{
|
||||||
IBasicEvents3 listener = robot.GetBasicEventListener() as IBasicEvents3;
|
IBasicEvents3 listener = robot.GetBasicEventListener() as IBasicEvents3;
|
||||||
|
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnRoundEnded(this);
|
listener.OnRoundEnded(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override sealed bool IsCriticalEvent
|
internal override sealed bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.RoundEndedEvent_TYPE; }
|
get { return RbSerializerN.RoundEndedEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, Object obje)
|
public int sizeOf(RbSerializerN serializer, Object obje)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + 3*RbSerializerN.SIZEOF_INT;
|
return RbSerializerN.SIZEOF_TYPEINFO + 3*RbSerializerN.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje)
|
||||||
{
|
{
|
||||||
RoundEndedEvent evnt = (RoundEndedEvent) obje;
|
RoundEndedEvent evnt = (RoundEndedEvent) obje;
|
||||||
|
|
||||||
serializer.serialize(buffer, evnt.round);
|
serializer.serialize(buffer, evnt.round);
|
||||||
serializer.serialize(buffer, evnt.turns);
|
serializer.serialize(buffer, evnt.turns);
|
||||||
serializer.serialize(buffer, evnt.totalTurns);
|
serializer.serialize(buffer, evnt.totalTurns);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public Object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
int round = serializer.deserializeInt(buffer);
|
int round = serializer.deserializeInt(buffer);
|
||||||
int turns = serializer.deserializeInt(buffer);
|
int turns = serializer.deserializeInt(buffer);
|
||||||
int totalTurns = serializer.deserializeInt(buffer);
|
int totalTurns = serializer.deserializeInt(buffer);
|
||||||
|
|
||||||
return new RoundEndedEvent(round, turns, totalTurns);
|
return new RoundEndedEvent(round, turns, totalTurns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,214 +1,214 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using Robocode.Util;
|
using Robocode.Util;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constants and methods that defines the rules of Robocode.
|
/// Constants and methods that defines the rules of Robocode.
|
||||||
/// Constants are used for rules that will not change.
|
/// Constants are used for rules that will not change.
|
||||||
/// Methods are provided for rules that can be changed between battles or which depends
|
/// Methods are provided for rules that can be changed between battles or which depends
|
||||||
/// on some other factor.
|
/// on some other factor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Rules
|
public static class Rules
|
||||||
{
|
{
|
||||||
// Hide the constructor in the docs as it should not be used
|
// Hide the constructor in the docs as it should not be used
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The acceleration of a robot, i.e. the increase of velocity when the
|
/// The acceleration of a robot, i.e. the increase of velocity when the
|
||||||
/// robot moves forward, which is 1 pixel/turn.
|
/// robot moves forward, which is 1 pixel/turn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double ACCELERATION = 1;
|
public static readonly double ACCELERATION = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The deceleration of a robot, i.e. the decrease of velocity when the
|
/// The deceleration of a robot, i.e. the decrease of velocity when the
|
||||||
/// robot moves backwards (or brakes), which is 2 pixels/turn.
|
/// robot moves backwards (or brakes), which is 2 pixels/turn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double DECELERATION = 2;
|
public static readonly double DECELERATION = 2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum velocity of a robot, which is 8 pixels/turn.
|
/// The maximum velocity of a robot, which is 8 pixels/turn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double MAX_VELOCITY = 8;
|
public static readonly double MAX_VELOCITY = 8;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The radar scan radius, which is 1200 pixels.
|
/// The radar scan radius, which is 1200 pixels.
|
||||||
/// Robots which is more than 1200 pixels away cannot be seen on the radar.
|
/// Robots which is more than 1200 pixels away cannot be seen on the radar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double RADAR_SCAN_RADIUS = 1200;
|
public static readonly double RADAR_SCAN_RADIUS = 1200;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimum bullet power, i.e the amount of energy required for firing a
|
/// The minimum bullet power, i.e the amount of energy required for firing a
|
||||||
/// bullet, which is 0.1 energy points.
|
/// bullet, which is 0.1 energy points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double MIN_BULLET_POWER = 0.1;
|
public static readonly double MIN_BULLET_POWER = 0.1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum bullet power, i.e. the maximum amount of energy that can be
|
/// The maximum bullet power, i.e. the maximum amount of energy that can be
|
||||||
/// transferred to a bullet when it is fired, which is 3 energy points.
|
/// transferred to a bullet when it is fired, which is 3 energy points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double MAX_BULLET_POWER = 3;
|
public static readonly double MAX_BULLET_POWER = 3;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum turning rate of the robot, in degrees, which is
|
/// The maximum turning rate of the robot, in degrees, which is
|
||||||
/// 10 degress/turn.
|
/// 10 degress/turn.
|
||||||
/// Note, that the turn rate of the robot depends on it's velocity.
|
/// Note, that the turn rate of the robot depends on it's velocity.
|
||||||
/// <seealso cref="MAX_TURN_RATE_RADIANS"/>
|
/// <seealso cref="MAX_TURN_RATE_RADIANS"/>
|
||||||
/// <seealso cref="GetTurnRate(double)"/>
|
/// <seealso cref="GetTurnRate(double)"/>
|
||||||
/// <seealso cref="GetTurnRateRadians(double)"/>
|
/// <seealso cref="GetTurnRateRadians(double)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double MAX_TURN_RATE = 10;
|
public static readonly double MAX_TURN_RATE = 10;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum turning rate of the robot measured in radians instead of
|
/// The maximum turning rate of the robot measured in radians instead of
|
||||||
/// degrees.
|
/// degrees.
|
||||||
///
|
///
|
||||||
/// <seealso cref="MAX_TURN_RATE"/>
|
/// <seealso cref="MAX_TURN_RATE"/>
|
||||||
/// <seealso cref="GetTurnRate(double)"/>
|
/// <seealso cref="GetTurnRate(double)"/>
|
||||||
/// <seealso cref="GetTurnRateRadians(double)"/>
|
/// <seealso cref="GetTurnRateRadians(double)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double MAX_TURN_RATE_RADIANS = Utils.ToRadians(MAX_TURN_RATE);
|
public static readonly double MAX_TURN_RATE_RADIANS = Utils.ToRadians(MAX_TURN_RATE);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The turning rate of the gun measured in degrees, which is 20 degrees/turn.
|
/// The turning rate of the gun measured in degrees, which is 20 degrees/turn.
|
||||||
/// Note, that if AdjustGunForRobotTurn = true has been set, the gun turn is
|
/// Note, that if AdjustGunForRobotTurn = true has been set, the gun turn is
|
||||||
/// independent of the robot turn. In this case the gun moves relatively to the screen.
|
/// independent of the robot turn. In this case the gun moves relatively to the screen.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// If AdjustGunForRobotTurn = false has been set or AdjustGunForRobotTurn has not
|
/// If AdjustGunForRobotTurn = false has been set or AdjustGunForRobotTurn has not
|
||||||
/// been called at all (this is the default), then the gun turn is dependent on
|
/// been called at all (this is the default), then the gun turn is dependent on
|
||||||
/// the robot turn, and in this case the gun moves relatively to the robot body.
|
/// the robot turn, and in this case the gun moves relatively to the robot body.
|
||||||
///
|
///
|
||||||
/// <seealso cref="GUN_TURN_RATE_RADIANS"/>
|
/// <seealso cref="GUN_TURN_RATE_RADIANS"/>
|
||||||
/// <seealso cref="Robot.IsAdjustGunForRobotTurn"/>
|
/// <seealso cref="Robot.IsAdjustGunForRobotTurn"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double GUN_TURN_RATE = 20;
|
public static readonly double GUN_TURN_RATE = 20;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The turning rate of the gun measured in radians instead of degrees.
|
/// The turning rate of the gun measured in radians instead of degrees.
|
||||||
///
|
///
|
||||||
/// <seealso cref="GUN_TURN_RATE"/>
|
/// <seealso cref="GUN_TURN_RATE"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double GUN_TURN_RATE_RADIANS = Utils.ToRadians(GUN_TURN_RATE);
|
public static readonly double GUN_TURN_RATE_RADIANS = Utils.ToRadians(GUN_TURN_RATE);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The turning rate of the radar measured in degrees, which is 45 degrees/turn.
|
/// The turning rate of the radar measured in degrees, which is 45 degrees/turn.
|
||||||
/// Note, that if AdjustRadarForRobotTurn = true and/or
|
/// Note, that if AdjustRadarForRobotTurn = true and/or
|
||||||
/// AdjustRadarForGunTurn = true has been set, the radar turn is independent of
|
/// AdjustRadarForGunTurn = true has been set, the radar turn is independent of
|
||||||
/// the robot and/or gun turn. If both properties hava been set to true, the radar
|
/// the robot and/or gun turn. If both properties hava been set to true, the radar
|
||||||
/// moves relatively to the screen.
|
/// moves relatively to the screen.
|
||||||
/// <p />
|
/// <p />
|
||||||
/// If AdjustRadarForRobotTurn = false and/or AdjustRadarForGunTurn = false
|
/// If AdjustRadarForRobotTurn = false and/or AdjustRadarForGunTurn = false
|
||||||
/// have been set or not set at all (this is the default), then the radar turn is
|
/// have been set or not set at all (this is the default), then the radar turn is
|
||||||
/// dependent on the robot and/or gun turn, and in this case the radar moves
|
/// dependent on the robot and/or gun turn, and in this case the radar moves
|
||||||
/// relatively to the gun and/or robot body.
|
/// relatively to the gun and/or robot body.
|
||||||
///
|
///
|
||||||
/// <seealso cref="RADAR_TURN_RATE_RADIANS"/>
|
/// <seealso cref="RADAR_TURN_RATE_RADIANS"/>
|
||||||
/// <seealso cref="Robot.IsAdjustGunForRobotTurn"/>
|
/// <seealso cref="Robot.IsAdjustGunForRobotTurn"/>
|
||||||
/// <seealso cref="Robot.IsAdjustRadarForGunTurn"/>
|
/// <seealso cref="Robot.IsAdjustRadarForGunTurn"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double RADAR_TURN_RATE = 45;
|
public static readonly double RADAR_TURN_RATE = 45;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The turning rate of the radar measured in radians instead of degrees.
|
/// The turning rate of the radar measured in radians instead of degrees.
|
||||||
///
|
///
|
||||||
/// <seealso cref="RADAR_TURN_RATE"/>
|
/// <seealso cref="RADAR_TURN_RATE"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double RADAR_TURN_RATE_RADIANS = Utils.ToRadians(RADAR_TURN_RATE);
|
public static readonly double RADAR_TURN_RATE_RADIANS = Utils.ToRadians(RADAR_TURN_RATE);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of damage taken when a robot hits or is hit by another robot,
|
/// The amount of damage taken when a robot hits or is hit by another robot,
|
||||||
/// which is 0.6 energy points.
|
/// which is 0.6 energy points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double ROBOT_HIT_DAMAGE = 0.6;
|
public static readonly double ROBOT_HIT_DAMAGE = 0.6;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of bonus given when a robot moving forward hits an opponent
|
/// The amount of bonus given when a robot moving forward hits an opponent
|
||||||
/// robot (ramming), which is 1.2 energy points.
|
/// robot (ramming), which is 1.2 energy points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly double ROBOT_HIT_BONUS = 1.2;
|
public static readonly double ROBOT_HIT_BONUS = 1.2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the turn rate of a robot given a specific velocity measured in
|
/// Returns the turn rate of a robot given a specific velocity measured in
|
||||||
/// degrees/turn.
|
/// degrees/turn.
|
||||||
/// <seealso cref="GetTurnRateRadians(double)"/>
|
/// <seealso cref="GetTurnRateRadians(double)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="velocity">The velocity of the robot.</param>
|
/// <param name="velocity">The velocity of the robot.</param>
|
||||||
public static double GetTurnRate(double velocity)
|
public static double GetTurnRate(double velocity)
|
||||||
{
|
{
|
||||||
return MAX_TURN_RATE - 0.75*velocity;
|
return MAX_TURN_RATE - 0.75*velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the turn rate of a robot given a specific velocity measured in
|
/// Returns the turn rate of a robot given a specific velocity measured in
|
||||||
/// radians/turn.
|
/// radians/turn.
|
||||||
/// <seealso cref="GetTurnRate(double)"/>
|
/// <seealso cref="GetTurnRate(double)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="velocity">the velocity of the robot.</param>
|
/// <param name="velocity">the velocity of the robot.</param>
|
||||||
public static double GetTurnRateRadians(double velocity)
|
public static double GetTurnRateRadians(double velocity)
|
||||||
{
|
{
|
||||||
return Utils.ToRadians(GetTurnRate(velocity));
|
return Utils.ToRadians(GetTurnRate(velocity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the amount of damage taken when robot hits a wall with a
|
/// Returns the amount of damage taken when robot hits a wall with a
|
||||||
/// specific velocity.
|
/// specific velocity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="velocity"> the velocity of the robot.</param>
|
/// <param name="velocity"> the velocity of the robot.</param>
|
||||||
public static double GetWallHitDamage(double velocity)
|
public static double GetWallHitDamage(double velocity)
|
||||||
{
|
{
|
||||||
return Math.Max(Math.Abs(velocity)/2 - 1, 0);
|
return Math.Max(Math.Abs(velocity)/2 - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the amount of damage of a bullet given a specific bullet power.
|
/// Returns the amount of damage of a bullet given a specific bullet power.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bulletPower"> the energy power of the bullet.</param>
|
/// <param name="bulletPower"> the energy power of the bullet.</param>
|
||||||
public static double GetBulletDamage(double bulletPower)
|
public static double GetBulletDamage(double bulletPower)
|
||||||
{
|
{
|
||||||
double damage = 4*bulletPower;
|
double damage = 4*bulletPower;
|
||||||
|
|
||||||
if (bulletPower > 1)
|
if (bulletPower > 1)
|
||||||
{
|
{
|
||||||
damage += 2*(bulletPower - 1);
|
damage += 2*(bulletPower - 1);
|
||||||
}
|
}
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the amount of bonus given when a robot's bullet hits an opponent
|
/// Returns the amount of bonus given when a robot's bullet hits an opponent
|
||||||
/// robot given a specific bullet power.
|
/// robot given a specific bullet power.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bulletPower">the energy power of the bullet</param>
|
/// <param name="bulletPower">the energy power of the bullet</param>
|
||||||
public static double GetBulletHitBonus(double bulletPower)
|
public static double GetBulletHitBonus(double bulletPower)
|
||||||
{
|
{
|
||||||
return 3*bulletPower;
|
return 3*bulletPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the speed of a bullet given a specific bullet power measured in
|
/// Returns the speed of a bullet given a specific bullet power measured in
|
||||||
/// pixels/turn.
|
/// pixels/turn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bulletPower">the energy power of the bullet.</param>
|
/// <param name="bulletPower">the energy power of the bullet.</param>
|
||||||
public static double GetBulletSpeed(double bulletPower)
|
public static double GetBulletSpeed(double bulletPower)
|
||||||
{
|
{
|
||||||
bulletPower = Math.Min(Math.Max(bulletPower, MIN_BULLET_POWER), MAX_BULLET_POWER);
|
bulletPower = Math.Min(Math.Max(bulletPower, MIN_BULLET_POWER), MAX_BULLET_POWER);
|
||||||
return 20 - 3 * bulletPower;
|
return 20 - 3 * bulletPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the heat produced by firing the gun given a specific bullet power.
|
/// Returns the heat produced by firing the gun given a specific bullet power.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bulletPower">the energy power of the bullet</param>
|
/// <param name="bulletPower">the energy power of the bullet</param>
|
||||||
public static double GetGunHeat(double bulletPower)
|
public static double GetGunHeat(double bulletPower)
|
||||||
{
|
{
|
||||||
return 1 + (bulletPower/5);
|
return 1 + (bulletPower/5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,238 +1,238 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A ScannedRobotEvent is sent to <see cref="Robot.OnScannedRobot(ScannedRobotEvent)"/>
|
/// A ScannedRobotEvent is sent to <see cref="Robot.OnScannedRobot(ScannedRobotEvent)"/>
|
||||||
/// OnScannedRobot()} when you scan a robot.
|
/// OnScannedRobot()} when you scan a robot.
|
||||||
/// You can use the information contained in this event to determine what to do.
|
/// You can use the information contained in this event to determine what to do.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <b>Note</b>: You should not inherit from this class in your own event class!
|
/// <b>Note</b>: You should not inherit from this class in your own event class!
|
||||||
/// The internal logic of this event class might change. Hence, your robot might
|
/// The internal logic of this event class might change. Hence, your robot might
|
||||||
/// not work in future Robocode versions, if you choose to inherit from this class.
|
/// not work in future Robocode versions, if you choose to inherit from this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScannedRobotEvent : Event
|
public class ScannedRobotEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 10;
|
private const int DEFAULT_PRIORITY = 10;
|
||||||
|
|
||||||
private readonly string name;
|
private readonly string name;
|
||||||
private readonly double energy;
|
private readonly double energy;
|
||||||
private readonly double heading;
|
private readonly double heading;
|
||||||
private readonly double bearing;
|
private readonly double bearing;
|
||||||
private readonly double distance;
|
private readonly double distance;
|
||||||
private readonly double velocity;
|
private readonly double velocity;
|
||||||
private readonly bool isSentryRobot;
|
private readonly bool isSentryRobot;
|
||||||
|
|
||||||
[Obsolete("ScannedRobotEvent() is obsolete.\n" +
|
[Obsolete("ScannedRobotEvent() is obsolete.\n" +
|
||||||
"Please use ScannedRobotEvent(string, double, double, double, double, double, bool) instead.")]
|
"Please use ScannedRobotEvent(string, double, double, double, double, double, bool) instead.")]
|
||||||
internal ScannedRobotEvent()
|
internal ScannedRobotEvent()
|
||||||
: this(null, 0, 0, 0, 0, 0, false)
|
: this(null, 0, 0, 0, 0, 0, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new ScannedRobotEvent.
|
/// Called by the game to create a new ScannedRobotEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the scanned robot</param>
|
/// <param name="name">The name of the scanned robot</param>
|
||||||
/// <param name="energy">The energy of the scanned robot</param>
|
/// <param name="energy">The energy of the scanned robot</param>
|
||||||
/// <param name="bearing">The bearing of the scanned robot, in radians</param>
|
/// <param name="bearing">The bearing of the scanned robot, in radians</param>
|
||||||
/// <param name="distance">The distance from your robot to the scanned robot</param>
|
/// <param name="distance">The distance from your robot to the scanned robot</param>
|
||||||
/// <param name="heading">The heading of the scanned robot</param>
|
/// <param name="heading">The heading of the scanned robot</param>
|
||||||
/// <param name="velocity">The velocity of the scanned robot</param>
|
/// <param name="velocity">The velocity of the scanned robot</param>
|
||||||
[Obsolete("ScannedRobotEvent(string, double, double, double, double, double) is obsolete.\n" +
|
[Obsolete("ScannedRobotEvent(string, double, double, double, double, double) is obsolete.\n" +
|
||||||
"Please use ScannedRobotEvent(string, double, double, double, double, double, bool) instead.")]
|
"Please use ScannedRobotEvent(string, double, double, double, double, double, bool) instead.")]
|
||||||
public ScannedRobotEvent(string name, double energy, double bearing, double distance, double heading, double velocity) :
|
public ScannedRobotEvent(string name, double energy, double bearing, double distance, double heading, double velocity) :
|
||||||
this(name, energy, bearing, distance, heading, velocity, false)
|
this(name, energy, bearing, distance, heading, velocity, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new ScannedRobotEvent.
|
/// Called by the game to create a new ScannedRobotEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the scanned robot</param>
|
/// <param name="name">The name of the scanned robot</param>
|
||||||
/// <param name="energy">The energy of the scanned robot</param>
|
/// <param name="energy">The energy of the scanned robot</param>
|
||||||
/// <param name="bearing">The bearing of the scanned robot, in radians</param>
|
/// <param name="bearing">The bearing of the scanned robot, in radians</param>
|
||||||
/// <param name="distance">The distance from your robot to the scanned robot</param>
|
/// <param name="distance">The distance from your robot to the scanned robot</param>
|
||||||
/// <param name="heading">The heading of the scanned robot</param>
|
/// <param name="heading">The heading of the scanned robot</param>
|
||||||
/// <param name="velocity">The velocity of the scanned robot</param>
|
/// <param name="velocity">The velocity of the scanned robot</param>
|
||||||
/// <param name="isSentryRobot">Flag specifying if the scanned robot is a sentry robot</param>
|
/// <param name="isSentryRobot">Flag specifying if the scanned robot is a sentry robot</param>
|
||||||
public ScannedRobotEvent(string name, double energy, double bearing, double distance, double heading, double velocity, bool isSentryRobot)
|
public ScannedRobotEvent(string name, double energy, double bearing, double distance, double heading, double velocity, bool isSentryRobot)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.energy = energy;
|
this.energy = energy;
|
||||||
this.bearing = bearing;
|
this.bearing = bearing;
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
this.heading = heading;
|
this.heading = heading;
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
this.isSentryRobot = isSentryRobot;
|
this.isSentryRobot = isSentryRobot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the robot you scanned, relative to your robot's
|
/// Returns the bearing to the robot you scanned, relative to your robot's
|
||||||
/// heading, in degrees (-180 <= getBearing() < 180)
|
/// heading, in degrees (-180 <= getBearing() < 180)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Bearing
|
public double Bearing
|
||||||
{
|
{
|
||||||
get { return bearing*180.0/Math.PI; }
|
get { return bearing*180.0/Math.PI; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the bearing to the robot you scanned, relative to your robot's
|
/// Returns the bearing to the robot you scanned, relative to your robot's
|
||||||
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
/// heading, in radians (-PI <= getBearingRadians() < PI)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double BearingRadians
|
public double BearingRadians
|
||||||
{
|
{
|
||||||
get { return bearing; }
|
get { return bearing; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the distance to the robot (your center to his center).
|
/// Returns the distance to the robot (your center to his center).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Distance
|
public double Distance
|
||||||
{
|
{
|
||||||
get { return distance; }
|
get { return distance; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the energy of the robot.
|
/// Returns the energy of the robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Energy
|
public double Energy
|
||||||
{
|
{
|
||||||
get { return energy; }
|
get { return energy; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the heading of the robot, in degrees (0 <= getHeading() < 360)
|
/// Returns the heading of the robot, in degrees (0 <= getHeading() < 360)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Heading
|
public double Heading
|
||||||
{
|
{
|
||||||
get { return heading*180.0/Math.PI; }
|
get { return heading*180.0/Math.PI; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the heading of the robot, in radians (0 <= getHeading() < 2 * PI)
|
/// Returns the heading of the robot, in radians (0 <= getHeading() < 2 * PI)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double HeadingRadians
|
public double HeadingRadians
|
||||||
{
|
{
|
||||||
get { return heading; }
|
get { return heading; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the robot.
|
/// Returns the name of the robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the velocity of the robot.
|
/// Returns the velocity of the robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Velocity
|
public double Velocity
|
||||||
{
|
{
|
||||||
get { return velocity; }
|
get { return velocity; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <code>true</code> if the scanned robot is a sentry robot; <code>false</code> otherwise.
|
/// <code>true</code> if the scanned robot is a sentry robot; <code>false</code> otherwise.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsSentryRobot
|
public bool IsSentryRobot
|
||||||
{
|
{
|
||||||
get { return isSentryRobot; }
|
get { return isSentryRobot; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override sealed int CompareTo(Event evnt)
|
public override sealed int CompareTo(Event evnt)
|
||||||
{
|
{
|
||||||
int res = base.CompareTo(evnt);
|
int res = base.CompareTo(evnt);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// Compare the distance, if the events are ScannedRobotEvents
|
// Compare the distance, if the events are ScannedRobotEvents
|
||||||
// The shorter distance to the robot, the higher priority
|
// The shorter distance to the robot, the higher priority
|
||||||
if (evnt is ScannedRobotEvent)
|
if (evnt is ScannedRobotEvent)
|
||||||
{
|
{
|
||||||
return (int) (Distance - ((ScannedRobotEvent) evnt).Distance);
|
return (int) (Distance - ((ScannedRobotEvent) evnt).Distance);
|
||||||
}
|
}
|
||||||
// No difference found
|
// No difference found
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnScannedRobot(this);
|
listener.OnScannedRobot(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.ScannedRobotEvent_TYPE; }
|
get { return RbSerializerN.ScannedRobotEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (ScannedRobotEvent) objec;
|
var obj = (ScannedRobotEvent) objec;
|
||||||
|
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 5 * RbSerializerN.SIZEOF_DOUBLE + RbSerializerN.SIZEOF_BOOL;
|
return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 5 * RbSerializerN.SIZEOF_DOUBLE + RbSerializerN.SIZEOF_BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (ScannedRobotEvent) objec;
|
var obj = (ScannedRobotEvent) objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.name);
|
serializer.serialize(buffer, obj.name);
|
||||||
serializer.serialize(buffer, obj.energy);
|
serializer.serialize(buffer, obj.energy);
|
||||||
serializer.serialize(buffer, obj.heading);
|
serializer.serialize(buffer, obj.heading);
|
||||||
serializer.serialize(buffer, obj.bearing);
|
serializer.serialize(buffer, obj.bearing);
|
||||||
serializer.serialize(buffer, obj.distance);
|
serializer.serialize(buffer, obj.distance);
|
||||||
serializer.serialize(buffer, obj.velocity);
|
serializer.serialize(buffer, obj.velocity);
|
||||||
serializer.serialize(buffer, obj.isSentryRobot);
|
serializer.serialize(buffer, obj.isSentryRobot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
string name = serializer.deserializeString(buffer);
|
string name = serializer.deserializeString(buffer);
|
||||||
double energy = buffer.getDouble();
|
double energy = buffer.getDouble();
|
||||||
double heading = buffer.getDouble();
|
double heading = buffer.getDouble();
|
||||||
double bearing = buffer.getDouble();
|
double bearing = buffer.getDouble();
|
||||||
double distance = buffer.getDouble();
|
double distance = buffer.getDouble();
|
||||||
double velocity = buffer.getDouble();
|
double velocity = buffer.getDouble();
|
||||||
bool isSentryRobot = serializer.deserializeBoolean(buffer);
|
bool isSentryRobot = serializer.deserializeBoolean(buffer);
|
||||||
|
|
||||||
return new ScannedRobotEvent(name, energy, bearing, distance, heading, velocity, isSentryRobot);
|
return new ScannedRobotEvent(name, energy, bearing, distance, heading, velocity, isSentryRobot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,125 +1,125 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A SkippedTurnEvent is sent to <see cref="AdvancedRobot.OnSkippedTurn(SkippedTurnEvent)"/>
|
/// A SkippedTurnEvent is sent to <see cref="AdvancedRobot.OnSkippedTurn(SkippedTurnEvent)"/>
|
||||||
/// OnSkippedTurn()} when your robot is forced to skipping a turn.
|
/// OnSkippedTurn()} when your robot is forced to skipping a turn.
|
||||||
/// You must take an action every turn in order to participate in the game.
|
/// You must take an action every turn in order to participate in the game.
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// Thread.Sleep(1000);
|
/// Thread.Sleep(1000);
|
||||||
/// </code>
|
/// </code>
|
||||||
/// will cause many SkippedTurnEvents, because you are not responding to the game.
|
/// will cause many SkippedTurnEvents, because you are not responding to the game.
|
||||||
/// If you receive 30 SkippedTurnEvents, you will be removed from the round.
|
/// If you receive 30 SkippedTurnEvents, you will be removed from the round.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Instead, you should do something such as:
|
/// Instead, you should do something such as:
|
||||||
/// <code>
|
/// <code>
|
||||||
/// for (int i = 0; i < 30; i++)
|
/// for (int i = 0; i < 30; i++)
|
||||||
/// {
|
/// {
|
||||||
/// DoNothing(); // or perhaps Scan();
|
/// DoNothing(); // or perhaps Scan();
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This event may also be generated if you are simply doing too much processing
|
/// This event may also be generated if you are simply doing too much processing
|
||||||
/// between actions, that is using too much processing power for the calculations
|
/// between actions, that is using too much processing power for the calculations
|
||||||
/// etc. in your robot.
|
/// etc. in your robot.
|
||||||
/// <seealso cref="AdvancedRobot.OnSkippedTurn(SkippedTurnEvent)"/>
|
/// <seealso cref="AdvancedRobot.OnSkippedTurn(SkippedTurnEvent)"/>
|
||||||
/// <seealso cref="SkippedTurnEvent"/>
|
/// <seealso cref="SkippedTurnEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class SkippedTurnEvent : Event
|
public sealed class SkippedTurnEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
||||||
|
|
||||||
private readonly long skippedTurn;
|
private readonly long skippedTurn;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by the game to create a new SkippedTurnEvent.
|
/// Called by the game to create a new SkippedTurnEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SkippedTurnEvent(long skippedTurn)
|
public SkippedTurnEvent(long skippedTurn)
|
||||||
{
|
{
|
||||||
this.skippedTurn = skippedTurn;
|
this.skippedTurn = skippedTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the turn that was skipped.
|
/// Returns the turn that was skipped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long SkippedTurn
|
public long SkippedTurn
|
||||||
{
|
{
|
||||||
get { return skippedTurn; }
|
get { return skippedTurn; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int Priority
|
public override int Priority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
if (statics.IsAdvancedRobot())
|
if (statics.IsAdvancedRobot())
|
||||||
{
|
{
|
||||||
IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();
|
IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnSkippedTurn(this);
|
listener.OnSkippedTurn(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override bool IsCriticalEvent
|
internal override bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.SkippedTurnEvent_TYPE; }
|
get { return RbSerializerN.SkippedTurnEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_LONG;
|
return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
var obj = (SkippedTurnEvent)objec;
|
var obj = (SkippedTurnEvent)objec;
|
||||||
|
|
||||||
serializer.serialize(buffer, obj.skippedTurn);
|
serializer.serialize(buffer, obj.skippedTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
long skippedTurn = buffer.getLong();
|
long skippedTurn = buffer.getLong();
|
||||||
|
|
||||||
return new SkippedTurnEvent(skippedTurn);
|
return new SkippedTurnEvent(skippedTurn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,66 +1,66 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event is sent to <see cref="Robot.OnStatus(StatusEvent)"/> every
|
/// This event is sent to <see cref="Robot.OnStatus(StatusEvent)"/> every
|
||||||
/// turn in a battle to provide the status of the robot.
|
/// turn in a battle to provide the status of the robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class StatusEvent : Event
|
public sealed class StatusEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 99;
|
private const int DEFAULT_PRIORITY = 99;
|
||||||
|
|
||||||
private readonly RobotStatus status;
|
private readonly RobotStatus status;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This constructor is called internally from the game in order to create
|
/// This constructor is called internally from the game in order to create
|
||||||
/// a new <see cref="RobotStatus"/>.
|
/// a new <see cref="RobotStatus"/>.
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="status">the current states</param>
|
/// <param name="status">the current states</param>
|
||||||
public StatusEvent(RobotStatus status)
|
public StatusEvent(RobotStatus status)
|
||||||
{
|
{
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="RobotStatus"/> at the time defined by <see cref="Robot.Time"/>.
|
/// Returns the <see cref="RobotStatus"/> at the time defined by <see cref="Robot.Time"/>.
|
||||||
/// <seealso cref="Event.Time"/>
|
/// <seealso cref="Event.Time"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RobotStatus Status
|
public RobotStatus Status
|
||||||
{
|
{
|
||||||
get { return status; }
|
get { return status; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnStatus(this);
|
listener.OnStatus(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { throw new System.Exception("Serialization of this type is not supported"); }
|
get { throw new System.Exception("Serialization of this type is not supported"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,193 +1,193 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
using Robocode.RobotInterfaces.Peer;
|
using Robocode.RobotInterfaces.Peer;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An advanced type of robot that supports sending messages between team
|
/// An advanced type of robot that supports sending messages between team
|
||||||
/// mates in a robot team.
|
/// mates in a robot team.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// If you have not done already, you should create a <see cref="Robot"/> or
|
/// If you have not done already, you should create a <see cref="Robot"/> or
|
||||||
/// <see cref="AdvancedRobot"/> first.
|
/// <see cref="AdvancedRobot"/> first.
|
||||||
/// <seealso cref="JuniorRobot"/>
|
/// <seealso cref="JuniorRobot"/>
|
||||||
/// <seealso cref="Robot"/>
|
/// <seealso cref="Robot"/>
|
||||||
/// <seealso cref="AdvancedRobot"/>
|
/// <seealso cref="AdvancedRobot"/>
|
||||||
/// <seealso cref="RateControlRobot"/>
|
/// <seealso cref="RateControlRobot"/>
|
||||||
/// <seealso cref="IDroid"/>
|
/// <seealso cref="IDroid"/>
|
||||||
/// <seealso cref="IBorderSentry"/>
|
/// <seealso cref="IBorderSentry"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class TeamRobot : AdvancedRobot, ITeamRobot, ITeamEvents
|
public abstract class TeamRobot : AdvancedRobot, ITeamRobot, ITeamEvents
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Broadcasts a message to all teammates.
|
/// Broadcasts a message to all teammates.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void Run()
|
/// public void Run()
|
||||||
/// {
|
/// {
|
||||||
/// BroadcastMessage("I'm here!");
|
/// BroadcastMessage("I'm here!");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">The message to broadcast to all teammates
|
/// <param name="message">The message to broadcast to all teammates
|
||||||
/// if the message could not be broadcasted to the teammates.
|
/// if the message could not be broadcasted to the teammates.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <seealso cref="IsTeammate(string)"/>
|
/// <seealso cref="IsTeammate(string)"/>
|
||||||
/// <seealso cref="Teammates()"/>
|
/// <seealso cref="Teammates()"/>
|
||||||
/// <seealso cref="SendMessage(string, object)"/>
|
/// <seealso cref="SendMessage(string, object)"/>
|
||||||
public void BroadcastMessage(object message)
|
public void BroadcastMessage(object message)
|
||||||
{
|
{
|
||||||
if (peer != null)
|
if (peer != null)
|
||||||
{
|
{
|
||||||
((ITeamRobotPeer) peer).BroadcastMessage(message);
|
((ITeamRobotPeer) peer).BroadcastMessage(message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UninitializedException();
|
UninitializedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list containing all MessageEvents currently in the robot's queue.
|
/// Returns a list containing all MessageEvents currently in the robot's queue.
|
||||||
/// You might, for example, call this while processing another event.
|
/// You might, for example, call this while processing another event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// foreach (MessageEvent e in GetMessageEvents())
|
/// foreach (MessageEvent e in GetMessageEvents())
|
||||||
/// {
|
/// {
|
||||||
/// // do something with e
|
/// // do something with e
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="OnMessageReceived(MessageEvent)"/>
|
/// <seealso cref="OnMessageReceived(MessageEvent)"/>
|
||||||
/// <seealso cref="MessageEvent"/>
|
/// <seealso cref="MessageEvent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MessageEvent> GetMessageEvents()
|
public IList<MessageEvent> GetMessageEvents()
|
||||||
{
|
{
|
||||||
if (peer != null)
|
if (peer != null)
|
||||||
{
|
{
|
||||||
return new List<MessageEvent>(((ITeamRobotPeer) peer).GetMessageEvents());
|
return new List<MessageEvent>(((ITeamRobotPeer) peer).GetMessageEvents());
|
||||||
}
|
}
|
||||||
UninitializedException();
|
UninitializedException();
|
||||||
return null; // never called
|
return null; // never called
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="ITeamRobot.GetTeamEventListener()"/>
|
/// <inheritdoc cref="ITeamRobot.GetTeamEventListener()"/>
|
||||||
ITeamEvents ITeamRobot.GetTeamEventListener()
|
ITeamEvents ITeamRobot.GetTeamEventListener()
|
||||||
{
|
{
|
||||||
return this; // this robot is listening
|
return this; // this robot is listening
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the names of all teammates, or null there is no teammates.
|
/// Returns the names of all teammates, or null there is no teammates.
|
||||||
/// The length of the string array is equal to the number of teammates.
|
/// The length of the string array is equal to the number of teammates.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void Run()
|
/// public void Run()
|
||||||
/// {
|
/// {
|
||||||
/// // Prints Out all teammates
|
/// // Prints Out all teammates
|
||||||
/// string[] teammates = GetTeammates();
|
/// string[] teammates = GetTeammates();
|
||||||
/// if (teammates != null)
|
/// if (teammates != null)
|
||||||
/// {
|
/// {
|
||||||
/// foreach (string member in teammates)
|
/// foreach (string member in teammates)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine(member);
|
/// Out.WriteLine(member);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="IsTeammate(string)"/>
|
/// <seealso cref="IsTeammate(string)"/>
|
||||||
/// <seealso cref="BroadcastMessage(object)"/>
|
/// <seealso cref="BroadcastMessage(object)"/>
|
||||||
/// <seealso cref="SendMessage(string, object)"/>
|
/// <seealso cref="SendMessage(string, object)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Teammates
|
public string[] Teammates
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (peer != null)
|
if (peer != null)
|
||||||
{
|
{
|
||||||
return ((ITeamRobotPeer) peer).GetTeammates();
|
return ((ITeamRobotPeer) peer).GetTeammates();
|
||||||
}
|
}
|
||||||
UninitializedException();
|
UninitializedException();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a given robot name is the name of one of your teammates.
|
/// Checks if a given robot name is the name of one of your teammates.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnScannedRobot(ScannedRobotEvent e)
|
/// public void OnScannedRobot(ScannedRobotEvent e)
|
||||||
/// {
|
/// {
|
||||||
/// if (IsTeammate(e.Name)
|
/// if (IsTeammate(e.Name)
|
||||||
/// {
|
/// {
|
||||||
/// return;
|
/// return;
|
||||||
/// }
|
/// }
|
||||||
/// Fire(1);
|
/// Fire(1);
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="Teammates"/>
|
/// <seealso cref="Teammates"/>
|
||||||
/// <seealso cref="BroadcastMessage(object)"/>
|
/// <seealso cref="BroadcastMessage(object)"/>
|
||||||
/// <seealso cref="SendMessage(string, object)"/>
|
/// <seealso cref="SendMessage(string, object)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The robot name to check</param>
|
/// <param name="name">The robot name to check</param>
|
||||||
public bool IsTeammate(string name)
|
public bool IsTeammate(string name)
|
||||||
{
|
{
|
||||||
if (peer != null)
|
if (peer != null)
|
||||||
{
|
{
|
||||||
return ((ITeamRobotPeer) peer).IsTeammate(name);
|
return ((ITeamRobotPeer) peer).IsTeammate(name);
|
||||||
}
|
}
|
||||||
UninitializedException();
|
UninitializedException();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void OnMessageReceived(MessageEvent evnt)
|
public virtual void OnMessageReceived(MessageEvent evnt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message to one (or more) teammates.
|
/// Sends a message to one (or more) teammates.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void Run()
|
/// public void Run()
|
||||||
/// {
|
/// {
|
||||||
/// SendMessage("Sample.DroidBot", "I'm here!");
|
/// SendMessage("Sample.DroidBot", "I'm here!");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="IsTeammate(string)"/>
|
/// <seealso cref="IsTeammate(string)"/>
|
||||||
/// <seealso cref="Teammates"/>
|
/// <seealso cref="Teammates"/>
|
||||||
/// <seealso cref="BroadcastMessage(object)"/>
|
/// <seealso cref="BroadcastMessage(object)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the intended recipient of the message</param>
|
/// <param name="name">The name of the intended recipient of the message</param>
|
||||||
/// <param name="message">The message to send</param>
|
/// <param name="message">The message to send</param>
|
||||||
public void SendMessage(string name, object message)
|
public void SendMessage(string name, object message)
|
||||||
{
|
{
|
||||||
if (peer != null)
|
if (peer != null)
|
||||||
{
|
{
|
||||||
((ITeamRobotPeer) peer).SendMessage(name, message);
|
((ITeamRobotPeer) peer).SendMessage(name, message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UninitializedException();
|
UninitializedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,134 +1,134 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using net.sf.robocode.io;
|
using net.sf.robocode.io;
|
||||||
using net.sf.robocode.security;
|
using net.sf.robocode.security;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper for .NET Thread, secured according to robocode rules.
|
/// Wrapper for .NET Thread, secured according to robocode rules.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Thread
|
public class Thread
|
||||||
{
|
{
|
||||||
private static readonly object syncRoot=new object();
|
private static readonly object syncRoot=new object();
|
||||||
private static int runningCounter;
|
private static int runningCounter;
|
||||||
|
|
||||||
private readonly System.Threading.Thread thread;
|
private readonly System.Threading.Thread thread;
|
||||||
private readonly ParameterizedThreadStart real1;
|
private readonly ParameterizedThreadStart real1;
|
||||||
private readonly ThreadStart real2;
|
private readonly ThreadStart real2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the Thread class
|
/// Initializes a new instance of the Thread class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="start">A ThreadStart delegate that represents the methods to be invoked when this thread begins executing.</param>
|
/// <param name="start">A ThreadStart delegate that represents the methods to be invoked when this thread begins executing.</param>
|
||||||
public Thread(ParameterizedThreadStart start)
|
public Thread(ParameterizedThreadStart start)
|
||||||
{
|
{
|
||||||
if (start == null)
|
if (start == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("start");
|
throw new ArgumentException("start");
|
||||||
}
|
}
|
||||||
int id = CheckCount();
|
int id = CheckCount();
|
||||||
real1 = start;
|
real1 = start;
|
||||||
thread = new System.Threading.Thread(main);
|
thread = new System.Threading.Thread(main);
|
||||||
string name = (string) AppDomain.CurrentDomain.GetData("robotName");
|
string name = (string) AppDomain.CurrentDomain.GetData("robotName");
|
||||||
if (!string.IsNullOrEmpty(name))
|
if (!string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
thread.Name = name + " [" + id + "]";
|
thread.Name = name + " [" + id + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the Thread class
|
/// Initializes a new instance of the Thread class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="start">A ThreadStart delegate that represents the methods to be invoked when this thread begins executing.</param>
|
/// <param name="start">A ThreadStart delegate that represents the methods to be invoked when this thread begins executing.</param>
|
||||||
public Thread(ThreadStart start)
|
public Thread(ThreadStart start)
|
||||||
{
|
{
|
||||||
if (start==null)
|
if (start==null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("start");
|
throw new ArgumentException("start");
|
||||||
}
|
}
|
||||||
int id = CheckCount();
|
int id = CheckCount();
|
||||||
real2 = start;
|
real2 = start;
|
||||||
thread = new System.Threading.Thread(main);
|
thread = new System.Threading.Thread(main);
|
||||||
string name = (string)AppDomain.CurrentDomain.GetData("robotName");
|
string name = (string)AppDomain.CurrentDomain.GetData("robotName");
|
||||||
if (!string.IsNullOrEmpty(name))
|
if (!string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
thread.Name = name + " [" + id + "]";
|
thread.Name = name + " [" + id + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int CheckCount()
|
private static int CheckCount()
|
||||||
{
|
{
|
||||||
lock (syncRoot)
|
lock (syncRoot)
|
||||||
{
|
{
|
||||||
if (runningCounter > 5)
|
if (runningCounter > 5)
|
||||||
{
|
{
|
||||||
string message = "Preventing " + HiddenAccessN.GetRobotName() + "from thread creation. You may only create 5 threads at same time.";
|
string message = "Preventing " + HiddenAccessN.GetRobotName() + "from thread creation. You may only create 5 threads at same time.";
|
||||||
LoggerN.logError(message);
|
LoggerN.logError(message);
|
||||||
LoggerN.WriteLineToRobotsConsole(message);
|
LoggerN.WriteLineToRobotsConsole(message);
|
||||||
throw new AccessViolationException(message);
|
throw new AccessViolationException(message);
|
||||||
}
|
}
|
||||||
runningCounter++;
|
runningCounter++;
|
||||||
return runningCounter;
|
return runningCounter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Blocks the current thread for the specified number of milliseconds.
|
/// Blocks the current thread for the specified number of milliseconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Sleep(int millisecondsTimeout)
|
public static void Sleep(int millisecondsTimeout)
|
||||||
{
|
{
|
||||||
System.Threading.Thread.Sleep(millisecondsTimeout);
|
System.Threading.Thread.Sleep(millisecondsTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Causes a thread to be scheduled for execution.
|
/// Causes a thread to be scheduled for execution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start(object param)
|
public void Start(object param)
|
||||||
{
|
{
|
||||||
thread.Start(param);
|
thread.Start(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Causes a thread to be scheduled for execution.
|
/// Causes a thread to be scheduled for execution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
thread.Start(null);
|
thread.Start(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void main(object param)
|
private void main(object param)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (real1!=null)
|
if (real1!=null)
|
||||||
{
|
{
|
||||||
real1.Invoke(param);
|
real1.Invoke(param);
|
||||||
}
|
}
|
||||||
real2.Invoke();
|
real2.Invoke();
|
||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Undandled exception on thread " + thread.Name);
|
Console.WriteLine("Undandled exception on thread " + thread.Name);
|
||||||
Console.WriteLine(ex);
|
Console.WriteLine(ex);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
lock (syncRoot)
|
lock (syncRoot)
|
||||||
{
|
{
|
||||||
runningCounter--;
|
runningCounter--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,52 +1,52 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A prebuilt condition you can use that indicates your robot has finished turning.
|
/// A prebuilt condition you can use that indicates your robot has finished turning.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="Condition"/>
|
/// <seealso cref="Condition"/>
|
||||||
public class TurnCompleteCondition : Condition
|
public class TurnCompleteCondition : Condition
|
||||||
{
|
{
|
||||||
private readonly AdvancedRobot robot;
|
private readonly AdvancedRobot robot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new TurnCompleteCondition with default priority.
|
/// Creates a new TurnCompleteCondition with default priority.
|
||||||
/// The default priority is 80.
|
/// The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||||
public TurnCompleteCondition(AdvancedRobot robot)
|
public TurnCompleteCondition(AdvancedRobot robot)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new TurnCompleteCondition with the specified priority.
|
/// Creates a new TurnCompleteCondition with the specified priority.
|
||||||
/// A condition priority is a value from 0 - 99. The higher value, the
|
/// A condition priority is a value from 0 - 99. The higher value, the
|
||||||
/// higher priority. The default priority is 80.
|
/// higher priority. The default priority is 80.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
/// <param name="robot">Your robot, which must be an <see cref="AdvancedRobot"/></param>
|
||||||
/// <param name="priority">The priority of this condition</param>
|
/// <param name="priority">The priority of this condition</param>
|
||||||
/// <seealso cref="Condition.Priority"/>
|
/// <seealso cref="Condition.Priority"/>
|
||||||
public TurnCompleteCondition(AdvancedRobot robot, int priority)
|
public TurnCompleteCondition(AdvancedRobot robot, int priority)
|
||||||
{
|
{
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests if the robot has finished turning.
|
/// Tests if the robot has finished turning.
|
||||||
/// Returns true if the robot has stopped turning; false otherwise
|
/// Returns true if the robot has stopped turning; false otherwise
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool Test()
|
public override bool Test()
|
||||||
{
|
{
|
||||||
return (robot.TurnRemaining == 0);
|
return (robot.TurnRemaining == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,80 +1,80 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using net.sf.robocode.nio;
|
using net.sf.robocode.nio;
|
||||||
using net.sf.robocode.peer;
|
using net.sf.robocode.peer;
|
||||||
using net.sf.robocode.serialization;
|
using net.sf.robocode.serialization;
|
||||||
using Robocode.RobotInterfaces;
|
using Robocode.RobotInterfaces;
|
||||||
|
|
||||||
namespace Robocode
|
namespace Robocode
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// This event is sent to <see cref="Robot.OnWin(WinEvent)"/> when your robot
|
/// This event is sent to <see cref="Robot.OnWin(WinEvent)"/> when your robot
|
||||||
/// wins the round in a battle.
|
/// wins the round in a battle.
|
||||||
///</summary>
|
///</summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class WinEvent : Event
|
public sealed class WinEvent : Event
|
||||||
{
|
{
|
||||||
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int Priority
|
public override int Priority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override int DefaultPriority
|
internal override int DefaultPriority
|
||||||
{
|
{
|
||||||
get { return DEFAULT_PRIORITY; }
|
get { return DEFAULT_PRIORITY; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
|
||||||
{
|
{
|
||||||
IBasicEvents listener = robot.GetBasicEventListener();
|
IBasicEvents listener = robot.GetBasicEventListener();
|
||||||
|
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
{
|
{
|
||||||
listener.OnWin(this);
|
listener.OnWin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override bool IsCriticalEvent
|
internal override bool IsCriticalEvent
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override byte SerializationType
|
internal override byte SerializationType
|
||||||
{
|
{
|
||||||
get { return RbSerializerN.WinEvent_TYPE; }
|
get { return RbSerializerN.WinEvent_TYPE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ISerializableHelperN createHiddenSerializer()
|
private static ISerializableHelperN createHiddenSerializer()
|
||||||
{
|
{
|
||||||
return new SerializableHelper();
|
return new SerializableHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SerializableHelper : ISerializableHelperN
|
private class SerializableHelper : ISerializableHelperN
|
||||||
{
|
{
|
||||||
public int sizeOf(RbSerializerN serializer, object objec)
|
public int sizeOf(RbSerializerN serializer, object objec)
|
||||||
{
|
{
|
||||||
return RbSerializerN.SIZEOF_TYPEINFO;
|
return RbSerializerN.SIZEOF_TYPEINFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
return new WinEvent();
|
return new WinEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,48 +1,48 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Robocode.Exception
|
namespace Robocode.Exception
|
||||||
{
|
{
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class EventInterruptedException : System.Exception
|
public class EventInterruptedException : System.Exception
|
||||||
{
|
{
|
||||||
private readonly int priority = int.MinValue;
|
private readonly int priority = int.MinValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used by game
|
/// Used by game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EventInterruptedException(int priority)
|
public EventInterruptedException(int priority)
|
||||||
{
|
{
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Last top priority
|
/// Last top priority
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Priority
|
public int Priority
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialization constructor
|
/// Serialization constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected EventInterruptedException(SerializationInfo info, StreamingContext context) :
|
protected EventInterruptedException(SerializationInfo info, StreamingContext context) :
|
||||||
base(info, context)
|
base(info, context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,45 +1,45 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Robocode.Exception
|
namespace Robocode.Exception
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Throw this exception to stop robot
|
/// Throw this exception to stop robot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RobotException : System.Exception
|
public class RobotException : System.Exception
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RobotException()
|
public RobotException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor with message
|
/// Constructor with message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RobotException(string s)
|
public RobotException(string s)
|
||||||
: base(s)
|
: base(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deserialization constructor
|
/// Deserialization constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected RobotException(SerializationInfo info, StreamingContext context) :
|
protected RobotException(SerializationInfo info, StreamingContext context) :
|
||||||
base(info, context)
|
base(info, context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,52 +1,52 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event interface for receiving advanced robot events with an
|
/// An event interface for receiving advanced robot events with an
|
||||||
/// <see cref="IAdvancedRobot"/>
|
/// <see cref="IAdvancedRobot"/>
|
||||||
/// <seealso cref="IAdvancedRobot"/>
|
/// <seealso cref="IAdvancedRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAdvancedEvents
|
public interface IAdvancedEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called if the robot is using too much time between
|
/// This method is called if the robot is using too much time between
|
||||||
/// actions. When this event occur, the robot's turn is skipped, meaning that
|
/// actions. When this event occur, the robot's turn is skipped, meaning that
|
||||||
/// it cannot take action anymore in this turn.
|
/// it cannot take action anymore in this turn.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// If you receive 30 skipped turn event, your robot will be removed from the
|
/// If you receive 30 skipped turn event, your robot will be removed from the
|
||||||
/// round and loose the round.
|
/// round and loose the round.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// You will only receive this event after taking an action. So a robot in an
|
/// You will only receive this event after taking an action. So a robot in an
|
||||||
/// infinite loop will not receive any events, and will simply be stopped.
|
/// infinite loop will not receive any events, and will simply be stopped.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// No correctly working, reasonable robot should ever receive this event
|
/// No correctly working, reasonable robot should ever receive this event
|
||||||
/// unless it is using too many CPU cycles.
|
/// unless it is using too many CPU cycles.
|
||||||
/// <seealso cref="Robocode.SkippedTurnEvent"/>
|
/// <seealso cref="Robocode.SkippedTurnEvent"/>
|
||||||
/// <seealso cref="Robocode.Event"/>
|
/// <seealso cref="Robocode.Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">The skipped turn event set by the game</param>
|
/// <param name="evnt">The skipped turn event set by the game</param>
|
||||||
void OnSkippedTurn(SkippedTurnEvent evnt);
|
void OnSkippedTurn(SkippedTurnEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a custom condition is met.
|
/// This method is called when a custom condition is met.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the sample robots for examples of use, e.g. the Sample.Target
|
/// See the sample robots for examples of use, e.g. the Sample.Target
|
||||||
/// robot.
|
/// robot.
|
||||||
/// <seealso cref="Robocode.AdvancedRobot.AddCustomEvent(Condition)"/>
|
/// <seealso cref="Robocode.AdvancedRobot.AddCustomEvent(Condition)"/>
|
||||||
/// <seealso cref="Robocode.CustomEvent"/>
|
/// <seealso cref="Robocode.CustomEvent"/>
|
||||||
/// <seealso cref="Robocode.Event"/>
|
/// <seealso cref="Robocode.Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">The custom event that occurred</param>
|
/// <param name="evnt">The custom event that occurred</param>
|
||||||
void OnCustomEvent(CustomEvent evnt);
|
void OnCustomEvent(CustomEvent evnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,32 +1,32 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot interface for creating a more advanced type of robot like
|
/// A robot interface for creating a more advanced type of robot like
|
||||||
/// <see cref="Robocode.AdvancedRobot"/> that is able to handle advanced robot events.
|
/// <see cref="Robocode.AdvancedRobot"/> that is able to handle advanced robot events.
|
||||||
/// An advanced robot allows non-blocking calls, custom events, get notifications
|
/// An advanced robot allows non-blocking calls, custom events, get notifications
|
||||||
/// about skipped turns, and also allow writes to the file system.
|
/// about skipped turns, and also allow writes to the file system.
|
||||||
/// <seealso cref="Robocode.AdvancedRobot"/>
|
/// <seealso cref="Robocode.AdvancedRobot"/>
|
||||||
/// <seealso cref="IBasicRobot"/>
|
/// <seealso cref="IBasicRobot"/>
|
||||||
/// <seealso cref="IJuniorRobot"/>
|
/// <seealso cref="IJuniorRobot"/>
|
||||||
/// <seealso cref="IInteractiveRobot"/>
|
/// <seealso cref="IInteractiveRobot"/>
|
||||||
/// <seealso cref="ITeamRobot"/>
|
/// <seealso cref="ITeamRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAdvancedRobot : IBasicRobot
|
public interface IAdvancedRobot : IBasicRobot
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the game to notify this robot about advanced
|
/// This method is called by the game to notify this robot about advanced
|
||||||
/// robot event. Hence, this method must be implemented so it returns your
|
/// robot event. Hence, this method must be implemented so it returns your
|
||||||
/// <see cref="IAdvancedEvents"/> listener.
|
/// <see cref="IAdvancedEvents"/> listener.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IAdvancedEvents GetAdvancedEventListener();
|
IAdvancedEvents GetAdvancedEventListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,270 +1,270 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event interface for receiving basic robot events with an
|
/// An event interface for receiving basic robot events with an
|
||||||
/// <see cref="IBasicRobot"/>.
|
/// <see cref="IBasicRobot"/>.
|
||||||
/// <seealso cref="IBasicRobot"/>
|
/// <seealso cref="IBasicRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBasicEvents
|
public interface IBasicEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called every turn in a battle round in order to provide
|
/// This method is called every turn in a battle round in order to provide
|
||||||
/// the robot status as a complete snapshot of the robot's current state at
|
/// the robot status as a complete snapshot of the robot's current state at
|
||||||
/// that specific time.
|
/// that specific time.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// The main benefit of this method is that you'll automatically receive all
|
/// The main benefit of this method is that you'll automatically receive all
|
||||||
/// current data values of the robot like e.g. the x and y coordinate,
|
/// current data values of the robot like e.g. the x and y coordinate,
|
||||||
/// heading, gun heat etc., which are grouped into the exact same time/turn.
|
/// heading, gun heat etc., which are grouped into the exact same time/turn.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This is the only way to map the robots data values to a specific time.
|
/// This is the only way to map the robots data values to a specific time.
|
||||||
/// For example, it is not possible to determine the exact time of the
|
/// For example, it is not possible to determine the exact time of the
|
||||||
/// robot's heading by calling first calling <see cref="Robot.Time"/> and then
|
/// robot's heading by calling first calling <see cref="Robot.Time"/> and then
|
||||||
/// <see cref="Robot.Heading"/> afterwards, as the time <em>might</em> change
|
/// <see cref="Robot.Heading"/> afterwards, as the time <em>might</em> change
|
||||||
/// after between the <see cref="Robot.Time"/> and <see cref="Robot.Heading"/>
|
/// after between the <see cref="Robot.Time"/> and <see cref="Robot.Heading"/>
|
||||||
/// call.
|
/// call.
|
||||||
/// <seealso cref="StatusEvent"/>
|
/// <seealso cref="StatusEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnStatus(StatusEvent evnt);
|
void OnStatus(StatusEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when one of your bullets hits another robot.
|
/// This method is called when one of your bullets hits another robot.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnBulletHit(BulletHitEvent evnt)
|
/// public void OnBulletHit(BulletHitEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine("I hit " + evnt.Name + "!");
|
/// Out.WriteLine("I hit " + evnt.Name + "!");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="BulletHitEvent"/>
|
/// <seealso cref="BulletHitEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnBulletHit(BulletHitEvent evnt);
|
void OnBulletHit(BulletHitEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when one of your bullets hits another bullet.
|
/// This method is called when one of your bullets hits another bullet.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnBulletHitBullet(BulletHitBulletEvent evnt)
|
/// public void OnBulletHitBullet(BulletHitBulletEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine("I hit a bullet fired by " + evnt.Bullet.Name + "!");
|
/// Out.WriteLine("I hit a bullet fired by " + evnt.Bullet.Name + "!");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
///</example>
|
///</example>
|
||||||
/// <seealso cref="BulletHitBulletEvent"/>
|
/// <seealso cref="BulletHitBulletEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnBulletHitBullet(BulletHitBulletEvent evnt);
|
void OnBulletHitBullet(BulletHitBulletEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when one of your bullets misses, i.e. hits a wall.
|
/// This method is called when one of your bullets misses, i.e. hits a wall.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnBulletMissed(BulletMissedEvent evnt)
|
/// public void OnBulletMissed(BulletMissedEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine("Drat, I missed.");
|
/// Out.WriteLine("Drat, I missed.");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
///</example>
|
///</example>
|
||||||
/// <seealso cref="BulletMissedEvent"/>
|
/// <seealso cref="BulletMissedEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnBulletMissed(BulletMissedEvent evnt);
|
void OnBulletMissed(BulletMissedEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called if your robot dies.
|
/// This method is called if your robot dies.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event. Actions will have no effect if called from this section. The
|
/// event. Actions will have no effect if called from this section. The
|
||||||
/// intent is to allow you to perform calculations or print something out
|
/// intent is to allow you to perform calculations or print something out
|
||||||
/// when the robot is killed.
|
/// when the robot is killed.
|
||||||
/// <seealso cref="DeathEvent"/>
|
/// <seealso cref="DeathEvent"/>
|
||||||
/// <seealso cref="WinEvent"/>
|
/// <seealso cref="WinEvent"/>
|
||||||
/// <seealso cref="BattleEndedEvent"/>
|
/// <seealso cref="BattleEndedEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnDeath(DeathEvent evnt);
|
void OnDeath(DeathEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when your robot is hit by a bullet.
|
/// This method is called when your robot is hit by a bullet.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// void OnHitByBullet(HitByBulletEvent evnt)
|
/// void OnHitByBullet(HitByBulletEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine(event.RobotName + " hit me!");
|
/// Out.WriteLine(event.RobotName + " hit me!");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
///</example>
|
///</example>
|
||||||
/// <seealso cref="HitByBulletEvent"/>
|
/// <seealso cref="HitByBulletEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnHitByBullet(HitByBulletEvent evnt);
|
void OnHitByBullet(HitByBulletEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when your robot collides with another robot.
|
/// This method is called when your robot collides with another robot.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// void OnHitRobot(HitRobotEvent evnt)
|
/// void OnHitRobot(HitRobotEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// if (event.Bearing > -90 && evnt.Bearing <= 90)
|
/// if (event.Bearing > -90 && evnt.Bearing <= 90)
|
||||||
/// {
|
/// {
|
||||||
/// Back(100);
|
/// Back(100);
|
||||||
/// }
|
/// }
|
||||||
/// else
|
/// else
|
||||||
/// {
|
/// {
|
||||||
/// Ahead(100);
|
/// Ahead(100);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// -- or perhaps, for a more advanced robot --
|
/// -- or perhaps, for a more advanced robot --
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnHitRobot(HitRobotEvent evnt)
|
/// public void OnHitRobot(HitRobotEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// if (event.Bearing > -90 && evnt.Bearing <= 90)
|
/// if (event.Bearing > -90 && evnt.Bearing <= 90)
|
||||||
/// {
|
/// {
|
||||||
/// SetBack(100);
|
/// SetBack(100);
|
||||||
/// }
|
/// }
|
||||||
/// else
|
/// else
|
||||||
/// {
|
/// {
|
||||||
/// SetAhead(100);
|
/// SetAhead(100);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// The angle is relative to your robot's facing. So 0 is straight ahead of
|
/// The angle is relative to your robot's facing. So 0 is straight ahead of
|
||||||
/// you.
|
/// you.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This event can be generated if another robot hits you, in which case
|
/// This event can be generated if another robot hits you, in which case
|
||||||
/// <see cref="HitRobotEvent.IsMyFault()"/> will return false.
|
/// <see cref="HitRobotEvent.IsMyFault()"/> will return false.
|
||||||
/// In this case, you will not be automatically stopped by the game --
|
/// In this case, you will not be automatically stopped by the game --
|
||||||
/// but if you continue moving toward the robot you will hit it (and
|
/// but if you continue moving toward the robot you will hit it (and
|
||||||
/// generate another event). If you are moving away, then you won't hit it.
|
/// generate another event). If you are moving away, then you won't hit it.
|
||||||
/// <seealso cref="HitRobotEvent"/>
|
/// <seealso cref="HitRobotEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnHitRobot(HitRobotEvent evnt);
|
void OnHitRobot(HitRobotEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when your robot collides with a wall.
|
/// This method is called when your robot collides with a wall.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// The wall at the top of the screen is 0 degrees, right is 90 degrees,
|
/// The wall at the top of the screen is 0 degrees, right is 90 degrees,
|
||||||
/// bottom is 180 degrees, left is 270 degrees. But this event is relative to
|
/// bottom is 180 degrees, left is 270 degrees. But this event is relative to
|
||||||
/// your heading, so: The bearing is such that <see cref="Robot.TurnRight(double)"/>
|
/// your heading, so: The bearing is such that <see cref="Robot.TurnRight(double)"/>
|
||||||
/// <see cref="HitWallEvent.Bearing"/> will point you perpendicular to the wall.
|
/// <see cref="HitWallEvent.Bearing"/> will point you perpendicular to the wall.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// void OnHitWall(HitWallEvent evnt)
|
/// void OnHitWall(HitWallEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine("Ouch, I hit a wall bearing " + evnt.Bearing + " degrees.");
|
/// Out.WriteLine("Ouch, I hit a wall bearing " + evnt.Bearing + " degrees.");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="HitWallEvent"/>
|
/// <seealso cref="HitWallEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnHitWall(HitWallEvent evnt);
|
void OnHitWall(HitWallEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when your robot sees another robot, i.e. when the
|
/// This method is called when your robot sees another robot, i.e. when the
|
||||||
/// robot's radar scan "hits" another robot.
|
/// robot's radar scan "hits" another robot.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event. (Almost all robots should override this!)
|
/// event. (Almost all robots should override this!)
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This event is automatically called if there is a robot in range of your
|
/// This event is automatically called if there is a robot in range of your
|
||||||
/// radar.
|
/// radar.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the robot's radar can only see robot within the range defined
|
/// Note that the robot's radar can only see robot within the range defined
|
||||||
/// by <see cref="Rules.RADAR_SCAN_RADIUS"/> (1200 pixels).
|
/// by <see cref="Rules.RADAR_SCAN_RADIUS"/> (1200 pixels).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Also not that the bearing of the scanned robot is relative to your
|
/// Also not that the bearing of the scanned robot is relative to your
|
||||||
/// robot's heading.
|
/// robot's heading.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// void OnScannedRobot(ScannedRobotEvent evnt)
|
/// void OnScannedRobot(ScannedRobotEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// // Assuming radar and gun are aligned...
|
/// // Assuming radar and gun are aligned...
|
||||||
/// if (event.Distance < 100)
|
/// if (event.Distance < 100)
|
||||||
/// {
|
/// {
|
||||||
/// Fire(3);
|
/// Fire(3);
|
||||||
/// }
|
/// }
|
||||||
/// else
|
/// else
|
||||||
/// {
|
/// {
|
||||||
/// Fire(1);
|
/// Fire(1);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <b>Note:</b><br/>
|
/// <b>Note:</b><br/>
|
||||||
/// The game assists Robots in firing, as follows:
|
/// The game assists Robots in firing, as follows:
|
||||||
/// <ul>
|
/// <ul>
|
||||||
/// <li>If the gun and radar are aligned (and were aligned last turn),</li>
|
/// <li>If the gun and radar are aligned (and were aligned last turn),</li>
|
||||||
/// <li>and the event is current,</li>
|
/// <li>and the event is current,</li>
|
||||||
/// <li>and you call Fire() before taking any other actions, Robot.Fire(double) will Fire directly at the robot.</li>
|
/// <li>and you call Fire() before taking any other actions, Robot.Fire(double) will Fire directly at the robot.</li>
|
||||||
/// </ul>
|
/// </ul>
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// In essence, this means that if you can see a robot, and it doesn't move,
|
/// In essence, this means that if you can see a robot, and it doesn't move,
|
||||||
/// then Fire will hit it.
|
/// then Fire will hit it.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// AdvancedRobots will NOT be assisted in this manner, and are expected to
|
/// AdvancedRobots will NOT be assisted in this manner, and are expected to
|
||||||
/// examine the event to determine if <see cref="Robot.Fire(double)"/> would
|
/// examine the event to determine if <see cref="Robot.Fire(double)"/> would
|
||||||
/// hit. (i.e. you are spinning your gun around, but by the time you get the
|
/// hit. (i.e. you are spinning your gun around, but by the time you get the
|
||||||
/// event, your gun is 5 degrees past the robot).
|
/// event, your gun is 5 degrees past the robot).
|
||||||
/// <seealso cref="ScannedRobotEvent"/>
|
/// <seealso cref="ScannedRobotEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// <seealso cref="Rules.RADAR_SCAN_RADIUS"/>
|
/// <seealso cref="Rules.RADAR_SCAN_RADIUS"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnScannedRobot(ScannedRobotEvent evnt);
|
void OnScannedRobot(ScannedRobotEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when another robot dies.
|
/// This method is called when another robot dies.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <seealso cref="RobotDeathEvent"/>
|
/// <seealso cref="RobotDeathEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnRobotDeath(RobotDeathEvent evnt);
|
void OnRobotDeath(RobotDeathEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called if your robot wins a battle.
|
/// This method is called if your robot wins a battle.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Your robot could perform a victory dance here! :-)
|
/// Your robot could perform a victory dance here! :-)
|
||||||
/// <seealso cref="DeathEvent"/>
|
/// <seealso cref="DeathEvent"/>
|
||||||
/// <seealso cref="BattleEndedEvent"/>
|
/// <seealso cref="BattleEndedEvent"/>
|
||||||
/// <seealso cref="Event"/>
|
/// <seealso cref="Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnWin(WinEvent evnt);
|
void OnWin(WinEvent evnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,38 +1,38 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// First extended version of the <see cref="IBasicEvents"/> interface.
|
/// First extended version of the <see cref="IBasicEvents"/> interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBasicEvents2 : IBasicEvents
|
public interface IBasicEvents2 : IBasicEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called after end of the battle, even when the battle is aborted.
|
/// This method is called after end of the battle, even when the battle is aborted.
|
||||||
/// You should override it in your robot if you want to be informed of this event.
|
/// You should override it in your robot if you want to be informed of this event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnBattleEnded(BattleEndedEvent evnt)
|
/// public void OnBattleEnded(BattleEndedEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine("The battle has ended");
|
/// Out.WriteLine("The battle has ended");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="BattleEndedEvent"/>
|
/// <seealso cref="BattleEndedEvent"/>
|
||||||
/// <seealso cref="Robocode.WinEvent"/>
|
/// <seealso cref="Robocode.WinEvent"/>
|
||||||
/// <seealso cref="Robocode.DeathEvent"/>
|
/// <seealso cref="Robocode.DeathEvent"/>
|
||||||
/// <seealso cref="Robocode.Event"/>
|
/// <seealso cref="Robocode.Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnBattleEnded(BattleEndedEvent evnt);
|
void OnBattleEnded(BattleEndedEvent evnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,40 +1,40 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Second extended version of the <see cref="IBasicEvents"/> interface.
|
/// Second extended version of the <see cref="IBasicEvents"/> interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBasicEvents3 : IBasicEvents2
|
public interface IBasicEvents3 : IBasicEvents2
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called after the end of a round.
|
/// This method is called after the end of a round.
|
||||||
/// You should override it in your robot if you want to be informed of this event.
|
/// You should override it in your robot if you want to be informed of this event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnRoundEnded(RoundEndedEvent event)
|
/// public void OnRoundEnded(RoundEndedEvent event)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine("The round has ended");
|
/// Out.WriteLine("The round has ended");
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="RoundEndedEvent"/>
|
/// <seealso cref="RoundEndedEvent"/>
|
||||||
/// <seealso cref="IBasicEvents2.OnBattleEnded(BattleEndedEvent)"/>
|
/// <seealso cref="IBasicEvents2.OnBattleEnded(BattleEndedEvent)"/>
|
||||||
/// <seealso cref="Robocode.WinEvent"/>
|
/// <seealso cref="Robocode.WinEvent"/>
|
||||||
/// <seealso cref="Robocode.DeathEvent"/>
|
/// <seealso cref="Robocode.DeathEvent"/>
|
||||||
/// <seealso cref="Robocode.Event"/>
|
/// <seealso cref="Robocode.Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt"></param>
|
/// <param name="evnt"></param>
|
||||||
void OnRoundEnded(RoundEndedEvent evnt);
|
void OnRoundEnded(RoundEndedEvent evnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Robocode.RobotInterfaces.Peer;
|
using Robocode.RobotInterfaces.Peer;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot interface for creating a basic type of robot like <see cref="Robocode.Robot"/>
|
/// A robot interface for creating a basic type of robot like <see cref="Robocode.Robot"/>
|
||||||
/// that is able to receive common robot events, but not interactive events as
|
/// that is able to receive common robot events, but not interactive events as
|
||||||
/// with the <see cref="Robocode.Robot"/> class.
|
/// with the <see cref="Robocode.Robot"/> class.
|
||||||
/// A basic robot allows blocking calls only and cannot handle custom events nor
|
/// A basic robot allows blocking calls only and cannot handle custom events nor
|
||||||
/// writes to the file system like an advanced robot.
|
/// writes to the file system like an advanced robot.
|
||||||
/// <seealso cref="Robocode.Robot"/>
|
/// <seealso cref="Robocode.Robot"/>
|
||||||
/// <seealso cref="IJuniorRobot"/>
|
/// <seealso cref="IJuniorRobot"/>
|
||||||
/// <seealso cref="IInteractiveRobot"/>
|
/// <seealso cref="IInteractiveRobot"/>
|
||||||
/// <seealso cref="IAdvancedRobot"/>
|
/// <seealso cref="IAdvancedRobot"/>
|
||||||
/// <seealso cref="ITeamRobot"/>
|
/// <seealso cref="ITeamRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBasicRobot
|
public interface IBasicRobot
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the game to invoke the <see cref="IRunnable.Run()"/>
|
/// This method is called by the game to invoke the <see cref="IRunnable.Run()"/>
|
||||||
/// method of your robot, where the program of your robot is implemented.
|
/// method of your robot, where the program of your robot is implemented.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IRunnable GetRobotRunnable();
|
IRunnable GetRobotRunnable();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the game to notify this robot about basic
|
/// This method is called by the game to notify this robot about basic
|
||||||
/// robot event. Hence, this method must be implemented so it returns your
|
/// robot event. Hence, this method must be implemented so it returns your
|
||||||
/// <see cref="IBasicEvents"/> listener.
|
/// <see cref="IBasicEvents"/> listener.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IBasicEvents GetBasicEventListener();
|
IBasicEvents GetBasicEventListener();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Do not call this method! Your robot will simply stop interacting with
|
/// Do not call this method! Your robot will simply stop interacting with
|
||||||
/// the game.
|
/// the game.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This method is called by the game. A robot peer is the object that deals
|
/// This method is called by the game. A robot peer is the object that deals
|
||||||
/// with game mechanics and rules, and makes sure your robot abides by them.
|
/// with game mechanics and rules, and makes sure your robot abides by them.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void SetPeer(IBasicRobotPeer peer);
|
void SetPeer(IBasicRobotPeer peer);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Do not call this method!
|
/// Do not call this method!
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This method is called by the game when setting the Out stream for your
|
/// This method is called by the game when setting the Out stream for your
|
||||||
/// robot.
|
/// robot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void SetOut(TextWriter output);
|
void SetOut(TextWriter output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,183 +1,183 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event interface for receiving interactive events with an <see cref="IInteractiveRobot"/>.
|
/// An event interface for receiving interactive events with an <see cref="IInteractiveRobot"/>.
|
||||||
/// <seealso cref="IInteractiveRobot"/>
|
/// <seealso cref="IInteractiveRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IInteractiveEvents
|
public interface IInteractiveEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a key has been pressed.
|
/// This method is called when a key has been pressed.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// key events.
|
/// key events.
|
||||||
/// <seealso cref="OnKeyReleased(KeyEvent)"/>
|
/// <seealso cref="OnKeyReleased(KeyEvent)"/>
|
||||||
/// <seealso cref="OnKeyTyped(KeyEvent)"/>
|
/// <seealso cref="OnKeyTyped(KeyEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnKeyPressed(KeyEvent evnt);
|
void OnKeyPressed(KeyEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a key has been released.
|
/// This method is called when a key has been released.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// key events.
|
/// key events.
|
||||||
/// <seealso cref="OnKeyPressed(KeyEvent)"/>
|
/// <seealso cref="OnKeyPressed(KeyEvent)"/>
|
||||||
/// <seealso cref="OnKeyTyped(KeyEvent)"/>
|
/// <seealso cref="OnKeyTyped(KeyEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnKeyReleased(KeyEvent evnt);
|
void OnKeyReleased(KeyEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a key has been typed (pressed and released).
|
/// This method is called when a key has been typed (pressed and released).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// key events.
|
/// key events.
|
||||||
/// <seealso cref="OnKeyPressed(KeyEvent)"/>
|
/// <seealso cref="OnKeyPressed(KeyEvent)"/>
|
||||||
/// <seealso cref="OnKeyReleased(KeyEvent)"/>
|
/// <seealso cref="OnKeyReleased(KeyEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnKeyTyped(KeyEvent evnt);
|
void OnKeyTyped(KeyEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a mouse button has been clicked (pressed and
|
/// This method is called when a mouse button has been clicked (pressed and
|
||||||
/// released).
|
/// released).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseClicked(MouseEvent evnt);
|
void OnMouseClicked(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the mouse has entered the battle view.
|
/// This method is called when the mouse has entered the battle view.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseEntered(MouseEvent evnt);
|
void OnMouseEntered(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the mouse has exited the battle view.
|
/// This method is called when the mouse has exited the battle view.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseExited(MouseEvent evnt);
|
void OnMouseExited(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a mouse button has been pressed.
|
/// This method is called when a mouse button has been pressed.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMousePressed(MouseEvent evnt);
|
void OnMousePressed(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a mouse button has been released.
|
/// This method is called when a mouse button has been released.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseReleased(MouseEvent evnt);
|
void OnMouseReleased(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the mouse has been moved.
|
/// This method is called when the mouse has been moved.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseMoved(MouseEvent evnt);
|
void OnMouseMoved(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a mouse button has been pressed and then
|
/// This method is called when a mouse button has been pressed and then
|
||||||
/// dragged.
|
/// dragged.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
/// <seealso cref="OnMouseWheelMoved(MouseWheelMovedEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseDragged(MouseEvent evnt);
|
void OnMouseDragged(MouseEvent evnt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the mouse wheel has been rotated.
|
/// This method is called when the mouse wheel has been rotated.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// See the Sample.Interactive robot for an example of how to use
|
/// See the Sample.Interactive robot for an example of how to use
|
||||||
/// mouse events.
|
/// mouse events.
|
||||||
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
/// <seealso cref="OnMouseMoved(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
/// <seealso cref="OnMousePressed(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
/// <seealso cref="OnMouseReleased(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
/// <seealso cref="OnMouseClicked(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
/// <seealso cref="OnMouseEntered(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
/// <seealso cref="OnMouseExited(MouseEvent)"/>
|
||||||
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
/// <seealso cref="OnMouseDragged(MouseEvent)"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">Holds details about current event</param>
|
/// <param name="evnt">Holds details about current event</param>
|
||||||
void OnMouseWheelMoved(MouseWheelMovedEvent evnt);
|
void OnMouseWheelMoved(MouseWheelMovedEvent evnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,36 +1,36 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot interface for creating an interactive type of robot like
|
/// A robot interface for creating an interactive type of robot like
|
||||||
/// <see cref="Robocode.Robot"/> and <see cref="Robocode.AdvancedRobot"/> that is able to
|
/// <see cref="Robocode.Robot"/> and <see cref="Robocode.AdvancedRobot"/> that is able to
|
||||||
/// receive interactive events from the keyboard or mouse.
|
/// receive interactive events from the keyboard or mouse.
|
||||||
/// If a robot is directly inherited from this class it will behave as similar to
|
/// If a robot is directly inherited from this class it will behave as similar to
|
||||||
/// a <see cref="IBasicRobot"/>. If you need it to behave similar to an
|
/// a <see cref="IBasicRobot"/>. If you need it to behave similar to an
|
||||||
/// <see cref="IAdvancedRobot"/> or <see cref="ITeamRobot"/>, you should inherit from these
|
/// <see cref="IAdvancedRobot"/> or <see cref="ITeamRobot"/>, you should inherit from these
|
||||||
/// interfaces instead, as these are inherited from this interface.
|
/// interfaces instead, as these are inherited from this interface.
|
||||||
/// <seealso cref="Robocode.Robot"/>
|
/// <seealso cref="Robocode.Robot"/>
|
||||||
/// <seealso cref="Robocode.AdvancedRobot"/>
|
/// <seealso cref="Robocode.AdvancedRobot"/>
|
||||||
/// <seealso cref="IBasicRobot"/>
|
/// <seealso cref="IBasicRobot"/>
|
||||||
/// <seealso cref="IJuniorRobot"/>
|
/// <seealso cref="IJuniorRobot"/>
|
||||||
/// <seealso cref="IAdvancedRobot"/>
|
/// <seealso cref="IAdvancedRobot"/>
|
||||||
/// <seealso cref="ITeamRobot"/>
|
/// <seealso cref="ITeamRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IInteractiveRobot : IBasicRobot
|
public interface IInteractiveRobot : IBasicRobot
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the game to notify this robot about interactive
|
/// This method is called by the game to notify this robot about interactive
|
||||||
/// events, i.e. keyboard and mouse events. Hence, this method must be
|
/// events, i.e. keyboard and mouse events. Hence, this method must be
|
||||||
/// implemented so it returns your <see cref="IInteractiveEvents"/> listener.
|
/// implemented so it returns your <see cref="IInteractiveEvents"/> listener.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IInteractiveEvents GetInteractiveEventListener();
|
IInteractiveEvents GetInteractiveEventListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,38 +1,38 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot interface for creating the most primitive robot type, which is a
|
/// A robot interface for creating the most primitive robot type, which is a
|
||||||
/// <see cref="Robocode.JuniorRobot"/>. A junior robot is simpler than the
|
/// <see cref="Robocode.JuniorRobot"/>. A junior robot is simpler than the
|
||||||
/// <see cref="Robocode.Robot"/> class.
|
/// <see cref="Robocode.Robot"/> class.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// A junior robot has a simplified model, in purpose of teaching programming
|
/// A junior robot has a simplified model, in purpose of teaching programming
|
||||||
/// skills to inexperienced in programming students.
|
/// skills to inexperienced in programming students.
|
||||||
/// The simplified robot model will keep player from overwhelming of Robocode's
|
/// The simplified robot model will keep player from overwhelming of Robocode's
|
||||||
/// rules, programming syntax and programming concept.
|
/// rules, programming syntax and programming concept.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Instead of using getters and setters, public fields are provided for
|
/// Instead of using getters and setters, public fields are provided for
|
||||||
/// receiving information like the last scanned robot, the coordinate of the
|
/// receiving information like the last scanned robot, the coordinate of the
|
||||||
/// robot etc.
|
/// robot etc.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// All methods on a junior robot are blocking calls, i.e. they do not return
|
/// All methods on a junior robot are blocking calls, i.e. they do not return
|
||||||
/// before their action has been completed and will at least take one turn to
|
/// before their action has been completed and will at least take one turn to
|
||||||
/// Execute.
|
/// Execute.
|
||||||
/// <seealso cref="Robocode.JuniorRobot"/>
|
/// <seealso cref="Robocode.JuniorRobot"/>
|
||||||
/// <seealso cref="IBasicRobot"/>
|
/// <seealso cref="IBasicRobot"/>
|
||||||
/// <seealso cref="IAdvancedRobot"/>
|
/// <seealso cref="IAdvancedRobot"/>
|
||||||
/// <seealso cref="IInteractiveRobot"/>
|
/// <seealso cref="IInteractiveRobot"/>
|
||||||
/// <seealso cref="ITeamRobot"/>
|
/// <seealso cref="ITeamRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IJuniorRobot : IBasicRobot
|
public interface IJuniorRobot : IBasicRobot
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,42 +1,42 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event interface for receiving paint events with an <see cref="IPaintRobot"/>.
|
/// An event interface for receiving paint events with an <see cref="IPaintRobot"/>.
|
||||||
/// <seealso cref="IPaintRobot"/>
|
/// <seealso cref="IPaintRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPaintEvents
|
public interface IPaintEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called every time the robot is painted. You should
|
/// This method is called every time the robot is painted. You should
|
||||||
/// override this method if you want to draw items for your robot on the
|
/// override this method if you want to draw items for your robot on the
|
||||||
/// battle field, e.g. targets, virtual bullets etc.
|
/// battle field, e.g. targets, virtual bullets etc.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// This method is very useful for debugging your robot.
|
/// This method is very useful for debugging your robot.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Note that the robot will only be painted if the "Paint" is enabled on the
|
/// Note that the robot will only be painted if the "Paint" is enabled on the
|
||||||
/// robot's console window; otherwise the robot will never get painted (the
|
/// robot's console window; otherwise the robot will never get painted (the
|
||||||
/// reason being that all robots might have graphical items that must be
|
/// reason being that all robots might have graphical items that must be
|
||||||
/// painted, and then you might not be able to tell what graphical items that
|
/// painted, and then you might not be able to tell what graphical items that
|
||||||
/// have been painted for your robot).
|
/// have been painted for your robot).
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// Also note that the coordinate system for the graphical context where you
|
/// Also note that the coordinate system for the graphical context where you
|
||||||
/// paint items fits for the Robocode coordinate system where (0, 0) is at
|
/// paint items fits for the Robocode coordinate system where (0, 0) is at
|
||||||
/// the bottom left corner of the battlefield, where X is towards right and Y
|
/// the bottom left corner of the battlefield, where X is towards right and Y
|
||||||
/// is upwards.
|
/// is upwards.
|
||||||
/// <seealso cref="System.Drawing.Graphics"/>
|
/// <seealso cref="System.Drawing.Graphics"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics">The graphics context to use for painting graphical items for the robot</param>
|
/// <param name="graphics">The graphics context to use for painting graphical items for the robot</param>
|
||||||
void OnPaint(IGraphics graphics);
|
void OnPaint(IGraphics graphics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,24 +1,24 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot interface that makes it possible for a robot to receive paint events.
|
/// A robot interface that makes it possible for a robot to receive paint events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPaintRobot : IBasicRobot
|
public interface IPaintRobot : IBasicRobot
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the game to notify this robot about painting
|
/// This method is called by the game to notify this robot about painting
|
||||||
/// events. Hence, this method must be implemented so it returns your
|
/// events. Hence, this method must be implemented so it returns your
|
||||||
/// <see cref="IPaintEvents"/> listener.
|
/// <see cref="IPaintEvents"/> listener.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IPaintEvents GetPaintEventListener();
|
IPaintEvents GetPaintEventListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,22 +1,22 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface to anything what could run
|
/// Interface to anything what could run
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IRunnable
|
public interface IRunnable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Robot main loop or anything what could run.
|
/// Robot main loop or anything what could run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Run();
|
void Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
|
@ -1,38 +1,38 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
using Robocode;
|
using Robocode;
|
||||||
|
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event interface for receiving robot team events with an <see cref="ITeamRobot"/>.
|
/// An event interface for receiving robot team events with an <see cref="ITeamRobot"/>.
|
||||||
/// <seealso cref="ITeamRobot"/>
|
/// <seealso cref="ITeamRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITeamEvents
|
public interface ITeamEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when your robot receives a message from a teammate.
|
/// This method is called when your robot receives a message from a teammate.
|
||||||
/// You should override it in your robot if you want to be informed of this
|
/// You should override it in your robot if you want to be informed of this
|
||||||
/// event.
|
/// event.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>
|
/// <code>
|
||||||
/// public void OnMessageReceived(MessageEvent evnt)
|
/// public void OnMessageReceived(MessageEvent evnt)
|
||||||
/// {
|
/// {
|
||||||
/// Out.WriteLine(event.Sender + " sent me: " + evnt.Message);
|
/// Out.WriteLine(event.Sender + " sent me: " + evnt.Message);
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
/// <seealso cref="Robocode.MessageEvent"/>
|
/// <seealso cref="Robocode.MessageEvent"/>
|
||||||
/// <seealso cref="Robocode.Event"/>
|
/// <seealso cref="Robocode.Event"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="evnt">The message event sent by the game</param>
|
/// <param name="evnt">The message event sent by the game</param>
|
||||||
void OnMessageReceived(MessageEvent evnt);
|
void OnMessageReceived(MessageEvent evnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//doc
|
//doc
|
|
@ -1,33 +1,33 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
* Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||||
*/
|
*/
|
||||||
namespace Robocode.RobotInterfaces
|
namespace Robocode.RobotInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A robot interface for creating a team robot like <see cref="Robocode.TeamRobot"/>
|
/// A robot interface for creating a team robot like <see cref="Robocode.TeamRobot"/>
|
||||||
/// that is able to receive team events.
|
/// that is able to receive team events.
|
||||||
/// A team robot is an advanced type of robot that supports sending messages
|
/// A team robot is an advanced type of robot that supports sending messages
|
||||||
/// between teammates that participates in a team.
|
/// between teammates that participates in a team.
|
||||||
/// <seealso cref="Robocode.TeamRobot"/>
|
/// <seealso cref="Robocode.TeamRobot"/>
|
||||||
/// <seealso cref="IBasicRobot"/>
|
/// <seealso cref="IBasicRobot"/>
|
||||||
/// <seealso cref="IJuniorRobot"/>
|
/// <seealso cref="IJuniorRobot"/>
|
||||||
/// <seealso cref="IInteractiveRobot"/>
|
/// <seealso cref="IInteractiveRobot"/>
|
||||||
/// <seealso cref="IAdvancedRobot"/>
|
/// <seealso cref="IAdvancedRobot"/>
|
||||||
/// <seealso cref="ITeamRobot"/>
|
/// <seealso cref="ITeamRobot"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITeamRobot : IAdvancedRobot
|
public interface ITeamRobot : IAdvancedRobot
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the game to notify this robot about team events.
|
/// This method is called by the game to notify this robot about team events.
|
||||||
/// Hence, this method must be implemented so it returns your
|
/// Hence, this method must be implemented so it returns your
|
||||||
/// <see cref="ITeamEvents"/> listener.
|
/// <see cref="ITeamEvents"/> listener.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ITeamEvents GetTeamEventListener();
|
ITeamEvents GetTeamEventListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doc
|
//doc
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue