1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579 |
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Serialization;
- using System;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using Random = UnityEngine.Random;
- public class Award
- {
- #region 变量
- public static int BonusCoin;
- public static int BonusDiamond;
- public static string Info;
-
- public int Rate;
- public int Coin;
- public int Score;
- public int Diamond;
- public bool FlowerFlag;
- public bool DiamondFlag;
- #region 配置
- public static int FlowerID;
- public static bool FlowerLock;
- public int DiamondMin;
- public int DiamondMax;
- public string CoinFml;
- public string FlowerFml;
- public string DiamondFml;
- public List<float> Odds = new List<float>();
- public List<float> Standard = new List<float>();
- #endregion
- #endregion
- public void GetAward(int score)
- {
- #region 获得奖励
- #region Rate
- Score = (int)Mathf.Clamp(score, 1, Mathf.Infinity);
- if (Score < Standard[1])
- {
- Rate = 0;
- }
- else if (Score < Standard[2])
- {
- Rate = 1;
- }
- else
- {
- Rate = 2;
- }
- #endregion
- #region Reset
- FlowerFlag = false;
- DiamondFlag = false;
- #endregion
- StringBuilder sb = new StringBuilder();
- #region Coin
- Coin = (int)Auxiliary.FmlParse(CoinFml, "s", Score.ToString(), "l", Mathf.Clamp(ManaCenter.Level, 1, 9999).ToString());
- Coin = (int)(Coin * (1 + ManaCenter.SkillPlus) + BonusCoin);
- Coin = (int) Mathf.Clamp(Coin, 1, Mathf.Infinity);
- ManaReso.Get<Text>("Da_CoinLab").text = Coin.ToString();
- ManaReso.Get<Text>("Da_CoinLab").Resize(true, false);
- ManaReso.Get<ContentSizeFitter>("Da_CoinGroup").enabled = true;
- ManaReso.SetActive("Da_CoinLab", true);
- ManaCenter.Coin += Coin;
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr("UI", "J_Info0"), "<(金币)>", Coin);
- #endregion
- #region Diamond
- float diamondRate = (float)Auxiliary.FmlParse(DiamondFml, "l", Mathf.Clamp(ManaCenter.Level, 1, 1000).ToString());
-
- if (Random.Range(0, 1f) <= diamondRate)
- {
- DiamondFlag = true;
- Diamond = (int)(Mathf.Lerp(DiamondMin, DiamondMax, Random.Range(0, 1f)) + BonusDiamond);
- ManaReso.Get<Text>("Da_DiamondLab").text = Diamond.ToString();
- ManaReso.Get<Text>("Da_DiamondLab").Resize(true, false);
- ManaReso.Get<ContentSizeFitter>("Da_DiamondGroup").enabled = true;
- ManaReso.SetActive("Da_DiamondLab", true);
- ManaCenter.Diamond += Diamond;
- ManaReso.SetActive("Da_Diamond", true);
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr("UI", "J_Info0"), "<(钻石)>", Diamond);
- }
- else
- {
- if (BonusDiamond > 0)
- {
- DiamondFlag = true;
- Diamond = BonusDiamond;
- ManaReso.Get<Text>("Da_DiamondLab").text = Diamond.ToString();
- ManaReso.Get<Text>("Da_DiamondLab").Resize(true, false);
- ManaReso.Get<ContentSizeFitter>("Da_DiamondGroup").enabled = true;
- ManaReso.SetActive("Da_DiamondLab", true);
- ManaCenter.Diamond += Diamond;
- ManaReso.SetActive("Da_Diamond", true);
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr("UI", "J_Info0"), "<(钻石)>", Diamond);
- }
- }
- #endregion
- #region Flower
- if (ManaTutorial.TutorialA)
- {
- FlowerFlag = true;
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[1];
- ManaReso.SetActive("Da_FlowerIcon", true);
- ManaReso.Get<Image>("Da_FlowerIcon").sprite = flowerInfo.Icon;
- ManaReso.Get<Image>("Da_FlowerIcon").Resize(true, 0.2f, 0.2f);
- ManaReso.SetText("Da_FlowerLab", flowerInfo.Name);
- sb.AppendFormat("{0}{1}{2}", Language.GetStr("UI", "J_Info0"), "<(花朵)>", flowerInfo.Name);
- }
- else
- {
- if (!FlowerLock)
- {
- FlowerFlag = true;
- if (Random.Range(0, 1f) <= Odds[Rate])
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerID];
- flowerInfo.Unlock = true;
- ManaReso.SetActive("Da_Flower", true);
- ManaReso.Get<Image>("Da_FlowerIcon").sprite = flowerInfo.Icon;
- ManaReso.Get<Image>("Da_FlowerIcon").Resize(true, 0.2f, 0.2f);
- ManaReso.SetText("Da_FlowerLab", flowerInfo.Name);
- sb.AppendFormat("{0}{1}{2}", Language.GetStr("UI", "J_Info0"), "<(花朵)>", flowerInfo.Name);
- }
- else
- {
- ManaReso.SetActive("Da_Flower", false);
- ManaReso.SetText("Da_FlowerLab", Language.GetStr("UI", "Da_HigherScore"));
- }
- }
- }
- #endregion
- Info = sb.ToString();
- BonusCoin = 0;
- BonusDiamond = 0;
- #endregion
- ManaReso.SetActive("Da_Info", true);
- Auxiliary.Instance.DelayCall
- (
- () =>
- {
- ManaReso.Get<Text>("Da_CoinLab").SetLayoutDirty();
- ManaReso.Get<Text>("Da_DiamondLab").SetLayoutDirty();
- ManaReso.Get<ContentSizeFitter>("Da_CoinGroup").enabled = false;
- ManaReso.Get<ContentSizeFitter>("Da_DiamondGroup").enabled = false;
- InitializeAnim();
- },
- 2
- );
- }
- public void InitializeAnim()
- {
- #region 构造动画
- #region Reset
- ManaReso.Get("Da_Info").TweenForCG();
- ManaReso.SetText("Da_Tit", Language.GetStr("UI", "Da_Tit1"));
- ManaReso.SetText("Da_CoinLab", "0");
- ManaReso.SetText("Da_DiamondLab", "0");
- ManaReso.SetActive("Da_Lab", false);
- ManaReso.SetActive("Da_Quit", false);
- ManaReso.SetActive("Da_Cancel", false);
- ManaReso.SetActive("Da_CoinLab", false);
- ManaReso.SetActive("Da_ScoreTit", false);
- ManaReso.SetActive("Da_ScoreLab", false);
- ManaReso.SetActive("Da_GetAward", false);
- ManaReso.SetActive("Da_DiamondLab", false);
- ManaReso.SetActive("Da_VGroup", true);
- ManaReso.SetActive("Da_HGroup1", false);
- ManaReso.SetActive("Da_FlowerGroup", false);
- ManaReso.SetActive("Da_DiamondGroup", false);
- if (FlowerFlag)
- {
- ManaReso.SetActive("Da_FlowerGroup", true);
- }
- if (DiamondFlag)
- {
- ManaReso.SetActive("Da_DiamondGroup", true);
- }
- Auxiliary.Instance.DelayCall
- (
- () =>
- {
- ManaReso.Get<VerticalLayoutGroup>("Da_VGroup").enabled = false;
- ManaReso.SetActive("Da_CoinGroup", false);
- ManaReso.SetActive("Da_FlowerGroup", false);
- ManaReso.SetActive("Da_DiamondGroup", false);
- },
- 1
- );
- float timeCoin = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(Coin / 15f));
- float timeScore = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(Score / 50f));
- float timeDiamond = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(Diamond / 15f));
- float time = Mathf.Max(timeCoin, timeDiamond);
- ManaReso.Get("Da_CoinLab").CreateTweenNumber(0, Coin, time, false, true, Curve.EaseOutQuad);
- ManaReso.Get("Da_ScoreLab").CreateTweenNumber(0, Score, timeScore, false, true, Curve.EaseOutQuad);
- ManaReso.Get("Da_DiamondLab").CreateTweenNumber(0, Diamond, time, false, true, Curve.EaseOutQuad);
- #endregion
- #region 花
- TweenRoot tween;
- if (FlowerFlag)
- {
- tween = ManaReso.Get("Da_CoinLab").GetTweenNumber();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_FlowerGroup").TweenReForScale();
- }
- );
- }
- #endregion
- #region 按钮
- if (FlowerFlag)
- {
- tween = ManaReso.Get("Da_FlowerGroup").GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_GetAward").TweenReForCG();
- }
- );
- }
- else
- {
- tween = ManaReso.Get("Da_CoinLab").GetTweenNumber();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_GetAward").TweenReForCG();
- }
- );
- }
- if (ManaTutorial.TutorialA)
- {
- tween = ManaReso.Get("Da_GetAward").GetTweenCG();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- Tutorial.HightScreen(ManaReso.Get("Da_Arrow0"), ManaReso.Get("Da_Arrow1"), ManaReso.Get("Da_GetAward"));
- }
- );
- }
- ManaReso.AddButtonEventOnetime
- (
- "Da_GetAward",
- () =>
- {
- ManaReso.Get("Da_VGroup").GetComponent<VerticalLayoutGroup>().enabled = true;
- }
- );
- #endregion
- #region 得分
- if (Rate == 0)
- {
- tween = ManaReso.Get("Da_Star1").GetTweenScale();
- }
- else if (Rate == 1)
- {
- tween = ManaReso.Get("Da_Star2").GetTweenScale();
- }
- else if (Rate == 2)
- {
- tween = ManaReso.Get("Da_Star3").GetTweenScale();
- }
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_ScoreTit").TweenReForFont();
- }
- );
- tween = ManaReso.Get("Da_ScoreTit").GetTweenFont();
- tween.InOrigin = true;
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_ScoreLab").TweenReForNumber();
- }
- );
- #endregion
- #region 五角星
- tween = ManaReso.Get("Da_Star3").GetTweenScale();
- tween.InOrigin = true;
- tween = ManaReso.Get("Da_Star2").GetTweenScale();
- tween.InOrigin = true;
- tween = ManaReso.Get("Da_Star1").GetTweenScale();
- tween.InOrigin = true;
- tween = ManaReso.Get("Da_Info").GetTweenCG();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_Star1").TweenReForScale();
- ManaReso.SetActive("Da_HGroup1", true);
- }
- );
- if (Rate == 0)
- {
- ManaReso.SetActive("Da_Star2", false);
- ManaReso.SetActive("Da_Star3", false);
- }
- else if (Rate == 1)
- {
- ManaReso.SetActive("Da_Star2", true);
- ManaReso.SetActive("Da_Star3", false);
- tween = ManaReso.Get("Da_Star1").GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_Star2").TweenReForScale();
- }
- );
- }
- else if (Rate == 2)
- {
- ManaReso.SetActive("Da_Star2", true);
- ManaReso.SetActive("Da_Star3", true);
- tween = ManaReso.Get("Da_Star1").GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_Star2").TweenReForScale();
- }
- );
- tween = ManaReso.Get("Da_Star2").GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_Star3").TweenReForScale();
- }
- );
- }
- #endregion
- #region 金币钻石
- tween = ManaReso.Get("Da_ScoreLab").GetTweenNumber();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_CoinGroup").TweenReForScale();
- if (DiamondFlag)
- {
- ManaReso.Get("Da_DiamondGroup").TweenReForScale();
- }
- }
- );
- tween = ManaReso.Get("Da_CoinGroup").GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_CoinLab").TweenReForNumber();
- }
- );
- if (DiamondFlag)
- {
- tween = ManaReso.Get("Da_DiamondGroup").GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("Da_DiamondLab").TweenReForNumber();
- }
- );
- }
- #endregion
- #endregion
- }
- public Award(XmlAttributeCollection attribute)
- {
- Flower.CoinFml = attribute[8].Value;
- DropGold.CoinFml = attribute[7].Value;
- Star.CD = float.Parse(attribute[9].Value);
- Star.Time = float.Parse(attribute[11].Value);
- string[] strings = attribute[10].Value.Split(',');
- ManaGarden.MinStarTime = float.Parse(strings[0]);
- ManaGarden.MaxStarTime = float.Parse(strings[1]);
- ManaGarden.StarTimer = Mathf.Lerp(ManaGarden.MinStarTime, ManaGarden.MaxStarTime, Random.Range(0f, 1f));
- CoinFml = attribute[1].Value;
- FlowerFml = attribute[4].Value;
- DiamondFml = attribute[3].Value;
-
- strings = attribute[2].Value.Split(',');
- DiamondMin = int.Parse(strings[0]);
- DiamondMax = int.Parse(strings[1]);
- strings = attribute[5].Value.Split(',');
- Odds = new List<float>()
- {
- float.Parse(strings[0]),
- float.Parse(strings[1]),
- float.Parse(strings[2]),
- };
- strings = attribute[6].Value.Split(',');
- Standard = new List<float>()
- {
- float.Parse(strings[0]),
- float.Parse(strings[1]),
- float.Parse(strings[2]),
- };
- }
- }
- public class ManaMiniGame : Regist
- {
- #region 变量
- public static int Score
- {
- get { return Score_; }
- set
- {
- Score_ = value;
- ManaReso.SetText("D_ScoreLab", ScoreLab + Score_);
- }
- }
- public static bool Game
- {
- get { return Game_; }
- set
- {
- Game_ = value;
- if (Game_)
- {
- ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab1"));
- }
- else
- {
- ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab0"));
- }
- }
- }
- public static bool Pause
- {
- get { return Pause_; }
- set
- {
- Pause_ = value;
- if (Game)
- {
- if (Pause_)
- {
- ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab2"));
- }
- else
- {
- ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab1"));
- }
- }
- else if (Prepare)
- {
- if (Pause_)
- {
- PrepareLab.GetStreamScale().Pause();
- }
- else
- {
- PrepareLab.GetStreamScale().Resume();
- }
- }
- }
- }
- public static bool Panalty
- {
- get { return Panalty_; }
- set
- {
- Panalty_ = value;
- if (Game)
- {
- if (Panalty_)
- {
- ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab3"));
- }
- else
- {
- ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab1"));
- }
- }
- }
- }
- public static float GameTimer
- {
- get { return GameTimer_; }
- set
- {
- GameTimer_ = value;
- TimerLab.text = (GameTime-GameTimer_).ToString("0.0");
- TimerBk.fillAmount = GameTimer_/GameTime;
- TimerBk.material.SetFloat("_Fill", TimerBk.fillAmount);
- }
- }
- private static int Score_;
- private static bool Game_;
- private static bool Pause_;
- private static bool Panalty_;
- private static float GameTimer_;
- public static Text TimerLab;
- public static Text PrepareLab;
- public static Image TimerBk;
- public static Award Award;
- public static Transform D_Grid;
- public static Transform D_Timer;
- public static Transform D_Begin;
- public static Transform D_Status1;
- public static Transform D_Status2;
- public static Transform D_Operate1;
- public static Transform D_Operate2;
- public static List<int> IndexList = new List<int>();
- public static List<Drop> DropList = new List<Drop>();
- public static List<Flower> OpList = new List<Flower>();
- public static List<Flower> IdleList = new List<Flower>();
- public static List<Flower> FadeList = new List<Flower>();
- public static Dictionary<int, Flower> FlowerDic = new Dictionary<int, Flower>();
- public static int MiniGameIndex;
- public static string ScoreLab;
- public static bool GameA;
- public static bool GameB;
- public static bool Prepare;
- public static bool FlowerLock;
- public static bool TutorialLock = true;
- public static bool DropDiamond;
- public static float OpTimer;
- public static float FadeTimer;
- public static float GoldTimer;
- public static float PanaltyTimer;
- public static float PrepareTimer;
- public static float DiamondTimer;
- public static float OpTime = 1.5f;
- public static float FadeTime = 2f;
- public static float GameTime = 45f;
- public static float PanaltyTime = 1f;
- public static float NewOpTime;
- public static float NewFadeTime;
- #endregion
- private void FixedUpdate()
- {
- if (Pause)
- {
- return;
- }
- if (Game)
- {
- GameThreadA();
- GameThreadB();
- }
- if (Prepare)
- {
- PrepareThread();
- }
- }
- private void GameThreadA()
- {
- if (GameB)
- {
- return;
- }
- GameTimer += Time.fixedDeltaTime;
- if (GameTimer >= GameTime)
- {
- GameOver();
- return;
- }
- if (Panalty)
- {
- PanaltyTimer -= Time.fixedDeltaTime;
- if (PanaltyTimer <= 0)
- {
- Panalty = false;
- }
- }
- if (IdleList.Count > 0)
- {
- OpTimer -= Time.fixedDeltaTime;
- if (OpTimer <= 0)
- {
- NewOpTime -= NewOpTime * 0.03f;
- OpTimer = NewOpTime;
- CreateOperate();
- }
- }
- BonusThread();
- }
- private void GameThreadB()
- {
- if (GameA)
- {
- return;
- }
- GameTimer += Time.fixedDeltaTime;
- if (GameTimer >= GameTime)
- {
- GameOver();
- return;
- }
- if (Panalty)
- {
- PanaltyTimer -= Time.fixedDeltaTime;
- if (PanaltyTimer <= 0)
- {
- Panalty = false;
- }
- }
-
- if (FadeList.Count < 6)
- {
- FadeTimer -= Time.fixedDeltaTime;
-
- if (FadeTimer <= 0)
- {
- FadeTimer = NewFadeTime;
- Fade();
- }
- }
- BonusThread();
- }
- private void BonusThread()
- {
- GoldTimer -= Time.fixedDeltaTime;
- if (GoldTimer < 0)
- {
- GoldTimer = Random.Range(3f, 6f);
- DropList.Add(ManaReso.GetDrop(ObjType.DropGold));
- }
- if (DropDiamond)
- {
- DiamondTimer -= Time.fixedDeltaTime;
- if (DiamondTimer < 0)
- {
- DropDiamond = false;
- DropList.Add(ManaReso.GetDrop(ObjType.DropDiamond));
- }
- }
- }
- private void PrepareThread()
- {
- PrepareTimer -= Time.fixedDeltaTime;
- if (PrepareTimer <= 0)
- {
- Prepare = false;
- GameBegin();
- }
- }
- public override void RegistValueA()
- {
- Award = new Award(ManaData.GetAwardConfig());
- MiniGameIndex = ManaData.GetPlayerInt("MiniGameIndex");
- }
- public override void RegistReference()
- {
- D_Grid = ManaReso.Get("D_Grid");
- D_Begin = ManaReso.Get("D_Begin");
- D_Timer = ManaReso.Get("D_Timer");
- D_Status1 = ManaReso.Get("D_Status1");
- D_Status2 = ManaReso.Get("D_Status2");
- D_Operate1 = ManaReso.Get("D_Operate1");
- D_Operate2 = ManaReso.Get("D_Operate2");
- TimerLab = ManaReso.Get<Text>("D_TimerLab");
- PrepareLab = ManaReso.Get<Text>("D_PrepareLab");
- TimerBk = ManaReso.Get<Image>("D_TimerIcon");
- }
- public static void Operate(int index)
- {
- if (Panalty || !FadeList.Valid())
- {
- return;
- }
- if (IndexList.Count == 0)
- {
- return;
- }
- if (index == IndexList[0])
- {
- int uiIndex = IndexMap(IndexList[0]);
- ManaReso.Get<Image>("D_FlowerBtn" + uiIndex).material = Shortcut.GrayMat;
- ManaReso.Get<Button>("D_FlowerBtn" + uiIndex).interactable = false;
- ManaReso.Get<Image>("D_FlowerIcon" + uiIndex).material = Shortcut.GrayMat;
- ManaReso.SetActive("D_FlowerTick" + uiIndex, true);
- IndexList.RemoveAt(0);
- Flower flower = FlowerDic[index];
- ManaReso.GetHudText("+45", Color.white, 90, flower.ChildDic["ScorePosTra"], ManaReso.Get("D_HudParent"), true);
- Score += 45;
- flower.PlayParticle();
- TweenRoot tween = flower.FlowerIcon.TweenBacSr();
- ManaAudio.PlayClip(Clip.BtnClip);
- if (IndexList.Count == 0)
- {
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- RoundEnd();
- RoundReset();
- RoundBegin();
- }
- );
- }
- }
- else
- {
- Panalty = true;
- PanaltyTimer = PanaltyTime;
- ManaAudio.PlayClip(Clip.ErrorClip);
- }
- }
- public static void Operate(OpType opType)
- {
- if (Panalty || !OpList.Valid())
- {
- return;
- }
- if (OpList[0].Operate(opType))
- {
- IdleList.Add(OpList[0]);
- OpList.Remove(OpList[0]);
- if (OpList.Count >= 2)
- {
- OpList[0].SetFirstOp();
- OpList[1].SetSecondOp();
- }
- else if (OpList.Count >= 1)
- {
- OpList[0].SetFirstOp();
- }
- }
- else
- {
- Panalty = true;
- PanaltyTimer = PanaltyTime;
- }
- }
- public static void ResetOprerate()
- {
- ManaReso.Get<Image>("D_FlowerBtn1").material = null;
- ManaReso.Get<Image>("D_FlowerBtn2").material = null;
- ManaReso.Get<Image>("D_FlowerBtn3").material = null;
- ManaReso.Get<Image>("D_FlowerBtn4").material = null;
- ManaReso.Get<Image>("D_FlowerBtn5").material = null;
- ManaReso.Get<Image>("D_FlowerBtn6").material = null;
- ManaReso.Get<Button>("D_FlowerBtn1").interactable = true;
- ManaReso.Get<Button>("D_FlowerBtn2").interactable = true;
- ManaReso.Get<Button>("D_FlowerBtn3").interactable = true;
- ManaReso.Get<Button>("D_FlowerBtn4").interactable = true;
- ManaReso.Get<Button>("D_FlowerBtn5").interactable = true;
- ManaReso.Get<Button>("D_FlowerBtn6").interactable = true;
- ManaReso.Get<Image>("D_FlowerIcon1").material = null;
- ManaReso.Get<Image>("D_FlowerIcon2").material = null;
- ManaReso.Get<Image>("D_FlowerIcon3").material = null;
- ManaReso.Get<Image>("D_FlowerIcon4").material = null;
- ManaReso.Get<Image>("D_FlowerIcon5").material = null;
- ManaReso.Get<Image>("D_FlowerIcon6").material = null;
- ManaReso.SetActive("D_FlowerTick1", false);
- ManaReso.SetActive("D_FlowerTick2", false);
- ManaReso.SetActive("D_FlowerTick3", false);
- ManaReso.SetActive("D_FlowerTick4", false);
- ManaReso.SetActive("D_FlowerTick5", false);
- ManaReso.SetActive("D_FlowerTick6", false);
- }
- public static void CreateOperate()
- {
- ManaAudio.PlayClip(Clip.BubbleClip);
- if (ManaTutorial.TutorialA && TutorialLock)
- {
- Pause = true;
- TutorialLock = false;
- Flower flower = IdleList[4];
- flower.CreateOp(OpList.Count, OpType.Water);
- OpList.Add(flower);
- IdleList.Remove(flower);
- Tutorial.HightScreen(ManaReso.Get("D_WaterArrow0"), ManaReso.Get("D_WaterArrow1"), ManaReso.Get("D_Water1"));
- Tutorial.SetArea(OpList[0].OperateIcon.transform, 0.1f, 0.125f);
- ManaReso.AddButtonEventOnetime
- (
- "D_Water2",
- () =>
- {
- Pause = false;
- Tutorial.HightDisable();
- }
- );
- }
- else
- {
- Flower flower = IdleList[Random.Range(0, IdleList.Count)];
- flower.CreateOp(OpList.Count);
- OpList.Add(flower);
- IdleList.Remove(flower);
- }
- }
- public static void Fade()
- {
- for (int i = 0; i < IndexList.Count; i++)
- {
- Flower flower = FlowerDic[IndexList[i]];
- if (FadeList.UniqueAdd(flower))
- {
- IdleList.Remove(flower);
- flower.PlayParticle();
- flower.FlowerIcon.TweenForSr();
- if (FadeList.Count == 6)
- {
- RoundBegin();
- }
- break;
- }
- }
- }
- public static void InitializeMode()
- {
- GameA = false;
- GameB = false;
- D_Operate1.SetActive(false);
- D_Operate2.SetActive(false);
- GameA = true;
- //if (ManaCenter.Level >= 18)
- //{
- // if (ManaTutorial.TutorialB)
- // {
- // GameB = true;
- // }
- // else
- // {
- // if (Random.Range(0f, 1f) <= 0.5f)
- // {
- // GameB = true;
- // }
- // else
- // {
- // GameA = true;
- // }
- // }
- //}
- //else
- //{
- // GameA = true;
- //}
- }
- public static void InitializeAward()
- {
- float flowerRate = (float)Auxiliary.FmlParse(Award.FlowerFml, "l", ManaCenter.Level.ToString(), "f", ManaGarden.MyFlower.ToString());
- if (Random.Range(0, 1f) <= flowerRate)
- {
- if (ManaGarden.MyFlower < ManaGarden.TotalFlower)
- {
- foreach (var kv in ManaGarden.FlowerInfoDic)
- {
- if (kv.Value.Unlock == false)
- {
- Award.FlowerID = kv.Value.ID_;
- Award.FlowerLock = false;
- break;
- }
- }
- }
- else
- {
- Award.FlowerLock = true;
- }
- }
- else
- {
- Award.FlowerLock = true;
- }
- }
- public static void GameEnd()
- {
- PrepareLab.GetStreamScale().InOrigin = true;
- if (Game)
- {
- ManaCenter.MiniLock = false;
- ManaCenter.MiniTimer = Mathf.Lerp(180, 300, Random.Range(0, 1f));
- }
- ManaReso.Get("C_MiniGame").TweenForCG();
- if (ManaCenter.MiniTimer > 0)
- {
- ManaReso.Get("C_MiniGame").TweenForRect();
- }
- Score = 0;
- Pause = false;
- Game = false;
- Panalty = false;
- Prepare = false;
- GameTimer = GameTime;
- for (int i = 0; i < OpList.Count; i++)
- {
- OpList[i].GameOver();
- }
- for (int i = 0; i < IdleList.Count; i++)
- {
- IdleList[i].GameOver();
- }
- for (int i = 0; i < DropList.Count; i++)
- {
- DropList[i].Retrieve();
- DropList.RemoveAt(i--);
- }
- }
- public static void GameOver()
- {
- ManaAudio.PlayClip(Clip.MiniEndClip);
- Award.GetAward(Score);
- ManaCenter.MiniGameAmt++;
- FlowerLock = false;
- GameEnd();
- }
- public static void GameEnter()
- {
- if (ManaTutorial.TutorialA)
- {
- Award.FlowerID = 1;
- Award.FlowerLock = true;
- InitializeMode();
- }
- else
- {
- if (!FlowerLock)
- {
- InitializeMode();
- InitializeAward();
- FlowerLock = true;
- }
- }
- if (ManaTutorial.TutorialB)
- {
- InitializeMode();
- }
- if (GameA)
- {
- GameEnterA();
- }
- if (GameB)
- {
- GameEnterB();
- }
- ScoreLab = Language.GetStr("UI", "D_ScoreLab");
- TimerBk.fillAmount = 0;
- TimerLab.text = GameTime.ToString("0");
- ManaReso.Get("C_MiniGame").TweenBacCG();
- }
- public static void GameEnterA()
- {
- D_Operate1.SetActive(true);
- D_Timer.SetParent(D_Status1);
- D_Grid.SetParent(D_Status1);
- D_Begin.SetParent(D_Operate1);
- PrepareLab.SetParent(ManaReso.Get("D_PrepareLayout1"));
- ManaReso.SetActive("D_Rip1", false);
- ManaReso.SetActive("D_Water1", false);
- ManaReso.SetActive("D_Fertilize1", false);
- ManaReso.SetActive("D_Begin", true);
- if (Award.FlowerLock)
- {
- for (int i = 1; i < 10; i++)
- {
- while (true)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
- if (flowerInfo.Unlock)
- {
- IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + i)));
- break;
- }
- }
- }
- }
- else
- {
- List<int> idList = new List<int>();
- idList = new List<int>() {1, 2, 3, 4, 5, 6, 7, 8, 9};
- int special = idList.Random(true);
- Flower flower = ManaReso.GetFlower(ManaGarden.FlowerInfoDic[Award.FlowerID], ManaReso.Get("SlotMini" + special));
- IdleList.Add(flower);
- for (int i = 0; i < idList.Count; i++)
- {
- while (true)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
- if (flowerInfo.Unlock)
- {
- flower = ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + idList[i]));
- IdleList.Add(flower);
- break;
- }
- }
- }
- }
- }
- public static void GameEnterB()
- {
- D_Operate2.SetActive(true);
- D_Timer.SetParent(D_Status2);
- D_Grid.SetParent(D_Status2);
- D_Begin.SetParent(D_Operate2);
- PrepareLab.SetParent(ManaReso.Get("D_PrepareLayout2"));
- ResetOprerate();
- ManaReso.Get("D_Mask").TweenBacGra();
- ManaReso.SetActive("D_FlowerBtn1", false);
- ManaReso.SetActive("D_FlowerBtn2", false);
- ManaReso.SetActive("D_FlowerBtn3", false);
- ManaReso.SetActive("D_FlowerBtn4", false);
- ManaReso.SetActive("D_FlowerBtn5", false);
- ManaReso.SetActive("D_FlowerBtn6", false);
- ManaReso.SetActive("D_Begin", true);
- List<int> idList = new List<int>() {1, 2, 4, 5, 7, 8};
- FlowerDic = new Dictionary<int, Flower>();
- Flower flower;
- if (Award.FlowerLock)
- {
- for (int i = 0; i < idList.Count; i++)
- {
- while (true)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
- if (flowerInfo.Unlock)
- {
- flower = ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + idList[i]));
- IdleList.Add(flower);
- FlowerDic.Add(idList[i], flower);
- break;
- }
- }
- }
- }
- else
- {
- int special = idList.Random(true);
- flower = ManaReso.GetFlower(ManaGarden.FlowerInfoDic[Award.FlowerID], ManaReso.Get("SlotMini" + special));
- IdleList.Add(flower);
- FlowerDic.Add(special, flower);
- for (int i = 0; i < idList.Count; i++)
- {
- while (true)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
- if (flowerInfo.Unlock)
- {
- flower = ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + idList[i]));
- IdleList.Add(flower);
- FlowerDic.Add(idList[i], flower);
- break;
- }
- }
- }
- }
- for (int i = 0; i < IdleList.Count; i++)
- {
- IdleList[i].FlowerIcon.CreateTweenSr(1, 0, 0.25f, true, false, Curve.EaseOutQuad, false, true);
- }
- }
- public static void GameBegin()
- {
- Game = true;
- MiniGameIndex++;
- Score = 0;
- OpTimer = OpTime;
- FadeTimer = FadeTime;
- GoldTimer = Random.Range(3f, 6f);
- GameTimer = 0;
- NewOpTime = OpTime;
- NewFadeTime = FadeTime;
- DiamondTimer = Random.Range(0f, GameTime - 5);
- if (GameA)
- {
- for (int i = 0; i < IdleList.Count; i++)
- {
- IdleList[i].GameBegin();
- }
- }
- if (GameB)
- {
- RoundReset();
- }
- if (Random.Range(5, 9) <= MiniGameIndex)
- {
- MiniGameIndex = 0;
- DropDiamond = true;
- }
- else
- {
- if (Random.Range(0, 1f) <= 0.01f)
- {
- DropDiamond = true;
- }
- else
- {
- DropDiamond = false;
- }
- }
- }
- public static void GamePrepare()
- {
- Prepare = true;
- PrepareTimer = 3;
- ManaReso.Get("D_Begin").SetActive(false);
- if (GameA)
- {
- ManaReso.Get("D_Rip1").SetActive(true);
- ManaReso.Get("D_Water1").SetActive(true);
- ManaReso.Get("D_Fertilize1").SetActive(true);
- }
- if (GameB)
- {
- ManaReso.Get("D_Mask").TweenForGra();
- ManaReso.SetActive("D_FlowerBtn1", true);
- ManaReso.SetActive("D_FlowerBtn2", true);
- ManaReso.SetActive("D_FlowerBtn3", true);
- ManaReso.SetActive("D_FlowerBtn4", true);
- ManaReso.SetActive("D_FlowerBtn5", true);
- ManaReso.SetActive("D_FlowerBtn6", true);
- ManaReso.SetSprite("D_FlowerIcon1", FlowerDic[1].FlowerInfo.Icon).Resize(true, 1f, 1f);
- ManaReso.SetSprite("D_FlowerIcon2", FlowerDic[2].FlowerInfo.Icon).Resize(true, 1f, 1f);
- ManaReso.SetSprite("D_FlowerIcon3", FlowerDic[4].FlowerInfo.Icon).Resize(true, 1f, 1f);
- ManaReso.SetSprite("D_FlowerIcon4", FlowerDic[5].FlowerInfo.Icon).Resize(true, 1f, 1f);
- ManaReso.SetSprite("D_FlowerIcon5", FlowerDic[7].FlowerInfo.Icon).Resize(true, 1f, 1f);
- ManaReso.SetSprite("D_FlowerIcon6", FlowerDic[8].FlowerInfo.Icon).Resize(true, 1f, 1f);
- }
- PrepareLab.StreamForScale();
- }
- public static void RoundEnd()
- {
- ManaReso.Get("D_Mask").TweenForGra();
- }
- public static void RoundReset()
- {
- for (int i = 0; i < FadeList.Count; i++)
- {
- IdleList.Add(FadeList[i]);
- }
- NewFadeTime -= NewFadeTime * 0.3f;
- FadeTimer = NewFadeTime;
- FadeList = new List<Flower>();
- IndexList = new List<int>();
- List<int> randomList = new List<int>() { 1, 2, 4, 5, 7, 8 };
- for (int i = 0; i < randomList.Count; i++)
- {
- IndexList.Add(randomList.Random(true));
- i--;
- }
- ResetOprerate();
- }
- public static void RoundBegin()
- {
- ManaReso.Get("D_Mask").TweenBacGra();
- if (ManaTutorial.TutorialB)
- {
- ManaTutorial.EnterB1();
- }
- }
- public static int IndexMap(int slotIndex)
- {
- if (slotIndex == 1)
- {
- return 1;
- }
- else if (slotIndex == 2)
- {
- return 2;
- }
- else if (slotIndex == 4)
- {
- return 3;
- }
- else if (slotIndex == 5)
- {
- return 4;
- }
- else if (slotIndex == 7)
- {
- return 5;
- }
- else if (slotIndex == 8)
- {
- return 6;
- }
- else
- {
- throw new Exception();
- }
- }
- public void OnApplicationPause(bool pause)
- {
- if (!pause)
- {
- if (!ManaTutorial.TutorialA)
- {
- if (Game || Prepare)
- {
- ManaReso.Get<Button>("D_Quit").onClick.Invoke();
- }
- }
- }
- }
- }
- #region DebugList
- //结束界面的图标能否重复显示
- #endregion
|