示例#1
0
    public MonsterRole AddSummon(Variant m)
    {
        this.init();
        bool        loading = GRMap.loading;
        MonsterRole result;

        if (loading)
        {
            this.cacheProxy.Add(m);
            result = null;
        }
        else
        {
            Vector3 pos  = new Vector3(m["x"] / 53.333f, 0f, m["y"] / 53.333f);
            int     num  = m["mid"];
            uint    num2 = m["iid"];
            bool    flag = this.m_mapMonster.ContainsKey(num2);
            if (flag)
            {
                this.RemoveMonster(num2);
            }
            SXML   sXML    = this.dMon[num];
            int    num3    = sXML.getInt("obj");
            float  @float  = sXML.getFloat("scale");
            string @string = sXML.getString("name");
            bool   flag2   = num2 <= 0u;
            if (flag2)
            {
                bool flag3 = Globle.m_nTestMonsterID > 0;
                if (flag3)
                {
                    num3 = Globle.m_nTestMonsterID;
                }
            }
            MS0000 mS = new MS0000();
            mS.tempXMl = sXML;
            mS.isBoos  = (sXML.getInt("boss") == 1);
            bool flag4 = @float > 0f;
            if (flag4)
            {
                mS.scale = @float;
            }
            bool flag5 = mS != null;
            if (flag5)
            {
                mS.Init("monster/" + num3, EnumLayer.LM_MONSTER, pos, 0f);
                PlayerNameUIMgr.getInstance().show(mS);
                PlayerNameUIMgr.getInstance().setName(mS, @string, m["owner_name"] + "的小伙伴");
                mS.roleName  = @string;
                mS.monsterid = num;
                bool flag6 = num2 > 0u;
                if (flag6)
                {
                    mS.m_unIID = num2;
                    this.m_mapMonster.Add(num2, mS);
                }
                else
                {
                    mS.isfake  = true;
                    mS.m_unIID = this.idIdx;
                    this.m_mapFakeMonster.Add(this.idIdx, mS);
                    this.idIdx += 1u;
                }
                bool flag7 = !GRMap.loading;
                if (flag7)
                {
                    mS.refreshViewType(2);
                }
                mS.issummon = true;
                mS.summonid = num;
                mS.masterid = m["owner_cid"];
                bool flag8 = mS.masterid == ModelBase <PlayerModel> .getInstance().cid;

                if (flag8)
                {
                    bool flag9 = a3_herohead.instance;
                    if (flag9)
                    {
                        ModelBase <A3_SummonModel> .getInstance().lastatkID = 0u;

                        a3_herohead.instance.refresh_sumHp(m["hp"], m["battleAttrs"]["max_hp"]);
                        a3_herohead.instance.refresh_sumbar();
                        a3_herohead.instance.do_sum_CD = false;
                    }
                }
            }
            this.m_listMonster.Add(mS);
            bool flag10 = mS != null;
            if (flag10)
            {
                base.dispatchEvent(GameEvent.Create(MonsterMgr.EVENT_MONSTER_ADD, this, mS, false));
            }
            bool flag11 = mS != null;
            if (flag11)
            {
                mS.curhp     = m["hp"];
                mS.maxHp     = m["battleAttrs"]["max_hp"];
                mS.owner_cid = m["owner_cid"];
            }
            result = mS;
        }
        return(result);
    }
    public MonsterRole AddSummon(Variant m)
    {
        init();
        if (GRMap.grmap_loading)
        {
            cacheProxy.Add(m);
            return(null);
        }

        Vector3 born_pt  = new Vector3(m["x"] / GameConstant.PIXEL_TRANS_UNITYPOS, 0f, m["y"] / GameConstant.PIXEL_TRANS_UNITYPOS);
        int     id       = m["mid"];
        uint    serverid = m["iid"];

        if (m_mapMonster.ContainsKey(serverid))
        {
            if (m["owner_cid"] == PlayerModel.getInstance().cid)
            {
                if (a3_herohead.instance)
                {
                    A3_SummonModel.getInstance().lastatkID = 0;
                    a3_herohead.instance.refresh_sumHp(m["hp"], m["battleAttrs"]["max_hp"]);
                    a3_herohead.instance.refresh_sumbar();
                    a3_herohead.instance.do_sum_CD = false;
                }
            }
            return(m_mapMonster[serverid]);
        }

        //return null;

        SXML   xml    = dMon[id];
        int    tempid = xml.getInt("obj");
        float  scale  = xml.getFloat("scale");
        string name   = xml.getString("name");

        if (serverid <= 0)
        {
            if (Globle.m_nTestMonsterID > 0)
            {
                tempid = Globle.m_nTestMonsterID;
            }
        }

        MS0000 mon = new MS0000();

        mon.tempXMl = xml;

        mon.isBoos   = xml.getInt("boss") == 1;
        mon.isBoss_c = xml.getInt("boss_c") == 1;
        if (scale > 0f)
        {
            mon.scale = scale;
        }

        if (mon != null)
        {
            if (serverid > 0)
            {
                mon.m_unIID = serverid;
                m_mapMonster.Add(serverid, mon);
                roleSummonMapping[m["owner_cid"]] = serverid;       // 人物对应的召唤兽 id
            }
            else
            {
                mon.isfake  = true;
                mon.m_unIID = idIdx;
                m_mapFakeMonster.Add(idIdx, mon);
                idIdx++;
            }

            mon.masterid = m["owner_cid"];
            mon.issummon = true;
            mon.summonid = id;

            if (SceneCamera.m_nModelDetail_Level != 1 && mon.masterid != PlayerModel.getInstance().cid)
            {//设置隐藏召唤兽
                mon.Init("monster_" + tempid, EnumLayer.LM_DEFAULT, born_pt, 0);
            }
            else
            {
                mon.Init("monster_" + tempid, EnumLayer.LM_MONSTER, born_pt, 0);
            }
            mon.m_layer = EnumLayer.LM_MONSTER;

            PlayerNameUIMgr.getInstance().show(mon);
            PlayerNameUIMgr.getInstance().setName(mon, name, m["owner_name"] + ContMgr.getCont("MonsterMgr"));
            mon.roleName  = name;
            mon.monsterid = id;

            //if (GRMap.grmap_loading == false)
            //    mon.refreshViewType(2);


            //mon.master = RoleMgr._instance.getRole(m["owner_cid"]);

            if (mon.masterid == PlayerModel.getInstance().cid)
            {
                if (a3_herohead.instance)
                {
                    A3_SummonModel.getInstance().lastatkID = 0;
                    a3_herohead.instance.refresh_sumHp(m["hp"], m["battleAttrs"]["max_hp"]);
                    a3_herohead.instance.refresh_sumbar();
                    a3_herohead.instance.do_sum_CD = false;
                }
            }
        }
        m_listMonster.Add(mon);

        if (mon != null)
        {
            dispatchEvent(GameEvent.Create(MonsterMgr.EVENT_MONSTER_ADD, this, mon));
        }

        if (mon != null)
        {
            mon.curhp     = m["hp"];
            mon.maxHp     = m["battleAttrs"]["max_hp"];
            mon.owner_cid = m["owner_cid"];
        }
        return(mon);
    }