Example #1
0
    public void Release()
    {
        Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
        if (rs == null)
        {
            Engine.Utility.Log.Error("获取RenderSystem失败!");
            return;
        }


        if (m_PuppetObj != null)
        {
            ClientGlobal.Instance().GetEntitySystem().RemoveEntity(m_PuppetObj);
            m_PuppetObj = null;
            m_RenderObj = null;
        }
        if (m_RenderObj != null)
        {
            rs.RemoveRenderObj(m_RenderObj);
        }

        if (m_Camera != null)
        {
            GameObject.DestroyImmediate(m_Camera);
        }
        if (m_RenderText != null)
        {
            m_RenderText.Release();
            GameObject.DestroyImmediate(m_RenderText);
            m_RenderText = null;
        }


        if (m_Root != null)
        {
            GameObject.DestroyImmediate(m_Root);
            m_Root = null;
        }
    }
Example #2
0
    public bool Create(List <GameCmd.SuitData> lstSuit, int nJob, int nSex, int nSize, GameObject parentObj, SkillSettingState eState = SkillSettingState.StateOne)
    {
        Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
        if (rs == null)
        {
            Engine.Utility.Log.Error("获取RenderSystem失败!");
            return(false);
        }

        // 对象创建
        if (m_Root == null)
        {
            m_Root = new GameObject("RTObj");
            if (parentObj != null)
            {
                m_Root.transform.parent = parentObj.transform;
            }
        }

        //
        m_RenderObj = null;

        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            return(false);
        }

        Client.EntityCreateData data = new Client.EntityCreateData();
        data.ID      = ++s_uPuppetID;
        data.strName = "";

        //int speed = player.GetProp((int)WorldObjProp.MoveSpeed);
        data.PropList = new EntityAttr[(int)PuppetProp.End - (int)EntityProp.Begin];
        int index = 0;

        data.PropList[index++] = new EntityAttr((int)PuppetProp.Job, nJob);
        data.PropList[index++] = new EntityAttr((int)PuppetProp.Sex, nSex);
        //data.PropList[index++] = new EntityAttr((int)EntityProp.BaseID, 0);
        //data.PropList[index++] = new EntityAttr((int)WorldObjProp.MoveSpeed, speed);
        data.eSkillState = eState;
        data.bViewModel  = true;
        // 处理时装外观数据
        EntityViewProp[] propList = new EntityViewProp[(int)Client.EquipPos.EquipPos_Max];
        index             = 0;
        propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Body, 0);
        propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Weapon, 0);

        if (lstSuit.Count > 0)
        {
            for (int i = 0; i < lstSuit.Count; ++i)
            {
                if (lstSuit[i] == null)
                {
                    continue;
                }

                int pos = GetPropPos((Client.EquipPos)lstSuit[i].suit_type, propList);
                if (pos >= 0)
                {
                    propList[pos] = new EntityViewProp((int)lstSuit[i].suit_type, (int)lstSuit[i].baseid);
                }
                else
                {
                    Client.EquipPos equipPos = (Client.EquipPos)lstSuit[i].suit_type;
                    propList[index++] = new EntityViewProp((int)equipPos, (int)lstSuit[i].baseid);
                }
            }
        }

        data.ViewList = propList;
        data.nLayer   = LayerMask.NameToLayer("ShowModel");

        m_PuppetObj = es.CreateEntity(Client.EntityType.EntityType_Puppet, data, true) as Client.IPuppet;
        if (m_PuppetObj == null)
        {
            Engine.Utility.Log.Error("创建Renderobj失败{0}!", "");
            return(false);
        }

        m_RenderObj = m_PuppetObj.renderObj;
        if (m_RenderObj == null)
        {
            return(false);
        }

        // 默认播放站立动作
        m_RenderObj.Play(Client.EntityAction.Stand);
        m_RenderObj.SetLayer((int)Engine.RenderLayer.ShowModel); // showModel

        // CreateCamera
        Camera cam = CreateCamera();

        m_RenderText = new RenderTexture(nSize, nSize, 24, RenderTextureFormat.ARGB32);
        if (m_RenderText == null)
        {
            return(false);
        }
        cam.targetTexture = m_RenderText;

        // 对象挂在父节点上
        if (m_Root != null)
        {
            m_RenderObj.GetNode().GetTransForm().parent = m_Root.transform;
            m_Camera.transform.parent = m_Root.transform;
        }

        return(true);
    }