|
@@ -5,7 +5,9 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using System.Xml;
|
|
|
+using UnityEngine.Events;
|
|
|
using UnityEngine.UI;
|
|
|
+using Object = UnityEngine.Object;
|
|
|
|
|
|
public enum AchieveType
|
|
|
{
|
|
@@ -34,6 +36,15 @@ public class Achieve
|
|
|
|
|
|
if (_Regist)
|
|
|
{
|
|
|
+ AchieveItem = ManaReso.Get("AchieveItem", Folder.UI, false, ManaReso.Get("M_Grid"), false, ObjType.AchieveItem);
|
|
|
+
|
|
|
+ ObjRoot objRoot = AchieveItem.GetComponent<ObjRoot>();
|
|
|
+
|
|
|
+ if (objRoot == null)
|
|
|
+ {
|
|
|
+ AchieveItem.AddComponent<ObjRoot>().ObjType = ObjType.AchieveItem;
|
|
|
+ }
|
|
|
+
|
|
|
RegistValue();
|
|
|
}
|
|
|
}
|
|
@@ -117,10 +128,37 @@ public class Achieve
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void RegistValue()
|
|
|
+ public void GetAward()
|
|
|
{
|
|
|
- AchieveItem = ManaReso.Get("AchieveItem", Folder.UI, false, ManaReso.Get("M_Grid"), false);
|
|
|
+ Valid = false;
|
|
|
+
|
|
|
+ ManaAchieve.DeleDic[Type] = null;
|
|
|
+
|
|
|
+ ManaData.Diamond += DiamondOnce;
|
|
|
+ ManaData.SkillPerson += Person;
|
|
|
+ ManaData.SkillCoinPerson += CoinPerson;
|
|
|
+
|
|
|
+ ManaDebug.Log(string.Format("获得钻石<color=red>{0}</color> 参观人次+<color=red>{1}</color> 每人次金币+<color=red>{2}</color>", DiamondOnce, Person, CoinPerson));
|
|
|
+
|
|
|
+ if (Delete)
|
|
|
+ {
|
|
|
+ ManaReso.Save(AchieveItem);
|
|
|
+
|
|
|
+ if (PostAchieveList.Count > 0)
|
|
|
+ {
|
|
|
+ PostAchieveList[0].Regist = true;
|
|
|
|
|
|
+ PostAchieveList.RemoveAt(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UpdateStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void RegistValue()
|
|
|
+ {
|
|
|
Dictionary<string, Transform> dic = new Dictionary<string, Transform>();
|
|
|
|
|
|
Auxiliary.CompileDic(AchieveItem, dic);
|
|
@@ -135,10 +173,27 @@ public class Achieve
|
|
|
ManaText.Add(Tit, new LanStr("AchieveName", "Achieve" + ID));
|
|
|
ManaText.Add(Lab, new LanStr("AchieveDescription", "Achieve" + ID));
|
|
|
|
|
|
- Slider.value = (float)(CurrentValue/TargetValue);
|
|
|
Image.sprite = ManaReso.Load<Sprite>(Icon, Folder.UI);
|
|
|
+ Button.onClick.AddListener(GetAward);
|
|
|
|
|
|
+ UpdateValue(CurrentValue);
|
|
|
UpdateStatus();
|
|
|
+
|
|
|
+ ManaAchieve.DeleDic[Type] += UpdateValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void UpdateValue(double value)
|
|
|
+ {
|
|
|
+ CurrentValue = value;
|
|
|
+
|
|
|
+ Slider.value = (float)(CurrentValue/TargetValue);
|
|
|
+
|
|
|
+ if (CurrentValue >= TargetValue)
|
|
|
+ {
|
|
|
+ Finish = true;
|
|
|
+
|
|
|
+ UpdateStatus();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void UpdateStatus()
|
|
@@ -320,8 +375,28 @@ public class ManaAchieve : Regist
|
|
|
}
|
|
|
set { _AchieveDic = value; }
|
|
|
}
|
|
|
+ public static Dictionary<AchieveType, UnityAction<double>> DeleDic
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (_DeleDic == null)
|
|
|
+ {
|
|
|
+ _DeleDic = new Dictionary<AchieveType, UnityAction<double>>();
|
|
|
+
|
|
|
+ _DeleDic.Add(AchieveType.CurrentCoin, CurrentCoin);
|
|
|
+ _DeleDic.Add(AchieveType.GardenLevel, GardenLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ return _DeleDic;
|
|
|
+ }
|
|
|
+ set { _DeleDic = value; }
|
|
|
+ }
|
|
|
|
|
|
public static Dictionary<int, Achieve> _AchieveDic;
|
|
|
+ public static Dictionary<AchieveType, UnityAction<double>> _DeleDic;
|
|
|
+
|
|
|
+ public static UnityAction<double> CurrentCoin;
|
|
|
+ public static UnityAction<double> GardenLevel;
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -365,14 +440,4 @@ public class ManaAchieve : Regist
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public override void RegistValueA()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public override void RegistReference()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
}
|