HexCardsClient/field.wren
2021-05-23 19:43:54 +02:00

41 lines
No EOL
1.2 KiB
Text

import "luxe: world" for Prototype, Entity, Transform
import "utils/vec" for Vec
import "utils/hex" for Hex
var Slots = [
[-1, 3, -2], [ 0, 2, -2], [ 1, 1, -2], [ 2, 0, -2], [ 3, -1, -2],
[-2, 3, -1], [-1, 2, -1], [ 0, 1, -1], [ 1, 0, -1], [ 2, -1, -1], [ 3, -2, -1],
[-3, 3, 0], [-2, 2, 0], [-1, 1, 0], [ 0, 0, 0], [ 1, -1, 0], [ 2, -2, 0], [ 3, -3, 0],
[-3, 2, 1], [-2, 1, 1], [-1, 0, 1], [ 0, -1, 1], [ 1, -2, 1], [ 2, -3, 1],
[-3, 1, 2], [-2, 0, 2], [-1, -1, 2], [ 0, -2, 2], [ 1, -3, 2]
]
var Hand = [
[-1, 2, -1], [ 0, 1, -1], [ 1, 0, -1], [ 2, -1, -1],
[-2, 2, 0], [-1, 1, 0], [ 0, 0, 0], [ 1, -1, 0], [ 2, -2, 0]
]
class Field{
root{_root}
construct new(world){
_world = world
_root = Entity.create(world)
Transform.create(_root)
_slots = []
}
add_slot(slot: List /*of Num*/){
var pos = Hex.coord_to_pos(slot, 66)
var new_instance = Prototype.create(_world, "prototype/card", "slot(%(slot.x), %(slot.y), %(slot.z))", pos, [0,0,0], [2,2,2])
Transform.link(new_instance, _root)
}
add_slots(slots: List /*of List of Num*/){
for(slot in slots){
add_slot(slot)
}
}
}