private void CreateHypotheticalStatsDisplay() { if ((validItems != null) && statsDisplayValid && (player != null)) { if ((checkingItemIndex > -1) && (checkingItemIndex < validItems.Count)) { PlayerAgent.EquipAttribute[] attributes = statsDisplay.attributes; if (attributes != null) { int totalAttributes = attributes.Length; float[] attributeValues = new float[totalAttributes]; player.GetHypotheticalEquipResults(validItems[checkingItemIndex], attributes, ref attributeValues); hypotheticObjects = new GameObject[totalAttributes]; hypotheticTexts = new SpritedStringUI[totalAttributes]; TextAlignment textAnchor = statsDisplay.attributeAnchorAlignment; Vector2 textScale = statsDisplay.attributeScales; int textPercentage = 0; int textPercentageLimited = 0; Vector2[] allPositionRates = statsDisplay.attributeEquipPosRates; Vector2 textPositionRates = Vector2.zero; GameObject newTextObject = null; RectTransform newTextTransform = null; SpritedStringUI newText = null; int[] oneAttributeValues = null; for (int i = 0; i < totalAttributes; i++) { textPercentage = UsefulFunctions.GetPercentage(attributeValues[i]); textPercentageLimited = (textPercentage > percentageLimit) ? percentageLimit : textPercentage; textPositionRates = allPositionRates[i] + hypotheticTextOffset; CreateTextDisplayObject("HypotheticStat", textPercentageLimited.ToString(), textScale, textPositionRates, textAnchor, ref newTextObject, ref newTextTransform, ref newText); hypotheticObjects[i] = newTextObject; hypotheticTexts[i] = newText; if ((statValues != null) && (aspects != null) && (newText != null)) { oneAttributeValues = statValues[i]; for (int j = 0; j < aspects.Length; j++) { if (aspects[j] == AttributeAspect.Equip) { if (textPercentage > oneAttributeValues[j]) { newText.SetColor(hypotheticColorIncrease, Vector4.zero); } else if (textPercentage < oneAttributeValues[j]) { newText.SetColor(hypotheticColorDecrease, Vector4.zero); } break; } } } } attributes = null; attributeValues = null; } } } }
private void ChangeButtonState(bool pressedState, ButtonAnimator buttonAnimator, SpritedStringUI buttonName, SpritedStringUI buttonAmount) { if (buttonAnimator != null) { buttonAnimator.SetPressed(pressedState); } Color textColor = pressedState ? equippedTextColor : Color.white; if (buttonName != null) { buttonName.SetColor(textColor, Vector4.zero); } if (buttonAmount != null) { buttonAmount.SetColor(textColor, Vector4.zero); } }
private bool AddCanvasText(string textString, SymbolDatabase textFont, Color textColor, Vector4 textColorGradient, int textEvolution, Transform originTransform, Vector2 originWorldPosition, bool workDuringPause) { GameObject textObject = null; RectTransform textTrans = null; SpritedStringUI text = null; int textIndex = -1; Vector3 completeWorldPos = Vector3.zero; Vector2 currentWorldPos = Vector2.zero; Vector2 canvasPosition = Vector2.zero; Vector2 textSpeed = Vector2.zero; Vector2 textIncreasedScale = Vector2.zero; Color textGeneralColor = Color.white; float textDurationShow = 0f; float textDurationPlain = 0f; float textDurationHide = 0f; int textStage = INVALID_TEXT_STAGE; if (originTransform != null) { completeWorldPos = originTransform.position; currentWorldPos = new Vector2(completeWorldPos.x, completeWorldPos.y); /*halmeida - in case there is an origin transform, the originWorldPosition vector is interpreted as an offset * from the transform's position.*/ currentWorldPos += originWorldPosition; } else { currentWorldPos = originWorldPosition; } if (TransformWorldToCanvasPosition(currentWorldPos, ref canvasPosition)) { textIndex = (textObjects == null) ? 0 : textObjects.Length; textObject = new GameObject("UIText" + textIndex, typeof(RectTransform)); if (textObject != null) { textTrans = textObject.GetComponent <RectTransform>(); text = textObject.AddComponent <SpritedStringUI>(); if (text != null) { text.SetSymbolSource(textFont); text.ToggleRaycastTargeting(false); text.SetValue(textString); textTrans.SetParent(interfaceCanvasTrans, false); textTrans.anchoredPosition = canvasPosition; switch (textEvolution) { case TEXT_EVOLUTION_ASCENT: textSpeed.y = TEXT_ASCENT_SPEED; textGeneralColor = text.GetGeneralColor(); textGeneralColor.a = 0f; text.SetGeneralColor(textGeneralColor); textStage = TEXT_STAGE_SHOW; textIncreasedScale = new Vector2(TEXT_ASCENT_START_SCALE_X, TEXT_ASCENT_START_SCALE_Y); textTrans.localScale = new Vector3(textIncreasedScale.x, textIncreasedScale.y, 1f); textDurationShow = TEXT_ASCENT_DURATION_SHOW; textDurationPlain = TEXT_ASCENT_DURATION_PLAIN; textDurationHide = TEXT_ASCENT_DURATION_HIDE; break; case TEXT_EVOLUTION_STAY: textGeneralColor = text.GetGeneralColor(); textGeneralColor.a = 0f; text.SetGeneralColor(textGeneralColor); textStage = TEXT_STAGE_SHOW; textIncreasedScale = new Vector2(TEXT_STAY_START_SCALE_X, TEXT_STAY_START_SCALE_Y); textTrans.localScale = new Vector3(textIncreasedScale.x, textIncreasedScale.y, 1f); textDurationShow = TEXT_STAY_DURATION_SHOW; textDurationPlain = TEXT_STAY_DURATION_PLAIN; textDurationHide = TEXT_STAY_DURATION_HIDE; break; case TEXT_EVOLUTION_NONE_WAIT: case TEXT_EVOLUTION_NONE_GO: textGeneralColor = text.GetGeneralColor(); textGeneralColor.a = 0f; text.SetGeneralColor(textGeneralColor); textStage = TEXT_STAGE_SHOW; textIncreasedScale = new Vector2(TEXT_NONE_START_SCALE_X, TEXT_NONE_START_SCALE_Y); textTrans.localScale = new Vector3(textIncreasedScale.x, textIncreasedScale.y, 1f); textDurationShow = TEXT_NONE_DURATION_SHOW; textDurationPlain = TEXT_NONE_DURATION_PLAIN; textDurationHide = TEXT_NONE_DURATION_HIDE; break; } text.SetColor(textColor, textColorGradient); UsefulFunctions.IncreaseArray <GameObject>(ref textObjects, textObject); UsefulFunctions.IncreaseArray <RectTransform>(ref textTransforms, textTrans); UsefulFunctions.IncreaseArray <SpritedStringUI>(ref texts, text); UsefulFunctions.IncreaseArray <int>(ref textEvolutions, textEvolution); UsefulFunctions.IncreaseArray <Transform>(ref textOriginTransforms, originTransform); UsefulFunctions.IncreaseArray <Vector2>(ref textOriginPositions, originWorldPosition); UsefulFunctions.IncreaseArray <Vector2>(ref textSpeeds, textSpeed); UsefulFunctions.IncreaseArray <Vector2>(ref textIncreasedScales, textIncreasedScale); UsefulFunctions.IncreaseArray <float>(ref textDurationsShow, textDurationShow); UsefulFunctions.IncreaseArray <float>(ref textDurationsPlain, textDurationPlain); UsefulFunctions.IncreaseArray <float>(ref textDurationsHide, textDurationHide); UsefulFunctions.IncreaseArray <int>(ref textStages, textStage); UsefulFunctions.IncreaseArray <float>(ref textStageElapseds, 0f); UsefulFunctions.IncreaseArray <float>(ref textElapseds, 0f); UsefulFunctions.IncreaseArray <bool>(ref textPauseds, workDuringPause); return(true); } } textTrans = null; if (textObject != null) { Destroy(textObject); } } return(false); }