// career  对应的职业  1.刺客 2.法师 3.战士

    public void SetPlayerModelTransform(int carrer, int rideId, Action <float> callBack = null)
    {
        if (carrer == 0)
        {
            Debug.LogError("没有匹配到职业");

            return;
        }

        RideConfigVo      vo    = A3_RideModel.getInstance().GetValueByType <RideConfigVo>(rideId);
        TransformConfigVo trans = vo.transformMapping[carrer];

        rideGo.transform.localPosition    = new Vector3(trans.postionMapping["x"], trans.postionMapping["y"], trans.postionMapping["z"]);
        rideGo.transform.localEulerAngles = new Vector3(trans.rotationMapping["x"], trans.rotationMapping["y"], trans.rotationMapping["z"]);
        rideGo.transform.localScale       = new Vector3(trans.scaleMapping["x"], trans.scaleMapping["y"], trans.scaleMapping["z"]);

        SetPlayerWeaponTransform(carrer);

        if (m_nLayer == EnumLayer.LM_ROLE_INVISIBLE && isUIShow)
        {
            m_curModel.localPosition = Vector3.zero;
            m_curModel.localPosition = m_curModel.localPosition + new Vector3(0, trans.baseoffest + 0.15f, 0);
        }

        if (callBack != null)
        {
            callBack(trans.baseoffest);
            SetFXPosition(true);
        }
    }
    public void ResetPosition()
    {
        if (rideGo == null || rideGo.GetComponent <Animator>().GetBool(EnumAni.ANI_T_RIDERUN) == lastState)
        {
            return;
        }

        lastState = rideGo.GetComponent <Animator>().GetBool(EnumAni.ANI_T_RIDERUN);

        //Debug.LogError(lastState);

        if (lastState)
        {
            float speed = (float)(this.speed - 259) / 100;

            speed = speed < 1f ? 1f : speed;

            playerAni.speed = speed > 1.6f ? 1.6f : speed;   //最大1.6f
        }
        else
        {
            playerAni.speed = 1f;
        }

        RideConfigVo vo = A3_RideModel.getInstance().GetValueByType <RideConfigVo>(this.rideId);

        if (vo == null)
        {
            return;
        }

        TransformConfigVo trans = vo.transformMapping[GetCarrer()];

        if (trans.runpostionMapping == null)
        {
            return;
        }

        if (lastState)
        {
            rideGo.transform.localPosition = new Vector3(trans.runpostionMapping["x"], trans.runpostionMapping["y"], trans.runpostionMapping["z"]);
        }
        else
        {
            rideGo.transform.localPosition = new Vector3(trans.postionMapping["x"], trans.postionMapping["y"], trans.postionMapping["z"]);
        }
    }
    public void SetShadowgoScale(int rideId, GameObject yingzi, float baseoffest)
    {
        if (yingzi == null)
        {
            return;
        }

        Transform _yingzi = yingzi.transform;

        RideConfigVo vo = A3_RideModel.getInstance().GetValueByType <RideConfigVo>(rideId);

        TransformConfigVo trans = vo.transformMapping[GetCarrer()];

        _yingzi.localPosition = Vector3.zero;
        _yingzi.localScale    = Vector3.one;

        _yingzi.localPosition = _yingzi.localPosition + new Vector3(0, -baseoffest, trans.yinzipostionMapping["z"]);

        _yingzi.localScale = new Vector3(trans.yinziscaleMapping["x"], trans.yinziscaleMapping["y"], trans.yinziscaleMapping["z"]);
    }
    public void SetPlayerWeaponTransform(int carrer)
    {
        var config = A3_RideModel.getInstance().GetWeaponVoByCarrer(carrer);

        if (config == null)
        {
            return;
        }

        if (carrer == 1 || carrer == 3)
        {
            if (m_Weapon_RObj == null)
            {
                return;
            }

            var posMapping_right  = config.rightVo.postionMapping;
            var roatMapping_right = config.rightVo.rotationMapping;
            m_Weapon_RObj.transform.localPosition    = new Vector3(posMapping_right["x"], posMapping_right["y"], posMapping_right["z"]);
            m_Weapon_RObj.transform.localEulerAngles = new Vector3(roatMapping_right["x"], roatMapping_right["y"], roatMapping_right["z"]);
        }


        if (carrer == 1 || carrer == 2)
        {
            if (m_Weapon_LObj == null)
            {
                return;
            }

            var posMapping_left  = config.leftVo.postionMapping;
            var roatMapping_left = config.leftVo.rotationMapping;
            m_Weapon_LObj.transform.localPosition    = new Vector3(posMapping_left["x"], posMapping_left["y"], posMapping_left["z"]);
            m_Weapon_LObj.transform.localEulerAngles = new Vector3(roatMapping_left["x"], roatMapping_left["y"], roatMapping_left["z"]);
        }
    }
