mirror of
https://github.com/klmp200/sarl-fireworks.git
synced 2024-11-26 02:54:21 +00:00
117 lines
2.3 KiB
Plaintext
117 lines
2.3 KiB
Plaintext
|
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<Double>()
|
||
|
var color: Color
|
||
|
var hidden = false
|
||
|
|
||
|
public def getPosition(){
|
||
|
return position
|
||
|
}
|
||
|
|
||
|
public def setPosition(position: Vector<Double>){
|
||
|
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<Vector<Double>>
|
||
|
var color: Color
|
||
|
|
||
|
public def getPositions(){
|
||
|
return positions
|
||
|
}
|
||
|
|
||
|
public def setPositions(positions: List<Vector<Double>>){
|
||
|
this.positions = positions
|
||
|
}
|
||
|
|
||
|
public def getColor(){
|
||
|
return color
|
||
|
}
|
||
|
|
||
|
public def setColor(color: Color){
|
||
|
this.color = color
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class Positions {
|
||
|
var rockets = new HashMap<UUID, RocketsPos>()
|
||
|
var fire = new HashMap<UUID, FirePos>()
|
||
|
|
||
|
|
||
|
public def getRockets() : Map<UUID, RocketsPos> {
|
||
|
return rockets.unmodifiableView
|
||
|
}
|
||
|
|
||
|
public def getFire() : Map<UUID, FirePos> {
|
||
|
return fire.unmodifiableView
|
||
|
}
|
||
|
|
||
|
public def setRocketPosition(id: UUID, position: Vector<Double>){
|
||
|
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<Vector<Double>>){
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|