/// <summary>
    /// 携程-加载模型
    /// </summary>
    /// <param name="modelInfo"></param>
    /// <param name="userModelData"></param>
    /// <param name="action"></param>
    /// <returns></returns>
    public IEnumerator CoroutineForLoadModel(ModelInfoBean modelInfo, UserModelDataBean userModelData, Action action)
    {
        //读取模型
        ResourceRequest resourceRequest = Resources.LoadAsync("Model/" + modelInfo.model_name);

        yield return(resourceRequest);

        GameObject objModelTemp = resourceRequest.asset as GameObject;

        //移除场景中的模型
        CptUtil.RemoveChildsByActive(gameObject);
        //创建模型
        GameObject objModel = Instantiate(gameObject, objModelTemp);

        //初始化模型位置
        objModel.transform.position = Vector3.zero;
        //添加模型控件
        GameModelCpt gameModel = CptUtil.AddCpt <GameModelCpt>(objModel);

        gameModel.SetData(userModelData, modelInfo);
        //设置加载的模型
        currentLoadModel = gameModel;
        action?.Invoke();
        Resources.UnloadUnusedAssets();
    }
Beispiel #2
0
    public void SetData(UserModelDataBean userModelData, ModelInfoBean modelInfo)
    {
        if (modelInfo == null)
        {
            return;
        }
        if (userModelData == null)
        {
            return;
        }
        dissolveAmountId = Shader.PropertyToID(m_DissolveAmount);
        mapMaterialForModel.Clear();
        Texture textureDisolveGuide = Resources.Load("Texture/noise_1") as Texture;

        if (!CheckUtil.ListIsNull(modelInfo.listPartData))
        {
            for (int i = 0; i < modelInfo.listPartData.Count; i++)
            {
                ModelPartInfoBean partInfo     = modelInfo.listPartData[i];
                Renderer          itemRenderer = CptUtil.GetCptInChildrenByName <Renderer>(gameObject, partInfo.part_name);
                //获取所有的Material
                List <Material> listMaterial = new List <Material>();
                itemRenderer.GetMaterials(listMaterial);
                //获取用户进度
                UserModelPartDataBean userModelPartData = userModelData.GetUserPartDataById(partInfo.id);
                float pro = 0;
                if (userModelPartData != null)
                {
                    pro = userModelPartData.GetProgress(partInfo.max_level);
                }
                //重新设置所有的shader
                foreach (Material itemMaterial in listMaterial)
                {
                    Texture itemTexture = itemMaterial.GetTexture("_MainTex");
                    if (itemTexture)
                    {
                        itemMaterial.shader = Shader.Find("ASESampleShaders/Community/DissolveBurnWithFire");
                        itemMaterial.SetTexture("_Albedo", itemTexture);
                        itemMaterial.SetTexture("_Normal", itemTexture);
                        itemMaterial.SetTexture("_BurnRamp", itemTexture);
                        itemMaterial.SetFloat("_MaskClipValue", 0.5f);
                    }
                    else
                    {
                        Color color = itemMaterial.GetColor("_Color");
                        itemMaterial.shader = Shader.Find("ASESampleShaders/Community/DissolveBurn_01");
                        itemMaterial.SetFloat("_Cutoff", 0.5f);
                        itemMaterial.SetColor("_MainColor", color);
                    }
                    itemMaterial.SetTexture("_DisolveGuide", textureDisolveGuide);
                    itemMaterial.SetFloat(dissolveAmountId, 1 - pro);
                }
                if (!mapMaterialForModel.ContainsKey(partInfo.part_name))
                {
                    mapMaterialForModel.Add(partInfo.part_name, listMaterial);
                }
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 加载模型
    /// </summary>
    /// <param name="userModelData"></param>
    public void LoadModel(UserModelDataBean userModelData, Action action)
    {
        Action <ModelInfoBean> callBack = (data) =>
        {
            //加载模型
            manager.StartCoroutine(manager.CoroutineForLoadModel(data, userModelData, action));
        };

        GetModelInfoById(userModelData.modelId, callBack);
    }
 /// <summary>
 /// 设置显示模型
 /// </summary>
 /// <param name="userModelData"></param>
 public void SetFirstUnlockModel(UserModelDataBean userModelData)
 {
     if (listUnlockModel == null)
     {
         listUnlockModel = new List <UserModelDataBean>();
     }
     if (listUnlockModel.Contains(userModelData))
     {
         listUnlockModel.Remove(userModelData);
     }
     listUnlockModel.Insert(0, userModelData);
 }
 /// <summary>
 /// 检测是否有模型
 /// </summary>
 /// <param name="modelId"></param>
 /// <returns></returns>
 public bool CheckHasModel(long modelId, out UserModelDataBean userModelData)
 {
     userModelData = null;
     for (int i = 0; i < listUnlockModel.Count; i++)
     {
         UserModelDataBean itemModelData = listUnlockModel[i];
         if (modelId == itemModelData.modelId)
         {
             userModelData = itemModelData;
             return(true);
         }
     }
     return(false);
 }
Beispiel #6
0
    public void InitData()
    {
        //打开UI
        manager_UI.OpenUI(UIEnum.GameMain);
        //加载模型
        UserModelDataBean userModelData = handler_GameData.GetUserData().GetFirstUnlockModel();

        if (userModelData != null)
        {
            handler_GameModel.LoadModel(userModelData, null);
        }
        else
        {
        }
    }
    /// <summary>
    /// 增加已解锁模型
    /// </summary>
    /// <param name="modelId"></param>
    public UserModelDataBean AddUnLockModel(long modelId)
    {
        if (listUnlockModel == null)
        {
            listUnlockModel = new List <UserModelDataBean>();
        }
        bool hasData = CheckHasModel(modelId, out UserModelDataBean userModelData);

        if (hasData)
        {
            return(userModelData);
        }
        else
        {
            UserModelDataBean modelData = new UserModelDataBean(modelId);
            listUnlockModel.Add(modelData);
            return(modelData);
        }
    }
    public void InitData()
    {
        UserDataBean userData = uiComponent.handler_GameData.GetUserData();

        userModelData = userData.GetFirstUnlockModel();
        if (userModelData == null)
        {
            ui_List.SetCellCount(0);
            ui_List.RefreshAllCells();
            return;
        }

        Action <ModelInfoBean> callBack = (data) =>
        {
            listPartInfoData = data.listPartData;
            ui_List.SetCellCount(listPartInfoData.Count);
            ui_List.RefreshAllCells();
        };

        uiComponent.handler_GameModel.GetModelInfoById(userModelData.modelId, callBack);
    }
Beispiel #9
0
    /// <summary>
    /// 点击解锁
    /// </summary>
    public void OnClickForUnlock()
    {
        UserDataBean userData = uiComponent.handler_GameData.GetUserData();
        bool         isPay    = userData.PayMoney(modelInfo.unlock_money);

        if (isPay)
        {
            //添加解锁数据
            UserModelDataBean userModelData = userData.AddUnLockModel(modelInfo.id);
            //设置为当前显示
            userData.SetFirstUnlockModel(userModelData);
            Action action = () =>
            {
                //uiComponent.handler_GameModel.SetPartProgress("Cube", 0f);
            };
            //加载模型
            uiComponent.handler_GameModel.LoadModel(userModelData, action);
        }
        else
        {
            LogUtil.Log("支付失败,没有足够的金钱");
        }
    }
    public IEnumerator CoroutineForGameDataChange()
    {
        while (gameObject)
        {
            yield return(new WaitForSeconds(1));

            UserDataBean userData = GetUserData();
            if (!CheckUtil.ListIsNull(userData.listUnlockModel))
            {
                for (int i = 0; i < userData.listUnlockModel.Count; i++)
                {
                    UserModelDataBean itemModelData = userData.listUnlockModel[i];
                    if (!CheckUtil.ListIsNull(itemModelData.listUnlockPart))
                    {
                        for (int f = 0; f < itemModelData.listUnlockPart.Count; f++)
                        {
                            UserModelPartDataBean itemModelPartData = itemModelData.listUnlockPart[f];
                            userData.AddUserMoney(itemModelPartData.addPrice);
                        }
                    }
                }
            }
        }
    }
Beispiel #11
0
 public void SetData(ModelPartInfoBean modelPartInfo, UserModelDataBean userModelData)
 {
     this.modelPartInfo = modelPartInfo;
     this.userModelData = userModelData;
     SetName(modelPartInfo.name);
 }
 public void SetData(UserModelDataBean userModelData, ModelInfoBean modelInfo)
 {
     gameModelProgress.SetData(userModelData, modelInfo);
 }