123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- using DragonBones;
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using Transform = UnityEngine.Transform;
- public class Player : Regist
- {
- #region 变量
- private string Eye;
- private string Top;
- private string Shoe;
- private string Head;
- private string Dress;
- private string Mouse;
- private string RightShoe;
- private string HeadWear;
- private UnityArmatureComponent EyeUac;
- private UnityArmatureComponent TopUac;
- private UnityArmatureComponent HeadUac;
- private UnityArmatureComponent DressUac;
- private UnityArmatureComponent MouseUac;
- private UnityArmatureComponent LeftShoeUac;
- private UnityArmatureComponent RightShoeUac;
- private UnityArmatureComponent HeadWearUac;
- private List<string> EyeList = new List<string>();
- private List<string> TopList = new List<string>();
- private List<string> ShoeList = new List<string>();
- private List<string> HeadList = new List<string>();
- private List<string> DressList = new List<string>();
- private List<string> MouseList = new List<string>();
- private List<string> HeadWearList = new List<string>();
- public UnityArmatureComponent UAC;
- public Dictionary<string, Transform> ChildDic = new Dictionary<string, Transform>();
- #endregion
- public override void RegistImmed()
- {
- if (RegistFlag)
- {
- return;
- }
- else
- {
- RegistFlag = true;
- }
- enabled = true;
- Auxiliary.CompileDic(transform, ChildDic);
- }
- #region 换装
- public UnityArmatureComponent Build()
- {
- UAC = UnityFactory.factory.BuildArmatureComponent("Armature");
- UAC.transform.parent = transform;
- UAC.transform.localScale = new Vector3(1, 1, 1);
- UAC.transform.localPosition = new Vector3();
- UAC.animation.Play("newAnimation");
- EyeList.Add("眼睛1");
- TopList.Add("上衣1");
- ShoeList.Add("鞋子1");
- HeadList.Add("脑壳1");
- DressList.Add("裙子1");
- MouseList.Add("嘴巴1");
- HeadWearList.Add("头饰品1");
- EyeList.Add("眼睛2");
- TopList.Add("上衣2");
- ShoeList.Add("鞋子2");
- HeadList.Add("脑壳2");
- DressList.Add("裙子2");
- MouseList.Add("嘴巴2");
- HeadWearList.Add("头饰品2");
- EyeList.Add("眼睛3");
- TopList.Add("上衣3");
- ShoeList.Add("鞋子3");
- HeadList.Add("脑壳3");
- DressList.Add("裙子3");
- MouseList.Add("嘴巴3");
- HeadWearList.Add("头饰品3");
- Eye = EyeList[0];
- Top = TopList[0];
- Shoe = ShoeList[0];
- Head = HeadList[0];
- Dress = DressList[0];
- Mouse = MouseList[0];
- HeadWear = HeadWearList[0];
- UAC.armature.GetSlot("眼睛").childArmature = UnityFactory.factory.BuildArmature(Eye);
- UAC.armature.GetSlot("上衣").childArmature = UnityFactory.factory.BuildArmature(Top);
- UAC.armature.GetSlot("脑壳").childArmature = UnityFactory.factory.BuildArmature(Head);
- UAC.armature.GetSlot("裙子").childArmature = UnityFactory.factory.BuildArmature(Dress);
- UAC.armature.GetSlot("嘴巴").childArmature = UnityFactory.factory.BuildArmature(Mouse);
- UAC.armature.GetSlot("鞋子左").childArmature = UnityFactory.factory.BuildArmature(Shoe);
- UAC.armature.GetSlot("鞋子右").childArmature = UnityFactory.factory.BuildArmature(Shoe);
- UAC.armature.GetSlot("头饰品").childArmature = UnityFactory.factory.BuildArmature(HeadWear);
-
- EyeUac = transform.FindChild("Armature/眼睛1").GetComponent<UnityArmatureComponent>();
- TopUac = transform.FindChild("Armature/上衣1").GetComponent<UnityArmatureComponent>();
- HeadUac = transform.FindChild("Armature/脑壳1").GetComponent<UnityArmatureComponent>();
- DressUac = transform.FindChild("Armature/裙子1").GetComponent<UnityArmatureComponent>();
- MouseUac = transform.FindChild("Armature/嘴巴1").GetComponent<UnityArmatureComponent>();
- LeftShoeUac = transform.FindChild("Armature/鞋子1").GetComponent<UnityArmatureComponent>();
- RightShoeUac = transform.FindChild("Armature/鞋子1").GetComponent<UnityArmatureComponent>();
- HeadWearUac = transform.FindChild("Armature/头饰品1").GetComponent<UnityArmatureComponent>();
- RightShoeUac = transform.FindChild("Armature").GetChild(LeftShoeUac.transform.GetSiblingIndex() + 1).GetComponent<UnityArmatureComponent>();
- return UAC;
- }
- public UnityArmatureComponent BuildPink()
- {
- Build();
- NextEye();
- NextTop();
- NextShoe();
- NextHead();
- NextDress();
- NextMouse();
- NextHeadWear();
- NextEye();
- NextTop();
- NextShoe();
- NextHead();
- NextDress();
- NextMouse();
- NextHeadWear();
- return UAC;
- }
- public UnityArmatureComponent BuildBlond()
- {
- Build();
- ResetDepth();
- return UAC;
- }
- public UnityArmatureComponent BuildBrown()
- {
- Build();
- NextEye();
- NextTop();
- NextShoe();
- NextHead();
- NextDress();
- NextMouse();
- NextHeadWear();
- return UAC;
- }
- public void PrevEye()
- {
- int index = EyeList.IndexOf(Eye);
- Eye = EyeList.Prev(index);
- ChangeClose(EyeUac, Eye);
- ResetDepth();
- }
- public void PrevTop()
- {
- int index = TopList.IndexOf(Top);
- Top = TopList.Prev(index);
- ChangeClose(TopUac, Top);
- ResetDepth();
- }
- public void PrevShoe()
- {
- int index = ShoeList.IndexOf(Shoe);
- Shoe = ShoeList.Prev(index);
- ChangeClose(LeftShoeUac, Shoe);
- ChangeClose(RightShoeUac, Shoe);
- ResetDepth();
- }
- public void PrevHead()
- {
- int index = HeadList.IndexOf(Head);
- Head = HeadList.Prev(index);
- ChangeClose(HeadUac, Head);
- ResetDepth();
- }
- public void PrevDress()
- {
- int index = DressList.IndexOf(Dress);
- Dress = DressList.Prev(index);
- ChangeClose(DressUac, Dress);
- ResetDepth();
- }
- public void PrevMouse()
- {
- int index = MouseList.IndexOf(Mouse);
- Mouse = MouseList.Prev(index);
- ChangeClose(MouseUac, Mouse);
- ResetDepth();
- }
- public void PrevHeadWear()
- {
- int index = HeadWearList.IndexOf(HeadWear);
- HeadWear = HeadWearList.Prev(index);
- ChangeClose(HeadWearUac, HeadWear);
- ResetDepth();
- }
- public void NextEye()
- {
- int index = EyeList.IndexOf(Eye);
- Eye = EyeList.Next(index);
- ChangeClose(EyeUac, Eye);
- ResetDepth();
- }
- public void NextTop()
- {
- int index = TopList.IndexOf(Top);
- Top = TopList.Next(index);
- ChangeClose(TopUac, Top);
- ResetDepth();
- }
- public void NextShoe()
- {
- int index = ShoeList.IndexOf(Shoe);
- Shoe = ShoeList.Next(index);
- ChangeClose(LeftShoeUac, Shoe);
- ChangeClose(RightShoeUac, Shoe);
- ResetDepth();
- }
- public void NextHead()
- {
- int index = HeadList.IndexOf(Head);
- Head = HeadList.Next(index);
- ChangeClose(HeadUac, Head);
- ResetDepth();
- }
- public void NextDress()
- {
- int index = DressList.IndexOf(Dress);
- Dress = DressList.Next(index);
- ChangeClose(DressUac, Dress);
- ResetDepth();
- }
- public void NextMouse()
- {
- int index = MouseList.IndexOf(Mouse);
- Mouse = MouseList.Next(index);
- ChangeClose(MouseUac, Mouse);
- ResetDepth();
- }
- public void NextHeadWear()
- {
- int index = HeadWearList.IndexOf(HeadWear);
- HeadWear = HeadWearList.Next(index);
- ChangeClose(HeadWearUac, HeadWear);
- ResetDepth();
- }
- public void ResetDepth()
- {
- HeadUac.transform.SetLZ(0);
- EyeUac.transform.SetLZ(-0.001f);
- TopUac.transform.SetLZ(-0.003f);
- DressUac.transform.SetLZ(-0.002f);
- MouseUac.transform.SetLZ(-0.001f);
- LeftShoeUac.transform.SetLZ(-0.001f);
- RightShoeUac.transform.SetLZ(-0.001f);
- HeadWearUac.transform.SetLZ(-0.001f);
- transform.FindChild("Armature/左腿").SetLZ(0);
- transform.FindChild("Armature/右腿").SetLZ(0);
- transform.FindChild("Armature/脖子").SetLZ(0);
- transform.FindChild("Armature/左手").SetLZ(-0.001f);
- transform.FindChild("Armature/右手").SetLZ(-0.001f);
- }
- public void ChangeClose(UnityArmatureComponent uac, string armatureName)
- {
- global::DragonBones.Slot slot = null;
- if (uac.armature != null)
- {
- slot = uac.armature.parent;
- uac.Dispose(false);
- }
- uac.armatureName = armatureName;
- uac = UnityFactory.factory.BuildArmatureComponent(uac.armatureName, "Closet_ske", null, null, uac.gameObject);
- if (slot != null)
- {
- slot.childArmature = uac.armature;
- }
- uac.sortingLayerName = uac.sortingLayerName;
- uac.sortingOrder = uac.sortingOrder;
- }
- #endregion
- }
|