12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427 |
- using DragonBones;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.EventSystems;
- using System;
- using System.Xml;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using Animation = DragonBones.Animation;
- using Slot = DragonBones.Slot;
- using Random = UnityEngine.Random;
- using Transform = UnityEngine.Transform;
- public enum BodyPart
- {
- Leg = 0,
- LeftHand = 1,
- RightHand = 2,
- LeftLongSleeve = 3,
- LeftShortSleeve = 4,
- RightLongSleeve = 5,
- RightShortSleeve = 6,
- Neck = 7,
- Eye = 8,
- Top = 9,
- Shoe = 10,
- Head = 11,
- Wing = 12,
- Dress = 13,
- Mouse = 14,
- Headwear = 15,
- }
- public class CloseUnit
- {
- public enum CloseType
- {
- Top,
- Hair,
- Wing,
- Dress,
- Decarator,
- Shoe,
- }
- #region Var
- public string Name
- {
- get { return Language.GetStr("DressRoom", "Armature" + ID); }
- }
- public int ID;
- public int Index;
- public int BuyLevel;
- public int PixelSize;
- public bool Bought;
- public string ArmatureName;
- public string[] ExtraArmatureNames;
- public BodyPart[] ExtraBodyParts;
- public float SpriteAlpha;
- public float IconOffset;
- public Text BuyBtnLab;
- public Sprite[] Sprites;
- public Image Icon1;
- public Image Icon2;
- public Image Icon3;
- public Button BuyBtn;
- public Button DressBtn;
- public Vector2 IconOffset1;
- public Vector2 IconOffset2;
- public BodyPart BodyPart;
- public Transform Transform;
- public CloseType Type;
- public bool Ignore;
- public double BuyAmt;
- public double BuyAdvanceAmt;
- public Current BuyCurrent;
- public Current BuyAdvanceCurrent;
- public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
- #endregion
- public CloseUnit(XmlAttributeCollection attribute)
- {
- Ignore = Auxiliary.BoolParse(attribute[19].Value, false);
- ID = Auxiliary.IntParse(attribute[0].Value, -1);
- BodyPart = BodyPartParse(attribute[4].Value);
- ArmatureName = attribute[16].Value;
- ManaPlayer.CloseIDDic.Add(ArmatureName, ID);
- ManaPlayer.CloseUnitDic.Add(ID, this);
- if (Ignore)
- {
- return;
- }
- Type = TypeParse(attribute[2].Value);
- Index = Auxiliary.IntParse(attribute[3].Value, -1);
- BuyLevel = Auxiliary.IntParse(attribute[5].Value, 0);
- BuyCurrent = Auxiliary.CurrentParse(attribute[6].Value);
- BuyAmt = Auxiliary.DoubleParse(attribute[7].Value, 0);
- BuyAdvanceCurrent = Auxiliary.CurrentParse(attribute[8].Value);
- BuyAdvanceAmt = Auxiliary.DoubleParse(attribute[9].Value, 0);
- PixelSize = Auxiliary.IntParse(attribute[10].Value, 100);
- IconOffset = Auxiliary.FloatParse(attribute[11].Value, 0);
- IconOffset1 = Auxiliary.VectorParse(',', attribute[12].Value, new Vector3());
- IconOffset2 = Auxiliary.VectorParse(',', attribute[13].Value, new Vector3());
- Sprites = SpriteParse(attribute[14].Value);
- SpriteAlpha = Auxiliary.FloatParse(attribute[15].Value, 1);
- ExtraBodyParts = BodyPartParses(attribute[17].Value);
- ExtraArmatureNames = Auxiliary.StringListParse(',', attribute[18].Value, new List<string>()).ToArray();
- CreateItem();
- }
- protected void CreateItem()
- {
- Transform = ManaReso.Get("CloseItem", Folder.UI, false, ManaReso.Get("Canvas"), false);
- if (Type == CloseType.Top)
- {
- Transform.SetParent(ManaReso.Get("Pb_TopGrid"));
- }
- else if (Type == CloseType.Hair)
- {
- Transform.SetParent(ManaReso.Get("Pa_HairGrid"));
- }
- else if (Type == CloseType.Dress)
- {
- Transform.SetParent(ManaReso.Get("Pc_DressGrid"));
- }
- else if (Type == CloseType.Wing)
- {
- Transform.SetParent(ManaReso.Get("Pe_WingGrid"));
- }
- else if (Type == CloseType.Decarator)
- {
- Transform.SetParent(ManaReso.Get("Pd_DecaratorGrid"));
- }
- else if (Type == CloseType.Shoe)
- {
- Transform.SetParent(ManaReso.Get("Pf_ShoeGrid"));
- }
- else
- {
- throw new Exception();
- }
- Transform.SetSiblingIndex(Index);
- Auxiliary.CompileDic(Transform, ChildDic);
- Icon1 = ChildDic["Icon1"].GetComponent<Image>();
- Icon2 = ChildDic["Icon2"].GetComponent<Image>();
- Icon3 = ChildDic["Icon3"].GetComponent<Image>();
- DressBtn = ChildDic["CloseItem"].GetComponent<Button>();
- BuyBtn = ChildDic["BuyBtn"].GetComponent<Button>();
- BuyBtnLab = ChildDic["BuyBtnLab"].GetComponent<Text>();
- BuyBtnLab.GetComponent<TextPlus>().SetY = true;
- float newSize = PixelSize / Sprites[0].rect.width;
- SetUpUI(newSize, new Vector2(), Icon1, Icon2, Icon3);
- if (BuyCurrent != Current.Free)
- {
- BuyBtnLab.text = Auxiliary.ImageParse(BuyCurrent) + Auxiliary.ShrinkNumberStr(BuyAmt);
- }
- if (BuyLevel > ManaCenter.Level)
- {
- BuyBtn.interactable = false;
- BuyBtn.image.material = Lib.GrayMat;
- }
- BuyBtn.onClick.AddListener
- (
- () =>
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- ManaReso.Get("Pa_Info").TweenForCG();
- SetUpUI(newSize, new Vector2(0, 22), ManaReso.Get<Image>("Pa_Icon1"), ManaReso.Get<Image>("Pa_Icon3"), ManaReso.Get<Image>("Pa_Icon2"));
- ManaReso.SetText("Pa_Lab", Name);
- ManaReso.SetText("Pa_BtnLab", Language.GetStr("UI", "Pa_BtnLab") + Auxiliary.ImageParse(BuyCurrent) + BuyAmt);
- ManaReso.SetButtonEvent
- (
- "Pa_Btn",
- OnBuy
- );
- }
- );
- DressBtn.onClick.AddListener
- (
- () =>
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- if (BuyLevel > ManaCenter.Level)
- {
- Bubble.Show(null, Language.GetStr("UI", "P_Unlock"));
- return;
- }
- ChangeDress(ManaPlayer.Player);
- }
- );
- }
- protected Sprite[] SpriteParse(string str)
- {
- string[] spriteNames = str.Split(',');
- Sprite[] sprites = new Sprite[spriteNames.Length];
- for (int i = 0; i < spriteNames.Length; i++)
- {
- if (!ManaPlayer.CloseSpriteDic.ContainsKey(spriteNames[i]))
- {
- Debug.Log(spriteNames[i]);
- }
- sprites[i] = ManaPlayer.CloseSpriteDic[spriteNames[i]];
- }
- return sprites;
- }
- protected BodyPart BodyPartParse(string str)
- {
- int type = Auxiliary.IntParse(str, -1);
- if (type == 1)
- {
- return BodyPart.Head;
- }
- else if (type == 2)
- {
- return BodyPart.Dress;
- }
- else if (type == 3)
- {
- return BodyPart.Shoe;
- }
- else if (type == 4)
- {
- return BodyPart.Headwear;
- }
- else if (type == 5)
- {
- return BodyPart.Top;
- }
- else if (type == 6)
- {
- return BodyPart.Wing;
- }
- else if (type == 7)
- {
- return BodyPart.LeftLongSleeve;
- }
- else if (type == 8)
- {
- return BodyPart.RightLongSleeve;
- }
- else if (type == 9)
- {
- return BodyPart.LeftShortSleeve;
- }
- else if (type == 10)
- {
- return BodyPart.RightShortSleeve;
- }
- else if (type == 11)
- {
- return BodyPart.Eye;
- }
- else if (type == 12)
- {
- return BodyPart.Mouse;
- }
- else
- {
- throw new Exception();
- }
- }
- protected BodyPart[] BodyPartParses(string str)
- {
- List<string> typeIDs = Auxiliary.StringListParse(',', str, new List<string>());
- BodyPart[] bodyParts = new BodyPart[typeIDs.Count];
- for (int i = 0; i < typeIDs.Count; i++)
- {
- bodyParts[i] = BodyPartParse(typeIDs[i]);
- }
- return bodyParts;
- }
- protected CloseType TypeParse(string str)
- {
- int type = Auxiliary.IntParse(str, -1);
- if (type == 1)
- {
- return CloseType.Hair;
- }
- else if (type == 2)
- {
- return CloseType.Top;
- }
- else if (type == 3)
- {
- return CloseType.Dress;
- }
- else if (type == 4)
- {
- return CloseType.Decarator;
- }
- else if (type == 5)
- {
- return CloseType.Wing;
- }
- else if (type == 6)
- {
- return CloseType.Shoe;
- }
- else
- {
- throw new Exception();
- }
- }
- public void SetUpUI(float newSize, Vector2 offset, Image icon1, Image icon2, Image icon3)
- {
- icon1.SetActive(false);
- icon3.SetActive(false);
- icon2.SetActive(true);
- icon2.sprite = Sprites[0];
- icon2.Resize(true, new Vector2(newSize, newSize));
- icon2.SetAlpha(SpriteAlpha);
- icon2.transform.localPosition = offset + new Vector2(0, IconOffset);
- if (Sprites.Length >= 2)
- {
- icon1.SetActive(true);
- icon1.sprite = Sprites[1];
- icon1.Resize(true, new Vector2(newSize, newSize));
- icon1.SetAlpha(SpriteAlpha);
- icon1.transform.localPosition = IconOffset1 * newSize + offset + new Vector2(0, IconOffset);
- }
- if (Sprites.Length >= 3)
- {
- icon3.SetActive(true);
- icon3.sprite = Sprites[2];
- icon3.Resize(true, new Vector2(newSize, newSize));
- icon3.SetAlpha(SpriteAlpha);
- icon3.transform.localPosition = IconOffset2 * newSize + offset + new Vector2(0, IconOffset);
- }
- }
- public void Unlock()
- {
- if (Ignore)
- {
- return;
- }
- Bought = true;
- BuyBtn.interactable = false;
- BuyBtn.image.material = Lib.GrayMat;
- BuyBtnLab.text = Language.GetStr("UI", "P_BtnLab2");
- ManaCenter.CloseAmt++;
- }
- public void OnBuy()
- {
- ManaCenter.Pay
- (
- "",
- BuyAmt,
- BuyCurrent,
- () =>
- {
- Unlock();
- ManaAudio.PlayClip(Clip.CurrentClip);
- ManaPlayer.BoughtCloseList.UniqueAdd(ID);
- ManaReso.Get("Pa_Info").TweenBacCG();
- ManaServer.Save();
- },
- StaticsManager.ItemID.解锁服装,
- StaticsManager.ConsumeModule.Shop,
- true,
- false,
- () =>
- {
- ManaPlayer.Player.Reset();
- TweenRoot tweenRoot = ManaReso.Get("Pa_Info").TweenBacCG();
- tweenRoot.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- ManaPlayer.Player.Return();
- }
- );
- ManaReso.Get("B_SignIn0").GetTweenCG().AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("F_Manage0").TweenForVec();
- }
- );
- }
- );
- }
- public void ChangeDress(Player player)
- {
- player.ChangeClose(BodyPart, ArmatureName);
- if (Ignore)
- {
- return;
- }
- if (ExtraBodyParts.Length > 0)
- {
- player.ChangeClose(BodyPart.LeftLongSleeve, "Empty");
- player.ChangeClose(BodyPart.LeftShortSleeve, "Empty");
- player.ChangeClose(BodyPart.RightLongSleeve, "Empty");
- player.ChangeClose(BodyPart.RightShortSleeve, "Empty");
- }
- for (int i = 0; i < ExtraArmatureNames.Length; i++)
- {
- player.ChangeClose(ExtraBodyParts[i], ExtraArmatureNames[i]);
- }
- }
- public void OnLevelChange()
- {
- if (Ignore)
- {
- return;
- }
- if (Bought)
- {
- return;
- }
- if (BuyLevel < ManaCenter.Level)
- {
- BuyBtn.interactable = true;
- BuyBtn.image.material = null;
- }
- }
- }
- public enum PlayerDirection
- {
- Left = 0,
- Right = 1,
- }
- public class Player : Regist , IPointerClickHandler
- {
- #region 变量
- public static string IdleAnimationName = "newAnimation";
- public static string JumpAnimationName = "newAnimation1";
- public static string WalkAnimationName = "newAnimation2";
- public static string RunAnimationName = "newAnimation3";
- public static bool InDressRoom;
- public static float JumpFrequency;
- public PlayerDirection PlayerDirection
- {
- get { return playerDirection; }
- set
- {
- playerDirection = value;
- Flip(playerDirection);
- }
- }
- private PlayerDirection playerDirection = PlayerDirection.Left;
- public bool AnimLock1;
- public bool AnimLock2;
- public float JumpTime;
- public float JumpTimer;
- public SpriteRenderer ExpressionSr;
- public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
- public static Dictionary<string, Vector3> LeftExpressionPositionDictionary = new Dictionary<string, Vector3>
- {
- {"郁闷", new Vector3(0, -0.22f, -0.001f)},
- {"汗颜", new Vector3(0.35f, 0.91f, -0.001f)},
- {"惊讶", new Vector3(0.09f, -0.07f, -0.001f)},
- {"开心", new Vector3(0.1f, -0.22f, -0.001f)},
- {"哭", new Vector3(0.07f, -0.64f, -0.001f)},
- {"期待", new Vector3(0.04f, -0.20f, -0.001f)},
- {"色咪咪", new Vector3(0.03f, -0.09f, -0.001f)},
- {"委屈", new Vector3(0f, -0.27f, -0.001f)},
- };
- public static Dictionary<string, Vector3> RightExpressionPositionDictionary = new Dictionary<string, Vector3>
- {
- {"郁闷", new Vector3(0, -0.22f, -0.001f)},
- {"汗颜", new Vector3(-0.22f, 0.91f, -0.001f)},
- {"惊讶", new Vector3(-0.09f, -0.07f, -0.001f)},
- {"开心", new Vector3(-0.1f, -0.22f, -0.001f)},
- {"哭", new Vector3(-0.07f, -0.64f, -0.001f)},
- {"期待", new Vector3(-0.04f, -0.20f, -0.001f)},
- {"色咪咪", new Vector3(-0.03f, -0.09f, -0.001f)},
- {"委屈", new Vector3(0f, -0.27f, -0.001f)},
- };
- #region 换装
- public string Eye;
- public string Top;
- public string Shoe;
- public string Head;
- public string Wing;
- public string Dress;
- public string Mouse;
- public string HeadWear;
- public string LeftLongSleeve;
- public string LeftShortSleeve;
- public string RightLongSleeve;
- public string RightShortSleeve;
- private string TempClose;
- public DragonBones.Slot NeckSlot;
- public DragonBones.Slot LeftHandSlot;
- public DragonBones.Slot RightHandSlot;
- public DragonBones.Slot LeftLegSlot;
- public DragonBones.Slot RightLegSlot;
- public DragonBones.Slot LeftShortSleeveSlot;
- public DragonBones.Slot RightShortSleeveSlot;
- public DragonBones.Slot EyeSlot;
- public DragonBones.Slot TopSlot;
- public DragonBones.Slot HeadSlot;
- public DragonBones.Slot DressSlot;
- public DragonBones.Slot WingSlot;
- public DragonBones.Slot MouseSlot;
- public DragonBones.Slot LeftShoeSlot;
- public DragonBones.Slot RightShoeSlot;
- public DragonBones.Slot HeadWearSlot;
- public UnityArmatureComponent UAC;
- public UnityArmatureComponent LeftLongSleeveUAC;
- public UnityArmatureComponent RightLongSleeveUAC;
- #endregion
- #endregion
- public override bool RegistImmed()
- {
- if (base.RegistImmed())
- {
- return true;
- }
- enabled = true;
- Auxiliary.CompileDic(transform, ChildDic);
- Vector3 bigShadowScale = new Vector3(1.820952f, 2.418199f, 1.820952f);
- Vector3 smallShadowScale = new Vector3(1.081191f, 1.435807f, 1.081191f);
- ChildDic["Shadow"].CreateStreamScale
- (
- new List<float>() {0, 0, 0},
- new List<float>() {0.33f, 0.33f, 0.33f, 0.33f},
- new List<VecPair>() {new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale), new VecPair(bigShadowScale, smallShadowScale), new VecPair(smallShadowScale, bigShadowScale)},
- true,
- true,
- Curve.EaseOutQuad
- );
- ExpressionSr = ChildDic["ExpressionSr"].GetComponent<SpriteRenderer>();
- return false;
- }
- public void Update()
- {
- if (InDressRoom)
- {
- JumpTimer += Time.deltaTime;
- if (JumpTimer > JumpTime)
- {
- if (!AnimLock1 && !AnimLock2)
- {
- PlayAnim(JumpAnimationName);
- }
- AnimLock2 = true;
- }
- if (JumpTimer > JumpFrequency)
- {
- AnimLock2 = false;
- JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
- JumpTimer = 0;
- }
- }
- //if (GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.InPlazaRoom)
- //{
- // MoveThread();
- //}
- }
- public void OnStart(string str, EventObject eventObject)
- {
- if (eventObject.animationState.name == JumpAnimationName)
- {
- ChildDic["Shadow"].StreamReForScale();
- AnimLock1 = true;
- TempClose = Eye;
- ChangeClose(BodyPart.Eye, "眼睛表情1");
- }
- else if (eventObject.animationState.name == IdleAnimationName)
- {
- AnimLock1 = false;
- if (TempClose != null)
- {
- ChangeClose(BodyPart.Eye, TempClose);
- }
- }
- }
- public string CurrentAnimationName;
- public void PlayAnim(string animName)
- {
- if (AnimLock1)
- {
- return;
- }
- if (UAC.anim.lastAnimationName == animName)
- {
- return;
- }
- if (GardenSmartFoxManager.GardenSmartFox.SFSPlazaRoomManager.InPlazaRoom)
- {
- CurrentAnimationName = animName;
- }
- UAC.anim.FadeIn(animName, GetFadeInTime(UAC.anim.lastAnimationName, animName));
- }
- public float GetFadeInTime(string lastAnimation, string targetAnimation)
- {
- if (lastAnimation == JumpAnimationName && targetAnimation == IdleAnimationName)
- return -1f;
- else
- return 0.1f;
- //throw new Exception();
- }
- public void SetAllCollider(bool enable)
- {
- BoxCollider2D[] colliders = GetComponentsInChildren<BoxCollider2D>();
- for (int i = 0; i < colliders.Length; i++)
- {
- colliders[i].enabled = enable;
- }
- }
- public void OnPointerClick(PointerEventData eventData)
- {
- ManaAudio.PlayClip(Clip.CurrentClip);
- ManaNickName.ShowNickNameSettingPanel();
- PlayAnim(JumpAnimationName);
- }
- public void ResetExpression()
- {
- ExpressionSr.SetActive(false);
- EyeSlot.UnityTransform.GetChild(0).SetActive(true);
- MouseSlot.UnityTransform.GetChild(0).SetActive(true);
- }
- private string ExpressionName;
- private Coroutine ResetExpressionCoroutine;
- public void ChangeExpression(string expressionName, float duration)
- {
- ExpressionName = expressionName;
- ExpressionSr.sprite = ManaReso.LoadSprite(expressionName, Folder.Scene);
- ExpressionSr.transform.parent = EyeSlot.UnityTransform;
- ExpressionSr.SetActive(true);
- EyeSlot.UnityTransform.GetChild(0).SetActive(false);
- MouseSlot.UnityTransform.GetChild(0).SetActive(false);
- FlipExpression(expressionName, PlayerDirection);
- if (ResetExpressionCoroutine != null)
- Auxiliary.Instance.StopCoroutine(ResetExpressionCoroutine);
- ResetExpressionCoroutine = Auxiliary.Instance.DelayCall
- (
- () =>
- {
- ResetExpression();
- },
- duration
- );
- }
- public void Flip(PlayerDirection direction)
- {
- FlipExpression(ExpressionName, direction);
- if (direction == PlayerDirection.Left)
- {
- UAC.armature.flipX = false;
- playerDirection = PlayerDirection.Left;
- }
- else if (direction == PlayerDirection.Right)
- {
- UAC.armature.flipX = true;
- playerDirection = PlayerDirection.Right;
- }
- else
- {
- throw new Exception();
- }
- }
- public void FlipExpression(string expressionName, PlayerDirection direction)
- {
- if (string.IsNullOrEmpty(ExpressionName))
- {
- return;
- }
- if (direction == PlayerDirection.Left)
- {
- ExpressionSr.flipX = false;
- ExpressionSr.transform.localPosition = LeftExpressionPositionDictionary[ExpressionName];
- }
- else if (direction == PlayerDirection.Right)
- {
- UAC.armature.flipX = true;
- ExpressionSr.flipX = true;
- ExpressionSr.transform.localPosition = RightExpressionPositionDictionary[ExpressionName];
- playerDirection = PlayerDirection.Right;
- }
- else
- {
- throw new Exception();
- }
- }
- public void Save(bool showNavigate)
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- List<CloseUnit> closeUnitList = new List<CloseUnit>();
- closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Head]]);
- closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Dress]]);
- closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Shoe]]);
- closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[HeadWear]]);
- closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Top]]);
- if (Wing != "Empty")
- {
- closeUnitList.Add(ManaPlayer.CloseUnitDic[ManaPlayer.CloseIDDic[Wing]]);
- }
- for (int i = 0; i < closeUnitList.Count; i++)
- {
- if (!closeUnitList[i].Bought)
- {
- if (showNavigate)
- {
- BuyNavigate(closeUnitList);
- }
- return;
- }
- }
- ManaPlayer.DressData[0] = Head;
- ManaPlayer.DressData[1] = Dress;
- ManaPlayer.DressData[2] = Shoe;
- ManaPlayer.DressData[3] = HeadWear;
- ManaPlayer.DressData[4] = Top;
- ManaPlayer.DressData[7] = Wing;
- ManaPlayer.DressData[8] = LeftLongSleeve;
- ManaPlayer.DressData[9] = LeftShortSleeve;
- ManaPlayer.DressData[10] = RightLongSleeve;
- ManaPlayer.DressData[11] = RightShortSleeve;
- //GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.SyncClose();
- }
- public void Reset()
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- List<string> dressData = new List<string>(ManaPlayer.DressData);
- dressData[5] = Eye;
- ManaPlayer.BuildPlayer(dressData);
- }
- public void Return()
- {
- bool allSave = true;
- bool allBought = true;
- List<string> currentDerssData = new List<string>() {Head, Dress, Shoe, HeadWear, Top, Wing};
- for (int i = 0; i < currentDerssData.Count; i++)
- {
- if (!ManaPlayer.CloseIDDic.ContainsKey(currentDerssData[i]))
- {
- continue;
- }
- int id = ManaPlayer.CloseIDDic[currentDerssData[i]];
- allBought = allBought && ManaPlayer.CloseUnitDic[id].Bought;
- //Debug.Log(ManaPlayer.CloseUnitDic[id].Name + " " + ManaPlayer.CloseUnitDic[id].Bought);
- allSave = allSave && currentDerssData[i] == ManaPlayer.DressData[i];
- }
- if (allBought)
- {
- if (allSave)
- {
- ExitDressRoom();
- }
- else
- {
- Reset();
- ExitDressRoom();
- }
- }
- else
- {
- Bubble.Show
- (
- null, Language.GetStr("UI", "P_Return"), null, null,
- () =>
- {
- Reset();
- ManaReso.Get("K_Bubble").GetTweenGra().AddEventOnetime(EventType.BackwardFinish, () => { ExitDressRoom(); });
- }
- );
- }
- }
- public void BuyNavigate(List<CloseUnit> closeUnitList)
- {
- for (int i = 0; i < closeUnitList.Count; i++)
- {
- if (closeUnitList[i].Bought)
- {
- closeUnitList.RemoveAt(i--);
- }
- else
- {
- closeUnitList[i].BuyBtn.onClick.Invoke();
- closeUnitList.RemoveAt(i--);
- ManaReso.Get("Pa_Info").GetTweenCG().AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- if (closeUnitList.Count == 0)
- {
- Save(false);
- }
- else
- {
- BuyNavigate(closeUnitList);
- }
- }
- );
- return;
- }
- }
- }
- public void ExitDressRoom()
- {
- ManaCenter.SceneSwitchLock = false;
- TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
- tweenRoot.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- transform.SetParent(ManaReso.Get("GardenNormal"));
- transform.position = ManaReso.Get("PlayerPosTra").position;
- transform.localScale = ManaReso.Get("PlayerPosTra").lossyScale;
- ManaReso.Get("Garden").TweenForSr();
- ManaReso.Get("DressRoom").TweenBacSr();
- ManaReso.Get("C_Main").TweenForCG();
- ManaReso.Get("P_DressRoom").TweenBacCG();
- }
- );
- tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
- tweenRoot.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- SetAllCollider(true);
- InDressRoom = false;
- JumpTimer = 0;
- PlayAnim(IdleAnimationName);
- ChildDic["Shadow"].GetStreamScale().Pause();
- ChildDic["Shadow"].GetStreamScale().InOrigin = true;
- ChildDic["ShadowParent"].SetActive(false);
- ManaReso.Get("B_SignIn0").TweenForCG();
- ManaReso.Get("I_BlackMask").TweenForCG();
- }
- );
- }
- public void EnterDressRoom()
- {
- if (ManaCenter.SceneSwitchLock)
- {
- return;
- }
- ManaReso.Get("B_SignIn0").TweenBacCG();
- InDressRoom = true;
- JumpTime = Mathf.Lerp(0, 10, Random.Range(0.5f, 1f));
- ManaCenter.SceneSwitchLock = true;
- ManaReso.Get("C_Main").TweenBacCG();
- SetAllCollider(false);
- TweenRoot tweenRoot = ManaReso.Get("I_BlackMask").TweenBacCG();
- tweenRoot.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- ManaGarden.RetrieveAllElf();
- ChildDic["ShadowParent"].SetActive(true);
- ChildDic["ShadowParent"].SetLZ(3);
- transform.SetParent(ManaReso.Get("DressRoom"));
- transform.position = ManaReso.Get("DressRoomPos").position;
- transform.localScale = ManaReso.Get("DressRoomPos").lossyScale;
- ManaReso.Get("Garden").TweenBacSr();
- ManaReso.Get("DressRoom").TweenForSr();
- ManaReso.Get("P_DressRoom").TweenForCG();
- }
- );
- tweenRoot = ManaReso.Get("P_DressRoom").GetTweenCG();
- tweenRoot.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ManaReso.Get("I_BlackMask").TweenForCG();
- }
- );
- }
- #region 换装
- public void CorrectPivot()
- {
- List<Transform> children = new List<Transform>();
- while (transform.childCount > 0)
- {
- children.Add(transform.GetChild(0));
- children.Back(0).parent = null;
- }
- Vector3 offset = UAC.transform.FindChild("Pivot").position - transform.position;
- children[0].position += offset;
- children[1].position += offset;
- transform.position += offset;
- for (int i = 0; i < children.Count; i++)
- {
- children[i].parent = transform;
- }
- }
- public UnityArmatureComponent Build()
- {
- if (!ManaPlayer.Complete)
- {
- UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
- UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
- ManaPlayer.Complete = true;
- }
- UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
-
- UAC.transform.parent = transform;
- UAC.transform.localScale = new Vector3(1, 1, 1);
- UAC.transform.localPosition = new Vector3();
- UAC.anim.Play(IdleAnimationName);
- UAC.AddEventListener(EventObject.START, OnStart);
- Eye = "眼睛1";
- Top = "上衣1";
- Shoe = "鞋子1";
- Head = "脑壳1";
- Wing = "Empty";
- Dress = "裙子1";
- Mouse = "嘴巴1";
- HeadWear = "头饰品1";
- NeckSlot = UAC.armature.GetSlot("脖子");
- LeftHandSlot = UAC.armature.GetSlot("左手");
- RightHandSlot = UAC.armature.GetSlot("右手");
- LeftLegSlot = UAC.armature.GetSlot("左腿");
- RightLegSlot = UAC.armature.GetSlot("右腿");
- LeftLongSleeveUAC = UAC.transform.FindChild("长袖9左 (长袖9左)").GetComponent<UnityArmatureComponent>();
- RightLongSleeveUAC = UAC.transform.FindChild("长袖9右 (长袖9右)").GetComponent<UnityArmatureComponent>();
- LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
- RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
- EyeSlot = UAC.armature.GetSlot("眼睛");
- TopSlot = UAC.armature.GetSlot("上衣");
- HeadSlot = UAC.armature.GetSlot("脑壳");
- WingSlot = UAC.armature.GetSlot("翅膀");
- DressSlot = UAC.armature.GetSlot("裙子");
- MouseSlot = UAC.armature.GetSlot("嘴巴");
- LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
- RightShoeSlot = UAC.armature.GetSlot("鞋子右");
- HeadWearSlot = UAC.armature.GetSlot("头饰品");
- ChangeClose(BodyPart.Eye, "眼睛1", false);
- ChangeClose(BodyPart.Top, "上衣1", false);
- ChangeClose(BodyPart.Shoe, "鞋子1", false);
- ChangeClose(BodyPart.Head, "脑壳1", false);
- ChangeClose(BodyPart.Dress, "裙子1", false);
- ChangeClose(BodyPart.Mouse, "嘴巴1", false);
- ChangeClose(BodyPart.Headwear, "头饰品1", false);
- ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
- ChangeClose(BodyPart.RightLongSleeve, "Empty", false);
- ChangeClose(BodyPart.LeftShortSleeve, "短袖2左", false);
- ChangeClose(BodyPart.RightShortSleeve, "短袖2右", false);
- CorrectPivot();
- return UAC;
- }
- public UnityArmatureComponent BuildPink()
- {
- Build();
- ChangeClose(BodyPart.Eye, "眼睛3", false);
- ChangeClose(BodyPart.Top, "上衣3", false);
- ChangeClose(BodyPart.Shoe, "鞋子3", false);
- ChangeClose(BodyPart.Head, "脑壳3", false);
- ChangeClose(BodyPart.Wing, "Empty", false);
- ChangeClose(BodyPart.Dress, "裙子3", false);
- ChangeClose(BodyPart.Mouse, "嘴巴3", false);
- ChangeClose(BodyPart.Headwear, "头饰品3", false);
- ResetDepth();
- return UAC;
- }
- public UnityArmatureComponent BuildBlond()
- {
- Build();
- ChangeClose(BodyPart.Wing, "Empty", false);
- ResetDepth();
- return UAC;
- }
- public UnityArmatureComponent BuildBrown()
- {
- Build();
- ChangeClose(BodyPart.Eye, "眼睛2", false);
- ChangeClose(BodyPart.Top, "上衣2", false);
- ChangeClose(BodyPart.Shoe, "鞋子2", false);
- ChangeClose(BodyPart.Head, "脑壳2", false);
- ChangeClose(BodyPart.Wing, "Empty", false);
- ChangeClose(BodyPart.Dress, "裙子2", false);
- ChangeClose(BodyPart.Mouse, "嘴巴2", false);
- ChangeClose(BodyPart.Headwear, "头饰品2", false);
- ResetDepth();
- return UAC;
- }
- public void ResetDepth()
- {
- UAC.transform.SetLZ(2.5f);
- WingSlot.UnityTransform.SetLZ(0);
- EyeSlot.UnityTransform.SetLZ(0);
- TopSlot.UnityTransform.SetLZ(0);
- MouseSlot.UnityTransform.SetLZ(0);
- HeadWearSlot.UnityTransform.SetLZ(0);
- LeftShoeSlot.UnityTransform.SetLZ(0);
- RightShoeSlot.UnityTransform.SetLZ(0);
- LeftLegSlot.UnityTransform.SetLZ(0);
- RightLegSlot.UnityTransform.SetLZ(0);
- NeckSlot.UnityTransform.SetLZ(0);
- LeftHandSlot.UnityTransform.SetLZ(0);
- RightHandSlot.UnityTransform.SetLZ(0);
- LeftShortSleeveSlot.UnityTransform.SetLZ(0);
- RightShortSleeveSlot.UnityTransform.SetLZ(0);
- WingSlot.SetLZ(0.003f);
- EyeSlot.SetLZ(-0.001f);
- TopSlot.SetLZ(-0.003f);
- MouseSlot.SetLZ(-0.001f);
- HeadWearSlot.SetLZ(-0.001f);
- HeadSlot.UnityTransform.SetLZ(0);
- if (HeadSlot.UnityTransform.childCount > 1)
- {
- HeadSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
- HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
- }
- DressSlot.UnityTransform.SetLZ(-0.002f);
- if (DressSlot.UnityTransform.childCount > 1)
- {
- DressSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
- DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
- }
- LeftShoeSlot.SetLZ(-0.001f);
- RightShoeSlot.SetLZ(-0.001f);
- LeftLegSlot.SetLZ(0);
- RightLegSlot.SetLZ(0);
- NeckSlot.SetLZ(0.001f);
- LeftHandSlot.SetLZ(-0.001f);
- RightHandSlot.SetLZ(-0.001f);
- LeftShortSleeveSlot.SetLZ(-0.0015f);
- RightShortSleeveSlot.SetLZ(-0.0015f);
- LeftLongSleeveUAC.transform.SetLZ(-0.0015f);
- RightLongSleeveUAC.transform.SetLZ(-0.0015f);
- }
- public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
- {
- // Debug.Log (bodyPart + " " + armatureName);
- List<DragonBones.Slot> slotList = new List<DragonBones.Slot>();
- if (bodyPart == BodyPart.Eye)
- {
- Eye = armatureName;
- slotList.Add(EyeSlot);
- }
- else if (bodyPart == BodyPart.Top)
- {
- Top = armatureName;
- slotList.Add(TopSlot);
- }
- else if (bodyPart == BodyPart.Shoe)
- {
- Shoe = armatureName;
- slotList.Add(LeftShoeSlot);
- slotList.Add(RightShoeSlot);
- }
- else if (bodyPart == BodyPart.Head)
- {
- Head = armatureName;
- slotList.Add(HeadSlot);
- }
- else if (bodyPart == BodyPart.Wing)
- {
- if (Wing == armatureName)
- {
- return;
- }
- else
- {
- Wing = armatureName;
- slotList.Add(WingSlot);
- }
- }
- else if (bodyPart == BodyPart.Dress)
- {
- Dress = armatureName;
- slotList.Add(DressSlot);
- }
- else if (bodyPart == BodyPart.Mouse)
- {
- Mouse = armatureName;
-
- slotList.Add(MouseSlot);
- }
- else if (bodyPart == BodyPart.Headwear)
- {
- HeadWear = armatureName;
- slotList.Add(HeadWearSlot);
- }
- else if (bodyPart == BodyPart.Leg)
- {
- slotList.Add(LeftLegSlot);
- slotList.Add(RightLegSlot);
- }
- else if (bodyPart == BodyPart.LeftHand)
- {
- slotList.Add(LeftHandSlot);
- }
- else if (bodyPart == BodyPart.RightHand)
- {
- slotList.Add(RightHandSlot);
- }
- else if (bodyPart == BodyPart.Neck)
- {
- slotList.Add(NeckSlot);
- }
- else if (bodyPart == BodyPart.LeftLongSleeve)
- {
- LeftLongSleeve = armatureName;
- ChangeClose(LeftLongSleeveUAC, armatureName);
- return;
- }
- else if (bodyPart == BodyPart.LeftShortSleeve)
- {
- LeftShortSleeve = armatureName;
-
- slotList.Add(LeftShortSleeveSlot);
- }
- else if (bodyPart == BodyPart.RightLongSleeve)
- {
- RightLongSleeve = armatureName;
- ChangeClose(RightLongSleeveUAC, armatureName);
- return;
- }
- else if (bodyPart == BodyPart.RightShortSleeve)
- {
- RightShortSleeve = armatureName;
- slotList.Add(RightShortSleeveSlot);
- }
- else
- {
- throw new Exception();
- }
- ChangeClose(slotList, armatureName, setDepth);
- if (bodyPart == BodyPart.Wing)
- {
- TweenRoot tweenRoot = transform.FindChild("Armature/" + Wing).GetChild(0).CreateTweenScale(new Vector3(1, 1, 1), new Vector3(0.6f, 1, 1), 0.75f, true, true, Curve.Linear);
- tweenRoot.PingPong = true;
- tweenRoot.StartForward();
- }
- }
- public void ChangeClose(List<DragonBones.Slot> slotList, string armatureName, bool setDepth = true)
- {
- for (int i = 0; i < slotList.Count; i++)
- {
- slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
- slotList[i].UnityTransform = slotList[i].childArmature.UnityTransform.parent;
- }
- if (setDepth)
- {
- ResetDepth();
- }
- }
- public void ChangeClose(UnityArmatureComponent uac, string armatureName, bool setDepth = true)
- {
- if (armatureName == "Empty")
- {
- uac.SetActive(false);
- }
- else
- {
- uac.SetActive(true);
- }
- if (setDepth)
- {
- ResetDepth();
- }
- }
- #endregion
- }
|