Example #5
0
    static public void Init() //玩家使用的职业的初始化
    {
        //锁定的脚底光圈
        GameObject obj_prefab = GAMEAPI.ABFight_LoadPrefab("common_lock_fx");
        GameObject obj_inst   = GameObject.Instantiate(obj_prefab) as GameObject;

        s_LockFX = obj_inst.transform;

        GameObject obj_boss_prefab = GAMEAPI.ABFight_LoadPrefab("common_lock_fx_boss");
        GameObject obj_boss_inst   = GameObject.Instantiate(obj_boss_prefab) as GameObject;

        s_LockFX_boss = obj_boss_inst.transform;


        int p = PlayerModel.getInstance().profession;

        if (p == 2)
        {
            FightText.userText = FightText.WARRIOR_TEXT;
        }
        else if (p == 3)
        {
            FightText.userText = FightText.MAGE_TEXT;
        }
        else if (p == 5)
        {
            FightText.userText = FightText.ASSI_TEXT;
        }


        //P1Warrior warrior = new P1Warrior();
        //warrior.Init();
        //_inst = warrior;

        //debug.Log("进入游戏的角色是 ................ " + PlayerModel.getInstance().profession+" "+PlayerModel.getInstance().iid);


        GameObject mainborn = GameObject.Find("mainbronpt");

        if (mainborn != null)
        {
            PlayerModel.getInstance().mapBeginX       = mainborn.transform.position.x;
            PlayerModel.getInstance().mapBeginY       = mainborn.transform.position.z;
            PlayerModel.getInstance().mapBeginroatate = mainborn.transform.eulerAngles.y;
        }

        ProfessionRole me    = null;
        A3_PROFESSION  a3_pf = (A3_PROFESSION)PlayerModel.getInstance().profession;

        if (A3_PROFESSION.Warrior == a3_pf)
        {
            P2Warrior p2 = new P2Warrior();
            p2.m_bUserSelf = true;
            p2.Init(PlayerModel.getInstance().name, EnumLayer.LM_SELFROLE, Vector3.zero, true);
            me = p2;
        }
        else if (A3_PROFESSION.Mage == a3_pf)
        {
            P3Mage p3 = new P3Mage();
            p3.m_bUserSelf = true;
            p3.Init(PlayerModel.getInstance().name, EnumLayer.LM_SELFROLE, Vector3.zero, true);
            me = p3;
        }
        else if (A3_PROFESSION.Assassin == a3_pf)
        {
            P5Assassin p5 = new P5Assassin();
            p5.m_bUserSelf = true;
            p5.Init(PlayerModel.getInstance().name, EnumLayer.LM_SELFROLE, Vector3.zero, true);
            me = p5;
        }
        else
        {
            P3Mage p3 = new P3Mage();
            p3.m_bUserSelf = true;
            p3.Init(PlayerModel.getInstance().name, EnumLayer.LM_SELFROLE, Vector3.zero, true);
            me = p3;
        }

        //P3Mage me = new P3Mage();
        me.m_ePK_Type   = PlayerModel.getInstance().up_lvl < 1 ? PK_TYPE.PK_PEACE : PK_TYPE.PK_PKALL;
        me.m_unIID      = PlayerModel.getInstance().iid;
        me.m_unPK_Param = PlayerModel.getInstance().cid;
        me.refreshmapCount((int)PlayerModel.getInstance().treasure_num);
        me.refreshserialCount(PlayerModel.getInstance().serial);
        me.serial = PlayerModel.getInstance().serial;
        me.refreshVipLvl((uint)A3_VipModel.getInstance().Level);
        me.m_curPhy.gameObject.layer = EnumLayer.LM_BT_SELF;
        _inst       = me;
        _inst.speed = PlayerModel.getInstance().speed;

        var rideInfo = A3_RideModel.getInstance().GetRideInfo();

        if (GRMap.curSvrConf.ContainsKey("maptype") && GRMap.curSvrConf["maptype"]._int > 0)
        {
            if (rideInfo != null && rideInfo.mount == (uint)RIDESTATE.UP)
            {
                A3_RideModel.getInstance().GetRideInfo().mount = 0;
                A3_RideProxy.getInstance().SendC2S(4, "mount", 0, true);
            }

            //副本中不携带坐骑
        }
        else
        {
            if (rideInfo != null && rideInfo.mount == ( uint )RIDESTATE.UP)
            {
                _inst.set_Ride(( int )rideInfo.dress, true);
            }
        }


        //Transform one = U3DAPI.DEF_TRANSFORM;
        //one.position = me.m_curModel.position;
        //OtherPlayerMgr._inst.AddOtherPlayer(one, 1);
        //OtherPlayerMgr._inst.AddOtherPlayer(one, 2);
        //OtherPlayerMgr._inst.AddOtherPlayer(one, 1);
        //OtherPlayerMgr._inst.AddOtherPlayer(one, 1);
        //OtherPlayerMgr._inst.AddOtherPlayer(one, 1);
        //OtherPlayerMgr._inst.AddOtherPlayer(one, 1);


        //临时存放在这里
        //GameObject raffle_group = GameObject.Find("a3_scene/raffle");
        GameObject raffle_group = GameObject.Find("game_scene/lv3/raffle");

        if (raffle_group != null)
        {
            //debug.Log("找到了木桶组");
            for (int i = 0; i < raffle_group.transform.childCount; i++)
            {
                Transform cur_tf = raffle_group.transform.GetChild(i);

                Transform cur_whole = cur_tf.Find("whole");
                Transform cur_boom  = cur_tf.Find("boom");

                if (cur_whole != null && cur_boom != null)
                {
                    RaffleHurtPoint rht = cur_tf.gameObject.AddComponent <RaffleHurtPoint>();
                    rht.m_Raffle   = cur_tf.gameObject;
                    rht.m_RafWhole = cur_whole.gameObject;
                    rht.m_RafBoom  = cur_boom.gameObject;

                    cur_tf.gameObject.layer = EnumLayer.LM_BT_FIGHT;
                }
                else
                {
                    GameObject.Destroy(cur_tf.gameObject);
                }
            }
        }

        //子弹墙
        //GameObject btwall_group = GameObject.Find("a3_scene/btwall");
        GameObject btwall_group = GameObject.Find("game_scene/lv3/btwall");

        if (btwall_group != null)
        {
            for (int i = 0; i < btwall_group.transform.childCount; i++)
            {
                Transform cur_tf = btwall_group.transform.GetChild(i);
                cur_tf.gameObject.AddComponent <BtWallHurtPoint>();

                cur_tf.gameObject.layer = EnumLayer.LM_BT_FIGHT;
            }
        }

        ////初始化装备模型
        //foreach (a3_BagItemData equip in a3_EquipModel.getInstance().getEquips().Values)
        //{
        //    a3_EquipModel.getInstance().equipModel_on(equip);
        //}
        //初始化装备模型
        if (a3_EquipModel.getInstance().getEquips() != null && a3_EquipModel.getInstance().getEquips().Count > 0)
        {
            foreach (a3_BagItemData equip in a3_EquipModel.getInstance().getEquips().Values)
            {
                a3_EquipModel.getInstance().equipModel_on(equip);
            }
        }
        else
        {
            a3_EquipModel.getInstance().equipModel_on(null);
        }


        //初始化翅膀模型
        A3_WingModel.getInstance().OnEquipModelChange();

        //初始化宠物模型和注册宠物avatar改变
        if (PlayerModel.getInstance().last_time != 0)
        {
            OnPetAvatarChange();
        }

        //A3_PetModel.getInstance().OnStageChange += OnPetAvatarChange;
        MonsterMgr._inst.dispatchEvent(GameEvent.Create(MonsterMgr.EVENT_ROLE_BORN, MonsterMgr._inst, SelfRole._inst));


        //用于设置第一次创建模型时不发移动协议,解决刚进副本激活怪物ai的bug
        MoveProxy.getInstance().resetFirstMove();

        _inst.m_LockDis = XMLMgr.instance.GetSXML("comm.lockdis").getFloat("dis");
    }
    public void Set_Ride(int rideId, Action <float> callBack = null, bool isUIShow = false)
    {
        this.rideId = rideId;

        this.isUIShow = isUIShow;

        string avatarName = m_strLow_or_High + A3_RideModel.getInstance().GetValueByType <RideConfigVo>(rideId).avatar;

        GAMEAPI.ABModel_LoadGameObject(avatarName, (go, data) => {
            remove_Ride();

            rideGo = GameObject.Instantiate(go) as  GameObject;

            rideGo.name = "zuoji";

            SkinnedMeshRenderer smr = rideGo.GetComponentInChildren <SkinnedMeshRenderer>();

            if (smr != null)
            {
                m_zuoji_Draw = smr;
                m_zuoji_Mtl  = smr.materials[0];

                if (smr.materials.Length > 1)
                {
                    m_zuoji_Mtl2 = smr.materials[1];
                }
            }

            int layer = EnumLayer.LM_DEFAULT;

            if (m_nLayer != EnumLayer.LM_ROLE_INVISIBLE && GRMap.curSvrConf.ContainsKey("id") && GRMap.curSvrConf.getValue("id")._int == 10)
            {
                layer = m_nLayer == EnumLayer.LM_SELFROLE ? EnumLayer.LM_SELFRIDE : EnumLayer.LM_OTHERRIDE;
            }

            else
            {
                layer = m_nLayer;
            }  //美术提的特殊需求 主城场景光太亮 单独一盏灯处理

            if (SceneCamera.m_nModelDetail_Level != 1 && this.m_nLayer != EnumLayer.LM_SELFROLE && isUIShow == false)
            {
                layer = EnumLayer.LM_DEFAULT;
            } //系统设置不显示其他玩家模型

            foreach (var item in rideGo.GetComponentsInChildren <Transform>())
            {
                item.gameObject.layer = layer;
            }

            rideGo.transform.SetParent(bip01);
            rideGo.transform.localPosition    = Vector3.zero;
            rideGo.transform.localEulerAngles = Vector3.zero;

            if (yingzi)
            {
                yingzi.transform.SetParent(rideGo.transform);
            }

            int carrer = GetCarrer();

            if (playerAni)
            {
                playerAni.SetFloat(EnumAni.ANI_F_FLY, 2f);
            }

            SetPlayerModelTransform(carrer, rideId, callBack);

            frameMoveCallBack = () =>
            {
                if (playerAni)
                {
                    playerAni.SetFloat(EnumAni.ANI_F_FLY, 2f);
                }

                frameMoveCallBack = null;
            }; // FrameMove  Rebind (可能比这里慢  所以加了个回调);
        }, avatarName);
    }