Пример #1
0
        //创建伙伴
        public static void CreateFellowModel(Obj_Init_Data initData)
        {
            if (null == initData)
            {
                return;
            }

            Tab_CabalFellowAttr fellowAttr = TableManager.GetCabalFellowAttrByID(initData.m_RoleBaseID, 0);

            if (null == fellowAttr)
            {
                return;
            }
            //根据ModelId找到CharModel资源
            Tab_CharModel charModel = TableManager.GetCharModelByID(fellowAttr.ModelId, 0);

            if (null == charModel)
            {
                return;
            }
            GameObject fellow = ResourceManager.InstantiateResource("Prefab/Model/FellowRoot", initData.m_ServerID.ToString()) as GameObject;

            if (null != fellow)
            {
                //加载逻辑体,同时异步加载渲染体
                Obj_Fellow objFellow = fellow.AddComponent <Obj_Fellow>();

                if (objFellow && objFellow.Init(initData))
                {
                    objFellow.CanLogic = true;
                    Singleton <ObjManager> .Instance.AddPoolObj(objFellow.ServerID.ToString(), objFellow);
                }
                LoadModelToRoot(fellowAttr.ModelId, EResourceType.CharacterModel, LoadModelComplete, fellow, charModel,
                                null);
                //ReloadModel(fellow, charModel.ResPath, AsycCreateFellowOver, initData);
            }
        }
