示例#1
0
        private static void LoadModelComplete(LoadedObjData data, LoadCompleteCallBackParameter parameter)
        {
            GameObject resObj = data.LoadedObj as GameObject;
            object     param1 = parameter.Parameter1;
            object     param2 = parameter.Parameter2;
            object     param3 = parameter.Parameter3;

            if (null == param1 || null == param2)
            {
                return;
            }

            GameObject rootObj = param1 as GameObject;

            if (null == rootObj)
            {
                return;
            }
            Tab_CharModel charModelTab = param2 as Tab_CharModel;

            Obj baseObj = rootObj.GetComponent <Obj>();

            if (baseObj == null)
            {
                return;
            }

            GameObject charModel = Object.Instantiate(resObj) as GameObject;

            if (null == charModel || charModelTab == null)
            {
                return;
            }
            else
            {
                charModel.name = "Model";
            }
            if (false == ReloadModel(rootObj, charModel))
            {
                return;
            }
            if (rootObj.GetComponent <Obj_NPC>())
            {
                if (rootObj.GetComponent <Obj_NPC>().isVisible)
                {
                    rootObj.GetComponent <Obj_NPC>().BecameVisible();
                }
            }
            string lastUrl = baseObj.MainModelUrl;

            baseObj.SetMainModelUrl(data.Url);
            ResourcesManager.Instance.AddCachedRef(data.Url, EResourceType.CharacterModel, baseObj.ObjType);
            baseObj.InitEffect();
            //特异化处理
            switch (baseObj.ObjType)
            {
            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_CLIENT:
            {
                Obj_Client curCharacter = baseObj as Obj_Client;
                if (curCharacter == null)
                {
                    LogModule.ErrorLog("charObj {0} loaded error!", rootObj.name);
                    break;
                }
                curCharacter.BaseAttr.RoleName = charModelTab.Name;

                curCharacter.AnimationFilePath = charModelTab.AnimPath;

                curCharacter.OnModelInitOk();
                DelAsycModelOver delOverFunction = param3 as DelAsycModelOver;
                if (null != delOverFunction)
                {
                    delOverFunction(curCharacter, null);
                }
                break;
            }

            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_NPC:
            {
                //由于InitAnimation中用到了Model,所以放在模型加载结束后初始化
                Obj_NPC objNPC = baseObj as Obj_NPC;
                if (objNPC == null)
                {
                    LogModule.ErrorLog("charObj {0} loaded error!", rootObj.name);
                    break;
                }


                if (MobileHardwareInfo.Instance.HardwareLevel == Games.GlobeDefine.GameDefine_Globe.HardwardLevel.LEVEL_HIGH)
                {
                    UpdateEdgeGlow edgeGlow = charModel.GetComponent <UpdateEdgeGlow>();
                    if (edgeGlow == null)
                    {
                        edgeGlow = charModel.AddComponent <UpdateEdgeGlow>();
                    }

                    objNPC.NpcEdgeGlow = edgeGlow;

                    if (objNPC.NpcType == GameDefine_Globe.NPC_TYPE.BOSS)
                    {
                        if (objNPC.NpcEdgeGlow != null)
                        {
                            //  objNPC.NpcEdgeGlow.SetBossOutLineWidth(GlobeVar.BOSS_OUTLINE_WIDTH);
                            //add 用Cabal/Light Probes Rim Alpha Test 代替原来的Cabal/EdgeGlow shader.
                        }
                    }
                }

                if (MobileHardwareInfo.Instance.HardwareLevel == Games.GlobeDefine.GameDefine_Globe.HardwardLevel.LEVEL_LOW)
                {
                    Transform trans = objNPC.transform.FindChild("shadow");
                    if (trans != null)
                    {
                        trans.gameObject.SetActive(false);
                    }
                }

                objNPC.OnModelInitOk();
                break;
            }

            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER:
            {
                Obj_OtherPlayer objOtherPlayer = baseObj as Obj_OtherPlayer;
                if (null == objOtherPlayer)
                {
                    return;
                }

                bool value = (bool)param3;
                if (null != objOtherPlayer)
                {
                    if (!value)
                    {
                        objOtherPlayer.NormalGameObject = charModel;
                    }
                    else
                    {
                        objOtherPlayer.ChangeGameObject = charModel;
                        Utils.SetActive(objOtherPlayer.ChangeGameObject, true);
                        objOtherPlayer.m_lastMainObjUrl = lastUrl;
                    }
                }
                objOtherPlayer.RealoadPlayerWeaponVisual();
                objOtherPlayer.RealoadPlayerFlyWingModel();

                //由于InitAnimation中用到了Model,所以放在模型加载结束后初始化
                objOtherPlayer.UpdateCombatValue();
                objOtherPlayer.OnModelInitOk();
                objOtherPlayer.UpdateBelleShow();
                //objOtherPlayer.RideOrUnMount(objOtherPlayer.MountID);
                break;
            }

            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_ZOMBIE_PLAYER:
            {
                Obj_ZombieUser zombieUser = baseObj as Obj_ZombieUser;
                if (null == zombieUser)
                {
                    return;
                }
                zombieUser.RealoadPlayerWeaponVisual();
                zombieUser.OnModelInitOk();
                break;
            }

            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_FELLOW:
            {
                //由于InitAnimation中用到了Model,所以放在模型加载结束后初始化
                Obj_Fellow objFellow = baseObj as Obj_Fellow;
                if (null != objFellow)
                {
                    objFellow.SetVisible(objFellow.IsVisibleChar());
                }
                break;
            }

            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER:
            {
                Obj_MainPlayer main  = baseObj as Obj_MainPlayer;
                bool           value = (bool)param3;
                if (null != main)
                {
                    if (!value)
                    {
                        main.NormalGameObject = charModel;
                    }
                    else
                    {
                        main.ChangeGameObject = charModel;
                        Utils.SetActive(main.ChangeGameObject, false);
                        main.m_lastMainObjUrl = lastUrl;
                    }
                    ObjManager.AddOutLineMaterial(charModel);
                    main.RealoadPlayerWeaponVisual();
                    main.UpdateCombatValue();
                    main.OnModelInitOk();
                    main.UpdateBelleShow();
                    //main.RideOrUnMount(main.MountID);
                }
                Singleton <ObjManager> .Instance.m_bBeginAsycCreateMainPlayer = false;
                SetPlayerShader(charModel);
                CameraManager.Instance.ResetCameraCullingMash();

                if (!value)
                {
                    GameManager.gameManager.FlyWingMananger.ReLoadFlyWing();
                }
                main.IsNoMove = false;

                break;
            }

            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_YANHUA:
            case Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_SNARE:
            {
                //并没有特殊处理
                break;
            }
            }
        }