Пример #1
0
    //private int idIdx = 0;
    public void AddOtherPlayer(Variant p)
    {
        if (GRMap.grmap_loading)
        {
            cacheProxy.Add(p);
            return;
        }
        debug.Log(p["name"] + "--------------:" + p.dump());
        uint iid       = p["iid"]._uint;
        uint lvlsideid = 0;

        if (p.ContainsKey("lvlsideid"))
        {
            lvlsideid = p["lvlsideid"];
        }
        if (m_mapOtherPlayer.ContainsKey(iid))
        {
            return;
        }
        uint cid  = 0;
        int  type = p["carr"];

        if (p.ContainsKey("cid"))
        {
            cid = p["cid"]._uint;
        }

        string  name    = p["name"];
        Vector3 born_pt = new Vector3(p["x"] / GameConstant.PIXEL_TRANS_UNITYPOS, 0f, p["y"] / GameConstant.PIXEL_TRANS_UNITYPOS);

        ProfessionRole pro_role = null;

        bool invisible = false;

        if (p.ContainsKey("invisible") && p["invisible"] > 0)
        {
            invisible = p["invisible"] > 0;
        }

        int title_sign = 0;

        //if ( p.ContainsKey( "title_sign" ) )
        //{
        //    title_sign = p[ "title_sign" ]._int;
        //}
        if (2 == type)
        {
            pro_role = new P2Warrior();
            if (SceneCamera.m_nModelDetail_Level != 1)
            {
                (pro_role as P2Warrior).Init(name, EnumLayer.LM_DEFAULT, born_pt, false, p);
            }
            else
            {
                (pro_role as P2Warrior).Init(name, invisible ? EnumLayer.LM_ROLE_INVISIBLE : EnumLayer.LM_OTHERPLAYER, born_pt, false, p);
            }
        }
        else if (3 == type)
        {
            pro_role = new P3Mage();
            if (SceneCamera.m_nModelDetail_Level != 1)
            {
                (pro_role as P3Mage).Init(name, EnumLayer.LM_DEFAULT, born_pt, false, p);
            }
            else
            {
                (pro_role as P3Mage).Init(name, invisible ? EnumLayer.LM_ROLE_INVISIBLE : EnumLayer.LM_OTHERPLAYER, born_pt, false, p);
            }
        }
        else if (5 == type)
        {
            pro_role = new P5Assassin();
            if (SceneCamera.m_nModelDetail_Level != 1)
            {
                (pro_role as P5Assassin).Init(name, EnumLayer.LM_DEFAULT, born_pt, false, p);
            }
            else
            {
                (pro_role as P5Assassin).Init(name, invisible ? EnumLayer.LM_ROLE_INVISIBLE : EnumLayer.LM_OTHERPLAYER, born_pt, false, p);
            }
        }
        else
        {
            pro_role = new P3Mage();
            if (SceneCamera.m_nModelDetail_Level != 1)
            {
                (pro_role as P3Mage).Init(name, EnumLayer.LM_DEFAULT, born_pt, false, p);
            }
            else
            {
                (pro_role as P3Mage).Init(name, invisible ? EnumLayer.LM_ROLE_INVISIBLE : EnumLayer.LM_OTHERPLAYER, born_pt, false, p);
            }
        }

        pro_role.m_layer = invisible ? EnumLayer.LM_ROLE_INVISIBLE : EnumLayer.LM_OTHERPLAYER;

        if (GameRoomMgr.getInstance().curRoom == GameRoomMgr.getInstance().dRooms[3342] || GameRoomMgr.getInstance().curRoom == GameRoomMgr.getInstance().dRooms[3358])
        {//解决多层阻挡点寻路的问题
            pro_role.setNavLay(NavmeshUtils.allARE);
        }

        //暂时都是可以自由pk的
        pro_role.m_curModel.position = born_pt;
        if (p.ContainsKey("face"))
        {
            pro_role.m_curModel.rotation = new Quaternion(pro_role.m_curModel.rotation.x, p["face"], pro_role.m_curModel.rotation.z, 0);
        }
        if (p.ContainsKey("lvlsideid"))
        {
            if (lvlsideid != 0 && PlayerModel.getInstance().inSpost)
            {
                if (1 == lvlsideid)
                {
                    pro_role.refresNameColor_spost(SPOSTNAME_TYPE.RED);
                }
                else if (2 == lvlsideid)
                {
                    pro_role.refresNameColor_spost(SPOSTNAME_TYPE.BULE);
                }
            }
            else if (lvlsideid != 0 && PlayerModel.getInstance().inCityWar)
            {
                if (lvlsideid == PlayerModel.getInstance().lvlsideid)
                {
                    pro_role.refresNameColor_spost(SPOSTNAME_TYPE.BULE);
                }
                else
                {
                    pro_role.refresNameColor_spost(SPOSTNAME_TYPE.RED);
                }
            }
        }

        if (pro_role == null)
        {
            return;
        }

        m_mapOtherPlayer.Add(iid, pro_role);
        m_mapOtherPlayerUnsee.Add(iid, pro_role);
        if (GRMap.curSvrConf["id"] == 24)
        {
            pro_role.setPos(new Vector3(born_pt.x, born_pt.y, born_pt.z + 18f));
        }
        else
        {
            pro_role.setPos(born_pt);
        }
        pro_role.SetDestPos(born_pt);
        pro_role.m_unIID      = iid;
        pro_role.m_unCID      = cid;
        pro_role.m_unPK_Param = cid;
        pro_role.lvlsideid    = lvlsideid;
        pro_role.invisible    = invisible;

        pro_role.spost_lvlsideid = (int)lvlsideid;
        debug.Log("对方是" + lvlsideid);

        pro_role.speed = p["speed"]._int;

        pro_role.maxHp = p["battleAttrs"]["max_hp"];
        pro_role.curhp = p["hp"];
        if (p.ContainsKey("zhuan"))
        {
            pro_role.zhuan = p["zhuan"];
        }
        if (p.ContainsKey("pk_state"))
        {
            pro_role.Pk_state = p["pk_state"];
        }
        switch (pro_role.Pk_state)
        {
        case 0:
            pro_role.m_ePK_Type = PK_TYPE.PK_PEACE;
            break;

        case 1:
            pro_role.m_ePK_Type = PK_TYPE.PK_PKALL;
            break;

        case 2:
            pro_role.m_ePK_Type = PK_TYPE.PK_TEAM;
            break;

        case 3:
            pro_role.m_ePK_Type = PK_TYPE.PK_LEGION;
            break;

        case 4:
            pro_role.m_ePK_Type = PK_TYPE.PK_PEACE;
            break;

        case 5:
            pro_role.m_ePK_Type = PK_TYPE.Pk_SPOET;
            break;
        }
        ;
        if (p.ContainsKey("teamid"))
        {
            pro_role.m_unTeamID = p["teamid"];
            PlayerNameUIMgr.getInstance().refeshHpColor(pro_role);
        }
        if (p.ContainsKey("clanid"))
        {
            pro_role.m_unLegionID = p["clanid"];
        }
        if (p.ContainsKey("pet"))
        {
            pro_role.ChangePetAvatar(p["pet"]["id"], 0);
        }
        if (p.ContainsKey("treasure_num"))
        {
            pro_role.mapCount = p["treasure_num"];
            debug.Log("对方宝图" + p["treasure_num"]);
            pro_role.refreshmapCount(p["treasure_num"]);
        }
        if (p.ContainsKey("serial_kp"))
        {
            pro_role.serial = p["serial_kp"];
            pro_role.refreshserialCount(p["serial_kp"]);
        }
        if (p.ContainsKey("vip"))
        {
            pro_role.refreshVipLvl((uint)p["vip"]);
        }

        if (p.ContainsKey("strike_back_tm") && p["strike_back_tm"] > 0)
        {
            pro_role.havefanjibuff = true;
            //也会发78号,不做处理也显示正常zzz
            debug.Log("这个人身上有反击buff");
        }
        else
        {
            pro_role.havefanjibuff = false;
        }

        //if (GRMap.grmap_loading == false)
        //    pro_role.refreshViewType(1);

        //if (pro_role != null)
        //{
        //    PlayerData dta = new PlayerData();
        //    dta.roleId = iid;
        //    //dta.monid = type;
        //    pro_role.playerDta = dta;
        //}

        //idIdx++;

        //if (mon != null)
        //    dispatchEvent(GameEvent.Create(MonsterMgr.EVENT_MONSTER_ADD, this, mon));
    }
