public static IEnumerator StretchBar(Image bar, float targetSize, float pixelsPerSec = 32f, bool isHP = false, Text hpText = null, Text hpTextShadow = null, int endValue = 0) { float increment = 0f; if (pixelsPerSec <= 0) { pixelsPerSec = 32; } float startSize = bar.rectTransform.sizeDelta.x; float distance = targetSize - startSize; float time = Mathf.Abs(distance) / pixelsPerSec; int startValue = (hpText != null) ? int.Parse(hpText.text) : 0; float valueDistance = endValue - startValue; while (increment < 1) { increment += (1 / time) * Time.deltaTime; if (increment > 1) { increment = 1; } var rectTransform = bar.rectTransform; rectTransform.sizeDelta = new Vector2(startSize + (distance * increment), rectTransform.sizeDelta.y); if (isHP) { BattleCalculation.SetHpBarColor(bar, 48f); } if (hpText != null) { hpText.text = "" + (startValue + Mathf.FloorToInt(valueDistance * increment)); if (hpTextShadow != null) { hpTextShadow.text = hpText.text; } } yield return(null); } }
public void SetCard(Board board, Hand hand, ref InputResult result) { this.wise = EnemyData.Main.Wise; Int32 playerScore = QuadMistGame.main.PlayerScore; Int32 enemyScore = QuadMistGame.main.EnemyScore; Int32[,,] array = new Int32[Board.SIZE_X, Board.SIZE_Y, hand.Count]; QuadMistCard defender = new QuadMistCard(); Int32 num; Int32 num2; if (enemyScore == playerScore) { num = 64; num2 = 1; } else if (enemyScore < playerScore) { num = 67; num2 = 1; } else { num = 1; num2 = 5; } if (UnityEngine.Random.Range(0, 100) > this.wiseResetChance[this.wise]) { num = 0; num2 = 0; } Int32 num3 = this.MIN_POINTS; Int32 num4 = 0; for (Int32 i = 0; i < hand.Count; i++) { for (Int32 j = 0; j < Board.SIZE_X; j++) { for (Int32 k = 0; k < Board.SIZE_Y; k++) { array[j, k, i] = 0; if (!board.IsFree(j, k)) { array[j, k, i] = this.MIN_POINTS; } else { Int32 num5 = this.Check(board, hand[i], new Vector2((Single)j, (Single)k), out defender); if (num5 > 0) { array[j, k, i] += num5 * num; } else if (num5 < 0) { BattleCalculation battleCalculation = QuadMistGame.main.Calculate(hand[i], defender); Int32 num6 = battleCalculation.atkStart * 100 / (battleCalculation.atkStart + battleCalculation.defStart); if (this.wise == 3) { num2 = 1; if (num6 < 60) { num6 -= 100; } else { num6 = 145 - num6; } } array[j, k, i] = num6 * num2; } } if (array[j, k, i] == num3) { num4++; } if (array[j, k, i] > num3) { num3 = array[j, k, i]; num4 = 1; } } } } num3 = this.MIN_POINTS; result.x = 0; result.y = 0; result.index = 0; result.selectedCard = hand[0]; for (Int32 l = 0; l < hand.Count; l++) { for (Int32 m = 0; m < Board.SIZE_X; m++) { for (Int32 n = 0; n < Board.SIZE_Y; n++) { Int32 num7 = 0; if (num3 < array[m, n, l]) { num7++; } if (num3 == array[m, n, l] && UnityEngine.Random.Range(0, 1000) < 1000 / num4) { num7++; } if (num7 != 0) { result.x = m; result.y = n; result.index = l; result.selectedCard = hand[l]; num3 = array[m, n, l]; } } } } hand.ClearFakeSelectData(); }