// Update is called once per frame void Update() { if (status == GameControllerStatus.CHECKINGLOGIC) { checkLogic(); } //S'ha de posar despres de la comprovacio de ended // Si estamos en modo "espera accion" y el jugador es una IA, calculamos la accion. if (status == GameControllerStatus.WAITINGFORACTION && currentPlayer.isPlayerAI()) { status = GameControllerStatus.AILOGIC; GetCurrentPlayer().ThinkAction(); } else if (status == GameControllerStatus.AILOGIC && !GetCurrentPlayer().IsThinking() && currentPlayer.isPlayerAI()) { status = GameControllerStatus.PLAYINGACTION; AISlimeAction action = currentPlayer.GetThoughtAction(); if (action != null) { SetSelectedSlime(action.GetMainSlime()); // Simulamos la seleccion de la slime que hace la accion. DoAction((SlimeAction)action); // Hacemos la accion. } else { Debug.Log("IA returned NULL action"); NextPlayer(); // No pot fer cap accio } } }
protected override void ThinkAction() { position++; Slime actionSlime = null; if (position == 3) { actionSlime = gameController.GetCurrentPlayer().GetSlimes()[1]; } else { actionSlime = gameController.GetCurrentPlayer().GetSlimes()[0]; } //Solucio cutre if (actions[position].GetAction() == ActionType.ATTACK) { actions[position] = new SlimeAction(ActionType.ATTACK, MapDrawer.GetTileAt(-1, -1).GetSlimeOnTop()); } if (position >= actions.Count) { thoughtAction = new AISlimeAction(actionSlime, ActionType.CONQUER, gameController.GetSelectedSlime().actualTile); } thoughtAction = new AISlimeAction(actionSlime, actions[position]); }
// Devuelve la accion pensada. public AISlimeAction PopAction() { AISlimeAction toReturn = thoughtAction; thoughtAction = null; return(toReturn); }