| | |
| | | public class EquipStarWin : Window |
| | | { |
| | | [SerializeField] CyclicScroll m_CandidateScroll; |
| | | [SerializeField] Image[] m_Stars; |
| | | [SerializeField] ImageCouple[] m_Stars; |
| | | [SerializeField] ItemCell m_TargetEquip; |
| | | [SerializeField] Materials m_Materials; |
| | | [SerializeField] Text m_SuccessRate; |
| | | [SerializeField] PropertyPreview[] m_PropertyPreviews; |
| | | [SerializeField] Text m_NewProperty; |
| | | [SerializeField] BaseProperty[] m_BasePropertys; |
| | | [SerializeField] Text[] m_LevelUpPropertys; |
| | | [SerializeField] Button m_StarUpgrade; |
| | | |
| | | EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } } |
| | |
| | | m_TargetEquip.Init(equip); |
| | | |
| | | var currentStarLevel = model.GetEquipStarLevel(equip.config.LV, equip.config.EquipPlace); |
| | | var maxStarLevel = model.GetMaxStarLevel(equip.config.LV); |
| | | for (var i = 0; i < m_Stars.Length; i++) |
| | | { |
| | | m_Stars[i].gameObject.SetActive(i < maxStarLevel); |
| | | if (i < maxStarLevel) |
| | | { |
| | | m_Stars[i].SetSprite(i < currentStarLevel ? "" : ""); |
| | | } |
| | | } |
| | | |
| | | var starConfig = EquipStarConfig.Get(equip.config.LV, equip.config.EquipPlace, currentStarLevel); |
| | | var equalCount = Mathf.Min(starConfig.BaseAttrInfo.Length, starConfig.StarAttrInfo.Length); |
| | | for (var i = 0; i < m_PropertyPreviews.Length; i++) |
| | | { |
| | | var behaviour = m_PropertyPreviews[i]; |
| | | if (i < equalCount) |
| | | { |
| | | behaviour.Display(starConfig.BaseAttrInfo[i].x, starConfig.BaseAttrInfo[i].y, starConfig.StarAttrInfo[i].y); |
| | | } |
| | | else |
| | | { |
| | | behaviour.Hide(); |
| | | } |
| | | } |
| | | |
| | | var newCount = starConfig.StarAttrInfo.Length - starConfig.BaseAttrInfo.Length; |
| | | if (newCount > 0) |
| | | { |
| | | var property = starConfig.StarAttrInfo[starConfig.StarAttrInfo.Length - 1]; |
| | | var propertyConfig = PlayerPropertyConfig.Get(property.x); |
| | | var valueDescription = propertyConfig.ISPercentage == 1 |
| | | ? StringUtility.Contact(Mathf.RoundToInt(property.y * 0.01f), "%") : property.y.ToString(); |
| | | m_NewProperty.text = StringUtility.Contact(propertyConfig.Name, " +", valueDescription); |
| | | m_NewProperty.gameObject.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | m_NewProperty.gameObject.SetActive(false); |
| | | } |
| | | DisplayStars(equip.config.LV, equip.config.EquipPlace, currentStarLevel); |
| | | DisplayBaseProperty(equip.config.LV, equip.config.EquipPlace, currentStarLevel); |
| | | DisplayLevelUpProperty(equip.config.LV, equip.config.EquipPlace, currentStarLevel); |
| | | } |
| | | |
| | | if (force || model.starUpgradeProbability.dirty) |
| | |
| | | } |
| | | } |
| | | |
| | | private void DisplayStars(int level, int equipPlace, int currentStarLevel) |
| | | { |
| | | var maxStarLevel = model.GetMaxStarLevel(level); |
| | | for (var i = 0; i < m_Stars.Length; i++) |
| | | { |
| | | if (i < maxStarLevel) |
| | | { |
| | | m_Stars[i].Display(i < currentStarLevel); |
| | | } |
| | | else |
| | | { |
| | | m_Stars[i].Hide(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void DisplayBaseProperty(int level, int equipPlace, int currentStarLevel) |
| | | { |
| | | var nowConfig = EquipStarConfig.Get(level, equipPlace, currentStarLevel); |
| | | var nextConfig = EquipStarConfig.Get(level, equipPlace, currentStarLevel + 1); |
| | | var count = nextConfig.BaseAttrInfo.Length; |
| | | for (var i = 0; i < m_BasePropertys.Length; i++) |
| | | { |
| | | var behaviour = m_BasePropertys[i]; |
| | | if (i < count) |
| | | { |
| | | var current = nowConfig == null ? 0 : nowConfig.BaseAttrInfo[i].y; |
| | | var next = nextConfig == null ? 0 : nextConfig.BaseAttrInfo[i].y; |
| | | behaviour.Display(nextConfig == null ? 0 : nextConfig.BaseAttrInfo[i].x, current, next); |
| | | } |
| | | else |
| | | { |
| | | behaviour.Hide(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void DisplayLevelUpProperty(int level, int equipPlace, int currentStarLevel) |
| | | { |
| | | var configs = EquipStarConfig.GetConfigs(level, equipPlace); |
| | | var levelUpProperties = new Dictionary<int, Int2>(); |
| | | var prePropertiesCount = 0; |
| | | foreach (var config in configs) |
| | | { |
| | | if (config.StarAttrInfo.Length > prePropertiesCount) |
| | | { |
| | | var length = config.StarAttrInfo.Length; |
| | | levelUpProperties[config.Star] = config.StarAttrInfo[length - 1]; |
| | | prePropertiesCount = config.StarAttrInfo.Length; |
| | | } |
| | | } |
| | | |
| | | var keys = new List<int>(levelUpProperties.Keys); |
| | | for (var i = 0; i < m_LevelUpPropertys.Length; i++) |
| | | { |
| | | var behaviour = m_LevelUpPropertys[i]; |
| | | if (i < keys.Count) |
| | | { |
| | | var property = levelUpProperties[keys[i]]; |
| | | var config = PlayerPropertyConfig.Get(property.x); |
| | | behaviour.gameObject.SetActive(true); |
| | | behaviour.text = string.Format("【{0}星】{1}+{2}", config.Name, PlayerPropertyConfig.GetPropertyDescription(property.x, property.y)); |
| | | behaviour.color = UIHelper.GetUIColor(keys[i] == currentStarLevel + 1 ? TextColType.Green : TextColType.Gray); |
| | | } |
| | | else |
| | | { |
| | | behaviour.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void StarUpgrade() |
| | | { |
| | | var equip = packModel.GetItemByGuid(model.selectedEquip.value); |
| | | model.DoStarUpgrade(equip.config.LV, equip.config.EquipPlace); |
| | | } |
| | | |
| | | [System.Serializable] |
| | | public class ImageCouple |
| | | { |
| | | public RectTransform container; |
| | | public Image imageBase; |
| | | public Image imageStar; |
| | | |
| | | public void Display(bool active) |
| | | { |
| | | container.gameObject.SetActive(true); |
| | | imageStar.gameObject.SetActive(active); |
| | | } |
| | | |
| | | public void Hide() |
| | | { |
| | | container.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | [System.Serializable] |
| | |
| | | } |
| | | |
| | | [System.Serializable] |
| | | public class PropertyPreview |
| | | public class BaseProperty |
| | | { |
| | | public RectTransform container; |
| | | public Text propertyName; |
| | | public Text current; |
| | | public Text next; |
| | | |
| | |
| | | var config = PlayerPropertyConfig.Get(propertyId); |
| | | if (config != null) |
| | | { |
| | | propertyName.text = config.Name; |
| | | this.current.text = config.ISPercentage == 1 ? |
| | | StringUtility.Contact(Mathf.RoundToInt(currentValue * 0.01f), "%") : currentValue.ToString(); |
| | | |
| | | this.next.text = config.ISPercentage == 1 ? |
| | | StringUtility.Contact(Mathf.RoundToInt(nextValue * 0.01f), "%") : nextValue.ToString(); |
| | | this.current.text = StringUtility.Contact(config.Name, ":", PlayerPropertyConfig.GetPropertyDescription(propertyId, currentValue)); |
| | | this.next.text = PlayerPropertyConfig.GetPropertyDescription(propertyId, nextValue); |
| | | } |
| | | } |
| | | |