|
|
@ -56,24 +56,38 @@ class ArKitView : ARView {
|
|
|
|
@objc private func handleGesture(_ recognizer: UIGestureRecognizer) {
|
|
|
|
@objc private func handleGesture(_ recognizer: UIGestureRecognizer) {
|
|
|
|
guard let translationGesture = recognizer as? EntityTranslationGestureRecognizer, let entity = translationGesture.entity else { return }
|
|
|
|
guard let translationGesture = recognizer as? EntityTranslationGestureRecognizer, let entity = translationGesture.entity else { return }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let positionInitial = entity.position
|
|
|
|
|
|
|
|
let initialPosGame = vmArkit!.converWorldPosIntoPosModele(pos: entity.position)
|
|
|
|
|
|
|
|
|
|
|
|
switch translationGesture.state {
|
|
|
|
switch translationGesture.state {
|
|
|
|
case .began:
|
|
|
|
case .began:
|
|
|
|
self.initialTransform = entity.transform
|
|
|
|
self.initialTransform = entity.transform
|
|
|
|
|
|
|
|
|
|
|
|
case .ended:
|
|
|
|
case .ended:
|
|
|
|
entity.move(to: initialTransform, relativeTo: entity.parent, duration: 1)
|
|
|
|
entity.move(to: initialTransform, relativeTo: entity.parent, duration: 1)
|
|
|
|
let pos = entity.position
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if ( pos.x > )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (localisation.x > 450 || localisation.x < -450 || localisation.y < -350 || localisation.y > 350){
|
|
|
|
let pos = entity.position
|
|
|
|
|
|
|
|
if ( pos.x > 0.14656 || pos.x < -0.14656 || pos.z < -0.2748 || pos.z > 0.2748 ){
|
|
|
|
print("Hors limite !")
|
|
|
|
print("Hors limite !")
|
|
|
|
self.position = returnPositionByCellPos(cellX:Int(self.cellPosition.x),cellY:Int(self.cellPosition.y))
|
|
|
|
// Return pos
|
|
|
|
|
|
|
|
entity.position = positionInitial
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let posX = Int(round((pos.x - (-0.14656)) / 0.458))
|
|
|
|
|
|
|
|
let posY = Int(round((pos.z - (-0.2748)) / 0.3435))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Récupéré le joueur qui doit jouer
|
|
|
|
|
|
|
|
let owner = vmArkit!.game.rules.getNextPlayer()
|
|
|
|
|
|
|
|
let player = vmArkit!.game.players[owner]!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( owner == vmArkit!.game.board.grid[Int(initialPosGame.x)][Int(initialPosGame.y)].piece!.owner ){
|
|
|
|
|
|
|
|
if player is HumanPlayer { // Player humain
|
|
|
|
|
|
|
|
Task {
|
|
|
|
|
|
|
|
try! await (player as! HumanPlayer).chooseMove(Move(of: owner, fromRow:Int(initialPosGame.x), andFromColumn: Int(initialPosGame.y), toRow: posX, andToColumn: posY))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break
|
|
|
|
break
|
|
|
|