Пример #1
0
    /// <summary>
    /// 创建角色
    /// </summary>
    /// <param name="index"></param>
    private void CreateActor(int index)
    {
        string bodyweaponstring = string.Empty;

        if (index >= 0 && index < mRoleData.Count)
        {
            // 获取配置的初始武器和装备信息
            //bodyweaponstring = GameConstHelper.GetString(string.Format("GAME_BORN_ROLE{0}", mRoleData[index].rid));

            string[]    splits    = bodyweaponstring.Split('[', ',', ']');
            List <uint> modelList = new List <uint>();
            if (splits.Length > 3)
            {
                uint bodyId = uint.Parse(splits[1]);
                modelList.Add(bodyId);
                uint weaponId = uint.Parse(splits[2]);
                modelList.Add(weaponId);
            }
            modelList = ActorManager.ReplaceModelList(modelList, (Actor.EVocationType)mRoleData[index].rid, false);

            UnitID actor_uid = null;
            if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetFashion() != 0)
            {
                //List<uint> npc_id = SDKHelper.GetRoleList();
                //actor_uid = ClientModel.CreateClientModelByActorIdForLua(ActorHelper.RoleIdToCreateTypeId(npc_id[index]), OnActorLoaded);


                uint        type_idx     = ActorHelper.RoleIdToTypeId(mRoleData[index].rid);
                List <uint> model_list   = new List <uint>();
                List <uint> fashion_list = new List <uint>();
                ActorHelper.GetModelFashionList(mRoleData[index].shows, model_list, fashion_list);
                fashion_list.Add(SDKHelper.GetFashion());
                var         model_id_list = ActorManager.ReplaceModelList(model_list, (Actor.EVocationType)mRoleData[index].rid, true);
                ClientModel actor         = ClientModel.CreateClientModel(type_idx, mRoleData[index].uuid, model_id_list, fashion_list, mRoleData[index].effects, OnActorLoaded);
                mActors.Add(actor);
            }
            else
            {
                actor_uid = ClientModel.CreateClientModelByActorIdForLua(ActorHelper.RoleIdToCreateTypeId(mRoleData[index].rid), OnActorLoaded);
            }



            var client_model = ActorManager.Instance.GetActor(actor_uid) as ClientModel;
            if (client_model != null)
            {
                client_model.AttackSpeed = 1.0f;// 攻速必须为1,不然出场特效与动作匹配不上
                mActors.Add(client_model);
            }
        }
    }
Пример #2
0
            // 创建对应的角色
            public void CreateActor(int index)
            {
                if (index >= 0 && index < mData.Count)
                {
                    //if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetRoleList() != null)
                    //{
                    //    List<uint> npc_id = SDKHelper.GetRoleList();
                    //    int rid = (int)mData[index].rid - 1;
                    //    UnitID actor_uid = ClientModel.CreateClientModelByActorIdForLua(ActorHelper.RoleIdToCreateTypeId(npc_id[rid]), OnResLoaded);
                    //    var client_model = ActorManager.Instance.GetActor(actor_uid) as ClientModel;
                    //    client_model.AttackSpeed = 1.0f;
                    //    mActorGameObjects.Add(client_model);
                    //    return;
                    //}



                    uint type_idx = ActorHelper.RoleIdToTypeId(mData [index].rid);

                    List <uint> model_list   = new List <uint>();
                    List <uint> fashion_list = new List <uint>();
                    ActorHelper.GetModelFashionList(mData[index].shows, model_list, fashion_list);

                    if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetSwitchModel() && SDKHelper.GetFashion() != 0)
                    {
                        fashion_list.Add(SDKHelper.GetFashion());
                    }

                    var         model_id_list = ActorManager.ReplaceModelList(model_list, (Actor.EVocationType)mData [index].rid, true);
                    ClientModel actor         = ClientModel.CreateClientModel(type_idx, mData[index].uuid, model_id_list, fashion_list, mData[index].effects, OnResLoaded, false, true);
                    // 攻速必须为1,不然出场特效与动作匹配不上
                    actor.AttackSpeed = 1.0f;
                    mActorGameObjects.Add(actor);
                    actor.Freeze(DBActor.UF_ANIMATION);
                }
            }
Пример #3
0
    /// <summary>
    /// 选中指定职业的角色
    /// </summary>
    /// <param name="rid"></param>
    /// <returns></returns>
    public bool SelectActorByVocation(uint rid, Action finishCallback)
    {
        int index = -1;

        for (int i = 0; i < mRoleData.Count; i++)
        {
            if (mRoleData[i] != null)
            {
                if (mRoleData[i].rid == rid)
                {
                    index = i;
                    break;
                }
            }
        }

        if (index >= 0)
        {
            var bSkipLogAni = false; // 跳过登场动作

            var isAuditAndIos = AuditManager.Instance.AuditAndIOS();
            if (isAuditAndIos)
            {
                if (SDKHelper.GetSwitchModel())
                {
                    bSkipLogAni = true;
                }
                else
                {
                    // SDKHelper.GetFashion() 有配置时,会改变创角初始模型,但该初始模型没有 "登场动作"
                    if (SDKHelper.GetFashion() != 0)
                    {
                        bSkipLogAni = true;
                    }
                }
            }

            if (bSkipLogAni)
            {
                if (finishCallback != null)
                {
                    finishCallback();
                }
                return(SelectActor(index));
            }

            // 播放剧情动画
            // 停止正在播放的
            TimelineManager.Instance.Stop();
            // 保存摄像机的位置和朝向
            Vector3     cameraPositionBeforePlay = mCamera.transform.position;
            Quaternion  cameraRotationBeforePlay = mCamera.transform.rotation;
            List <uint> timelineIds = xc.GameConstHelper.GetUintList("GAME_CREATE_ROLE_TIMELINE_IDS");
            if (timelineIds.Count >= rid)
            {
                TimelineManager.Instance.Play(timelineIds[(int)rid - 1], () =>
                {
                    // 恢复摄像机的位置和朝向
                    mCamera.transform.position = cameraPositionBeforePlay;
                    mCamera.transform.rotation = cameraRotationBeforePlay;

                    if (finishCallback != null)
                    {
                        finishCallback();
                    }
                });
            }

            return(SelectActor(index));
        }
        else
        {
            GameDebug.LogError("CreateActorScene.MoveToActorByVocation 找不到Rid 对应的 Index,Rid:" + rid.ToString());
        }

        return(false);
    }