private void CreateStepLine() { int textID = GameTextDatabase.INVALID_TEXT_ID; GameTextDatabase gameTextDatabase = null; bool autoClose = false; Vector2 stepLineDimensions = Vector2.zero; gameTextDatabase = GameTextDatabase.Instance; if ((gameTextDatabase != null) && (symbolDatabase != null) && (stepLineObject == null)) { if (invest) { textID = GameTextDatabase.TEXT_ID_TRANSACTION_INVEST_UNIT; } else { textID = GameTextDatabase.TEXT_ID_TRANSACTION_DRAW_UNIT; } stepLine = gameTextDatabase.GetSystemText(textID, ref autoClose); stepLine = stepLine + " " + currentValueStep; stepLineObject = new GameObject("StepLineObject"); stepLineObject.transform.SetParent(transform, false); stepLineObject.transform.localPosition = Vector3.zero; stepLineComponent = stepLineObject.AddComponent <SpritedString>(); stepLineComponent.SetSymbolSource(symbolDatabase); stepLineComponent.SetValue(stepLine); stepLineDimensions = stepLineComponent.GetWorldDimensions(); stepLineArea.width = stepLineDimensions.x; stepLineArea.height = stepLineDimensions.y; } }
private bool LoadSaveQuestion(bool overwriting) { int enunciateTextID = GameTextDatabase.INVALID_TEXT_ID; string textEnunciate = null; string textOptionZero = null; string textOptionOne = null; bool toDiscard = false; bool textCreated = false; if ((gameTextDatabase != null) && (textBoxManager != null)) { enunciateTextID = (overwriting ? GameTextDatabase.TEXT_ID_SAVE_OVERWRITE_ENUNCIATE : GameTextDatabase.TEXT_ID_SAVE_ENUNCIATE); textEnunciate = gameTextDatabase.GetSystemText(enunciateTextID, ref toDiscard); textOptionZero = gameTextDatabase.GetSystemText(GameTextDatabase.TEXT_ID_YES, ref toDiscard); textOptionOne = gameTextDatabase.GetSystemText(GameTextDatabase.TEXT_ID_NO, ref toDiscard); if ((textEnunciate != null) && (textOptionZero != null) && (textOptionOne != null)) { textBoxManager.PrepareForQuestion(this, 2); textCreated = textBoxManager.ShowDialogue(null, textEnunciate, true, false, null, TextBoxManager.QuestionRole.Enunciate); if (textCreated) { textCreated = textBoxManager.ShowDialogue(null, textOptionZero, true, false, null, TextBoxManager.QuestionRole.Option); } if (textCreated) { textCreated = textBoxManager.ShowDialogue(null, textOptionOne, true, false, null, TextBoxManager.QuestionRole.Option); } if (!textCreated) { textBoxManager.ClearAllDialogues(); } else { /*halmeida - set option indexes for a generic confirmation and a generic cancellation commands, so that options * don't actually need to be clicked to be chosen.*/ textBoxManager.SetOptionIndexConfirm(0); textBoxManager.SetOptionIndexCancel(1); } } } return(textCreated); }
protected override void PerformAction(float timeStep) { string text = null; string speakerName = null; bool tryAbove = false; bool autoClose = false; base.PerformAction(timeStep); if (!dialogueCreated) { if ((gameTextDatabase != null) && (textBoxManager != null)) { switch (dialogueType) { case GameTextDatabase.TextType.Platform: text = gameTextDatabase.GetPlatformText(dialogueID, dialoguePlatform, ref autoClose); dialogueCreated = textBoxManager.ShowDialogue(null, text, false, autoClose, this); break; case GameTextDatabase.TextType.System: text = gameTextDatabase.GetSystemText(dialogueID, ref autoClose); dialogueCreated = textBoxManager.ShowDialogue(null, text, false, autoClose, this); break; case GameTextDatabase.TextType.Dialogue: text = gameTextDatabase.GetDialogueText(dialogueID, ref speakerName, ref tryAbove, ref autoClose); dialogueCreated = textBoxManager.ShowDialogue(speakerName, text, tryAbove, autoClose, this); break; case GameTextDatabase.TextType.Item: text = gameTextDatabase.GetItemDescription(dialogueID, ref speakerName); dialogueCreated = textBoxManager.ShowDialogue(speakerName, text, false, false, this); break; } } } }
protected virtual bool UpdateStatsDisplay() { GameTextDatabase textDatabase = null; string textValue = null; float statValueOriginal = 0f; float statValueBase = 0f; float statEquippedSum = 0f; bool toDiscard = false; Vector2 textDimensions = Vector2.zero; Vector2 textScales = Vector2.zero; Vector2 textPositionRates = Vector2.zero; TextAlignment textAnchor = TextAlignment.Center; bool skipUpdate = false; textDatabase = GameTextDatabase.Instance; if (statsDisplayValid && (interfaceCanvasTrans != null) && (player != null) && (textDatabase != null)) { if (levelObject != null) { textValue = textDatabase.GetSystemText(GameTextDatabase.TEXT_ID_PLAYER_LEVEL, ref toDiscard); textValue += " " + player.GetCurrentLevel(); textScales = statsDisplay.levelScales; textPositionRates = statsDisplay.levelPositionRates; textAnchor = statsDisplay.levelAnchorAlignment; UpdateTextDisplayObject(textValue, textScales, textPositionRates, textAnchor, levelTransform, levelText); } if (statObjects != null) { textAnchor = statsDisplay.attributeAnchorAlignment; textScales = statsDisplay.attributeScales; RectTransform[] oneStatTransforms = null; SpritedStringUI[] oneStatTexts = null; int[] oneStatValues = null; int percentageBase = 0; int percentageBaseLimited = 0; int percentageEquip = 0; int percentageEquipLimited = 0; int percentageTotal = 0; int percentageTotalLimited = 0; bool percentageBaseReady = false; bool percentageEquipReady = false; int statValue = -1; for (int i = 0; i < stats.Length; i++) { oneStatTransforms = statTransforms[i]; oneStatTexts = statTexts[i]; oneStatValues = statValues[i]; player.GetStatValueSegments(stats[i], ref statValueOriginal, ref statValueBase, ref statEquippedSum); percentageBaseReady = false; percentageEquipReady = false; for (int j = 0; j < aspects.Length; j++) { skipUpdate = false; switch (aspects[j]) { case AttributeAspect.Name: skipUpdate = true; break; case AttributeAspect.Base: if (!percentageBaseReady) { percentageBase = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal); statValue = percentageBase; percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase; percentageBaseReady = true; } textValue = percentageBaseLimited.ToString(); textPositionRates = statsDisplay.attributeBasePosRates[i]; break; case AttributeAspect.Equip: if (!percentageEquipReady) { percentageEquip = UsefulFunctions.GetPercentage(statEquippedSum); statValue = percentageEquip; percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip; percentageEquipReady = true; } textValue = percentageEquipLimited.ToString(); textPositionRates = statsDisplay.attributeEquipPosRates[i]; break; case AttributeAspect.Total: if (!percentageBaseReady) { percentageBase = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal); percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase; percentageBaseReady = true; } if (!percentageEquipReady) { percentageEquip = UsefulFunctions.GetPercentage(statEquippedSum); percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip; percentageEquipReady = true; } percentageTotal = percentageBase + percentageEquip; statValue = percentageTotal; percentageTotalLimited = (percentageTotal > percentageLimit) ? percentageLimit : percentageTotal; textValue = percentageTotalLimited.ToString(); textPositionRates = statsDisplay.attributeTotalPosRates[i]; break; } if (!skipUpdate) { UpdateTextDisplayObject(textValue, textScales, textPositionRates, textAnchor, oneStatTransforms[j], oneStatTexts[j]); oneStatValues[j] = statValue; } } } } return(true); } return(false); }
protected virtual bool CreateStatsDisplay() { GameTextDatabase textDatabase = null; int totalStats = 0; string statName = null; string textName = null; string textValue = null; float statValueOriginal = 0f; float statValueBase = 0f; float statEquippedSum = 0f; bool toDiscard = false; GameObject textObject = null; RectTransform textTransform = null; SpritedStringUI textComponent = null; Vector2 textDimensions = Vector2.zero; Vector2 textScales = Vector2.zero; Vector2 textPositionRates = Vector2.zero; TextAlignment textAnchor = TextAlignment.Center; textDatabase = GameTextDatabase.Instance; if (statsDisplayValid && (interfaceCanvasTrans != null) && (player != null) && (textDatabase != null)) { if (statsDisplay.displayLevel && (levelObject == null)) { statName = textDatabase.GetSystemText(GameTextDatabase.TEXT_ID_PLAYER_LEVEL, ref toDiscard); statName += " " + player.GetCurrentLevel(); textScales = statsDisplay.levelScales; textPositionRates = statsDisplay.levelPositionRates; textAnchor = statsDisplay.levelAnchorAlignment; CreateTextDisplayObject("LevelDisplay", statName, textScales, textPositionRates, textAnchor, ref levelObject, ref levelTransform, ref levelText); } if (statObjects == null) { stats = statsDisplay.attributes; if (stats != null) { totalStats = stats.Length; if (totalStats > 0) { statObjects = new GameObject[totalStats][]; statTransforms = new RectTransform[totalStats][]; statTexts = new SpritedStringUI[totalStats][]; statValues = new int[totalStats][]; GameObject[] newStatObjects = null; RectTransform[] newStatTransforms = null; SpritedStringUI[] newStatTexts = null; int[] newStatValues = null; int statValue = -1; int percentageBase = 0; int percentageBaseLimited = 0; int percentageEquip = 0; int percentageEquipLimited = 0; int percentageTotal = 0; int percentageTotalLimited = 0; bool percentageBaseReady = false; bool percentageEquipReady = false; textAnchor = statsDisplay.attributeAnchorAlignment; textScales = statsDisplay.attributeScales; for (int i = 0; i < stats.Length; i++) { newStatObjects = new GameObject[aspects.Length]; newStatTransforms = new RectTransform[aspects.Length]; newStatTexts = new SpritedStringUI[aspects.Length]; newStatValues = new int[aspects.Length]; statName = textDatabase.GetEquipAttributeName(stats[i]); player.GetStatValueSegments(stats[i], ref statValueOriginal, ref statValueBase, ref statEquippedSum); percentageBaseReady = false; percentageEquipReady = false; for (int j = 0; j < aspects.Length; j++) { switch (aspects[j]) { case AttributeAspect.Name: textName = "StatName" + statName; textValue = statName; textPositionRates = statsDisplay.attributeNamePosRates[i]; statValue = -1; break; case AttributeAspect.Base: textName = "StatBase" + statName; if (!percentageBaseReady) { percentageBase = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal); statValue = percentageBase; percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase; percentageBaseReady = true; } textValue = percentageBaseLimited.ToString(); textPositionRates = statsDisplay.attributeBasePosRates[i]; break; case AttributeAspect.Equip: textName = "StatEquip" + statName; if (!percentageEquipReady) { percentageEquip = UsefulFunctions.GetPercentage(statEquippedSum); statValue = percentageEquip; percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip; percentageEquipReady = true; } textValue = percentageEquipLimited.ToString(); textPositionRates = statsDisplay.attributeEquipPosRates[i]; break; case AttributeAspect.Total: textName = "StatTotal" + statName; if (!percentageBaseReady) { percentageBase = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal); percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase; percentageBaseReady = true; } if (!percentageEquipReady) { percentageEquip = UsefulFunctions.GetPercentage(statEquippedSum); percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip; percentageEquipReady = true; } percentageTotal = percentageBase + percentageEquip; statValue = percentageTotal; percentageTotalLimited = (percentageTotal > percentageLimit) ? percentageLimit : percentageTotal; textValue = percentageTotalLimited.ToString(); textPositionRates = statsDisplay.attributeTotalPosRates[i]; break; } CreateTextDisplayObject(textName, textValue, textScales, textPositionRates, textAnchor, ref textObject, ref textTransform, ref textComponent); newStatObjects[j] = textObject; newStatTransforms[j] = textTransform; newStatTexts[j] = textComponent; newStatValues[j] = statValue; } statObjects[i] = newStatObjects; statTransforms[i] = newStatTransforms; statTexts[i] = newStatTexts; statValues[i] = newStatValues; } } } } return(true); } return(false); }
private void CreateSectionButtons() { bool toDiscard = false; GameObject buttonObject = null; RectTransform buttonTransform = null; ButtonAnimator buttonAnimator = null; GameObject buttonTextObject = null; RectTransform buttonTextTrans = null; SpritedStringUI buttonText = null; Vector2 buttonScale = Vector2.one; Vector2 buttonPositionRates = Vector2.zero; if ((sectionButtonModel != null) && (interfaceCanvasTrans != null) && (sectionButtons == null)) { GameTextDatabase gameTextDatabase = GameTextDatabase.Instance; int totalSections = 1; if (firstSections != null) { if (firstSections.Length > 0) { totalSections += firstSections.Length; } } sectionButtonObjects = new GameObject[totalSections]; sectionButtonTransforms = new RectTransform[totalSections]; sectionButtons = new ButtonAnimator[totalSections]; /*halmeida - the button objects and the text objects have to be separate objects so that they * can have different scaling.*/ sectionTextObjects = new GameObject[totalSections]; sectionTexts = new SpritedStringUI[totalSections]; buttonScale = sectionDisplayScheme.buttonElementScale; string sectionTitle = null; Vector2[] allPositionRates = sectionDisplayScheme.elementPositionRates; for (int i = 0; i < totalSections; i++) { if (gameTextDatabase != null) { if (i == (totalSections - 1)) { sectionTitle = gameTextDatabase.GetSystemText(GameTextDatabase.TEXT_ID_NON_EQUIPPABLE_ITEMS, ref toDiscard); } else { sectionTitle = gameTextDatabase.GetEquipBodyPartName(firstSections[i]); } } if (allPositionRates != null) { buttonPositionRates = (allPositionRates.Length > i) ? allPositionRates[i] : new Vector2(0.5f, 0.5f); } CreateButtonObject(sectionButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center, ref buttonObject, ref buttonTransform, ref buttonAnimator); sectionButtonObjects[i] = buttonObject; sectionButtonTransforms[i] = buttonTransform; sectionButtons[i] = buttonAnimator; CreateTextDisplayObject("SectionName", sectionTitle, Vector2.one, buttonPositionRates, TextAlignment.Center, ref buttonTextObject, ref buttonTextTrans, ref buttonText); sectionTextObjects[i] = buttonTextObject; sectionTexts[i] = buttonText; } } }