Ejemplo n.º 1
0
    //-------------------------------------------------------------------------------------------------------

    /**
     * @brief 构建Box属性列表
     * @param
     */
    private static void BuildBoxPropList(t_MapObjectData data, ref EntityAttr[] propList)
    {
        if (propList.Length < 0 || propList.Length > (int)BoxProp.End - (int)EntityProp.Begin)
        {
            Engine.Utility.Log.Error("BuildPlayerPropList:属性列表长度非法");
            return;
        }

        int index = 0;

        propList[index++] = new EntityAttr((int)EntityProp.BaseID, (int)data.dwObjectID); // 玩家没有模板ID 0则使用默认数据 需要根据职业和性别来获取 需要读取配置表
        propList[index++] = new EntityAttr((int)BoxProp.Number, (int)data.wdNumber);
        propList[index++] = new EntityAttr((int)BoxProp.OwnerType, (int)data.byOwnerType);
        //propList[index++] = new EntityAttr((int)BoxProp.Owner, (int)data.dwOwner);

        //氏族ID分为两个存
        uint owner     = data.dwOwner;
        int  ownerLow  = (int)(owner & 0x0000ffff);
        int  ownerHigh = (int)(owner >> 16);

        propList[index++] = new EntityAttr((int)BoxProp.OwnerLow, ownerLow);
        propList[index++] = new EntityAttr((int)BoxProp.OwnerHigh, ownerHigh);

        uint low      = (uint)ownerLow;
        uint high     = (uint)ownerHigh;
        uint newhigh  = high << 16;
        uint newOwner = newhigh | low;

        Engine.Utility.Log.Error("--->>> 服务器owner:" + data.dwOwner);
        Engine.Utility.Log.Error("--->>> 客户端owner:" + newOwner);
    }
Ejemplo n.º 2
0
    //-------------------------------------------------------------------------------------------------------

    /**
     * @brief 构建实体创建数据
     * @param type 实体类型
     * @param data 服务器数据
     */
    public static EntityCreateData BuildCreateEntityData(EntityType type, t_MapObjectData data)
    {
        EntityCreateData entityData = new EntityCreateData();

        // 构建EntityCreateData
        entityData.ID      = data.qwThisID;
        entityData.strName = "";

        switch (type)
        {
        case EntityType.EntityType_Box:
        {
            entityData.PropList = new EntityAttr[(int)BoxProp.End - (int)EntityProp.Begin];
            BuildBoxPropList(data, ref entityData.PropList);
            break;
        }
        }

        return(entityData);
    }
Ejemplo n.º 3
0
        public IBox AddBox(t_MapObjectData BoxData, uint nlefttime)
        {
            if (BoxData == null)
            {
                return(null);
            }
            //Engine.Utility.Log.Info("创建box{0}", BoxData.dwObjectID);
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

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

//            if (es.FindBox(BoxData.qwThisID) == null)
            {
                //AddPetEntity(petdata);
                // 创建box
                //MapVector2 mapPos = MapVector2.FromCoordinate(BoxData.x, BoxData.y);
                Vector3 pos = new Vector3(BoxData.cur_pos.x * 0.01f, 0, -BoxData.cur_pos.y * 0.01f); // 服务器到客户端坐标转换

                EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_Box, BoxData);
                IBox             box  = es.FindBox(BoxData.qwThisID);
                if (box != null)
                {
                    box.UpdateProp(data);
                }
                else
                {
                    box = es.CreateEntity(EntityType.EntityType_Box, data, true) as IBox;
                }

                box.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
                box.AddTrigger(new BoxOnTrigger());
                return(box);
            }
            return(null);
        }