Пример #2
0
        public uint Execute(PacketDistributed ipacket)
        {
            GC_MOVE packet = (GC_MOVE)ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }

            //临时代码,先返回,调试的时候打开
            //return (uint)PACKET_EXE.PACKET_EXE_CONTINUE;

            //判断ServerID
            if (packet.Serverid == GlobeVar.INVALID_ID)
            {
                return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
            }

            //查找该NPC
            Obj_Character obj = Singleton <ObjManager> .GetInstance().FindObjCharacterInScene(packet.Serverid);

            if (null == obj)
            {
                return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
            }

            //主玩家,消息包无效
            if (obj.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER)
            {
                return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
            }

            //主玩家伙伴,消息包无效
            if (obj.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_FELLOW)
            {
                Obj_Fellow objFellow = obj as Obj_Fellow;
                if (objFellow.OwnerObjId == Singleton <ObjManager> .GetInstance().MainPlayer.ServerID)
                {
                    return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
                }
            }

            if (obj.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
            {
                Obj_OtherPlayer objOther = obj as Obj_OtherPlayer;
                if (null != objOther)
                {
                    if (objOther.QingGongState == true || objOther.IsLightState == true || objOther.BindParent > 0)
                    {
                        return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
                    }

                    if (objOther.AnimLogic != null && objOther.AnimLogic.CurAnimData != null)
                    {
                        if (objOther.AnimLogic.CurAnimData.AnimID == (int)CharacterDefine.CharacterAnimId.Hit)
                        {
                            objOther.AnimLogic.Stop();
                        }
                        else if (objOther.SkillCore != null && objOther.SkillCore.UsingSkillBaseInfo != null && objOther.SkillCore.UsingSkillBaseInfo.IsMove != 1)
                        {
                            int nAnimationId = objOther.SkillCore.UsingSkillStartAni;
                            while (nAnimationId != GlobeVar.INVALID_ID)
                            {
                                if (nAnimationId == objOther.AnimLogic.CurAnimData.AnimID)
                                {
                                    objOther.AnimLogic.Stop();
                                    break;
                                }

                                Tab_Animation tabAnimation = TableManager.GetAnimationByID(nAnimationId, 0);
                                if (tabAnimation == null)
                                {
                                    break;
                                }

                                nAnimationId = tabAnimation.NextAnimId;
                            }
                        }
                    }

                    if (objOther.SkillCore.UsingSkillStartAni != GlobeVar.INVALID_ID && objOther.SkillCore.UsingSkillBaseInfo == null)
                    {
                        objOther.SkillCore.UsingSkillStartAni = GlobeVar.INVALID_ID;
                    }
                }
            }

            //查找Obj是否绑定AutoMove组件
            AutoMove autoMove = obj.AutoMoveComponent;

            if (null != autoMove)
            {
                autoMove.InsertAutoMovePoint(packet);
            }

            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }
        public uint Execute(PacketDistributed ipacket)
        {
            GC_UPDATE_FELLOW packet = (GC_UPDATE_FELLOW)ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            //取得伙伴在容器中的索引
            int             index     = packet.Packindex;
            FellowContainer container = GameManager.gameManager.PlayerDataPool.FellowContainer;

            if (container != null)
            {
                Fellow fellow = container.GetFellowByIndex(index);
                if (fellow != null)
                {
                    //GUID
                    fellow.Guid = packet.Guid;
                    //ID
                    fellow.DataId = packet.Dataid;
                    //昵称
                    fellow.Name = packet.Name;
                    //品质
                    if (packet.HasQuality)
                    {
                        fellow.Quality = packet.Quality;
                    }
                    //经验
                    if (packet.HasExp)
                    {
                        fellow.Exp = packet.Exp;
                    }
                    //级别
                    if (packet.HasLevel)
                    {
                        fellow.Level = packet.Level;
                    }
                    //打星等级
                    if (packet.HasStarexp)
                    {
                        fellow.StarExp = packet.Starexp;
                    }
                    //打星等级
                    if (packet.HasStarlevel)
                    {
                        fellow.StarLevel = packet.Starlevel;
                    }
                    //成长率
                    //if (packet.HasGrowup)
                    //{
                    //    fellow.GrowUp = (float)packet.Growup / 100.0f;
                    //}
                    //幸运值
                    if (packet.HasLucky)
                    {
                        fellow.Lucky = packet.Lucky;
                    }
                    //当前可用繁殖次数
                    if (packet.HasProcreatecount)
                    {
                        fellow.ProcreateCount = packet.Procreatecount;
                    }
                    //元素属性
                    if (packet.HasElementattr)
                    {
                        fellow.ElementAttr = packet.Elementattr;
                    }
                    //上锁
                    if (packet.HasIslock)
                    {
                        fellow.Locked = (packet.Islock == 1) ? true : false;
                    }
                    //初始五围属性
                    if (packet.HasBaseattack)
                    {
                        fellow.BaseAttack = packet.Baseattack;
                    }
                    if (packet.HasBasehit)
                    {
                        fellow.BaseHit = packet.Basehit;
                    }
                    if (packet.HasBasecritical)
                    {
                        fellow.BaseCritical = packet.Basecritical;
                    }
                    if (packet.HasBaseguard)
                    {
                        fellow.BaseGuard = packet.Baseguard;
                    }
                    if (packet.HasBasebless)
                    {
                        fellow.BaseBless = packet.Basebless;
                    }
                    if (packet.tallentskillidCount > 0 && packet.tallentskilllevelCount > 0)
                    {
                        fellow.TallentSkill.Clear();
                        for (int i = 0; i < packet.tallentskillidCount && i < packet.tallentskilllevelCount; i++)
                        {
                            if (false == fellow.TallentSkill.ContainsKey(packet.tallentskillidList[i]))
                            {
                                fellow.TallentSkill.Add(packet.tallentskillidList[i], packet.tallentskilllevelList[i]);
                            }
                        }
                    }
                    for (int i = 0; i < packet.elementskillidCount; i++)
                    {
                        if (false == fellow.IsHaveSkillId(packet.elementskillidList[i]))
                        {
                            fellow.SetElementSkillId(packet.elementskillidList[i], i);
                        }
                    }

                    if (PartnerFrameLogic.Instance() != null)
                    {
                        PartnerFrameLogic.Instance().UpdateFellowInfo_Refresh();
                        if (PartnerFrameLogic.Instance().rebirthFellowGuid != GlobeVar.INVALID_GUID)
                        {
                            PartnerFrameLogic.Instance().InitPartnerList(PartnerFrameLogic.Instance().rebirthFellowGuid);
                            PartnerFrameLogic.Instance().rebirthFellowGuid = Games.GlobeDefine.GlobeVar.INVALID_GUID;
                        }
                    }

                    if (Singleton <ObjManager> .GetInstance().MainPlayer != null && fellow.Guid == Singleton <ObjManager> .GetInstance().MainPlayer.CurFellowObjGuid)
                    {
                        Obj_Fellow curFellow = Singleton <ObjManager> .GetInstance().FindObjInScene(Singleton <ObjManager> .GetInstance().MainPlayer.CurFellowObjId) as Obj_Fellow;

                        if (curFellow != null)
                        {
                            curFellow.SetBordName(fellow.Name);
                        }
                    }
                }
            }
            if (MenuBarLogic.Instance() != null)
            {
                MenuBarLogic.Instance().UpdateFellowRedTip();
            }
            if (PartnerFrameLogic.Instance() != null)
            {
                PartnerFrameLogic.Instance().UpdateFellowTip();
            }
            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Пример #4
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;
            }
            }
        }