package io.sarl.demos.fireworks import java.util.HashMap import java.util.List import java.util.Map import java.util.UUID import java.util.Vector import javafx.scene.paint.Color class RocketsPos { public val ROCKETREFRESHDELAY = 100 var position = new Vector() var color: Color var hidden = false public def getPosition(){ return position } public def setPosition(position: Vector){ this.position = position } public def getColor(){ return color } public def setColor(color: Color){ this.color = color } public def setHidden(hidden: boolean){ this.hidden = hidden } public def getHidden(){ return this.hidden } } class FirePos { public val FIREREFRESHDELAY = 100 var positions: List> var color: Color public def getPositions(){ return positions } public def setPositions(positions: List>){ this.positions = positions } public def getColor(){ return color } public def setColor(color: Color){ this.color = color } } class Positions { var rockets = new HashMap() var fire = new HashMap() public def getRockets() : Map { return rockets.unmodifiableView } public def getFire() : Map { return fire.unmodifiableView } public def setRocketPosition(id: UUID, position: Vector){ var pos = new RocketsPos() pos.setPosition(position) if (rockets.containsKey(id)){ pos.setColor(rockets.get(id).getColor) rockets.replace(id, pos) } else { pos.setColor(Color.color(Math.random(), Math.random(), Math.random())) rockets.put(id, pos) } } public def removeRocketPosition(id: UUID){ rockets.remove(id) } public def hideHocketPosition(id: UUID){ rockets.get(id).setHidden(true) } public def setFirePosition(id: UUID, rocketID: UUID, positions: List>){ var pos = new FirePos() pos.setPositions(positions) if (fire.containsKey(id)){ pos.setColor(fire.get(id).getColor) fire.replace(id, pos) } else { if (this.rockets.containsKey(rocketID)) pos.setColor(this.rockets.get(rocketID).getColor) else pos.setColor(Color.color(Math.random(), Math.random(), Math.random())) fire.put(id, pos) } } public def removeFirePosition(id: UUID){ fire.remove(id) } }