Ejemplo n.º 1
0
    /// <summary>
    /// 点击-升级
    /// </summary>
    public void OnClickForLevel()
    {
        UserDataBean          userData          = uiComponent.handler_GameData.GetUserData();
        UserModelPartDataBean userModelPartData = userModelData.GetUserPartDataById(modelPartInfo.id);

        if (userModelPartData == null)
        {
            return;
        }
        long levelMoney = modelPartInfo.GetLevelUpMoney(userModelPartData.level);
        bool isPay      = userData.PayMoney(levelMoney);

        if (isPay)
        {
            //升级
            int level = userModelPartData.LevelUp(1);
            //计算收益
            long addPrice = modelPartInfo.GetAddPrice(level);
            //增加收益
            userModelPartData.SetAddPrice(addPrice);
            //设置舰船显示进度
            uiComponent.handler_GameModel.SetPartProgress(modelPartInfo.part_name, userModelPartData.GetProgress(modelPartInfo.max_level));
        }
        else
        {
            LogUtil.Log("升级失败,没有足够的金钱");
        }
    }
Ejemplo n.º 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);
                }
            }
        }
    }