void Update() { if (BoardManager == null) { return; } if (online) { //Cambiamos el objetivo if (this.currentTarget == null || !this.currentTarget.Walkable) { changeTarget(); PathController.Repath(); var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); } if (LocomotionController.MoveNeed) { currentTiempoPensamiento++; //Volvemos a buscar if (currentTiempoPensamiento >= tiempoDePensamiento) { PathController.Repath(); var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); currentTiempoPensamiento = 0; } //Ejucutamos el pan actual else { var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); } if (this.currentTarget == LocomotionController.CurrentEndPosition()) { SetCurrentTarget(null); currentTiempoPensamiento = tiempoDePensamiento; } } } else { if (LocomotionController.MoveNeed) { var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); return; } } }
void Update() { if (BoardManager == null) { return; } //Si el modo de juego es del planner if (this.currentTarget == null) { CellInfo nextAction = PlanController.GetNextAction(); this.SetCurrentTarget(nextAction); PathController.Repath(); } //Si el modo de juego en online if (online) { if (esMeta(LocomotionController.CurrentEndPosition())) { enemies.RemoveAt(0); currentTiempoPensamiento = tiempoDePensamiento; ObjetivoConseguido = true; } if (LocomotionController.MoveNeed || ObjetivoConseguido) { currentTiempoPensamiento++; ObjetivoConseguido = false; if (currentTiempoPensamiento < 0) { changeTarget(); var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); return; } if (currentTiempoPensamiento >= tiempoDePensamiento) { currentTiempoPensamiento = 0; changeTarget(); var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); PathController.Repath(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); return; } else { var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); } } } else { //Si el modo de juego es offline if (LocomotionController.MoveNeed) { var boardClone = (BoardInfo)BoardManager.boardInfo.Clone(); LocomotionController.SetNewDirection(PathController.GetNextMove(boardClone, LocomotionController.CurrentEndPosition(), new[] { this.currentTarget })); if (this.currentTarget == LocomotionController.CurrentEndPosition()) { SetCurrentTarget(null); } } } }