1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000 |
- 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 Slot = DragonBones.Slot;
- using Random = UnityEngine.Random;
- using Transform = UnityEngine.Transform;
- public enum BodyPart
- {
- Eye,
- Top,
- Shoe,
- Head,
- Wing,
- Dress,
- Mouse,
- Headwear,
- }
- public class CloseUnit
- {
- public enum CloseType
- {
- Top,
- Hair,
- Wing,
- Dress,
- Decarator,
- }
- #region Var
- public string Description
- {
- 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 float SpriteAlpha;
- public float IconOffset;
- public Text BuyBtnLab;
- public Sprite[] Sprites;
- public Image Icon1;
- public Image Icon2;
- public Button BuyBtn;
- public Button DressBtn;
- public Vector2 IconOffset1;
- public BodyPart BodyPart;
- public Transform Transform;
- public CloseType Type;
- 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)
- {
- ID = Auxiliary.IntParse(attribute[0].Value, -1);
- Type = TypeParse(attribute[2].Value);
- Index = Auxiliary.IntParse(attribute[3].Value, -1);
- BodyPart = BodyPartParse(attribute[4].Value);
- 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());
- Sprites = SpriteParse(attribute[13].Value);
- SpriteAlpha = Auxiliary.FloatParse(attribute[14].Value, 1);
- ArmatureName = attribute[15].Value;
-
- ManaPlayer.CloseIDDic.Add(ArmatureName, ID);
- ManaPlayer.CloseUnitDic.Add(ID, this);
- 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
- {
- throw new Exception();
- }
- Transform.SetSiblingIndex(Index);
- Auxiliary.CompileDic(Transform, ChildDic);
- Icon1 = ChildDic["Icon1"].GetComponent<Image>();
- Icon2 = ChildDic["Icon2"].GetComponent<Image>();
- DressBtn = ChildDic["CloseItem"].GetComponent<Button>();
- BuyBtn = ChildDic["BuyBtn"].GetComponent<Button>();
- BuyBtnLab = ChildDic["BuyBtnLab"].GetComponent<Text>();
- Icon2.sprite = Sprites[0];
- float newSize = PixelSize / Icon2.sprite.rect.width;
- Icon2.Resize(true, new Vector2(newSize, newSize));
- Icon2.SetAlpha(SpriteAlpha);
- Icon2.transform.localPosition = new Vector2(0, IconOffset);
- if (Sprites.Length > 1)
- {
- Icon1.SetActive(true);
- Icon1.sprite = Sprites[1];
- Icon1.Resize(true, new Vector2(newSize, newSize));
- Icon1.SetAlpha(SpriteAlpha);
- Icon1.transform.localPosition = IconOffset1*newSize + new Vector2(0, IconOffset);
- }
- if (BuyCurrent != Current.Free)
- {
- BuyBtnLab.text = Language.GetStr("UI", "P_BtnLab1") + Auxiliary.ImageParse(BuyCurrent) + Auxiliary.ShrinkNumberStr(BuyAmt);
- }
- BuyBtn.onClick.AddListener
- (
- () =>
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- ManaReso.Get("Pa_Info").TweenForCG();
- Image image = ManaReso.Get<Image>("Pa_Icon2");
- image.sprite = Sprites[0];
- image.Resize(true, new Vector2(newSize, newSize));
- image.transform.localPosition = new Vector3(0, 22) + new Vector3(0, IconOffset);
- if (Sprites.Length > 1)
- {
- ManaReso.SetActive("Pa_Icon1", true);
- Image image1 = ManaReso.Get<Image>("Pa_Icon1");
- image1.sprite = Sprites[1];
- image1.Resize(true, new Vector2(newSize, newSize));
- image1.transform.localPosition = new Vector3(0, 22) + new Vector3(0, IconOffset) + (Vector3) IconOffset1*newSize;
- }
- else
- {
- ManaReso.SetActive("Pa_Icon1", false);
- }
- ManaReso.SetText("Pa_Lab", Description);
- 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);
- ManaPlayer.Player.ChangeClose(BodyPart, ArmatureName);
- }
- );
- }
- protected Sprite[] SpriteParse(string str)
- {
- string[] spriteNames = str.Split(',');
- Sprite[] sprites = new Sprite[spriteNames.Length];
- for (int i = 0; i < spriteNames.Length; 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
- {
- throw new Exception();
- }
- }
- 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
- {
- throw new Exception();
- }
- }
- public void Unlock()
- {
- 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();
- },
- StaticsManager.ItemID.解锁服装,
- StaticsManager.ConsumeModule.Shop,
- false
- );
- }
- public void OnLevelChange()
- {
- }
- }
- public class Player : Regist , IPointerClickHandler
- {
- #region 变量
- public static bool InDressRoom;
- public static float JumpFrequency;
- public bool AnimLock1;
- public bool AnimLock2;
- public float JumpTime;
- public float JumpTimer;
- public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
- #region 换装
- private string Eye;
- private string Top;
- private string Shoe;
- private string Head;
- private string Wing;
- private string Dress;
- private string Mouse;
- private string HeadWear;
- private string TempClose;
- 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;
- #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
- );
- return false;
- }
- public void Update()
- {
- if (Input.GetKeyDown(KeyCode.Space))
- {
- UnityFactory.factory.BuildArmature("脑壳1");
- }
- }
- public void FixedUpdate()
- {
- if (InDressRoom)
- {
- JumpTimer += Time.fixedDeltaTime;
- if (JumpTimer > JumpTime)
- {
- if (!AnimLock1 && !AnimLock2)
- {
- PlayAnim("newAnimation1");
- }
- AnimLock2 = true;
- }
- if (JumpTimer > JumpFrequency)
- {
- AnimLock2 = false;
- JumpTime = Mathf.Lerp(0, JumpFrequency, Random.Range(0f, 1f));
- JumpTimer = 0;
- }
- }
- }
- public void OnStart(string str, EventObject eventObject)
- {
- if (eventObject.animationState.name == "newAnimation1")
- {
- ChildDic["Shadow"].StreamReForScale();
- AnimLock1 = true;
- TempClose = Eye;
- ChangeClose(BodyPart.Eye, "眼睛表情1");
- }
- else if (eventObject.animationState.name == "newAnimation")
- {
- AnimLock1 = false;
- if (TempClose != null)
- {
- ChangeClose(BodyPart.Eye, TempClose);
- }
- }
- }
- public void PlayAnim(string animName)
- {
- if (AnimLock1)
- {
- return;
- }
- UAC.anim.Play(animName);
- }
- 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)
- {
- if (ManaCenter.Level < 13)
- {
- return;
- }
- ManaReso.Get("I_BlackMask").GetTweenCG().Duration = 0.5f;
- ManaAudio.PlayClip(Clip.CurrentClip);
- EnterDressRoom();
- }
- 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;
- }
- 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, Eye, Mouse, 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;
- 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,
- () =>
- {
- 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.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("newAnimation");
- ChildDic["Shadow"].GetStreamScale().Pause();
- ChildDic["Shadow"].GetStreamScale().InOrigin = true;
- ChildDic["Shadow"].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,
- () =>
- {
- for (int i = 0; i < ManaGarden.PlantList.Count; i++)
- {
- ManaGarden.PlantList[i].Flower.RetrieveElf();
- }
- ChildDic["Shadow"].SetActive(true);
- 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,
- () =>
- {
- if (!ManaPlayer.DressRoomInitialized)
- {
- ManaReso.SetText("I_Lab", Language.GetStr("UI", "I_Lab"));
- ManaReso.SetActive("I_Lab", true);
- Auxiliary.Instance.DelayCall
- (
- () =>
- {
- ManaPlayer.InitializeDressRoom();
- ManaReso.Get("I_BlackMask").TweenForCG();
- },
- 1
- );
- }
- else
- {
- ManaReso.Get("I_BlackMask").TweenForCG();
- }
- }
- );
- }
- #region 换装
- public UnityArmatureComponent Build()
- {
- if (!ManaPlayer.Complete)
- {
- UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
- UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("Closet_ske", Folder.Config));
- UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
- UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("Closet_tex", Folder.Config), "Closet_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("newAnimation");
- UAC.AddEventListener(EventObject.START, OnStart);
- Eye = "眼睛1";
- Top = "上衣1";
- Shoe = "鞋子1";
- Head = "脑壳1";
- Wing = "Empty";
- Dress = "裙子1";
- Mouse = "嘴巴1";
- HeadWear = "头饰品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);
- 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);
-
- if (Wing != "Empty")
- {
- transform.FindChild("Armature/" + Wing).SetLZ(0.003f);
- }
- transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
- transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
- transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
- transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
- Transform tempTra = transform.FindChild("Armature/" + Head);
-
- tempTra.SetLZ(0);
- if (tempTra.childCount > 1)
- {
- tempTra.GetChild(0).SetLZ(0.002f);
- tempTra.GetChild(1).SetLZ(0f);
- }
- tempTra = transform.FindChild("Armature/" + Dress);
- tempTra.SetLZ(-0.002f);
- if (tempTra.childCount > 1)
- {
- tempTra.GetChild(0).SetLZ(0.001f);
- }
- tempTra = transform.FindChild("Armature/" + Shoe);
- tempTra.SetLZ(-0.001f);
- transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
- transform.FindChild("Armature/左腿").SetLZ(0);
- transform.FindChild("Armature/右腿").SetLZ(0);
- transform.FindChild("Armature/脖子").SetLZ(0.001f);
- transform.FindChild("Armature/左手").SetLZ(-0.001f);
- transform.FindChild("Armature/右手").SetLZ(-0.001f);
- }
- public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
- {
- 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
- {
- 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);
- }
- if (setDepth)
- {
- ResetDepth();
- }
- }
- #endregion
- }
|