예제 #1
0
        public void TakeOffPetAccessory(Accessory accessory)
        {
            if (this.objModel == null)
            {
                Debug.LogError("<><PetPlayer.TakeOffPetAccessory>objModel is null");
                return;
            }

            if (accessory != null)
            {
                if (!string.IsNullOrEmpty(accessory.AB))
                {
                    this.AssetBundleUtils.StopLoadAsset(accessory.AB);
                }

                switch (accessory.AccessoryType)
                {
                case Gululu.Config.AccessoryTypes.Head:
                    UnityHelper.DeleteAllChildren(this.objModel.transform, RolePlayer.BodyPart.HEAD);
                    break;

                case Gululu.Config.AccessoryTypes.Back:
                    UnityHelper.DeleteAllChildren(this.objModel.transform, RolePlayer.BodyPart.WING);
                    break;

                case Gululu.Config.AccessoryTypes.Suit:
                    UnityHelper.DeleteAllChildren(this.objModel.transform, RolePlayer.BodyPart.SUIT);
                    break;
                }
                Debug.LogFormat("<><PetPlayer.TakeOffPetAccessory>AB: {0}, Prefab: {1}", accessory.AB, accessory.Prefab);
            }
        }
예제 #2
0
 public void TakeOffAllAccessories()
 {
     if (this.objModel == null)
     {
         Debug.LogError("<><PetPlayer.TakeOffAllAccessories>Parameter 'petRoot' is null");
         return;
     }
     UnityHelper.DeleteAllChildren(this.objModel.transform, RolePlayer.BodyPart.HEAD);
     UnityHelper.DeleteAllChildren(this.objModel.transform, RolePlayer.BodyPart.WING);
     UnityHelper.DeleteAllChildren(this.objModel.transform, RolePlayer.BodyPart.SUIT);
     Debug.Log("<><PetPlayer.TakeOffAllAccessories>+ + + + + + + +");
 }
예제 #3
0
        public void SetupPetAccessory(Accessory accessory)
        {
            if (this.objModel == null)
            {
                Debug.LogError("<><PetPlayer.SetupPetAccessory>Parameter 'petRoot' is null");
                return;
            }

            if (accessory != null)
            {
                if (accessory.CanWear)
                {                                                                             //只有配饰和套装能穿在身上
                    UnityHelper.DeleteAllChildren(this.objModel.transform, accessory.Region); //删除此部位的配饰
                    Transform bodyPart = UnityHelper.FindDeepChild(this.objModel.transform, accessory.Region);
                    if (bodyPart == null)
                    {
                        bodyPart = this.objModel.transform;
                    }

                    this.AssetBundleUtils.LoadAssetAsync(accessory.AB, accessory.Prefab, (gameObject) =>
                    {
                        if (gameObject != null)
                        {
                            gameObject.transform.SetParent(bodyPart);
                            gameObject.transform.localPosition = Vector3.zero;
                            gameObject.transform.localRotation = Quaternion.identity;
                            gameObject.transform.localScale    = Vector3.one;
                            gameObject.AddComponent <FixShader>();
                            gameObject.SetActive(true);
                            this.PlayAccessoryAnimation(gameObject.GetComponent <Animator>());
                            Debug.LogFormat("<><PetPlayer.SetupPetAccessory>AB: {0}, Prefab: {1}, GameObject: {2}", accessory.AB, accessory.Prefab, gameObject.name);
                        }
                    },
                                                         (errorText) =>
                    {
                        Debug.LogErrorFormat("<><PetPlayer.SetupPetAccessory>Error: {0}", errorText);
                    });
                }
            }
            else
            {
                Debug.LogErrorFormat("<><PetPlayer.SetupPetAccessory>Can't find the accessory [{0}]", accessory);
            }
        }