Example #1
0
    //-------------------------------------------------------------------------------------------------------

    /**
     * @brief 添加玩家(木偶)
     * @param strName 名称
     * @param nJob 职业
     * @param nSex 性别
     * @param propList 外观属性
     * @param bMainHost 是否是主角对象
     */
    public IPuppet AddPuppet(string strName, int nJob, int nSex, EntityViewProp[] propList, bool bMainHost = false)
    {
        EntityCreateData data = new EntityCreateData();

        data.ID      = ++m_uEntityID;
        data.strName = strName;

        int speed = 0;

        Client.IPlayer player = ClientGlobal.Instance().MainPlayer;
        if (player != null)
        {
            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.ViewList          = propList;

        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return(null);
        }

        IPuppet entity = es.CreateEntity(EntityType.EntityType_Puppet, data) as IPuppet;

        if (entity == null)
        {
            Engine.Utility.Log.Error("AddEntity:创建家园对象失败!");
            return(null);
        }

        if (bMainHost)
        {
            IControllerSystem cs = ClientGlobal.Instance().GetControllerSystem();
            if (cs == null)
            {
                return(null);
            }

            cs.GetActiveCtrl().SetHost(entity);
            CameraFollow.Instance.target = entity;
        }

        m_dicPuppet.Add((int)entity.GetID(), entity);

        return(entity);
    }
Example #2
0
        private void GetService(string pid)
        {
            string puppetURL;

            lock (_puppetAddresses) {
                puppetURL = _puppetAddresses[pid];
            }
            IPuppet puppetSlave = (IPuppet)Activator.GetObject(typeof(IPuppet), puppetURL);

            lock (_puppetServices) {
                _puppetServices[pid] = puppetSlave;
            }
        }
        public void BindPuppet(IPuppet value)
        {
            if (mPuppet != value)
            {
                if (mPuppet != null)
                {
                    OnPuppetUnbind(mPuppet);
                    mPuppet.Controller = null;
                }

                mPuppet            = value;
                mPuppet.Controller = this;
                OnPuppetBind(value);
            }
        }
Example #4
0
    public void RemoveEntity(IPuppet puppet)
    {
        if (puppet == null)
        {
            return;
        }
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            return;
        }

        m_dicPuppet.Remove((int)puppet.GetID());
        es.RemoveEntity(puppet);
    }
Example #5
0
    void CreatePlayer()
    {
        IPlayer player = ClientGlobal.Instance().MainPlayer;

        if (player != null)
        {
            int job   = player.GetProp((int)PlayerProp.Job);
            int sex   = player.GetProp((int)PlayerProp.Sex);
            int index = 0;
            EntityViewProp[] propList = new EntityViewProp[(int)Client.EquipPos.EquipPos_Max];
            propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Body, 0);
            propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Weapon, (int)0);
            //propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Wing, (int)0);

            mainPlayer = HomeScene.Instance.AddPuppet(player.GetName(), job, sex, propList, true);
            if (mainPlayer != null && HomePlayerPos.Count == 2)
            {
                mainPlayer.SendMessage(EntityMessage.EntityCommand_SetPos, new Vector3(HomePlayerPos[0], 0f, -HomePlayerPos[1]));
            }
        }
    }
 protected virtual void OnPuppetUnbind(IPuppet puppet)
 {
 }