|
@@ -90,7 +90,7 @@ public class Sign
|
|
|
{
|
|
|
if (IsLottery)
|
|
|
{
|
|
|
- Lottery.PlayAnimation();
|
|
|
+ Lottery.EnterAnimation();
|
|
|
|
|
|
return;
|
|
|
}
|
|
@@ -229,16 +229,21 @@ public class Lottery
|
|
|
{
|
|
|
#region Var
|
|
|
|
|
|
+ public int PosIndex;
|
|
|
public int Type;
|
|
|
public int Value;
|
|
|
public Text Lab;
|
|
|
- public Transform BK;
|
|
|
public Image Icon1;
|
|
|
public Image Icon2;
|
|
|
public Button Button;
|
|
|
+ public Transform BK;
|
|
|
+ public Transform Item;
|
|
|
+
|
|
|
+ public static List<int> TempTypeList = new List<int>();
|
|
|
+ public static List<int> TempValueList = new List<int>();
|
|
|
+ public static List<Lottery> TempLotteryList = new List<Lottery>();
|
|
|
|
|
|
public static List<int> TypeList = new List<int>();
|
|
|
- public static List<int> ValueList = new List<int>();
|
|
|
public static List<float> RateList = new List<float>();
|
|
|
public static List<Vector3> PosList = new List<Vector3>();
|
|
|
public static List<List<int>> LeftBorderDList = new List<List<int>>();
|
|
@@ -274,160 +279,143 @@ public class Lottery
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void CreateLottery(Transform lotteryItem)
|
|
|
+ public static Lottery CreateLottery(int type, int posIndex, Transform lotteryItem)
|
|
|
{
|
|
|
Lottery lottery = new Lottery();
|
|
|
|
|
|
- #region 默认值
|
|
|
-
|
|
|
- lottery.Type = TypeList[0];
|
|
|
+ lottery.Type = type;
|
|
|
|
|
|
lottery.Value = Random.Range(LeftBorderDList[0][0], RightBorderDList[0][0] + 1);
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- float random = Random.Range(0f, 1f);
|
|
|
|
|
|
- for (int i = 0; i < RateList.Count; i++)
|
|
|
+ if (lottery.Type == 3)
|
|
|
{
|
|
|
- if (random <= RateList.MySum(f => f, i + 1))
|
|
|
- {
|
|
|
- lottery.Type = TypeList[i];
|
|
|
+ #region
|
|
|
|
|
|
- if (lottery.Type == 3)
|
|
|
- {
|
|
|
- #region
|
|
|
+ bool allUnlock = true;
|
|
|
|
|
|
- bool allUnlock = true;
|
|
|
-
|
|
|
- for (int j = 0; j < LeftBorderDList[i].Count; j++)
|
|
|
- {
|
|
|
- for (int k = LeftBorderDList[i][j]; k < RightBorderDList[i][j] + 1; k++)
|
|
|
- {
|
|
|
- if (!ManaGarden.FlowerInfoDic[k].Unlock && !ValueList.Contains(k))
|
|
|
- {
|
|
|
- allUnlock = false;
|
|
|
-
|
|
|
- goto exit;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- exit :
|
|
|
-
|
|
|
- if (allUnlock)
|
|
|
+ for (int j = 0; j < LeftBorderDList[type - 1].Count; j++)
|
|
|
+ {
|
|
|
+ for (int k = LeftBorderDList[type - 1][j]; k < RightBorderDList[type - 1][j] + 1; k++)
|
|
|
+ {
|
|
|
+ if (!ManaGarden.FlowerInfoDic[k].Unlock && !TempValueList.Contains(k))
|
|
|
{
|
|
|
- int index = Random.Range(0, LeftBorderDList[i].Count);
|
|
|
-
|
|
|
- lottery.Value = Random.Range(LeftBorderDList[i][index], RightBorderDList[i][index] + 1);
|
|
|
+ allUnlock = false;
|
|
|
|
|
|
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[lottery.Value];
|
|
|
-
|
|
|
- lottery.Value = flowerInfo.UnlockAmt/5;
|
|
|
-
|
|
|
- if (flowerInfo.UnlockCur == Current.Coin)
|
|
|
- {
|
|
|
- lottery.Type = 1;
|
|
|
- }
|
|
|
- else if (flowerInfo.UnlockCur == Current.Diamond)
|
|
|
- {
|
|
|
- lottery.Type = 2;
|
|
|
- }
|
|
|
+ goto exit;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- int anticrush = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exit :
|
|
|
|
|
|
- do
|
|
|
- {
|
|
|
- if (anticrush++>10000)
|
|
|
- {
|
|
|
- throw new Exception();
|
|
|
- }
|
|
|
+ if (allUnlock)
|
|
|
+ {
|
|
|
+ int index = Random.Range(0, LeftBorderDList[type - 1].Count);
|
|
|
|
|
|
- int index = Random.Range(0, LeftBorderDList[i].Count);
|
|
|
+ lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
|
|
|
|
|
|
- lottery.Value = Random.Range(LeftBorderDList[i][index], RightBorderDList[i][index] + 1);
|
|
|
- }
|
|
|
- while (ManaGarden.FlowerInfoDic[lottery.Value].Unlock || ValueList.Contains(lottery.Value));
|
|
|
+ FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[lottery.Value];
|
|
|
|
|
|
- ValueList.Add(lottery.Value);
|
|
|
- }
|
|
|
+ lottery.Value = flowerInfo.UnlockAmt/5;
|
|
|
|
|
|
- #endregion
|
|
|
+ if (flowerInfo.UnlockCur == Current.Coin)
|
|
|
+ {
|
|
|
+ lottery.Type = 1;
|
|
|
}
|
|
|
- else if (lottery.Type == 4)
|
|
|
+ else if (flowerInfo.UnlockCur == Current.Diamond)
|
|
|
{
|
|
|
- #region
|
|
|
-
|
|
|
- bool allBought = true;
|
|
|
+ lottery.Type = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int anticrush = 0;
|
|
|
|
|
|
- for (int j = 0; j < LeftBorderDList[i].Count; j++)
|
|
|
+ do
|
|
|
+ {
|
|
|
+ if (anticrush++ > 10000)
|
|
|
{
|
|
|
- for (int k = LeftBorderDList[i][j]; k < RightBorderDList[i][j] + 1; k++)
|
|
|
- {
|
|
|
- if (!ManaPlayer.CloseUnitDic[k].Bought && !ValueList.Contains(k))
|
|
|
- {
|
|
|
- allBought = false;
|
|
|
-
|
|
|
- goto exit;
|
|
|
- }
|
|
|
- }
|
|
|
+ throw new Exception();
|
|
|
}
|
|
|
- exit :
|
|
|
|
|
|
- if (allBought)
|
|
|
- {
|
|
|
- int index = Random.Range(0, LeftBorderDList[i].Count);
|
|
|
+ int index = Random.Range(0, LeftBorderDList[type - 1].Count);
|
|
|
|
|
|
- lottery.Value = Random.Range(LeftBorderDList[i][index], RightBorderDList[i][index] + 1);
|
|
|
+ lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
|
|
|
+ } while (ManaGarden.FlowerInfoDic[lottery.Value].Unlock || TempValueList.Contains(lottery.Value));
|
|
|
|
|
|
- CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
|
|
|
+ TempValueList.Add(lottery.Value);
|
|
|
+ }
|
|
|
|
|
|
- lottery.Value = (int) closeUnit.BuyAmt/5;
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+ else if (lottery.Type == 4)
|
|
|
+ {
|
|
|
+ #region
|
|
|
|
|
|
- if (closeUnit.BuyCurrent == Current.Coin)
|
|
|
- {
|
|
|
- lottery.Type = 1;
|
|
|
- }
|
|
|
- else if (closeUnit.BuyCurrent == Current.Diamond)
|
|
|
- {
|
|
|
- lottery.Type = 2;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ bool allBought = true;
|
|
|
+
|
|
|
+ for (int j = 0; j < LeftBorderDList[type - 1].Count; j++)
|
|
|
+ {
|
|
|
+ for (int k = LeftBorderDList[type - 1][j]; k < RightBorderDList[type - 1][j] + 1; k++)
|
|
|
+ {
|
|
|
+ if (!ManaPlayer.CloseUnitDic[k].Bought && !TempValueList.Contains(k))
|
|
|
{
|
|
|
- int anticrush = 0;
|
|
|
+ allBought = false;
|
|
|
|
|
|
- do
|
|
|
- {
|
|
|
- if (anticrush++ > 10000)
|
|
|
- {
|
|
|
- throw new Exception();
|
|
|
- }
|
|
|
+ goto exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exit :
|
|
|
|
|
|
- int index = Random.Range(0, LeftBorderDList[i].Count);
|
|
|
+ if (allBought)
|
|
|
+ {
|
|
|
+ int index = Random.Range(0, LeftBorderDList[type - 1].Count);
|
|
|
|
|
|
- lottery.Value = Random.Range(LeftBorderDList[i][index], RightBorderDList[i][index] + 1);
|
|
|
- }
|
|
|
- while (ManaPlayer.CloseUnitDic[lottery.Value].Bought || ValueList.Contains(lottery.Value));
|
|
|
+ lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
|
|
|
|
|
|
- ValueList.Add(lottery.Value);
|
|
|
- }
|
|
|
+ CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
|
|
|
+
|
|
|
+ lottery.Value = (int) closeUnit.BuyAmt/5;
|
|
|
|
|
|
- #endregion
|
|
|
+ if (closeUnit.BuyCurrent == Current.Coin)
|
|
|
+ {
|
|
|
+ lottery.Type = 1;
|
|
|
}
|
|
|
- else
|
|
|
+ else if (closeUnit.BuyCurrent == Current.Diamond)
|
|
|
{
|
|
|
- int index = Random.Range(0, LeftBorderDList[i].Count);
|
|
|
-
|
|
|
- lottery.Value = Random.Range(LeftBorderDList[i][index], RightBorderDList[i][index] + 1);
|
|
|
+ lottery.Type = 2;
|
|
|
}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int anticrush = 0;
|
|
|
|
|
|
- break;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ if (anticrush++ > 10000)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = Random.Range(0, LeftBorderDList[type - 1].Count);
|
|
|
+
|
|
|
+ lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
|
|
|
+ } while (ManaPlayer.CloseUnitDic[lottery.Value].Bought || TempValueList.Contains(lottery.Value));
|
|
|
+
|
|
|
+ TempValueList.Add(lottery.Value);
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int index = Random.Range(0, LeftBorderDList[type - 1].Count);
|
|
|
|
|
|
+ lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
|
|
|
+ }
|
|
|
|
|
|
+ lottery.PosIndex = posIndex;
|
|
|
+ lottery.Item = lotteryItem;
|
|
|
lottery.BK = lotteryItem.GetChild(0);
|
|
|
lottery.Icon1 = lotteryItem.GetChild(1).GetChild(0).GetComponent<Image>();
|
|
|
lottery.Icon2 = lotteryItem.GetChild(1).GetChild(1).GetComponent<Image>();
|
|
@@ -480,7 +468,7 @@ public class Lottery
|
|
|
{
|
|
|
CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
|
|
|
|
|
|
- float newSize = closeUnit.PixelSize / closeUnit.Sprites[0].rect.width;
|
|
|
+ float newSize = closeUnit.PixelSize/closeUnit.Sprites[0].rect.width;
|
|
|
|
|
|
lottery.Icon2.sprite = closeUnit.Sprites[0];
|
|
|
|
|
@@ -490,7 +478,7 @@ public class Lottery
|
|
|
|
|
|
lottery.Lab.SetActive(false);
|
|
|
|
|
|
- if (closeUnit.Sprites.Length>1)
|
|
|
+ if (closeUnit.Sprites.Length > 1)
|
|
|
{
|
|
|
lottery.Icon1.SetActive(true);
|
|
|
|
|
@@ -508,47 +496,39 @@ public class Lottery
|
|
|
|
|
|
lottery.Button.onClick = new Button.ButtonClickedEvent();
|
|
|
|
|
|
- lottery.Button.onClick.AddListener
|
|
|
- (
|
|
|
- () =>
|
|
|
- {
|
|
|
- ManaAudio.PlayClip(Clip.CurrentClip);
|
|
|
-
|
|
|
- ManaReso.Get<Button>("Bc_LotteryBack1").interactable = false;
|
|
|
- ManaReso.Get<Button>("Bc_LotteryBack2").interactable = false;
|
|
|
- ManaReso.Get<Button>("Bc_LotteryBack3").interactable = false;
|
|
|
-
|
|
|
- lotteryItem.TweenBacEuler();
|
|
|
-
|
|
|
- lottery.BK.SetActive(true);
|
|
|
-
|
|
|
- lottery.GetAward();
|
|
|
+ lottery.Button.onClick.AddListener(() => { OnClick(posIndex); });
|
|
|
|
|
|
- Auxiliary.Instance.DelayCall
|
|
|
- (
|
|
|
- () =>
|
|
|
- {
|
|
|
- ManaReso.Get("Bc_Confirm").TweenForCG();
|
|
|
-
|
|
|
- ManaReso.Get("Bc_LotteryItem1").TweenBacEuler();
|
|
|
- ManaReso.Get("Bc_LotteryItem2").TweenBacEuler();
|
|
|
- ManaReso.Get("Bc_LotteryItem3").TweenBacEuler();
|
|
|
- },
|
|
|
- 1f
|
|
|
- );
|
|
|
- }
|
|
|
- );
|
|
|
+ return lottery;
|
|
|
}
|
|
|
|
|
|
- public static void PlayAnimation()
|
|
|
+ public static void EnterAnimation()
|
|
|
{
|
|
|
ManaReso.Get("Bc_Lottery").TweenForCG();
|
|
|
ManaReso.Get("Ba_Notice0").TweenBacCG();
|
|
|
|
|
|
- CreateLottery(ManaReso.Get("Bc_LotteryItem1"));
|
|
|
- CreateLottery(ManaReso.Get("Bc_LotteryItem2"));
|
|
|
- CreateLottery(ManaReso.Get("Bc_LotteryItem3"));
|
|
|
-
|
|
|
+ float random = Random.Range(0f, 1f);
|
|
|
+
|
|
|
+ for (int i = 0; i < RateList.Count; i++)
|
|
|
+ {
|
|
|
+ if (random <= RateList.MySum(f => f, i + 1))
|
|
|
+ {
|
|
|
+ TempTypeList.Add(TypeList[i]);
|
|
|
+ TempTypeList.AddRange(TypeList.Random(2, true, false, type => !TempTypeList.Contains(type)));
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ TempLotteryList.Add(CreateLottery(TempTypeList[0], 0, ManaReso.Get("Bc_LotteryItem1")));
|
|
|
+ TempLotteryList.Add(CreateLottery(TempTypeList[1], 1, ManaReso.Get("Bc_LotteryItem2")));
|
|
|
+ TempLotteryList.Add(CreateLottery(TempTypeList[2], 2, ManaReso.Get("Bc_LotteryItem3")));
|
|
|
+
|
|
|
+ List<Vector3> posList = PosList.Disturb();
|
|
|
+
|
|
|
+ TempLotteryList[0].Item.position = posList[0];
|
|
|
+ TempLotteryList[1].Item.position = posList[1];
|
|
|
+ TempLotteryList[2].Item.position = posList[2];
|
|
|
+
|
|
|
Button button1 = ManaReso.Get<Button>("Bc_LotteryBack1");
|
|
|
Button button2 = ManaReso.Get<Button>("Bc_LotteryBack2");
|
|
|
Button button3 = ManaReso.Get<Button>("Bc_LotteryBack3");
|
|
@@ -587,11 +567,9 @@ public class Lottery
|
|
|
button2.interactable = true;
|
|
|
button3.interactable = true;
|
|
|
|
|
|
- List<Vector3> posList = PosList.Disturb();
|
|
|
-
|
|
|
- ManaReso.Get("Bc_LotteryItem1").Move2D(posList[0], 0.25f, false, Curve.EaseOutQuad);
|
|
|
- ManaReso.Get("Bc_LotteryItem2").Move2D(posList[1], 0.25f, false, Curve.EaseOutQuad);
|
|
|
- ManaReso.Get("Bc_LotteryItem3").Move2D(posList[2], 0.25f, false, Curve.EaseOutQuad);
|
|
|
+ ManaReso.Get("Bc_LotteryItem1").Move2D(PosList[0], 0.25f, false, Curve.EaseOutQuad);
|
|
|
+ ManaReso.Get("Bc_LotteryItem2").Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
|
|
|
+ ManaReso.Get("Bc_LotteryItem3").Move2D(PosList[2], 0.25f, false, Curve.EaseOutQuad);
|
|
|
},
|
|
|
2f
|
|
|
);
|
|
@@ -608,9 +586,11 @@ public class Lottery
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public static void EndLottery()
|
|
|
+ public static void EndAnimation()
|
|
|
{
|
|
|
- ValueList = new List<int>();
|
|
|
+ TempTypeList = new List<int>();
|
|
|
+ TempValueList = new List<int>();
|
|
|
+ TempLotteryList = new List<Lottery>();
|
|
|
|
|
|
ManaReso.Get("Bc_Lab").TweenBacCG();
|
|
|
ManaReso.Get("Bc_Confirm").TweenBacCG();
|
|
@@ -626,6 +606,42 @@ public class Lottery
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static void OnClick(int index)
|
|
|
+ {
|
|
|
+ ManaAudio.PlayClip(Clip.CurrentClip);
|
|
|
+
|
|
|
+ ManaReso.Get<Button>("Bc_LotteryBack1").interactable = false;
|
|
|
+ ManaReso.Get<Button>("Bc_LotteryBack2").interactable = false;
|
|
|
+ ManaReso.Get<Button>("Bc_LotteryBack3").interactable = false;
|
|
|
+
|
|
|
+ TempLotteryList[0].Item.TweenBacEuler();
|
|
|
+
|
|
|
+ TempLotteryList[0].BK.SetActive(true);
|
|
|
+
|
|
|
+ TempLotteryList[0].GetAward();
|
|
|
+
|
|
|
+ List<Vector3> posList = new List<Vector3>(PosList);
|
|
|
+ posList.Remove(PosList[index]);
|
|
|
+ posList = posList.Disturb();
|
|
|
+
|
|
|
+ TempLotteryList[0].Item.position = PosList[index];
|
|
|
+ TempLotteryList[1].Item.position = posList[0];
|
|
|
+ TempLotteryList[2].Item.position = posList[1];
|
|
|
+
|
|
|
+ Auxiliary.Instance.DelayCall
|
|
|
+ (
|
|
|
+ () =>
|
|
|
+ {
|
|
|
+ ManaReso.Get("Bc_Confirm").TweenForCG();
|
|
|
+
|
|
|
+ ManaReso.Get("Bc_LotteryItem1").TweenBacEuler();
|
|
|
+ ManaReso.Get("Bc_LotteryItem2").TweenBacEuler();
|
|
|
+ ManaReso.Get("Bc_LotteryItem3").TweenBacEuler();
|
|
|
+ },
|
|
|
+ 1f
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
public void GetAward()
|
|
|
{
|
|
|
Sign.ResetSign();
|