public async Task Handle(MakeMovement message, CancellationToken token = new CancellationToken()) { var item = await _session.Get <GameAggregate>(message.Id, message.ExpectedVersion, token); item.MakeMovement(message.PlayerId, message.X, message.Y); await _session.Commit(token); }
void Update() { if (GameController.turn.ToString().Equals(this.tag)) { //Debug.Log (this.tag); GameController.turn = GameController.Turn.Movement; TreeGenerate2 tree = new TreeGenerate2(this.tag, maxDepth); //DebugTree.imprime (tree.Raiz); float fUtility = MiniMax.seach(tree.Raiz); //Debug.Log (this.tag + " " + fUtility); int choiceWin = -1; int choiceAttack = -1; List <Movement> movements = new List <Movement> (); foreach (Nodo nodo in tree.Raiz.Children) { if (nodo.FUtility == fUtility) { Debug.Log(nodo.Movement.To); movements.Add(nodo.Movement); if (nodo.Movement.MoveType.Equals(Movement.Move.Attack)) { choiceAttack = movements.Count - 1; } else if (nodo.Movement.MoveType.Equals(Movement.Move.Win)) { choiceWin = movements.Count - 1; } } } if (movements.Count != 0) { Debug.Log("Escolha: " + this.tag + " " + fUtility); if (choiceAttack == -1 && choiceWin == -1) { MakeMovement.move(movements [Random.Range(0, movements.Count)], this.tag); } else if (choiceWin != -1) { MakeMovement.move(movements [choiceWin], this.tag); } else { MakeMovement.move(movements [choiceAttack], this.tag); } } else { GameController.changeTurn(); } } }
void Update() { if (GameController.turn.ToString().Equals(this.tag)) { if (this.tag.Equals("BlueTeam")) { if (GameController.board.BlueTeam [0].x == -10f && GameController.board.BlueTeam [1].x == -10f) { GameController.changeTurn(); } } else { if (GameController.board.RedTeam [0].x == -10f && GameController.board.RedTeam [1].x == -10f) { GameController.changeTurn(); } } if (Input.GetKeyDown(KeyCode.Mouse0) && flag) { flag = false; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider.tag.Equals(this.tag)) { destroy(); movementCalculate(hit.transform.localPosition); } else if (hit.collider.tag.Equals("Move")) { GameController.turn = GameController.Turn.Movement; int index = moveObjects.IndexOf(hit.transform.gameObject); destroy(); MakeMovement.move(movements[index], this.tag); } } } } if (Input.GetKeyUp(KeyCode.Mouse0)) { flag = true; } }