mirror of
https://github.com/klmp200/sarl-fireworks.git
synced 2024-11-22 06:43:20 +00:00
reformatting all classes
This commit is contained in:
parent
9890daffc8
commit
9316a74f07
Binary file not shown.
@ -7,7 +7,7 @@ import io.sarl.demos.fireworks.gui.FXMLViewerController
|
|||||||
import static io.janusproject.Boot.*
|
import static io.janusproject.Boot.*
|
||||||
|
|
||||||
class Firework {
|
class Firework {
|
||||||
static def main(controller: FXMLViewerController) {
|
static def main(controller : FXMLViewerController) {
|
||||||
Boot::offline = true
|
Boot::offline = true
|
||||||
Boot::startJanus(typeof(LaunchingArea), controller)
|
Boot::startJanus(typeof(LaunchingArea), controller)
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ class FireworksFXApplication extends Application {
|
|||||||
private var loader : FXMLLoader
|
private var loader : FXMLLoader
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public def start(stage: Stage) throws Exception {
|
public def start(stage : Stage) throws Exception {
|
||||||
var location : URL = getClass().getResource("FireworksFXApplication.fxml");
|
var location : URL = getClass().getResource("FireworksFXApplication.fxml");
|
||||||
loader = new FXMLLoader();
|
loader = new FXMLLoader();
|
||||||
loader.setLocation(location);
|
loader.setLocation(location);
|
||||||
loader.setBuilderFactory(new JavaFXBuilderFactory());
|
loader.setBuilderFactory(new JavaFXBuilderFactory());
|
||||||
@ -26,14 +26,14 @@ class FireworksFXApplication extends Application {
|
|||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static def main(args: String[]) {
|
public static def main(args : String[]) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public def stop() throws Exception {
|
public def stop() throws Exception {
|
||||||
super.stop();
|
super.stop();
|
||||||
(loader.getController() as FXMLViewerController).cleanExit();
|
(loader.getController() as FXMLViewerController).cleanExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,54 +8,54 @@ import java.util.Vector
|
|||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
|
|
||||||
class RocketsPos {
|
class RocketsPos {
|
||||||
public val ROCKETREFRESHDELAY = 100
|
public val ROCKETREFRESHDELAY = 100
|
||||||
var position = new Vector<Double>()
|
var position = new Vector<Double>()
|
||||||
var color: Color
|
var color : Color
|
||||||
var hidden = false
|
var hidden = false
|
||||||
|
|
||||||
public def getPosition(){
|
public def getPosition() {
|
||||||
return position
|
return position
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setPosition(position: Vector<Double>){
|
public def setPosition(position : Vector<Double>) {
|
||||||
this.position = position
|
this.position = position
|
||||||
}
|
}
|
||||||
|
|
||||||
public def getColor(){
|
public def getColor() {
|
||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setColor(color: Color){
|
public def setColor(color : Color) {
|
||||||
this.color = color
|
this.color = color
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setHidden(hidden: boolean){
|
public def setHidden(hidden : boolean) {
|
||||||
this.hidden = hidden
|
this.hidden = hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
public def getHidden(){
|
public def getHidden() {
|
||||||
return this.hidden
|
return this.hidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FirePos {
|
class FirePos {
|
||||||
public val FIREREFRESHDELAY = 100
|
public val FIREREFRESHDELAY = 100
|
||||||
var positions: List<Vector<Double>>
|
var positions : List<Vector<Double>>
|
||||||
var color: Color
|
var color : Color
|
||||||
|
|
||||||
public def getPositions(){
|
public def getPositions() {
|
||||||
return positions
|
return positions
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setPositions(positions: List<Vector<Double>>){
|
public def setPositions(positions : List<Vector<Double>>) {
|
||||||
this.positions = positions
|
this.positions = positions
|
||||||
}
|
}
|
||||||
|
|
||||||
public def getColor(){
|
public def getColor() {
|
||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setColor(color: Color){
|
public def setColor(color : Color) {
|
||||||
this.color = color
|
this.color = color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,20 +63,19 @@ class FirePos {
|
|||||||
class Positions {
|
class Positions {
|
||||||
var rockets = new HashMap<UUID, RocketsPos>()
|
var rockets = new HashMap<UUID, RocketsPos>()
|
||||||
var fire = new HashMap<UUID, FirePos>()
|
var fire = new HashMap<UUID, FirePos>()
|
||||||
|
|
||||||
|
|
||||||
public def getRockets() : Map<UUID, RocketsPos> {
|
public def getRockets() : Map<UUID, RocketsPos> {
|
||||||
return rockets.unmodifiableView
|
return rockets.unmodifiableView
|
||||||
}
|
}
|
||||||
|
|
||||||
public def getFire() : Map<UUID, FirePos> {
|
public def getFire() : Map<UUID, FirePos> {
|
||||||
return fire.unmodifiableView
|
return fire.unmodifiableView
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setRocketPosition(id: UUID, position: Vector<Double>){
|
public def setRocketPosition(id : UUID, position : Vector<Double>) {
|
||||||
var pos = new RocketsPos()
|
var pos = new RocketsPos()
|
||||||
pos.setPosition(position)
|
pos.setPosition(position)
|
||||||
if (rockets.containsKey(id)){
|
if (rockets.containsKey(id)) {
|
||||||
pos.setColor(rockets.get(id).getColor)
|
pos.setColor(rockets.get(id).getColor)
|
||||||
rockets.replace(id, pos)
|
rockets.replace(id, pos)
|
||||||
} else {
|
} else {
|
||||||
@ -84,19 +83,19 @@ class Positions {
|
|||||||
rockets.put(id, pos)
|
rockets.put(id, pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public def removeRocketPosition(id: UUID){
|
public def removeRocketPosition(id : UUID) {
|
||||||
rockets.remove(id)
|
rockets.remove(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
public def hideHocketPosition(id: UUID){
|
public def hideHocketPosition(id : UUID) {
|
||||||
rockets.get(id).setHidden(true)
|
rockets.get(id).setHidden(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
public def setFirePosition(id: UUID, rocketID: UUID, positions: List<Vector<Double>>){
|
public def setFirePosition(id : UUID, rocketID : UUID, positions : List<Vector<Double>>) {
|
||||||
var pos = new FirePos()
|
var pos = new FirePos()
|
||||||
pos.setPositions(positions)
|
pos.setPositions(positions)
|
||||||
if (fire.containsKey(id)){
|
if (fire.containsKey(id)) {
|
||||||
pos.setColor(fire.get(id).getColor)
|
pos.setColor(fire.get(id).getColor)
|
||||||
fire.replace(id, pos)
|
fire.replace(id, pos)
|
||||||
} else {
|
} else {
|
||||||
@ -107,10 +106,9 @@ class Positions {
|
|||||||
fire.put(id, pos)
|
fire.put(id, pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public def removeFirePosition(id: UUID){
|
public def removeFirePosition(id : UUID) {
|
||||||
fire.remove(id)
|
fire.remove(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -18,23 +18,23 @@ import java.util.List
|
|||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import java.util.Vector
|
import java.util.Vector
|
||||||
|
|
||||||
agent Fire {
|
agent Fire {
|
||||||
uses Lifecycle, Logging, Behaviors, DefaultContextInteractions, Schedules
|
uses Lifecycle, Logging, Behaviors, DefaultContextInteractions, Schedules
|
||||||
|
|
||||||
var x: List<Double>
|
var x : List<Double>
|
||||||
var y: List<Double>
|
var y : List<Double>
|
||||||
var lifetime = 300
|
var lifetime = 300
|
||||||
var frozen = false
|
var frozen = false
|
||||||
var destroyed = false
|
var destroyed = false
|
||||||
var exited = false
|
var exited = false
|
||||||
var grid: Positions
|
var grid : Positions
|
||||||
var xf: Double
|
var xf : Double
|
||||||
var yf: Double
|
var yf : Double
|
||||||
var id = UUID.randomUUID
|
var id = UUID.randomUUID
|
||||||
var parentID: UUID
|
var parentID : UUID
|
||||||
var move: AgentTask
|
var move : AgentTask
|
||||||
var parentAgent: UUID
|
var parentAgent : UUID
|
||||||
|
|
||||||
on Freeze {
|
on Freeze {
|
||||||
this.frozen = occurrence.value
|
this.frozen = occurrence.value
|
||||||
if (frozen)
|
if (frozen)
|
||||||
@ -42,11 +42,11 @@ agent Fire {
|
|||||||
else
|
else
|
||||||
wake(new UpdateFirePosition)
|
wake(new UpdateFirePosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
on Initialize {
|
on Initialize {
|
||||||
x = new ArrayList()
|
x = new ArrayList()
|
||||||
y = new ArrayList()
|
y = new ArrayList()
|
||||||
if (occurrence.parameters.size.equals(4)){
|
if (occurrence.parameters.size.equals(4)) {
|
||||||
x.add(occurrence.parameters.get(0) as Double)
|
x.add(occurrence.parameters.get(0) as Double)
|
||||||
y.add(occurrence.parameters.get(1) as Double)
|
y.add(occurrence.parameters.get(1) as Double)
|
||||||
grid = occurrence.parameters.get(2) as Positions
|
grid = occurrence.parameters.get(2) as Positions
|
||||||
@ -55,60 +55,67 @@ agent Fire {
|
|||||||
info("Error in fire Initialize : bad parameter number")
|
info("Error in fire Initialize : bad parameter number")
|
||||||
}
|
}
|
||||||
parentAgent = occurrence.spawner
|
parentAgent = occurrence.spawner
|
||||||
|
|
||||||
xf = Math.random() * 10.0 - Math.random() * 5
|
xf = Math.random() * 10.0 - Math.random() * 5
|
||||||
yf = Math.random() * 10.0 + 1.0
|
yf = Math.random() * 10.0 + 1.0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
on FireReady {
|
on FireReady {
|
||||||
move = atFixedDelay(30)[try{
|
move = atFixedDelay(30) [
|
||||||
wake(new UpdateFirePosition);}
|
try {
|
||||||
catch(e: Exception) {e.printStackTrace}]
|
wake(new UpdateFirePosition);
|
||||||
|
} catch (e : Exception) {
|
||||||
|
e.printStackTrace
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
on UpdateFirePosition [isFromMe(occurrence) && !frozen && !destroyed]{
|
on UpdateFirePosition [isFromMe(occurrence) && !frozen && !destroyed] {
|
||||||
var newx = x.last + xf
|
var newx = x.last + xf
|
||||||
var newy = y.last + yf
|
var newy = y.last + yf
|
||||||
x.add(newx)
|
x.add(newx)
|
||||||
y.add(newy)
|
y.add(newy)
|
||||||
|
|
||||||
if (grid !== null){
|
if (grid !== null) {
|
||||||
var list = new ArrayList<Vector<Double>>
|
var list = new ArrayList<Vector<Double>>
|
||||||
x.forEach[pos | {
|
x.forEach [pos |
|
||||||
var nvect = new Vector(2)
|
{
|
||||||
nvect.add(pos)
|
var nvect = new Vector(2)
|
||||||
list.add(nvect)
|
nvect.add(pos)
|
||||||
}]
|
list.add(nvect)
|
||||||
y.forEach[pos, i | {
|
}
|
||||||
var nvect = list.get(i)
|
]
|
||||||
nvect.add(pos)
|
y.forEach [pos, i |
|
||||||
list.set(i, nvect)
|
{
|
||||||
}]
|
var nvect = list.get(i)
|
||||||
|
nvect.add(pos)
|
||||||
|
list.set(i, nvect)
|
||||||
|
}
|
||||||
|
]
|
||||||
grid.setFirePosition(id, parentID, list)
|
grid.setFirePosition(id, parentID, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
lifetime = lifetime - 10
|
lifetime = lifetime - 10
|
||||||
|
|
||||||
if (lifetime <= 0){
|
if (lifetime <= 0) {
|
||||||
grid.removeFirePosition(id)
|
grid.removeFirePosition(id)
|
||||||
this.cleanBeforeExit
|
this.cleanBeforeExit
|
||||||
in(1000)[killMe]
|
in(1000)[killMe]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def cleanBeforeExit(){
|
def cleanBeforeExit() {
|
||||||
cancel(move, true)
|
cancel(move, true)
|
||||||
exited = true
|
exited = true
|
||||||
destroyed = true
|
destroyed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
on Exit [!exited && isFrom(getParentID)] {
|
on Exit [!exited && isFrom(getParentID)] {
|
||||||
frozen = true
|
frozen = true
|
||||||
this.cleanBeforeExit
|
this.cleanBeforeExit
|
||||||
emit(new Exit, Scopes.addresses(defaultSpace.getAddress(parentAgent)))
|
emit(new Exit, Scopes.addresses(defaultSpace.getAddress(parentAgent)))
|
||||||
killMe
|
killMe
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,68 +21,68 @@ import java.util.UUID
|
|||||||
agent LaunchingArea {
|
agent LaunchingArea {
|
||||||
uses DefaultContextInteractions, Lifecycle, Behaviors, Logging, InnerContextAccess
|
uses DefaultContextInteractions, Lifecycle, Behaviors, Logging, InnerContextAccess
|
||||||
|
|
||||||
var rocketsQuantity: Integer
|
var rocketsQuantity : Integer
|
||||||
var fireQuantity: Integer
|
var fireQuantity : Integer
|
||||||
var gravity: Double
|
var gravity : Double
|
||||||
var grid: Positions = new Positions
|
var grid : Positions = new Positions
|
||||||
var maxWidth = 10.0
|
var maxWidth = 10.0
|
||||||
var exited = false
|
var exited = false
|
||||||
|
|
||||||
on SetupSettings {
|
on SetupSettings {
|
||||||
this.rocketsQuantity = occurrence.rocketsQuantity
|
this.rocketsQuantity = occurrence.rocketsQuantity
|
||||||
this.fireQuantity = occurrence.fireQuatity
|
this.fireQuantity = occurrence.fireQuatity
|
||||||
this.gravity = occurrence.gravity
|
this.gravity = occurrence.gravity
|
||||||
this.maxWidth = occurrence.maxWidth
|
this.maxWidth = occurrence.maxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
on Exit [!hasMemberAgent]{
|
on Exit [!hasMemberAgent] {
|
||||||
killMe
|
killMe
|
||||||
}
|
}
|
||||||
|
|
||||||
on Exit [hasMemberAgent && !exited] {
|
on Exit [hasMemberAgent && !exited] {
|
||||||
exited = true
|
exited = true
|
||||||
innerContext.defaultSpace.emit(new Exit)
|
innerContext.defaultSpace.emit(new Exit)
|
||||||
}
|
}
|
||||||
|
|
||||||
on Initialize [ occurrence.parameters.empty ] {
|
on Initialize [occurrence.parameters.empty] {
|
||||||
rocketsQuantity = 20
|
rocketsQuantity = 20
|
||||||
fireQuantity = 30
|
fireQuantity = 30
|
||||||
gravity = 0.5
|
gravity = 0.5
|
||||||
|
|
||||||
info("Setup Area")
|
info("Setup Area")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on Initialize [ !occurrence.parameters.empty ]{
|
on Initialize [!occurrence.parameters.empty] {
|
||||||
var ctrl = occurrence.parameters.get(0) as FXMLViewerController
|
var ctrl = occurrence.parameters.get(0) as FXMLViewerController
|
||||||
var ^space = defaultContext.createSpace(OpenEventSpaceSpecification, UUID.randomUUID)
|
var ^space = defaultContext.createSpace(OpenEventSpaceSpecification, UUID.randomUUID)
|
||||||
ctrl.setGUISpace(^space)
|
ctrl.setGUISpace(^space)
|
||||||
^space.register(asEventListener)
|
^space.register(asEventListener)
|
||||||
|
|
||||||
ctrl.listenAndDraw(grid)
|
ctrl.listenAndDraw(grid)
|
||||||
|
|
||||||
info("Setup Area")
|
info("Setup Area")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on CreateArea {
|
on CreateArea {
|
||||||
var x: Double
|
var x : Double
|
||||||
var i=0
|
var i = 0
|
||||||
var rnd = new Random()
|
var rnd = new Random()
|
||||||
while (i<rocketsQuantity){
|
while (i < rocketsQuantity) {
|
||||||
x = rnd.nextDouble() * maxWidth
|
x = rnd.nextDouble() * maxWidth
|
||||||
spawnInContext(RocketLauncher, getInnerContext, x, 0.0, fireQuantity, gravity, grid)
|
spawnInContext(RocketLauncher, getInnerContext, x, 0.0, fireQuantity, gravity, grid)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
on Freeze[!isFromMe(occurrence)] {
|
on Freeze [!isFromMe(occurrence)] {
|
||||||
innerContext.defaultSpace.emit(occurrence)
|
innerContext.defaultSpace.emit(occurrence)
|
||||||
}
|
}
|
||||||
|
|
||||||
on MemberJoined [ occurrence.inInnerDefaultSpace && memberAgentCount == rocketsQuantity]{
|
on MemberJoined [occurrence.inInnerDefaultSpace && memberAgentCount == rocketsQuantity] {
|
||||||
info("Area Ready")
|
info("Area Ready")
|
||||||
innerContext.defaultSpace.emit(new Launch)
|
innerContext.defaultSpace.emit(new Launch)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,9 @@ import java.util.UUID
|
|||||||
import java.util.Vector
|
import java.util.Vector
|
||||||
|
|
||||||
agent Rocket {
|
agent Rocket {
|
||||||
|
|
||||||
uses Lifecycle, Logging, Schedules, Behaviors, DefaultContextInteractions, InnerContextAccess
|
uses Lifecycle, Logging, Schedules, Behaviors, DefaultContextInteractions, InnerContextAccess
|
||||||
|
|
||||||
var x : Double
|
var x : Double
|
||||||
var y : Double
|
var y : Double
|
||||||
var gravity : Double
|
var gravity : Double
|
||||||
@ -31,26 +32,26 @@ agent Rocket {
|
|||||||
var fireQuantity : Integer
|
var fireQuantity : Integer
|
||||||
var lifetime : Integer
|
var lifetime : Integer
|
||||||
var frozen = false
|
var frozen = false
|
||||||
var exploded = false
|
var exploded = false
|
||||||
var exited = false
|
var exited = false
|
||||||
var grid: Positions
|
var grid : Positions
|
||||||
var id: UUID
|
var id : UUID
|
||||||
var move: AgentTask
|
var move : AgentTask
|
||||||
|
|
||||||
on Exit [!hasMemberAgent]{
|
on Exit [!hasMemberAgent] {
|
||||||
emit(new Exit)
|
emit(new Exit)
|
||||||
killMe
|
killMe
|
||||||
}
|
}
|
||||||
|
|
||||||
on Exit [hasMemberAgent && !exited]{
|
on Exit [hasMemberAgent && !exited] {
|
||||||
exploded = true
|
exploded = true
|
||||||
frozen = true
|
frozen = true
|
||||||
exited = true
|
exited = true
|
||||||
cancel(move, true)
|
cancel(move, true)
|
||||||
|
|
||||||
innerContext.defaultSpace.emit(new Exit)
|
innerContext.defaultSpace.emit(new Exit)
|
||||||
}
|
}
|
||||||
|
|
||||||
on Freeze {
|
on Freeze {
|
||||||
this.frozen = occurrence.value
|
this.frozen = occurrence.value
|
||||||
if (frozen)
|
if (frozen)
|
||||||
@ -58,11 +59,11 @@ agent Rocket {
|
|||||||
if (!frozen)
|
if (!frozen)
|
||||||
wake(new UpdateRocketPosition)
|
wake(new UpdateRocketPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
on Initialize {
|
on Initialize {
|
||||||
info("New rocket launched")
|
info("New rocket launched")
|
||||||
var rnd = new Random()
|
var rnd = new Random()
|
||||||
if (occurrence.parameters.size.equals(7)){
|
if (occurrence.parameters.size.equals(7)) {
|
||||||
x = occurrence.parameters.get(0) as Double
|
x = occurrence.parameters.get(0) as Double
|
||||||
y = occurrence.parameters.get(1) as Double
|
y = occurrence.parameters.get(1) as Double
|
||||||
speedx = occurrence.parameters.get(2) as Double
|
speedx = occurrence.parameters.get(2) as Double
|
||||||
@ -75,12 +76,16 @@ agent Rocket {
|
|||||||
}
|
}
|
||||||
lifetime = rnd.nextInt(5) * 300 + 300
|
lifetime = rnd.nextInt(5) * 300 + 300
|
||||||
id = UUID.randomUUID
|
id = UUID.randomUUID
|
||||||
|
|
||||||
move = atFixedDelay(30)[try{
|
move = atFixedDelay(30) [
|
||||||
wake(new UpdateRocketPosition);}
|
try {
|
||||||
catch(e: Exception) {e.printStackTrace}]
|
wake(new UpdateRocketPosition);
|
||||||
|
} catch (e : Exception) {
|
||||||
|
e.printStackTrace
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
on UpdateRocketPosition [isFromMe(occurrence) && !frozen && !exploded] {
|
on UpdateRocketPosition [isFromMe(occurrence) && !frozen && !exploded] {
|
||||||
var vect = new Vector(2)
|
var vect = new Vector(2)
|
||||||
x = x + speedx
|
x = x + speedx
|
||||||
@ -89,32 +94,32 @@ agent Rocket {
|
|||||||
vect.add(x)
|
vect.add(x)
|
||||||
vect.add(y)
|
vect.add(y)
|
||||||
lifetime = lifetime - 10
|
lifetime = lifetime - 10
|
||||||
if (grid!==null)
|
if (grid !== null)
|
||||||
grid.setRocketPosition(id, vect)
|
grid.setRocketPosition(id, vect)
|
||||||
if (lifetime <= 0){
|
if (lifetime <= 0) {
|
||||||
exploded = true
|
exploded = true
|
||||||
cancel(move, true)
|
cancel(move, true)
|
||||||
grid.hideHocketPosition(id)
|
grid.hideHocketPosition(id)
|
||||||
wake(new Explode)
|
wake(new Explode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
on Explode {
|
on Explode {
|
||||||
for (var i=0; i < fireQuantity; i++){
|
for (var i = 0; i < fireQuantity; i++) {
|
||||||
spawnInContext(Fire, innerContext, x, y, grid, id)
|
spawnInContext(Fire, innerContext, x, y, grid, id)
|
||||||
}
|
}
|
||||||
// emit(new Launch)
|
// emit(new Launch)
|
||||||
}
|
}
|
||||||
|
|
||||||
on MemberLeft [!isFromMe(occurrence) && !frozen && !hasMemberAgent] {
|
on MemberLeft [!isFromMe(occurrence) && !frozen && !hasMemberAgent] {
|
||||||
exited = true
|
exited = true
|
||||||
grid.removeRocketPosition(id)
|
grid.removeRocketPosition(id)
|
||||||
// emit(new Launch)
|
// emit(new Launch)
|
||||||
killMe
|
killMe
|
||||||
}
|
}
|
||||||
|
|
||||||
on MemberJoined [!isFromMe(occurrence) && hasMemberAgent && memberAgentCount == fireQuantity]{
|
on MemberJoined [!isFromMe(occurrence) && hasMemberAgent && memberAgentCount == fireQuantity] {
|
||||||
innerContext.defaultSpace.emit(new FireReady)
|
innerContext.defaultSpace.emit(new FireReady)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,21 +14,21 @@ import io.sarl.demos.fireworks.events.Launch
|
|||||||
import io.sarl.demos.fireworks.events.RocketReady
|
import io.sarl.demos.fireworks.events.RocketReady
|
||||||
|
|
||||||
agent RocketLauncher {
|
agent RocketLauncher {
|
||||||
|
|
||||||
uses Logging, Behaviors, DefaultContextInteractions, InnerContextAccess, Lifecycle
|
uses Logging, Behaviors, DefaultContextInteractions, InnerContextAccess, Lifecycle
|
||||||
|
|
||||||
var x: Double
|
var x : Double
|
||||||
var y: Double
|
var y : Double
|
||||||
var fireQuantity : Integer
|
var fireQuantity : Integer
|
||||||
var gravity : Double
|
var gravity : Double
|
||||||
var grid: Positions
|
var grid : Positions
|
||||||
var exited = false
|
var exited = false
|
||||||
|
|
||||||
on Exit [!hasMemberAgent] {
|
on Exit [!hasMemberAgent] {
|
||||||
emit(new Exit)
|
emit(new Exit)
|
||||||
killMe
|
killMe
|
||||||
}
|
}
|
||||||
|
|
||||||
on Exit [hasMemberAgent && !exited] {
|
on Exit [hasMemberAgent && !exited] {
|
||||||
exited = true
|
exited = true
|
||||||
innerContext.defaultSpace.emit(new Exit)
|
innerContext.defaultSpace.emit(new Exit)
|
||||||
@ -40,11 +40,11 @@ agent RocketLauncher {
|
|||||||
fireQuantity = occurrence.parameters.get(2) as Integer
|
fireQuantity = occurrence.parameters.get(2) as Integer
|
||||||
gravity = occurrence.parameters.get(3) as Double
|
gravity = occurrence.parameters.get(3) as Double
|
||||||
grid = occurrence.parameters.get(4) as Positions
|
grid = occurrence.parameters.get(4) as Positions
|
||||||
|
|
||||||
info("New rocket launcher created")
|
info("New rocket launcher created")
|
||||||
}
|
}
|
||||||
|
|
||||||
on Initialize [occurrence.parameters.empty]{
|
on Initialize [occurrence.parameters.empty] {
|
||||||
x = 0.0
|
x = 0.0
|
||||||
y = 0.0
|
y = 0.0
|
||||||
fireQuantity = 30
|
fireQuantity = 30
|
||||||
@ -54,19 +54,19 @@ agent RocketLauncher {
|
|||||||
info("New rocket launcher created")
|
info("New rocket launcher created")
|
||||||
emit(new RocketReady)
|
emit(new RocketReady)
|
||||||
}
|
}
|
||||||
|
|
||||||
on Launch {
|
on Launch {
|
||||||
var vx = Math.random() * 2.0
|
var vx = Math.random() * 2.0
|
||||||
var vy = Math.random() * 5.5 + 2.0
|
var vy = Math.random() * 5.5 + 2.0
|
||||||
spawnInContext(Rocket, getInnerContext, x, y, vx, vy, gravity, fireQuantity, grid)
|
spawnInContext(Rocket, getInnerContext, x, y, vx, vy, gravity, fireQuantity, grid)
|
||||||
}
|
}
|
||||||
|
|
||||||
on Freeze[!isFromMe(occurrence)] {
|
on Freeze [!isFromMe(occurrence)] {
|
||||||
innerContext.defaultSpace.emit(occurrence)
|
innerContext.defaultSpace.emit(occurrence)
|
||||||
}
|
}
|
||||||
|
|
||||||
on MemberLeft [!isFromMe(occurrence) && !exited]{
|
on MemberLeft [!isFromMe(occurrence) && !exited] {
|
||||||
wake(new Launch)
|
wake(new Launch)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ event SetupSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event Freeze {
|
event Freeze {
|
||||||
var value : boolean
|
var value : boolean
|
||||||
|
|
||||||
@ -44,6 +43,3 @@ event Freeze {
|
|||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,29 +23,26 @@ import javafx.util.Duration
|
|||||||
|
|
||||||
class FXMLViewerController implements EventListener {
|
class FXMLViewerController implements EventListener {
|
||||||
|
|
||||||
private var ispace : OpenEventSpace;
|
|
||||||
private val id : UUID = UUID.randomUUID();
|
private val id : UUID = UUID.randomUUID();
|
||||||
|
|
||||||
|
private var ispace : OpenEventSpace;
|
||||||
private var launched : boolean = false;
|
private var launched : boolean = false;
|
||||||
private var areaCreated : boolean = false;
|
private var areaCreated : boolean = false;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private var draw_zone : Canvas;
|
private var draw_zone : Canvas;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private var gravity_display : Label;
|
private var gravity_display : Label;
|
||||||
@FXML
|
@FXML
|
||||||
private var rocket_quantity_display : Label;
|
private var rocket_quantity_display : Label;
|
||||||
@FXML
|
@FXML
|
||||||
private var fire_quantity_display : Label;
|
private var fire_quantity_display : Label;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private var gravity_input : ScrollBar;
|
private var gravity_input : ScrollBar;
|
||||||
@FXML
|
@FXML
|
||||||
private var rocket_quantity_input : ScrollBar;
|
private var rocket_quantity_input : ScrollBar;
|
||||||
@FXML
|
@FXML
|
||||||
private var fire_quantity_input : ScrollBar;
|
private var fire_quantity_input : ScrollBar;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private var setup_button : Button;
|
private var setup_button : Button;
|
||||||
@FXML
|
@FXML
|
||||||
|
Loading…
Reference in New Issue
Block a user