|
@@ -5,7 +5,7 @@ using System;
|
|
|
using System.Xml;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
-
|
|
|
+using System.Linq;
|
|
|
using Random = UnityEngine.Random;
|
|
|
|
|
|
public class Sign
|
|
@@ -237,16 +237,15 @@ public class Lottery
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
public static void Configure(List<XmlAttributeCollection> attributeList)
|
|
|
{
|
|
|
for (int i = 0; i < attributeList.Count; i++)
|
|
|
{
|
|
|
- RateList.Add((float) Auxiliary.FmlParse(attributeList[i][0].Value));
|
|
|
+ RateList.Add((float) Auxiliary.FmlParse(attributeList[i][2].Value));
|
|
|
TypeList.Add((int) Auxiliary.FmlParse(attributeList[i][1].Value));
|
|
|
|
|
|
- List<string> leftBorderStrList = Auxiliary.StringListParse(',', attributeList[i][2].Value, null);
|
|
|
- List<string> rightBorderStrList = Auxiliary.StringListParse(',', attributeList[i][3].Value, null);
|
|
|
+ List<string> leftBorderStrList = Auxiliary.StringListParse(',', attributeList[i][3].Value, null);
|
|
|
+ List<string> rightBorderStrList = Auxiliary.StringListParse(',', attributeList[i][4].Value, null);
|
|
|
|
|
|
List<int> leftBorderList = new List<int>();
|
|
|
List<int> rightBorderList = new List<int>();
|
|
@@ -266,18 +265,16 @@ public class Lottery
|
|
|
{
|
|
|
Lottery lottery = new Lottery();
|
|
|
|
|
|
- float random = Random.Range(0f, 1f);
|
|
|
-
|
|
|
#region 默认值
|
|
|
|
|
|
lottery.Type = TypeList[0];
|
|
|
|
|
|
- int tempIndex = Random.Range(0, LeftBorderDList[0].Count);
|
|
|
-
|
|
|
- lottery.Value = Random.Range(LeftBorderDList[0][tempIndex], RightBorderDList[0][tempIndex] + 1);
|
|
|
-
|
|
|
+ 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 (random <= RateList.MySum(f => f, i + 1))
|
|
@@ -287,6 +284,83 @@ public class Lottery
|
|
|
int index = Random.Range(0, LeftBorderDList[i].Count);
|
|
|
|
|
|
lottery.Value = Random.Range(LeftBorderDList[i][index], RightBorderDList[i][index] + 1);
|
|
|
+
|
|
|
+ if (lottery.Type == 3)
|
|
|
+ {
|
|
|
+ #region
|
|
|
+
|
|
|
+ FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[lottery.Value];
|
|
|
+
|
|
|
+ if (!flowerInfo.Unlock)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ lottery.Value = k;
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (flowerInfo.UnlockCur == Current.Coin)
|
|
|
+ {
|
|
|
+ lottery.Type = 1;
|
|
|
+ lottery.Value = flowerInfo.UnlockAmt/5;
|
|
|
+ }
|
|
|
+ else if (flowerInfo.UnlockCur == Current.Diamond)
|
|
|
+ {
|
|
|
+ lottery.Type = 2;
|
|
|
+ lottery.Value = flowerInfo.UnlockAmt / 5;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+ else if (lottery.Type == 4)
|
|
|
+ {
|
|
|
+ #region
|
|
|
+
|
|
|
+ CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
|
|
|
+
|
|
|
+ if (!closeUnit.Bought)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int j = 0; j < LeftBorderDList[i].Count; j++)
|
|
|
+ {
|
|
|
+ for (int k = LeftBorderDList[i][j]; k < RightBorderDList[i][j] + 1; k++)
|
|
|
+ {
|
|
|
+ if (!ManaPlayer.CloseUnitDic[k].Bought)
|
|
|
+ {
|
|
|
+ lottery.Value = k;
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (closeUnit.BuyCurrent == Current.Coin)
|
|
|
+ {
|
|
|
+ lottery.Type = 1;
|
|
|
+ lottery.Value = (int) closeUnit.BuyAmt/5;
|
|
|
+ }
|
|
|
+ else if (closeUnit.BuyCurrent == Current.Diamond)
|
|
|
+ {
|
|
|
+ lottery.Type = 2;
|
|
|
+ lottery.Value = (int) closeUnit.BuyAmt/5;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -302,26 +376,40 @@ public class Lottery
|
|
|
if (lottery.Type == 1)
|
|
|
{
|
|
|
lottery.Icon1.SetActive(false);
|
|
|
+
|
|
|
lottery.Icon2.sprite = ManaReso.LoadSprite("金币", Folder.UI);
|
|
|
+
|
|
|
lottery.Icon2.Resize(true, 1, 1);
|
|
|
|
|
|
+ lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
|
|
|
+
|
|
|
lottery.Lab.SetActive(true);
|
|
|
+
|
|
|
lottery.Lab.text = lottery.Value.ToString();
|
|
|
}
|
|
|
else if (lottery.Type == 2)
|
|
|
{
|
|
|
lottery.Icon1.SetActive(false);
|
|
|
+
|
|
|
lottery.Icon2.sprite = ManaReso.LoadSprite("钻石", Folder.UI);
|
|
|
+
|
|
|
lottery.Icon2.Resize(true, 1, 1);
|
|
|
|
|
|
+ lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
|
|
|
+
|
|
|
lottery.Lab.SetActive(true);
|
|
|
+
|
|
|
lottery.Lab.text = lottery.Value.ToString();
|
|
|
}
|
|
|
else if (lottery.Type == 3)
|
|
|
{
|
|
|
lottery.Icon1.SetActive(false);
|
|
|
+
|
|
|
lottery.Icon2.sprite = ManaGarden.FlowerInfoDic[lottery.Value].Icon;
|
|
|
- lottery.Icon2.Resize(true, 0.2f, 0.2f);
|
|
|
+
|
|
|
+ lottery.Icon2.Resize(true, 0.25f, 0.25f);
|
|
|
+
|
|
|
+ lottery.Icon2.transform.localPosition = new Vector3();
|
|
|
|
|
|
lottery.Lab.SetActive(false);
|
|
|
}
|
|
@@ -329,25 +417,30 @@ public class Lottery
|
|
|
{
|
|
|
CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
|
|
|
|
|
|
+ float newSize = closeUnit.PixelSize / closeUnit.Sprites[0].rect.width;
|
|
|
+
|
|
|
+ lottery.Icon2.sprite = closeUnit.Sprites[0];
|
|
|
+
|
|
|
+ lottery.Icon2.Resize(true, newSize, newSize);
|
|
|
+
|
|
|
+ lottery.Icon2.transform.localPosition = new Vector2(0, closeUnit.IconOffset);
|
|
|
+
|
|
|
+ lottery.Lab.SetActive(false);
|
|
|
+
|
|
|
if (closeUnit.Sprites.Length>1)
|
|
|
{
|
|
|
lottery.Icon1.SetActive(true);
|
|
|
+
|
|
|
lottery.Icon1.sprite = closeUnit.Sprites[1];
|
|
|
- lottery.Icon1.Resize(true, closeUnit.PixelSize, closeUnit.PixelSize);
|
|
|
|
|
|
- lottery.Icon1.transform.localPosition = new Vector2(0, closeUnit.IconOffset) + closeUnit.IconOffset1;
|
|
|
+ lottery.Icon1.Resize(true, newSize, newSize);
|
|
|
+
|
|
|
+ lottery.Icon1.transform.localPosition = new Vector2(0, closeUnit.IconOffset) + closeUnit.IconOffset1*newSize;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
lottery.Icon1.SetActive(false);
|
|
|
}
|
|
|
-
|
|
|
- lottery.Icon2.sprite = ManaGarden.FlowerInfoDic[lottery.Value].Icon;
|
|
|
- lottery.Icon2.Resize(true, 0.2f, 0.2f);
|
|
|
-
|
|
|
- lottery.Icon2.transform.localPosition = new Vector2(0, closeUnit.IconOffset);
|
|
|
-
|
|
|
- lottery.Lab.SetActive(false);
|
|
|
}
|
|
|
}
|
|
|
|