/// <summary> /// Muestra los subtitulos por pantalla en la parte de abajo /// </summary> /// <param name="subs">subtitulos que se quieren mostrar</param> /// <param name="isDaySub"> si es el subtitulo que muestra el dia le añadade su numero</param> /// <returns></returns> public IEnumerator ShowSubtitles(Subtitles subs, bool isDaySub) { int cont = 0; if (arrowBack.enabled) { arrowBack.interactable = false; } yield return(StartCoroutine(CorgiTools.FadeCanvasGroup(subtitlesGroup, 0.5f, 1f))); while (cont < subs.SubList.Count) { this.subtitleText.text = subs.SubList[cont].Txt; if (isDaySub) { this.subtitleText.text += (DaysManager.Instance.Day + 1); } yield return(new WaitForSeconds(subs.SubList[cont].Duration)); cont++; } this.subtitleText.text = ""; yield return(StartCoroutine(CorgiTools.FadeCanvasGroup(subtitlesGroup, 0.5f, 0f))); if (arrowBack.enabled) { arrowBack.interactable = true; } this.currentCorutine = null; }
/// <summary> /// Muestra los subtitulos por pantalla en la parte central de la pantalla /// </summary> /// <param name="id">identificador de los subtitulos que se quieren mostrar</param> /// <returns></returns> public IEnumerator ShowSubsInCartel(int id, bool endDay) { this.currentCartel = TextsManager.Instance.GameSubtitles.Single(x => x.Id == id); int cont = 0; yield return(StartCoroutine(FadeInOut.Instance.CrossFadeAlpha(1, 0.5f))); yield return(StartCoroutine(CorgiTools.FadeText(cartelText, 0.5f, Color.white))); while (cont < currentCartel.SubList.Count) { subDuration = currentCartel.SubList[cont].Duration; SkipSubtitles = false; timeWaitedSub = 0; this.cartelText.text = currentCartel.SubList[cont].Txt; while (timeWaitedSub < subDuration && SkipSubtitles == false) { timeWaitedSub += 0.3f; yield return(new WaitForSeconds(0.3f)); } cont++; } this.cartelText.text = ""; if (!endDay) { yield return(StartCoroutine(CorgiTools.FadeText(cartelText, 0.5f, Color.white))); yield return(StartCoroutine(FadeInOut.Instance.CrossFadeAlpha(0, 0.5f))); } this.currentCorutine = null; }
/// <summary> /// Corutina que realiza el movimiento a la posicion indicada /// </summary> /// <param name="finalPosition"></param> /// <returns></returns> public IEnumerator ExecuteMovement() { //Si no he seleccionado la carta if (this.TargetPosition == null) { yield break; } //Si se esta moviendo el barco, no hago nada if (this.isMoving) { yield break; } this.isMoving = true; //Reseteo la posicion inicial GridManager.Instance.GetCell(this.ActualPosition).SetShipCell(null); //Calculo la distancia entre las posiciones y la descompongo en movimientos unitarios Vector3 finalRotation = this.transform.localEulerAngles; PositionGrid distance = this.TargetPosition - this.ActualPosition; List <DIRECTIONS> movements = new List <DIRECTIONS>(); if (finalRotation.y == 270 || finalRotation.y == 90) { //Caso de estar mirando arriba o abajo y el destino esta detras mio if ((distance.X > 0 && finalRotation.y == 270) || (distance.X < 0 && finalRotation.y == 90)) { movements = this.ConfigMovements(distance, false); } else { movements = this.ConfigMovements(distance, true); } } else if (finalRotation.y == 0 || finalRotation.y == 180) { //Caso de estar mirando izq o dr y el destino esta detras mio if ((distance.Y > 0 && finalRotation.y == 180) || (distance.Y < 0 && finalRotation.y == 0)) { movements = this.ConfigMovements(distance, true); } else { movements = this.ConfigMovements(distance, false); } } //Segun los movimientos unitarios, los convierto en posiciones en el tablero y configuro la rotacion segun el movimiento PositionGrid pos = new PositionGrid(0, 0); foreach (DIRECTIONS dir in movements) { switch (dir) { case DIRECTIONS.UP: pos = new PositionGrid(-1, 0); finalRotation = new Vector3(0, 270, 0); break; case DIRECTIONS.RIGHT: pos = new PositionGrid(0, 1); finalRotation = new Vector3(0, 0, 0); break; case DIRECTIONS.DOWN: pos = new PositionGrid(1, 0); finalRotation = new Vector3(0, 90, 0); break; case DIRECTIONS.LEFT: pos = new PositionGrid(0, -1); finalRotation = new Vector3(0, 180, 0); break; } //Actualizo la finalPosition this.TargetPosition = this.ActualPosition + pos; //Realizo la rotacion y el movimiento del barco if (this.transform.localEulerAngles != finalRotation) { yield return(StartCoroutine(CorgiTools.RotateFromTo(this.gameObject, this.transform.localEulerAngles, finalRotation, this.RotationTime))); } yield return(StartCoroutine(CorgiTools.MoveFromTo(this.gameObject, this.transform.position, new Vector3(GridManager.Instance.GetCell(this.TargetPosition).WorldPosition.x, this.ShipHeight, GridManager.Instance.GetCell(this.TargetPosition).WorldPosition.z), this.MovementTime))); //Actualizo la posicion actual this.ActualPosition = this.TargetPosition; } this.isMoving = false; //Reseteo la posicion this.TargetPosition = null; //Actualizo la celda actual GridManager.Instance.GetCell(this.ActualPosition).SetShipCell(this); }