Пример #2
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");
    }
Пример #3
0
    public void AddOtherPlayer(Variant p)
    {
        bool loading = GRMap.loading;

        if (loading)
        {
            this.cacheProxy.Add(p);
        }
        else
        {
            uint @uint = p["iid"]._uint;
            bool flag  = this.m_mapOtherPlayer.ContainsKey(@uint);
            if (!flag)
            {
                uint num   = 0u;
                int  num2  = p["carr"];
                bool flag2 = p.ContainsKey("cid");
                if (flag2)
                {
                    num = p["cid"]._uint;
                }
                string         name   = p["name"];
                Vector3        vector = new Vector3(p["x"] / 53.333f, 0f, p["y"] / 53.333f);
                bool           flag3  = 2 == num2;
                ProfessionRole professionRole;
                if (flag3)
                {
                    professionRole = new P2Warrior();
                    (professionRole as P2Warrior).Init(name, EnumLayer.LM_OTHERPLAYER, vector, false);
                }
                else
                {
                    bool flag4 = 3 == num2;
                    if (flag4)
                    {
                        professionRole = new P3Mage();
                        (professionRole as P3Mage).Init(name, EnumLayer.LM_OTHERPLAYER, vector, false);
                    }
                    else
                    {
                        bool flag5 = 5 == num2;
                        if (flag5)
                        {
                            professionRole = new P5Assassin();
                            (professionRole as P5Assassin).Init(name, EnumLayer.LM_OTHERPLAYER, vector, false);
                        }
                        else
                        {
                            professionRole = new P3Mage();
                            (professionRole as P3Mage).Init(name, EnumLayer.LM_OTHERPLAYER, vector, false);
                        }
                    }
                }
                bool flag6 = GameRoomMgr.getInstance().curRoom == GameRoomMgr.getInstance().dRooms[3342u];
                if (flag6)
                {
                    professionRole.setNavLay(NavmeshUtils.allARE);
                }
                professionRole.m_curModel.position = vector;
                bool flag7 = p.ContainsKey("face");
                if (flag7)
                {
                    professionRole.m_curModel.rotation = new Quaternion(professionRole.m_curModel.rotation.x, p["face"], professionRole.m_curModel.rotation.z, 0f);
                }
                bool flag8 = professionRole == null;
                if (!flag8)
                {
                    this.m_mapOtherPlayer.Add(@uint, professionRole);
                    this.m_mapOtherPlayerUnsee.Add(@uint, professionRole);
                    professionRole.setPos(vector);
                    professionRole.SetDestPos(vector);
                    professionRole.m_unIID      = @uint;
                    professionRole.m_unCID      = num;
                    professionRole.m_unPK_Param = num;
                    professionRole.maxHp        = p["battleAttrs"]["max_hp"];
                    professionRole.curhp        = p["hp"];
                    bool flag9 = p.ContainsKey("zhuan");
                    if (flag9)
                    {
                        professionRole.zhuan = p["zhuan"];
                    }
                    bool flag10 = p.ContainsKey("pk_state");
                    if (flag10)
                    {
                        professionRole.Pk_state = p["pk_state"];
                    }
                    switch (professionRole.Pk_state)
                    {
                    case 0:
                        professionRole.m_ePK_Type = PK_TYPE.PK_PEACE;
                        break;

                    case 1:
                        professionRole.m_ePK_Type = PK_TYPE.PK_PKALL;
                        break;

                    case 2:
                        professionRole.m_ePK_Type = PK_TYPE.PK_TEAM;
                        break;

                    case 3:
                        professionRole.m_ePK_Type = PK_TYPE.PK_LEGION;
                        break;

                    case 4:
                        professionRole.m_ePK_Type = PK_TYPE.PK_PEACE;
                        break;
                    }
                    bool flag11 = p.ContainsKey("teamid");
                    if (flag11)
                    {
                        professionRole.m_unTeamID = p["teamid"];
                    }
                    bool flag12 = p.ContainsKey("clanid");
                    if (flag12)
                    {
                        professionRole.m_unLegionID = p["clanid"];
                    }
                    bool flag13 = p.ContainsKey("pet");
                    if (flag13)
                    {
                        professionRole.ChangePetAvatar(p["pet"]["id"], 0);
                    }
                    bool flag14 = p.ContainsKey("treasure_num");
                    if (flag14)
                    {
                        professionRole.mapCount = p["treasure_num"];
                        debug.Log("对方宝图" + p["treasure_num"]);
                        professionRole.refreshmapCount(p["treasure_num"]);
                    }
                    bool flag15 = p.ContainsKey("serial_kp");
                    if (flag15)
                    {
                        professionRole.serial = p["serial_kp"];
                        professionRole.refreshserialCount(p["serial_kp"]);
                    }
                    bool flag16 = p.ContainsKey("vip");
                    if (flag16)
                    {
                        professionRole.refreshVipLvl(p["vip"]);
                    }
                    bool flag17 = !GRMap.loading;
                    if (flag17)
                    {
                        professionRole.refreshViewType(1);
                    }
                }
            }
        }
    }