|
@@ -3,9 +3,10 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using LitJson;
|
|
|
using UnityEngine;
|
|
|
+using UnityEngine.UI;
|
|
|
using Random = UnityEngine.Random;
|
|
|
|
|
|
-public class RechargeGiftManager
|
|
|
+public class RechargeGiftJsonLabel
|
|
|
{
|
|
|
public static string PackID = "packid";
|
|
|
public static string StartTime = "starttime";
|
|
@@ -52,38 +53,46 @@ public class RechargeGift
|
|
|
/// <returns>true-全部领完</returns>
|
|
|
public abstract bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo);
|
|
|
|
|
|
- protected void GetGiftAward(GiftType type, int value)
|
|
|
+ protected void GetGiftAward(GiftType type, int value, out KV<GiftType, int> giftAwardInfo)
|
|
|
{
|
|
|
if (type == GiftType.开垦土地)
|
|
|
{
|
|
|
+ AudioManager.PlayClip(ResourceLabel.CurrentClip);
|
|
|
for (int i = 0; i < value; i++)
|
|
|
{
|
|
|
GardenManager.UnlockSlot();
|
|
|
int extraSlot = ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot);
|
|
|
ConfigManager.SaveIntToConfig(PlayerConfigLabel.ExtraSlot, extraSlot + 1);
|
|
|
- Debug.LogWarning($"{type}");
|
|
|
}
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
}
|
|
|
else if (type == GiftType.服装)
|
|
|
{
|
|
|
CloseItem closeItem = PlayerManager.CloseItemDictionary[value];
|
|
|
if (closeItem.IsBought)
|
|
|
{
|
|
|
- ExchangeInfo info =
|
|
|
- closeItem.GetExchangeValue(CloseExchangeRatio, StaticsManager.ConsumeModule.Gift);
|
|
|
- Debug.LogWarning($"{type} {info.Current} {info.Value}");
|
|
|
+ AudioManager.PlayClip(ResourceLabel.CurrentClip);
|
|
|
+ ExchangeInfo info = closeItem.GetExchangeValue(CloseExchangeRatio, StaticsManager.ConsumeModule.Gift);
|
|
|
+ giftAwardInfo.Key = CurrentToGiftType(info.Current);
|
|
|
+ giftAwardInfo.Value = (int) info.Value;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
closeItem.OnBuySucceed();
|
|
|
- Debug.LogWarning($"{type} {value}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
}
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
}
|
|
|
else if (type == GiftType.礼包)
|
|
|
{
|
|
|
string packID = SkillConfigLabel.GetFullID(SkillType.Pack, value);
|
|
|
(Manager.SkillDictionary[packID] as Pack).OnBuySucceed(false);
|
|
|
- Debug.LogWarning($"{type} {SkillConfigLabel.Pack + value}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
}
|
|
|
else if (type == GiftType.精灵)
|
|
|
{
|
|
@@ -91,36 +100,72 @@ public class RechargeGift
|
|
|
Ability ability = Manager.SkillDictionary[abilityID] as Ability;
|
|
|
if (ability.ItemStatus == SkillStatus.Lock)
|
|
|
{
|
|
|
- ExchangeInfo info =
|
|
|
- ability.GetUnlockAheadExchangeValue(AbilityExchangeRatio, StaticsManager.ConsumeModule.Gift);
|
|
|
- Debug.LogWarning($"{type} {info.Current} {info.Value}");
|
|
|
+ AudioManager.PlayClip(ResourceLabel.CurrentClip);
|
|
|
+ ExchangeInfo info = ability.GetUnlockAheadExchangeValue(AbilityExchangeRatio, StaticsManager.ConsumeModule.Gift);
|
|
|
+ giftAwardInfo.Key = CurrentToGiftType(info.Current);
|
|
|
+ giftAwardInfo.Value = (int)info.Value;
|
|
|
}
|
|
|
else if (ability.ItemStatus == SkillStatus.UnLock)
|
|
|
{
|
|
|
ability.UnlockSucceed();
|
|
|
- Debug.LogWarning($"{type} {SkillConfigLabel.Pack + value}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
}
|
|
|
else if (ability.ItemStatus == SkillStatus.Upgrade)
|
|
|
{
|
|
|
ability.UpgradeSucceed();
|
|
|
- Debug.LogWarning($"{type} {SkillConfigLabel.Pack + value}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
}
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
}
|
|
|
else if (type == GiftType.花朵)
|
|
|
{
|
|
|
FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[value];
|
|
|
flowerInfo.Add();
|
|
|
- Debug.LogWarning($"{type} {flowerInfo.Name}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
}
|
|
|
else if (type == GiftType.金币)
|
|
|
{
|
|
|
+ AudioManager.PlayClip(ResourceLabel.CurrentClip);
|
|
|
Manager.AddCoin(value, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Gift);
|
|
|
- Debug.LogWarning($"{type} {value}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
}
|
|
|
else if (type == GiftType.钻石)
|
|
|
{
|
|
|
+ AudioManager.PlayClip(ResourceLabel.CurrentClip);
|
|
|
Manager.AddDiamond(value, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Gift);
|
|
|
- Debug.LogWarning($"{type} {value}");
|
|
|
+ giftAwardInfo.Key = type;
|
|
|
+ giftAwardInfo.Value = value;
|
|
|
+ Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected GiftType CurrentToGiftType(Current current)
|
|
|
+ {
|
|
|
+ if (current == Current.Coin)
|
|
|
+ {
|
|
|
+ return GiftType.金币;
|
|
|
+ }
|
|
|
+ else if (current == Current.Diamond)
|
|
|
+ {
|
|
|
+ return GiftType.钻石;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -132,14 +177,12 @@ public class RechargeGift
|
|
|
public SingleGiftAward(GiftType giftType, int value) : base(giftType)
|
|
|
{
|
|
|
Value = value;
|
|
|
- Debug.Log($"{giftType} {value}");
|
|
|
+ //Debug.Log($"{giftType} {value}");
|
|
|
}
|
|
|
|
|
|
public override bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
|
|
|
{
|
|
|
- GetGiftAward(GiftType, Value);
|
|
|
- giftAwardInfo.Key = GiftType;
|
|
|
- giftAwardInfo.Value = Value;
|
|
|
+ GetGiftAward(GiftType, Value, out giftAwardInfo);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -151,14 +194,12 @@ public class RechargeGift
|
|
|
public MultipleGiftAward(GiftType giftType, List<int> values) : base(giftType)
|
|
|
{
|
|
|
Values = values;
|
|
|
- Debug.Log($"{giftType} {Auxiliary.IntsToString(Values)}");
|
|
|
+ //Debug.Log($"{giftType} {Auxiliary.IntsToString(Values)}");
|
|
|
}
|
|
|
|
|
|
public override bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
|
|
|
{
|
|
|
- GetGiftAward(GiftType, Values[0]);
|
|
|
- giftAwardInfo.Key = GiftType;
|
|
|
- giftAwardInfo.Value = Values[0];
|
|
|
+ GetGiftAward(GiftType, Values[0], out giftAwardInfo);
|
|
|
Values.RemoveAt(0);
|
|
|
if (Values.Count > 0)
|
|
|
{
|
|
@@ -181,21 +222,24 @@ public class RechargeGift
|
|
|
{
|
|
|
StartIndex = startIndex;
|
|
|
EndIndex = endIndex;
|
|
|
- Debug.Log($"{giftType} {StartIndex} {EndIndex}");
|
|
|
+ //Debug.Log($"{giftType} {StartIndex} {EndIndex}");
|
|
|
}
|
|
|
|
|
|
public override bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
|
|
|
{
|
|
|
int value = Random.Range(StartIndex, EndIndex + 1);
|
|
|
- GetGiftAward(GiftType, value);
|
|
|
- giftAwardInfo.Key = GiftType;
|
|
|
- giftAwardInfo.Value = value;
|
|
|
+ GetGiftAward(GiftType, value, out giftAwardInfo);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region Config
|
|
|
|
|
|
+ public int RemainGiftAward
|
|
|
+ {
|
|
|
+ get { return GiftAwards.Count; }
|
|
|
+ }
|
|
|
+
|
|
|
private DateTime StartDate;
|
|
|
private DateTime EndDate;
|
|
|
private List<GiftAward> GiftAwards = new List<GiftAward>();
|
|
@@ -205,50 +249,50 @@ public class RechargeGift
|
|
|
public RechargeGift(JsonData jsonData)
|
|
|
{
|
|
|
//Debug.Log(jsonData.ToJson());
|
|
|
- string label = RechargeGiftManager.TypeDictionary[GiftType.金币];
|
|
|
+ string label = RechargeGiftJsonLabel.TypeDictionary[GiftType.金币];
|
|
|
string valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.金币, valueStr));
|
|
|
}
|
|
|
- label = RechargeGiftManager.TypeDictionary[GiftType.钻石];
|
|
|
+ label = RechargeGiftJsonLabel.TypeDictionary[GiftType.钻石];
|
|
|
valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.钻石, valueStr));
|
|
|
}
|
|
|
- label = RechargeGiftManager.TypeDictionary[GiftType.礼包];
|
|
|
+ label = RechargeGiftJsonLabel.TypeDictionary[GiftType.礼包];
|
|
|
valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.礼包, valueStr));
|
|
|
}
|
|
|
- label = RechargeGiftManager.TypeDictionary[GiftType.花朵];
|
|
|
+ label = RechargeGiftJsonLabel.TypeDictionary[GiftType.花朵];
|
|
|
valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.花朵, valueStr));
|
|
|
}
|
|
|
- label = RechargeGiftManager.TypeDictionary[GiftType.服装];
|
|
|
+ label = RechargeGiftJsonLabel.TypeDictionary[GiftType.服装];
|
|
|
valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.服装, valueStr));
|
|
|
}
|
|
|
- label = RechargeGiftManager.TypeDictionary[GiftType.开垦土地];
|
|
|
+ label = RechargeGiftJsonLabel.TypeDictionary[GiftType.开垦土地];
|
|
|
valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.开垦土地, valueStr));
|
|
|
}
|
|
|
- label = RechargeGiftManager.TypeDictionary[GiftType.精灵];
|
|
|
+ label = RechargeGiftJsonLabel.TypeDictionary[GiftType.精灵];
|
|
|
valueStr = jsonData[label].ToString();
|
|
|
- if (valueStr != RechargeGiftManager.UnvalidValueStr)
|
|
|
+ if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
|
|
|
{
|
|
|
GiftAwards.AddRange(ParseAllGiftAward(GiftType.精灵, valueStr));
|
|
|
}
|
|
|
- StartDate = DateTime.Parse(jsonData[RechargeGiftManager.StartTime].ToString());
|
|
|
- EndDate = DateTime.Parse(jsonData[RechargeGiftManager.EndTime].ToString());
|
|
|
+ StartDate = DateTime.Parse(jsonData[RechargeGiftJsonLabel.StartTime].ToString());
|
|
|
+ EndDate = DateTime.Parse(jsonData[RechargeGiftJsonLabel.EndTime].ToString());
|
|
|
//Debug.LogWarning(StartDate);
|
|
|
//Debug.LogWarning(EndDate);
|
|
|
}
|
|
@@ -296,7 +340,7 @@ public class RechargeGift
|
|
|
}
|
|
|
|
|
|
|
|
|
- public bool IsGiftAvailable()
|
|
|
+ public bool IsAwardAvailable()
|
|
|
{
|
|
|
if (HttpManager.CurrentDateTime > EndDate)
|
|
|
{
|
|
@@ -336,13 +380,28 @@ public class RechargeGift
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-public class ThanksGift
|
|
|
+public class RechargeGiftManager
|
|
|
{
|
|
|
#region Config
|
|
|
|
|
|
- private static bool Inited;
|
|
|
+ public static bool Inited;
|
|
|
+
|
|
|
private static Dictionary<int, RechargeGift> GiftDictionary = new Dictionary<int, RechargeGift>();
|
|
|
|
|
|
+ private static string AmountTextPrefix = "x";
|
|
|
+ private static RechargeGift CurrentRechargeGift;
|
|
|
+
|
|
|
+ private static Text Title;
|
|
|
+ private static Text Description;
|
|
|
+ private static Text ConfirmButtonText;
|
|
|
+ private static Image AwardImage0;
|
|
|
+ private static Image AwardImage1;
|
|
|
+ private static Image AwardImage2;
|
|
|
+ private static Image FlowerAwardImage;
|
|
|
+ private static Button ConfirmButton;
|
|
|
+ private static Transform PanelBK;
|
|
|
+ private static List<Image> AwardImages = new List<Image>();
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
public static void Init(JsonData jsonData)
|
|
@@ -351,39 +410,205 @@ public class ThanksGift
|
|
|
Inited = true;
|
|
|
for (int i = 0; i < jsonData.Count; i++)
|
|
|
{
|
|
|
- int packID = (int) jsonData[i][RechargeGiftManager.PackID];
|
|
|
+ int packID = (int) jsonData[i][RechargeGiftJsonLabel.PackID];
|
|
|
RechargeGift rechargeGift = new RechargeGift(jsonData[i]);
|
|
|
GiftDictionary.Add(packID, rechargeGift);
|
|
|
}
|
|
|
+
|
|
|
+ Title = ResourceManager.Get<Text>(ObjectLabel.AB_Title);
|
|
|
+ Description = ResourceManager.Get<Text>(ObjectLabel.AB_Description);
|
|
|
+ ConfirmButtonText = ResourceManager.Get<Text>(ObjectLabel.AB_ConfirmText);
|
|
|
+ AwardImage0 = ResourceManager.Get<Image>(ObjectLabel.AB_AwardImage0);
|
|
|
+ AwardImage1 = ResourceManager.Get<Image>(ObjectLabel.AB_AwardImage1);
|
|
|
+ AwardImage2 = ResourceManager.Get<Image>(ObjectLabel.AB_AwardImage2);
|
|
|
+ FlowerAwardImage = ResourceManager.Get<Image>(ObjectLabel.AB_FlowerAwardImage);
|
|
|
+ ConfirmButton = ResourceManager.Get<Button>(ObjectLabel.AB_Confirm);
|
|
|
+ PanelBK = ResourceManager.Get(ObjectLabel.AB_PanelBK);
|
|
|
+ AwardImages.Add(AwardImage0);
|
|
|
+ AwardImages.Add(AwardImage1);
|
|
|
+ AwardImages.Add(AwardImage2);
|
|
|
+
|
|
|
+ PanelBK.CreateTweenCG(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
|
|
|
+ ConfirmButton.onClick.AddListener(() => GetNextRechargeGiftAward(CurrentRechargeGift));
|
|
|
+
|
|
|
+ LanguageManager.Add(Title, new MulLanStr(LanguageLabel.UI__AB_RechargeGiftTitle));
|
|
|
+ LanguageManager.Add(ConfirmButtonText, new MulLanStr(LanguageLabel.Common__Confirm));
|
|
|
}
|
|
|
|
|
|
- public static void GetAllGift(int packID)
|
|
|
+ public static void GetAllRechargeGiftAward(int packID)
|
|
|
{
|
|
|
- if (!Inited)
|
|
|
+ if (!GiftDictionary.ContainsKey(packID))
|
|
|
{
|
|
|
- HttpManager.GetThanksGiftInfo
|
|
|
- (
|
|
|
- jData =>
|
|
|
- {
|
|
|
- Init(jData);
|
|
|
- getGift(packID);
|
|
|
- },
|
|
|
- () => Bubble.Show(null, Language.GetStr(LanguageLabel.UI__GetThanksGiftInfoFailed)
|
|
|
- )
|
|
|
- );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CurrentRechargeGift = GiftDictionary[packID];
|
|
|
+
|
|
|
+ if (!CurrentRechargeGift.IsAwardAvailable())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PanelBK.TweenForCG();
|
|
|
+ GetNextRechargeGiftAward(CurrentRechargeGift);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void GetNextRechargeGiftAward(RechargeGift rechargeGift)
|
|
|
+ {
|
|
|
+ if (rechargeGift.RemainGiftAward == 0)
|
|
|
+ {
|
|
|
+ PanelBK.TweenBacCG();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- getGift(packID);
|
|
|
+ KV<RechargeGift.GiftType, int> awardInfo;
|
|
|
+ rechargeGift.GetOneGiftAward(out awardInfo);
|
|
|
+ SetupRechargeGiftAwardUI(awardInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void getGift(int packID)
|
|
|
+ private static void SetupRechargeGiftAwardUI(KV<RechargeGift.GiftType, int> awardInfo)
|
|
|
{
|
|
|
- if (GiftDictionary.ContainsKey(packID))
|
|
|
- {
|
|
|
- //RechargeGift rechargeGift = GiftDictionary[packID];
|
|
|
- //rechargeGift.GetOneGiftAward();
|
|
|
+ if (awardInfo.Key == RechargeGift.GiftType.花朵)
|
|
|
+ {
|
|
|
+ AwardImages.Remove(FlowerAwardImage);
|
|
|
+ AwardImages.Insert(0 ,FlowerAwardImage);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AwardImages.Remove(FlowerAwardImage);
|
|
|
+ AwardImages.Add(FlowerAwardImage);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (awardInfo.Key == RechargeGift.GiftType.金币)
|
|
|
+ {
|
|
|
+ SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.75f, 0.75f);
|
|
|
+ Description.text = AmountTextPrefix + awardInfo.Value;
|
|
|
+ }
|
|
|
+ else if (awardInfo.Key == RechargeGift.GiftType.钻石)
|
|
|
+ {
|
|
|
+ SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.75f, 0.75f);
|
|
|
+ Description.text = AmountTextPrefix + awardInfo.Value;
|
|
|
+ }
|
|
|
+ else if (awardInfo.Key == RechargeGift.GiftType.花朵)
|
|
|
+ {
|
|
|
+ FlowerInfo flowerInfo = (FlowerInfo) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.3f, 0.3f);
|
|
|
+ Description.text = flowerInfo.Name;
|
|
|
+ }
|
|
|
+ else if (awardInfo.Key == RechargeGift.GiftType.精灵)
|
|
|
+ {
|
|
|
+ SkillRoot skillRoot = (SkillRoot) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.4f, 0.4f);
|
|
|
+ Description.text = skillRoot.Name;
|
|
|
+ }
|
|
|
+ else if (awardInfo.Key == RechargeGift.GiftType.服装)
|
|
|
+ {
|
|
|
+ CloseItem closeItem = (CloseItem) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 1f, 1f);
|
|
|
+ Description.text = closeItem.Name;
|
|
|
+ }
|
|
|
+ else if (awardInfo.Key == RechargeGift.GiftType.礼包)
|
|
|
+ {
|
|
|
+ SkillRoot skillRoot = (SkillRoot) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.4f, 0.4f);
|
|
|
+ Description.text = skillRoot.Name;
|
|
|
+ }
|
|
|
+ else if (awardInfo.Key == RechargeGift.GiftType.开垦土地)
|
|
|
+ {
|
|
|
+ SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.4f, 0.4f);
|
|
|
+ Description.text = AmountTextPrefix + awardInfo.Value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static object SetupRechargeGiftAwardUI(RechargeGift.GiftType type, int id, List<Image> images, float deltaSizeX, float deltaSizeY)
|
|
|
+ {
|
|
|
+ if (type == RechargeGift.GiftType.花朵)
|
|
|
+ {
|
|
|
+ for (int i = 1; i < images.Count; i++)
|
|
|
+ {
|
|
|
+ images[i].transform.localPosition = new Vector3();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (int i = 0; i < images.Count - 1; i++)
|
|
|
+ {
|
|
|
+ images[i].transform.localPosition = new Vector3();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < images.Count; i++)
|
|
|
+ {
|
|
|
+ images[i].transform.SetActive(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type == RechargeGift.GiftType.金币)
|
|
|
+ {
|
|
|
+ images[0].transform.SetActive(true);
|
|
|
+ images[0].sprite = ResourceManager.LoadSprite(ResourceLabel.Gold, Folder.Atlas);
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ else if (type == RechargeGift.GiftType.钻石)
|
|
|
+ {
|
|
|
+ images[0].transform.SetActive(true);
|
|
|
+ images[0].sprite = ResourceManager.LoadSprite(ResourceLabel.Diamond, Folder.Atlas);
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ else if (type == RechargeGift.GiftType.花朵)
|
|
|
+ {
|
|
|
+ FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[id];
|
|
|
+ images[0].transform.SetActive(true);
|
|
|
+ images[0].sprite = flowerInfo.Icon;
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
|
|
|
+ return flowerInfo;
|
|
|
+ }
|
|
|
+ else if (type == RechargeGift.GiftType.精灵)
|
|
|
+ {
|
|
|
+ string abilityFullId = SkillRoot.AbilityFullIDPrefix + id;
|
|
|
+ SkillRoot skillRoot = Manager.SkillDictionary[abilityFullId];
|
|
|
+ images[0].transform.SetActive(true);
|
|
|
+ images[0].sprite = skillRoot.Icon;
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
|
|
|
+ return skillRoot;
|
|
|
+ }
|
|
|
+ else if (type == RechargeGift.GiftType.服装)
|
|
|
+ {
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[1].SetNativeSize();
|
|
|
+ images[2].SetNativeSize();
|
|
|
+ CloseItem closeItem = PlayerManager.CloseItemDictionary[id];
|
|
|
+ float newSize = closeItem.PixelSize / closeItem.Sprites[0].rect.width * deltaSizeX;
|
|
|
+ closeItem.SetupUI(newSize, new Vector2(), images[0], images[1], images[2]);
|
|
|
+ return closeItem;
|
|
|
+ }
|
|
|
+ else if (type == RechargeGift.GiftType.礼包)
|
|
|
+ {
|
|
|
+ string packFullId = SkillRoot.PackFullIDPrefix + id;
|
|
|
+ SkillRoot skillRoot = Manager.SkillDictionary[packFullId];
|
|
|
+ images[0].transform.SetActive(true);
|
|
|
+ images[0].sprite = skillRoot.Icon;
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
|
|
|
+ return skillRoot;
|
|
|
+ }
|
|
|
+ else if (type == RechargeGift.GiftType.开垦土地)
|
|
|
+ {
|
|
|
+ images[0].transform.SetActive(true);
|
|
|
+ images[0].sprite = ResourceManager.LoadSprite(ResourceLabel.Slot, Folder.Scene);
|
|
|
+ images[0].SetNativeSize();
|
|
|
+ images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
}
|
|
|
}
|
|
|
}
|