public double receiveDamage(double damage) { damage = applyShieldDamageReduction(damage); if (damage < 0) { damage = 0; } health -= damage; if (health < 0) { health = 0; } if (!BattleManager.isTutorial) { Player.stats[Player.Stat.TOTAL_DAMAGE_DEALT] += damage; } refreshHealthHUD(false); BattleManager.bmInstance.showInfoTextPanel(); string attackDescription = TextScript.get(TextScript.Sentence.CAUSE_DAMAGE_A) + " " + NumberStringConverter.convert(damage) + " " + TextScript.get(TextScript.Sentence.CAUSE_DAMAGE_B); BattleManager.bmInstance.changeInfoText(attackDescription); return(damage); }
string getExplanationText() { double newRerollPoints = getRerollPoints(HubControl.maxUnlockedDifficultyId); string explanationText = TextScript.get(TextScript.Sentence.REROLL_EXPLANATION_INTRO) + "<b>" + TextScript.get(TextScript.Sentence.REROLL_CARDS) + " +" + NumberStringConverter.convert(newRerollPoints + Player.rerollPoints) + "</b> (" + TextScript.get(TextScript.Sentence.CURRENT) + ": +" + NumberStringConverter.convert(Player.rerollPoints) + ")\n" + "<b>" + TextScript.get(TextScript.Sentence.REROLL_EXP) + " x" + NumberStringConverter.convert(getRerollExpMult(newRerollPoints + Player.rerollPoints)) + "</b> (" + TextScript.get(TextScript.Sentence.CURRENT) + ": x" + NumberStringConverter.convert(getRerollExpMult(Player.rerollPoints)) + ")\n" + "<b>" + TextScript.get(TextScript.Sentence.REROLL_SKIP) + " " + NumberStringConverter.convert(getRerollSkip(newRerollPoints + Player.rerollPoints)) + "</b> (" + TextScript.get(TextScript.Sentence.CURRENT) + ": " + NumberStringConverter.convert(getRerollSkip(Player.rerollPoints)) + ")\n\n" + ((Player.isAndroid()) ? TextScript.get(TextScript.Sentence.REROLL_EXPLANATION_END_TAP) : TextScript.get(TextScript.Sentence.REROLL_EXPLANATION_END_CLICK)); return(explanationText); }
void updateExpText() { double totalSellValue = getTotalSellValueToShow(); expText.text = NumberStringConverter.convert(Player.experience) + " " + TextScript.get(TextScript.Sentence.EXP); if (totalSellValue > 0) { expText.text += "\n<color=#559911>(+" + NumberStringConverter.convert(totalSellValue) + " " + TextScript.get(TextScript.Sentence.EXP) + ")</color>"; } }
public string getDescription() { string conditionText; switch (condition) { case Condition.INSTANT: case Condition.FIRST: conditionText = TextScript.get(TextScript.Sentence.INSTANT); break; default: conditionText = TextScript.get(TextScript.Sentence.CONTINUOUS); break; } string effectText; switch (condition) { default: case Condition.INSTANT: case Condition.INSTANT_PERMANENT: effectText = getTextEffect(); break; case Condition.FIRST: effectText = TextScript.get(TextScript.Sentence.COND0) + " " + conditionNumber + ": " + getTextEffect(); break; case Condition.LAST: if (effect == Effect.DICE_MOD) { effectText = TextScript.get(TextScript.Sentence.COND1) + " " + conditionNumber + " " + TextScript.get(TextScript.Sentence.COND1_A) + " +" + NumberStringConverter.convert(effectNumber); } else { effectText = TextScript.get(TextScript.Sentence.COND2) + " " + conditionNumber + ": " + getTextEffect(); } break; } string costText = (cost == 0) ? "" : "[" + TextScript.get(TextScript.Sentence.COST) + ": " + NumberStringConverter.convert(cost) + TextScript.get(TextScript.Sentence.DICE_ABBR) + "] "; string text = "<b>" + conditionText + "</b>\n\n" + costText + effectText; return(text); }
IEnumerator healthTextLerp(double currentHealthValue, double nextHealthValue, bool instant) { float transitionTime = (instant) ? 0 : 1f; float timer = 0; while (timer < transitionTime) { double transitionHealthValue = doubleLerp(currentHealthValue, nextHealthValue, timer / transitionTime); transitionHealthValue = System.Math.Round(transitionHealthValue); healthText.text = NumberStringConverter.convert(transitionHealthValue) + " / " + NumberStringConverter.convert(maxHealth); timer += Time.deltaTime; yield return(null); } healthText.text = NumberStringConverter.convert(health) + " / " + NumberStringConverter.convert(maxHealth); healthBeforeLastDamage = health; }
public void TestConvert() { Assert.AreEqual("1", NumberStringConverter.convert(1d)); Assert.AreEqual("7", NumberStringConverter.convert(7d)); Assert.AreEqual("123", NumberStringConverter.convert(123d)); Assert.AreEqual("5432", NumberStringConverter.convert(5432d)); Assert.AreEqual("54.3K", NumberStringConverter.convert(54321d)); Assert.AreEqual("128K", NumberStringConverter.convert(128325d)); Assert.AreEqual("1.23M", NumberStringConverter.convert(1234567d)); Assert.AreEqual("20M", NumberStringConverter.convert(20000000d)); Assert.AreEqual("146M", NumberStringConverter.convert(146761842d)); Assert.AreEqual("7.21B", NumberStringConverter.convert(7216325741d)); Assert.AreEqual("127B", NumberStringConverter.convert(127832952030d)); Assert.AreEqual("73.4T", NumberStringConverter.convert(73462631752923d)); Assert.AreEqual("73.4q", NumberStringConverter.convert(73462631752923000d)); Assert.AreEqual("73.4Q", NumberStringConverter.convert(73462631752923000000d)); Assert.AreEqual("73.4s", NumberStringConverter.convert(73462631752000923000000d)); Assert.AreEqual("73.4S", NumberStringConverter.convert(73462630001752000923000000d)); Assert.AreEqual("73.4O", NumberStringConverter.convert(73462630001752000923000000000d)); Assert.AreEqual("73.4N", NumberStringConverter.convert(73460002630001752000923000000000d)); Assert.AreEqual("73.4D", NumberStringConverter.convert(73460002630001752000923000000000000d)); // Check that trailing zeros are removed Assert.AreEqual("1T", NumberStringConverter.convert(1000000000000d)); Assert.AreEqual("10T", NumberStringConverter.convert(10000000000000d)); Assert.AreEqual("100T", NumberStringConverter.convert(100000000000000d)); Assert.AreEqual("1.20T", NumberStringConverter.convert(1200000000000d)); Assert.AreEqual("12T", NumberStringConverter.convert(12000000000000d)); // Check that non-trailing zeros aren't removed Assert.AreEqual("1.05T", NumberStringConverter.convert(1050000000000d)); // Values represented via scientific notation Assert.AreEqual("712D", NumberStringConverter.convert(712860002630001752000923000000000000d)); Assert.AreEqual("7.12E36", NumberStringConverter.convert(7128600026300017520009230000000000000d)); Assert.AreEqual("7.12E37", NumberStringConverter.convert(71286000263000175200092300000000000000d)); Assert.AreEqual("7.12E38", NumberStringConverter.convert(712860002630001752000923000000000000000d)); Assert.AreEqual("7.12E42", NumberStringConverter.convert(7128600026300017520009230000000000000000000d)); Assert.AreEqual("1E100", NumberStringConverter.convert(1E+100)); Assert.AreEqual("1.53E100", NumberStringConverter.convert(1.53523452E+100)); Assert.AreEqual("1.03E100", NumberStringConverter.convert(1.03523452E+100)); Assert.AreEqual("1.70E100", NumberStringConverter.convert(1.70523452E+100)); }
void createSplashTextAt(RectTransform parentTransform, double value) { GameObject splashText = Instantiate(splashTextObject); splashText.transform.SetParent(parentTransform); splashText.GetComponent <RectTransform>().localPosition = Vector3.zero; splashText.GetComponent <RectTransform>().localScale = Vector3.one; string valueSign = (value >= 0) ? "+" : "-"; Color valueColor = (value >= 0) ? Color.green : Color.red; splashText.GetComponent <Text>().text = valueSign + NumberStringConverter.convert(System.Math.Abs(value)); splashText.GetComponent <Text>().color = valueColor; if (speedUpBattleAnimations) { splashText.GetComponent <Animator>().speed = 1.5f; } }
public static void updateModifiersInHUDFromArray(Text[] modifierTexts, CardEffect.Condition condition) { foreach (Text t in modifierTexts) { t.text = "+0"; } foreach (CardEffect ce in Player.cardEffects) { if (ce.condition == condition && ce.effect != CardEffect.Effect.DICE_MOD) { int arrayIndex = ce.conditionNumber; double modValue = ce.effectNumber;//double.Parse(modifierTexts[arrayIndex].text) + ce.effectNumber; modifierTexts[arrayIndex].text = "+" + NumberStringConverter.convert(modValue); Color textColor = (modValue == 0) ? Color.white : (condition == CardEffect.Condition.FIRST) ? Color.green : Color.blue; modifierTexts[arrayIndex].color = textColor; } } }
void updateHUDTextWithoutPopup(Text text, double value, RectTransform textIcon) { if (value < 0) { value = 0; // If value is below 0, make it 0 } text.text = NumberStringConverter.convert(value); if (textIcon == diceIcon && Player.diceMultiplier != 1) { text.text += " (x" + NumberStringConverter.convert(Player.diceMultiplier) + ")"; } float textWidth = text.preferredWidth; float textX = text.GetComponent <RectTransform>().anchoredPosition.x; float iconWidth = textIcon.rect.width; float padding = 20; float newIconX = textX - (textWidth / 2) - (iconWidth / 2) - padding; textIcon.anchoredPosition = new Vector2(newIconX, textIcon.anchoredPosition.y); }
string getTextEffect() { switch (effect) { case Effect.DICE: return(TextScript.get(TextScript.Sentence.DICE_UPPER) + " +" + NumberStringConverter.convert(effectNumber)); case Effect.HEALTH: return(TextScript.get(TextScript.Sentence.HEALTH_UPPER) + " +" + NumberStringConverter.convert(effectNumber)); case Effect.DICE_MULT: string turnString = (conditionNumber == 0) ? " " + TextScript.get(TextScript.Sentence.THIS_TURN) + "" : (conditionNumber == 1) ? " " + TextScript.get(TextScript.Sentence.NEXT_TURN) : " " + TextScript.get(TextScript.Sentence.IN) + " " + conditionNumber + " " + TextScript.get(TextScript.Sentence.TURNS); return(TextScript.get(TextScript.Sentence.DICE_UPPER) + " x" + effectNumber + turnString + " (" + TextScript.get(TextScript.Sentence.TEMPORARY) + ")"); case Effect.FIXED_DICE: return(TextScript.get(TextScript.Sentence.FIXED_DICE_A) + " " + effectNumber + " " + TextScript.get(TextScript.Sentence.FIXED_DICE_B)); case Effect.FORBID_NUMBER: return(TextScript.get(TextScript.Sentence.FORBID_NUMBER_A) + " " + effectNumber + " " + TextScript.get(TextScript.Sentence.FORBID_NUMBER_B)); case Effect.ADD_ATTACK_ROLL: return(TextScript.get(TextScript.Sentence.ADD_ATTACK_ROLL_A) + " " + effectNumber + " " + TextScript.get(TextScript.Sentence.ADD_ATTACK_ROLL_B)); case Effect.LOWER_MAX: return(TextScript.get(TextScript.Sentence.LOWER_MAX) + " " + effectNumber); case Effect.IMPROVE: return(TextScript.get(TextScript.Sentence.IMPROVE)); default: return(""); } }
public IEnumerator launchAttack(Attack attack) { string attackDescription = TextScript.get(TextScript.Sentence.EXCL) + enemyName + " " + attackDescriptor(attack) + "\n"; double actualDamage = 0; double extraDamage = 0; switch (attack) { case Attack.NOTHING: break; case Attack.NORMAL_ATTACK: // Attack against health actualDamage = Player.receiveDamage(damageAgainstHealth); attackDescription += TextScript.get(TextScript.Sentence.LOSE_HEALTH_A) + " " + NumberStringConverter.convert(actualDamage) + " " + TextScript.get(TextScript.Sentence.LOSE_HEALTH_B) + "."; break; case Attack.DICE_ATTACK: // Attack against dice if (minDiceToAllowDiceAttacks > Player.nDice) // If the player has too few dice, choose another attack { decideAttack(); yield break; } float dicePercDamage = Random.Range(damageAgainstDiceMin, damageAgainstDiceMax); double diceDamage = System.Math.Round(Player.nDice * dicePercDamage); actualDamage = Player.loseDice(diceDamage); string diceSingOrPlural = (actualDamage == 1) ? TextScript.get(TextScript.Sentence.SINGLE_DICE) : TextScript.get(TextScript.Sentence.DICE); attackDescription += TextScript.get(TextScript.Sentence.LOSE_DICE) + " " + NumberStringConverter.convert(actualDamage) + " " + diceSingOrPlural; if (diceAttackLv > 0) // Advanced attack, deal damage while knocking off dice { extraDamage = Player.receiveDamage(damageAgainstHealth * diceAttackLv); attackDescription += " " + TextScript.get(TextScript.Sentence.AND) + " " + NumberStringConverter.convert(extraDamage) + " " + TextScript.get(TextScript.Sentence.HEALTH); } attackDescription += "."; break; case Attack.MILL: if (BattleManager.bmInstance.noCardsLeftInDeck()) // If the player has no cards in deck, choose another attack { decideAttack(); yield break; } int nMilledCards = (buzzsawAttackLv < 0.7f) ? 1 : 2; actualDamage = BattleManager.bmInstance.mill(nMilledCards); string cardSingOrPlural = (actualDamage == 1) ? TextScript.get(TextScript.Sentence.CARD_SINGLE) : TextScript.get(TextScript.Sentence.CARD_PLURAL); if (buzzsawAttackLv == 0) // Only milling { attackDescription += TextScript.get(TextScript.Sentence.YOUR_DECK_LOSES) + " " + actualDamage + " " + cardSingOrPlural + "."; } else // Mill + damage { extraDamage = Player.receiveDamage(damageAgainstHealth * buzzsawAttackLv); attackDescription += TextScript.get(TextScript.Sentence.YOUR_DECK_LOSES) + " " + actualDamage + " " + cardSingOrPlural + ". " + TextScript.get(TextScript.Sentence.LOSE_HEALTH_A) + " " + NumberStringConverter.convert(extraDamage) + " " + TextScript.get(TextScript.Sentence.LOSE_HEALTH_B) + ".";; } break; case Attack.DISCARD: if (BattleManager.bmInstance.noCardsLeftInHand()) // If the player has no cards in hand, choose another attack { decideAttack(); yield break; } BattleManager.bmInstance.discard(); if (fanAttackLv == 0) { attackDescription += TextScript.get(TextScript.Sentence.DISCARD); } else { extraDamage = Player.receiveDamage(damageAgainstHealth * fanAttackLv); attackDescription += TextScript.get(TextScript.Sentence.DISCARD_PLUS_DAMAGE_A) + " " + TextScript.get(TextScript.Sentence.DISCARD_PLUS_DAMAGE_B) + " " + NumberStringConverter.convert(extraDamage) + " " + TextScript.get(TextScript.Sentence.LOSE_HEALTH_B); } break; case Attack.HEAL: if (health >= maxHealth && healLv < 0.35) // Cannot overheal with normal arms { decideAttack(); yield break; } bool allowExcedeMax = (healLv > 0.35f); double healedAmount = healPerc(healLv, allowExcedeMax); attackDescription += TextScript.get(TextScript.Sentence.RECOVER) + " " + NumberStringConverter.convert(healedAmount) + " " + TextScript.get(TextScript.Sentence.HEALTH) + "."; break; case Attack.RECOIL_ATTACK: double cost = System.Math.Round(maxHealth * recoilAttackCost); if (cost >= health) { decideAttack(); yield break; } health -= cost; refreshHealthHUD(false); double recoilPower = damageAgainstHealth * recoilAttackLv; actualDamage = Player.receiveDamage(recoilPower); attackDescription += TextScript.get(TextScript.Sentence.LOSE_HEALTH_A) + " " + NumberStringConverter.convert(actualDamage) + " " + TextScript.get(TextScript.Sentence.LOSE_HEALTH_B) + "."; break; case Attack.DRAIN: if (health >= maxHealth) { decideAttack(); yield break; } double drainDamage = System.Math.Round(damageAgainstHealth * drainLv); actualDamage = Player.receiveDamage(drainDamage); healValue(actualDamage, false); attackDescription += TextScript.get(TextScript.Sentence.DRAIN_A) + " " + NumberStringConverter.convert(actualDamage) + " " + TextScript.get(TextScript.Sentence.DRAIN_B) + "."; break; case Attack.CHARGE: damageAgainstHealth = System.Math.Round(damageAgainstHealth * chargeLv); attackDescription += TextScript.get(TextScript.Sentence.ATTACK_PLUS); break; case Attack.CURSE: if (Player.nDice == 1) { decideAttack(); yield break; } Player.diceMultiplier *= curseLv; if (curseLv == 0.5) { attackDescription += TextScript.get(TextScript.Sentence.CURSE_HALF); } else { attackDescription += TextScript.get(TextScript.Sentence.CURSE_GENERIC); } break; case Attack.WEAKEN_CARDS: BattleManager.bmInstance.applyCardImproveMultiplicative(floeAttackLv); attackDescription += TextScript.get(TextScript.Sentence.WEAKEN_CARDS); break; case Attack.SWAP_CARDS: BattleManager.bmInstance.applyCardSwap(magicianAttackLv); attackDescription += TextScript.get(TextScript.Sentence.SWAP_CARDS); break; } lastUsedAttack = attack; damageFromLastAttack = actualDamage; BattleManager.bmInstance.showInfoTextPanel(); BattleManager.bmInstance.changeInfoText(attackDescription); BattleManager.busy = false; }
void showWinLosePanel(Color panelColor, Color textColor, Result result) { // Show panel victoryPanel.SetActive(true); victoryPanel.GetComponent <Image>().color = panelColor; Text victoryText = victoryPanel.GetComponentInChildren <Text>(); victoryText.text = (result == Result.VICTORY) ? TextScript.get(TextScript.Sentence.VICTORY) : TextScript.get(TextScript.Sentence.DEFEAT); victoryText.color = textColor; victoryPanel.GetComponentInChildren <Outline>().effectColor = panelColor; Text returnText = victoryPanel.GetComponentInChildren <Button>().GetComponentInChildren <Text>(); returnText.text = TextScript.get(TextScript.Sentence.RETURN); // Move help text panel RectTransform helpTextPanelrt = helpTextPanel.GetComponent <RectTransform>(); helpTextPanel.transform.SetParent(victoryPanel.transform); helpTextPanelrt.anchoredPosition = new Vector2(50, 0); helpText.text = ""; helpTextPanel.SetActive(true); // Add exp if (result == Result.VICTORY && !isTutorial) { double rewardExp = CardFactory.getAbsoluteCardPoints(enemy.difficultyId); // Enemy difficulty bonus rewardExp = System.Math.Floor(rewardExp * (1 + System.Math.Pow(enemy.difficultyId / 5d, 1.75d)) * Player.expModifier); // Arm aspect bonus foreach (ArmManager.ArmAspect armAspect in enemy.armAspects) { switch (armAspect) { case ArmManager.ArmAspect.SILVER: rewardExp = System.Math.Floor(rewardExp * 1.25f); break; case ArmManager.ArmAspect.GOLD: rewardExp = System.Math.Floor(rewardExp * 1.5f); break; } } // Add exp to player rewardExp = Player.gainExp(rewardExp); GameObject.Find("ExpText").GetComponent <Text>().text = "(+" + NumberStringConverter.convert(rewardExp) + " " + TextScript.get(TextScript.Sentence.EXP) + ")"; } else { GameObject.Find("ExpText").GetComponent <Text>().text = ""; } // Show prize cards Card[] prizeCards = getPrizeCards(result, enemy.difficultyId); Transform prizeCardPanel = victoryPanel.transform.Find("PrizeCardPanel"); foreach (Card c in prizeCards) { Player.getNewCard(c); GameObject cardObj = Instantiate(cardObject, Vector3.zero, Quaternion.identity); cardObj.GetComponent <CardObject>().initialize(c); cardObj.transform.SetParent(prizeCardPanel); cardObj.GetComponent <RectTransform>().localScale = Vector3.one; } GridLayoutGroup glg = prizeCardPanel.GetComponent <GridLayoutGroup>(); // Alignment if (prizeCards.Length <= 4) // Change alignment (1 row -> center it, 2 rows -> one on top of another) { glg.childAlignment = TextAnchor.MiddleCenter; } else { glg.childAlignment = TextAnchor.UpperCenter; } // Spacing if (prizeCards.Length == 2) { glg.spacing = new Vector2(150, 0); } else if (prizeCards.Length == 3) { glg.spacing = new Vector2(50, 0); } // Deactivate the Grid Layout to avoid reordering when hovering over a card StartCoroutine(removeGridLayoutGroupAfterAFrame(glg)); // Unlock new enemies if (result == Result.VICTORY && !isTutorial && enemy.difficultyId == HubControl.maxUnlockedDifficultyId) { HubControl.maxUnlockedDifficultyId++; if (enemy.difficultyId < Player.stats[Player.Stat.GREATEST_RANK]) { HubControl.maxUnlockedDifficultyId += RerollManager.getRerollSkip(Player.rerollPoints); // Skip enemies // Only up to the greatest rank ever reached if (HubControl.maxUnlockedDifficultyId > Player.stats[Player.Stat.GREATEST_RANK]) { HubControl.maxUnlockedDifficultyId = (int)Player.stats[Player.Stat.GREATEST_RANK]; } } // Update greatest rank if (HubControl.maxUnlockedDifficultyId > Player.stats[Player.Stat.GREATEST_RANK]) { Player.stats[Player.Stat.GREATEST_RANK] = HubControl.maxUnlockedDifficultyId; } // Move onwards HubControl.currentDifficultyId = HubControl.maxUnlockedDifficultyId; } // Update defeated silver/gold enemies if (result == Result.VICTORY && !isTutorial) { foreach (ArmManager.ArmAspect aspect in enemy.armAspects) { if (aspect == ArmManager.ArmAspect.SILVER) { Player.stats[Player.Stat.SILVER_DEFEATED]++; } if (aspect == ArmManager.ArmAspect.GOLD) { Player.stats[Player.Stat.GOLD_DEFEATED]++; } } } if (Player.keyboardModeOn) { victoryPanel.GetComponentInChildren <Button>().Select(); } }
public void updateImage(GameObject cardObj, CardEffect cardEffect) { // Delete old model foreach (Transform child in cardObj.transform) { Destroy(child.gameObject); } cardObj.transform.DetachChildren(); // Get the card's model Model cardModel = getCardImageModel(cardEffect); GameObject modelObjPrefab = getCardModelObject(cardModel); GameObject modelObj = Instantiate(modelObjPrefab); modelObj.transform.SetParent(cardObj.transform); // Position/scale the model RectTransform modelRt = modelObj.GetComponent <RectTransform>(); modelRt.localScale = Vector3.one; modelRt.localPosition = modelObjPrefab.GetComponent <RectTransform>().localPosition; modelRt.localPosition += Vector3.up * templateHalfHeight; // Push up icons (since cards are south-aligned) Image[] images = cardObj.GetComponentsInChildren <Image>(); Text[] texts = cardObj.GetComponentsInChildren <Text>(); // Fill in the images for that model switch (cardModel) { case Model.STANDARD: case Model.STANDARD_COMPACT: case Model.DELAYED: case Model.DELAYED_COMPACT: // 0 - Background, 1 - Condition, 2 - Effect , 3 - Effect sign; 0 - Condition digit, 1 - Effect digit images[0].sprite = getBackground(cardEffect); images[1].sprite = getConditionImage(cardEffect); images[2].sprite = getEffectImage(cardEffect.effect, images[2]); images[3].sprite = getEffectSignImage(cardEffect); texts[0].text = cardEffect.conditionNumber + ""; texts[1].text = NumberStringConverter.convert(cardEffect.effectNumber); if (cardModel == Model.DELAYED) { changeTextSize(texts[1]); } if (cardModel == Model.STANDARD || cardModel == Model.STANDARD_COMPACT) { texts[0].GetComponent <Outline>().effectColor = getEffectColor(cardEffect); } break; case Model.ADDER: case Model.ADDER_COMPACT: case Model.ADDER_COMPACTER: // 0 - Background, 3 - Effect , 4 - Effect sign; 0 - Effect digit images[0].sprite = getBackground(cardEffect); images[1].sprite = getEffectImage(cardEffect.effect, images[1]); images[2].sprite = getEffectSignImage(cardEffect); texts[0].text = NumberStringConverter.convert(cardEffect.effectNumber); if (cardModel == Model.ADDER) { changeTextSize(texts[0]); } break; case Model.SINGLE_DICE: // 0 - Background, 1 - Condition Image ; 0 - Effect digit images[0].sprite = getBackground(cardEffect); images[1].sprite = getConditionImage(cardEffect); texts[0].text = cardEffect.effectNumber + ""; break; case Model.FORBID: case Model.SINGLE_VALUE: // 0 - Background, 1 - Effect Image ; 0 - Effect digit images[0].sprite = getBackground(cardEffect); images[1].sprite = getEffectImage(cardEffect.effect, images[1]); if (cardEffect.effect == CardEffect.Effect.IMPROVE) { texts[0].text = "+" + NumberStringConverter.convert(cardEffect.effectNumber) + ""; if (texts[0].text.Length == 4) { texts[0].fontSize = 130; } else if (texts[0].text.Length >= 5) { texts[0].fontSize = 100; } } else { texts[0].text = cardEffect.effectNumber + ""; } break; case Model.LOWER_MAX: // 0 - Background ; 1 - Effect digit images[0].sprite = getBackground(cardEffect); texts[1].text = "-" + cardEffect.effectNumber; break; } // If the card has a cost, add the cost label if (cardEffect.cost > 0) { GameObject costLabelObj = Instantiate(costLabel); costLabelObj.transform.SetParent(modelObj.transform); // Set as child of the model, not the card itself Text costText = costLabelObj.GetComponentInChildren <Text>(); costText.text = NumberStringConverter.convert(cardEffect.cost); switch (costText.text.Length) { case 2: costText.fontSize = 60; break; case 3: costText.fontSize = 50; break; case 4: case 5: costText.fontSize = 45; break; } costLabelObj.GetComponent <RectTransform>().localPosition = costLabel.GetComponent <RectTransform>().localPosition; costLabelObj.GetComponent <RectTransform>().localScale = Vector3.one; images = cardObj.GetComponentsInChildren <Image>(); // Add new image to array (text is already included) } // If the card is locked, add the icon (only on deck editor) if (inDeckEditor && cardObj.GetComponent <DeckEditorCardObject>().card.isLocked) { GameObject lockIconObj = Instantiate(lockIcon); lockIconObj.transform.SetParent(modelObj.transform); // Set as child of the model, not the card itself lockIconObj.GetComponent <RectTransform>().localPosition = lockIcon.GetComponent <RectTransform>().localPosition; lockIconObj.GetComponent <RectTransform>().localScale = Vector3.one; images = cardObj.GetComponentsInChildren <Image>(); // Add new image to array } // If in deck editor, fix scaling issues if (inDeckEditor) { DeckEditorCardObject.Origin cardOrigin = cardObj.GetComponent <DeckEditorCardObject>().origin; float scaledSize = (cardOrigin == DeckEditorCardObject.Origin.COLLECTION) ? 140 : 120; float newScale = getNewScale(scaledSize); fixScalingIssues(newScale, images, texts); } }
void updatePlayerExperience() { expText.text = NumberStringConverter.convert(Player.experience) + " " + TextScript.get(TextScript.Sentence.EXP); }
public string getDescription() { updateName(); string description = "<b><size=60>" + name + "</size></b>"; if (level > 0) { description += "<size=50> (" + TextScript.get(TextScript.Sentence.LV) + " " + NumberStringConverter.convert(level) + ")</size>"; } description += " [" + TextScript.get(TextScript.Sentence.PRICE) + ": " + NumberStringConverter.convert(priceToNextLevel) + " " + TextScript.get(TextScript.Sentence.EXP) + "]\n"; switch (id) { case FortuneId.ENDURANCE: description += TextScript.get(TextScript.Sentence.F0_DESC) + "\n" + "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: " + NumberStringConverter.convert(getEffectFormula(level)) + " " + TextScript.get(TextScript.Sentence.HEALTH) + "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: " + NumberStringConverter.convert(getEffectFormula(level + 1)) + " " + TextScript.get(TextScript.Sentence.HEALTH); break; case FortuneId.QUICK_START: description += TextScript.get(TextScript.Sentence.F1_DESC) + "\n" + "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: x" + NumberStringConverter.convert(getEffectFormula(level)) + " " + TextScript.get(TextScript.Sentence.DICE) + "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: x" + NumberStringConverter.convert(getEffectFormula(level + 1)) + " " + TextScript.get(TextScript.Sentence.DICE); break; case FortuneId.SHIELD: description += TextScript.get(TextScript.Sentence.F2_DESC) + "\n"; description += (level == 0) ? "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: " + TextScript.get(TextScript.Sentence.NONE) : "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: -" + getFractionAsString((float)getEffectFormula(level)) + "% " + TextScript.get(TextScript.Sentence.DMG); description += "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: -" + getFractionAsString((float)getEffectFormula(level + 1)) + "% " + TextScript.get(TextScript.Sentence.DMG); break; case FortuneId.REGEN: description += TextScript.get(TextScript.Sentence.F3_DESC) + "\n"; description += (level == 0) ? "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: " + TextScript.get(TextScript.Sentence.NONE) : "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: " + getFractionAsString((float)getEffectFormula(level)) + "% " + TextScript.get(TextScript.Sentence.HEALTH); description += "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: " + getFractionAsString((float)getEffectFormula(level + 1)) + "% " + TextScript.get(TextScript.Sentence.HEALTH); break; case FortuneId.LOWER_CEIL: description += TextScript.get(TextScript.Sentence.F4_DESC) + "\n" + "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: -" + getEffectFormula(level) + "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: -" + getEffectFormula(level + 1); break; case FortuneId.EXTRA_EXP: description += TextScript.get(TextScript.Sentence.F5_DESC) + "\n" + "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: +" + getMultiplierAsString(getEffectFormula(level)) + "% " + TextScript.get(TextScript.Sentence.EXP) + "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: +" + getMultiplierAsString(getEffectFormula(level + 1)) + "% " + TextScript.get(TextScript.Sentence.EXP); break; case FortuneId.EXTRA_PRIZE_CARD: description += TextScript.get(TextScript.Sentence.F6_DESC) + "\n" + "<b>" + TextScript.get(TextScript.Sentence.CURRENT) + "</b>: " + getFractionAsString((float)getEffectFormula(level)) + "%" + "\t\t\t\t\t<b>" + TextScript.get(TextScript.Sentence.NEXT) + "</b>: " + getFractionAsString((float)getEffectFormula(level + 1)) + "%"; break; } return(description); }
public static string getMultiplierAsString(double multiplier) { multiplier -= 1; multiplier *= 100; return(NumberStringConverter.convert(System.Math.Floor(multiplier))); }