示例#1
0
    public void Equip(EtyAvatar avatar, int _equipId, Action callback)
    {
        //Debug.Log("_equipId:" + _equipId);
        if (avatar.gameObject == null)
        {
            Debug.Log("Transform == null");
            //Debug.LogError("Transform == null");
            return;
        }
        System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
        stopWatch.Start();

        if (!ItemEquipmentData.dataMap.ContainsKey(_equipId))
        {
            Debug.LogError("can not find equip:" + _equipId);
            return;
        }
        ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId];

        if (equip.mode > 0)
        {
            if (avatar.actorParent == null)
            {
                Debug.Log("the actor is null!!!!");
                //Debug.LogError("the actor is null!!!!");
                return;
            }
            avatar.actorParent.m_isChangingWeapon = true;
            avatar.actorParent.Equip(equip.mode, () =>
            {
                if (equip.type == (int)EquipType.Weapon)
                {
                    //Debug.Log("ControllerOfWeaponData:" + equip.id);
                    //Debug.Log("ControllerOfWeaponData:" + equip.subtype);
                    //Debug.Log("ControllerOfWeaponData:" + (int)vocation);
                    ControllerOfWeaponData controllerData = ControllerOfWeaponData.dataMap[equip.subtype];
                    RuntimeAnimatorController controller;
                    AssetCacheMgr.GetResource(controllerData.controller,
                                              (obj) =>
                    {
                        controller = obj as RuntimeAnimatorController;
                        if (avatar.animator == null)
                        {
                            return;
                        }
                        avatar.animator.runtimeAnimatorController = controller;


                        if (MogoWorld.inCity)
                        {
                            avatar.animator.SetInteger("Action", -1);
                        }
                        else
                        {
                            avatar.animator.SetInteger("Action", 0);
                        }
                        callback();
                    });
                }
                else
                {
                    callback();
                }
            });

            stopWatch.Stop();
        }
        else
        {
            callback();
        }
    }
示例#2
0
        public void Equip(int _equipId)
        {
            if (Transform == null)
            {
                return;
            }
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();

            if (!ItemEquipmentData.dataMap.ContainsKey(_equipId))
            {
                LoggerHelper.Error("can not find equip:" + _equipId);
                return;
            }
            ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId];

            if (equip.mode > 0)
            {
                if (Actor == null)
                {
                    return;
                }
                Actor.m_isChangingWeapon = true;
                Actor.Equip(equip.mode);
                if (equip.type == (int)EquipType.Weapon)
                {
                    ControllerOfWeaponData    controllerData = ControllerOfWeaponData.dataMap[equip.subtype];
                    RuntimeAnimatorController controller;
                    if (animator == null)
                    {
                        return;
                    }
                    string controllerName = (MogoWorld.inCity ? controllerData.controllerInCity : controllerData.controller);
                    if (animator.runtimeAnimatorController != null)
                    {
                        if (animator.runtimeAnimatorController.name == controllerName)
                        {
                            return;
                        }
                        AssetCacheMgr.ReleaseResource(animator.runtimeAnimatorController);
                    }

                    AssetCacheMgr.GetResource(controllerName,
                                              (obj) =>
                    {
                        controller = obj as RuntimeAnimatorController;
                        if (animator == null)
                        {
                            return;
                        }
                        animator.runtimeAnimatorController = controller;
                        if (this is EntityMyself)
                        {
                            (this as EntityMyself).UpdateSkillToManager();
                            EventDispatcher.TriggerEvent <int, int>(InventoryEvent.OnChangeEquip, equip.type, equip.subtype);
                        }
                        if (this is EntityPlayer)
                        {
                            if (MogoWorld.inCity)
                            {
                                animator.SetInteger("Action", -1);
                            }
                            else
                            {
                                animator.SetInteger("Action", 0);
                            }
                            if (MogoWorld.isReConnect)
                            {
                                ulong s   = stateFlag;
                                stateFlag = 0;
                                stateFlag = s;
                            }
                        }
                    });
                }

                stopWatch.Stop();

                //if (!isCreatingModel)
                //{
                //    SetPosition();
                //    stopWatch.Start();
                //    //AssetCacheMgr.ReleaseInstance(GameObject);
                //    CreateActualModel();
                //    stopWatch.Stop();
                //    Mogo.Util.LoggerHelper.Debug("CreateModel:" + stopWatch.Elapsed.Milliseconds);

                //}
            }
        }