/// <summary> /// 判断动物购买是否可以升级(钱够/等级不超过最大值) 等级判断没做 /// </summary> /// <returns></returns> private bool SetBuyAnimalGradeBool(int animalID) { if (LittleZooModule.GetAnimalUpLevelPriceFormula(animalID) <= playerData.playerZoo.diamond) { return(true); } return(false); }
private void InitData() { littleZooID = int.Parse(m_data.ToString()); playerStar = GlobalDataManager.GetInstance().playerData.playerZoo.star; needStar = LittleZooModule.AddNewlittleZooCoin(littleZooID); //LogWarp.Log("UIBuildOpenPage 测试:需要开启的 当前动物栏ID"+littleZooID+" 需要花费多少钱:"+needCoin+" 现有财产"+coinval); this.InitCompent(); }
/// <summary> /// 动物升级消息 /// </summary> private void SendSetAnimalLevelMessageManager(int animalID) { if (animalMSS15.GetAnimalProp(animalID).lv >= animalLvUpLimit) { return; } SetBuyAnimalObjectData.Send((int)GameMessageDefine.SetAnimalLevel, 1, animalID, 1, 0, LittleZooModule.GetAnimalUpLevelPriceFormula(animalID), nameID); }
/// <summary> /// 初始化属性数值 切换动物栏ID时候需要调用 /// </summary> private void InitData() { if (m_data == null) { this.Hide(); return; } nameID = int.Parse(m_data.ToString()); buildUpCell = Config.buildupConfig.getInstace().getCell(m_data.ToString()); animalLvUpLimit = Config.globalConfig.getInstace().AnimalLvUpLimit; pricebase = BigInteger.Parse(buildUpCell.pricebase); animalMSS15 = GlobalDataManager.GetInstance().playerData.playerZoo.animalMSS15; littleZooName = Config.translateConfig.getInstace().getCell(buildUpCell.buildname);//根据动物栏的名字ID去语言表获取动物栏的中文显示 littleZooTicketsLevel = GlobalDataManager.GetInstance().playerData.GetLittleZooModuleData(nameID).littleZooTicketsLevel; littleZooVisitorSeatLevel = GlobalDataManager.GetInstance().playerData.GetLittleZooModuleData(nameID).littleZooVisitorSeatLevel; littleZooEnterVisitorSpawnLevel = GlobalDataManager.GetInstance().playerData.GetLittleZooModuleData(nameID).littleZooEnterVisitorSpawnLevel; coinVal = playerData.playerZoo.playerCoin.GetCoinByScene(playerData.playerZoo.currSceneID).coinBigInt; //获取玩家现有金币 ticketsLevelConsumeCoins = LittleZooModule.GetUpGradeConsumption(nameID, littleZooTicketsLevel + 1); //动物栏下一级需要的金钱 visitorSeatLevelConsumeCoins = LittleZooModule.GetUpGradeVisitorLocationLevelConsumption(nameID, littleZooVisitorSeatLevel + 1); //动物栏下一级需要的金钱 EnterVisitorSpawnLevelConsumeCoins = LittleZooModule.GetUpGradeEnterVisitorSpawnLevelConsumption(nameID, littleZooEnterVisitorSpawnLevel + 1); //动物栏下一级需要的金钱 int idx = PlayerDataModule.FindLevelRangIndex(buildUpCell.lvshage, littleZooTicketsLevel); maxGrade = buildUpCell.lvshage[idx]; oldMaxGrade = buildUpCell.lvshage[idx - 1]; TicketsMaxGrade = Config.buildupConfig.getInstace().getCell(nameID).lvmax; if (TicketsMaxGrade == 0) { TicketsMaxGrade = 1; } VisitorSeatMaxGrade = Config.buildupConfig.getInstace().getCell(nameID).watchmaxlv; EnterVisitorSpawnMaxGrade = Config.buildupConfig.getInstace().getCell(nameID).itemmaxlv; starLevelReached = PlayerDataModule.FindLevelRangIndex01(Config.buildupConfig.getInstace().getCell(nameID).lvshage, littleZooTicketsLevel); if (littleZooTicketsLevel >= TicketsMaxGrade) { starLevelReached = PlayerDataModule.FindLevelRangIndex01(Config.buildupConfig.getInstace().getCell(nameID).lvshage, littleZooTicketsLevel); } if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true) { zooCultivateButton.enabled = false; zooKindButton.enabled = false; } else { zooCultivateButton.enabled = true; zooKindButton.enabled = true; } var array = buildUpCell.animalid; animalCellID.Clear(); animalCellID = array.OfType <int>().ToList(); }
public void ExportToCSHARP() { string csharpFile = "///本代码由动物栏 位置编辑器 自动生成, 请勿手动修改! by : Fan Zheng Yong\r\n" + "using System.Collections.Generic;\r\n" + "using UFrame.Common;\r\n" + "using UnityEngine;\r\n" + "namespace Game\r\n" + "{\r\n" + " public partial class LittleZooPosManager : Singleton<LittleZooPosManager>, ISingleton\r\n" + " {\r\n" + " public void $AddFunc$()\r\n" + " {\r\n"; int littleZooNum = littleZooPos.transform.childCount; for (int i = 0; i < littleZooNum; i++) { var littleZooNode = littleZooPos.transform.GetChild(i); //动物栏ID int mapLittleZooID = int.Parse(littleZooNode.name); mapLittleZooID = LittleZooModule.MapToFirstSceneLittleZooID(mapLittleZooID); string littleZooID = "littleZoo_" + mapLittleZooID.ToString(); //声明 Debug.Log(littleZooNode.position); string littleZooST = string.Format("\r\n var {0} = new Vector3({1}f, {2}f, {3}f);\r\n", littleZooID, littleZooNode.position.x, littleZooNode.position.y, littleZooNode.position.z); csharpFile += littleZooST; string addToMap = string.Format(" posMap.Add({0}, {1});\r\n", mapLittleZooID.ToString(), littleZooID); csharpFile += addToMap; } csharpFile += " }\r\n"; csharpFile += " }\r\n"; csharpFile += "}\r\n"; FileUtil.CreateDir("./EditorConfig", true); string fileName = "LittleZooPosManager_Style_Ten_LittleZoo.cs"; if (littleZooNum == 9) { fileName = "LittleZooPosManager_Style_Nine_LittleZoo.cs"; csharpFile = csharpFile.Replace("$AddFunc$", "Add_Style_Nine_LittleZoo"); } else { csharpFile = csharpFile.Replace("$AddFunc$", "Add_Style_Ten_LittleZoo"); } //string filepath = "./EditorConfig/LittleZooPosManager_AddAll.cs"; string filepath = string.Format("./EditorConfig/{0}", fileName); File.WriteAllText(filepath, csharpFile, Encoding.UTF8); AssetDatabase.Refresh(); UnityEditor.EditorApplication.isPlaying = false; }
/// <summary> /// 控件显示赋值 /// </summary> private void InitCompent() { needNumText.text = needStar.ToString(); if (needStar > playerStar) { SwitchButtonUnClickable(advertPalyButton, false); } else { SwitchButtonUnClickable(advertPalyButton, true); } //LogWarp.LogErrorFormat("测试: 动物栏={0},收益={1} ",littleZooID,LittleZooModule.GetlittleZooShowExpenditure(littleZooID, 1)); rewardText.text = MinerBigInt.ToDisplay(LittleZooModule.GetlittleZooShowExpenditure(littleZooID, 1)) + GetL10NString("Ui_Text_67"); string path = Config.buildupConfig.getInstace().getCell(littleZooID).icon; touristIcon.sprite = ResourceManager.LoadSpriteFromPrefab(path); }
private void InitCompentCultivate() { if (m_data == null) { return; } bool isShowAnimalCultivate = GlobalDataManager.GetInstance().playerData.playerZoo.isShowAnimalCultivate; tipsText.text = GetL10NString("Ui_Text_61"); int childCount = animalGroup.transform.childCount; animalCellList.Add(animal_1); for (int i = 0; i < childCount; i++) { int animalID = buildUpCell.animalid[i]; animalCellID[i] = animalID; Text nameText = animalCellList[i].transform.Find("NameText").GetComponent <Text>(); nameText.text = GetL10NString(Config.animalupConfig.getInstace().getCell(animalID).nametranslate); Image iconImage = animalCellList[i].transform.Find("Icon").GetComponent <Image>(); string iconPath = Config.animalupConfig.getInstace().getCell(animalID).icon; iconImage.sprite = ResourceManager.LoadSpriteFromPrefab(iconPath); //动物等级 int zooLevel = 0; Text NameText = animalCellList[i].transform.Find("LvBg/LvNum").GetComponent <Text>(); if (animalMSS15.GetAnimalProp(animalID) != null) { zooLevel = animalMSS15.GetAnimalProp(animalID).lv; } NameText.text = zooLevel.ToString(); //提示文本 Text AnimalNumber = animalCellList[i].transform.Find("AnimalNumber").GetComponent <Text>(); AnimalNumber.text = LittleZooModule.GetAnimalsBuff(animalID).ToString() + "%"; //购买、解锁按钮 Button buyButton = animalCellList[i].transform.Find("BuyButton").GetComponent <Button>(); ////小锁标识 Image lockIcon = animalCellList[i].transform.Find("LockIcon").GetComponent <Image>(); ////购买价格 if (buyButton == null) { string e = string.Format("紧急 注意: buyButton 为null"); throw new System.Exception(e); } Text buyText = buyButton.transform.Find("NumText").GetComponent <Text>(); Text tipsText = animalTransformData[animalID].transform.Find("TipsText").GetComponent <Text>(); tipsText.gameObject.SetActive(true); //解锁提示文本 Text openText = buyButton.transform.Find("OpenText").GetComponent <Text>(); Image goldImage = buyButton.transform.Find("Gold").GetComponent <Image>(); if (animalMSS15.GetAnimalProp(animalID) == null) { AnimalNumber.gameObject.SetActive(true); //Ui_Text_62 tipsText.text = string.Format(GetL10NString("Ui_Text_62"), buildUpCell.lvanimal[i], titleText.text); buyButton.gameObject.SetActive(false); lockIcon.gameObject.SetActive(true); int openScene = Config.animalupConfig.getInstace().getCell(animalID).openscene; if (openScene == playerData.playerZoo.currSceneID) { string str = GetL10NString("Ui_Text_62"); tipsText.text = string.Format(str, buildUpCell.lvanimal[i], titleText.text); } else { string str = GetL10NString("Ui_Text_125"); var sceneCell = Config.sceneConfig.getInstace().getCell(openScene); string str1 = string.Format(GetL10NString(sceneCell.scenename), sceneCell.sceneorder); tipsText.text = string.Format(str, str1); } } else if (animalMSS15.GetAnimalProp(animalID).lv > 0) { AnimalNumber.gameObject.SetActive(true); lockIcon.gameObject.SetActive(false); openText.gameObject.SetActive(false); buyText.text = LittleZooModule.GetAnimalUpLevelPriceFormula(animalID).ToString(); tipsText.gameObject.SetActive(false); buyButton.gameObject.SetActive(true); buyText.gameObject.SetActive(true); goldImage.gameObject.SetActive(true); if (LittleZooModule.GetAnimalUpLevelPriceFormula(animalID) <= playerData.playerZoo.diamond && zooLevel < animalLvUpLimit) { SwitchButtonUnClickable(buyButton, true); } else if (LittleZooModule.GetAnimalUpLevelPriceFormula(animalID) > playerData.playerZoo.diamond) { //buyText.color = Color.white; SwitchButtonUnClickable(buyButton, false); } if (zooLevel >= animalLvUpLimit) { openText.text = GetL10NString("Ui_Text_46"); openText.gameObject.SetActive(true); buyText.gameObject.SetActive(false); goldImage.gameObject.SetActive(false); AnimalNumber.gameObject.SetActive(true); buyButton.transform.Find("ButtonTipsText").GetComponent <Text>().gameObject.SetActive(false); SwitchButtonUnClickable(buyButton, false); } else { buyButton.transform.Find("ButtonTipsText").GetComponent <Text>().gameObject.SetActive(true); } //if (playerAnimal.getPlayerAnimalCell(animalID).animalLevel>0) //{ // tipsText.text = GetL10NString("Ui_Text_114"); //} //关于动物培养的显隐 if (isShowAnimalCultivate) { buyButton.gameObject.SetActive(true); } else { buyButton.gameObject.SetActive(false); } } } }
private void InitCompentZoo() { if (maxGrade > TicketsMaxGrade) { maxGrade = TicketsMaxGrade; } LVUpSlider.value = AddPercentage(littleZooTicketsLevel - oldMaxGrade, maxGrade - oldMaxGrade); lVUpSliderText.text = littleZooTicketsLevel.ToString() + "/" + maxGrade.ToString(); //最大等级上限 tipsText.text = GetL10NString("Ui_Text_8"); GradeSliderAwardImage(); if (littleZooTicketsLevel >= TicketsMaxGrade) { LVUpSlider.value = 1; lVUpSliderText.text = GetL10NString("Ui_Text_126"); //最大等级上限 tipsText.text = GetL10NString("Ui_Text_8"); GradeSliderAwardImage(); } //LVUpSlider.value = AddPercentage(littleZooTicketsLevel - oldMaxGrade, maxGrade - oldMaxGrade); //lVUpSliderText.text = littleZooTicketsLevel.ToString() + "/" + maxGrade.ToString(); //最大等级上限 //tipsText.text = GetL10NString("Ui_Text_8"); //GradeSliderAwardImage(); tickets_Text2.text = MinerBigInt.ToDisplay(LittleZooModule.GetLittleZooPrice(nameID, littleZooTicketsLevel, true).ToString());; //价格标签2 tickets_Text3.text = "+" + MinerBigInt.ToDisplay(LittleZooModule.GetLittleZooPrice(nameID, littleZooTicketsLevel, 1).ToString()); //价格标签3 tickets_LvText.text = littleZooTicketsLevel.ToString(); tickets_Button_NeedGoldText.text = MinerBigInt.ToDisplay(ticketsLevelConsumeCoins.ToString()); tickets_Button_buttonLvUpText.text = GetL10NString("Ui_Text_7"); visitorSeat_Text2.text = LittleZooModule.OpenVisitPosNumber(nameID, littleZooVisitorSeatLevel).ToString(); //数量标签2 visitorSeat_Text3.text = "+" + LittleZooModule.OpenVisitPosNumber(nameID, littleZooVisitorSeatLevel, 1).ToString(); //数量标签3 visitorSeat_Button_NeedGoldText.text = MinerBigInt.ToDisplay(visitorSeatLevelConsumeCoins.ToString()); visitorSeat_LvText.text = littleZooVisitorSeatLevel.ToString(); visitorSeat_Button_buttonLvUpText.text = GetL10NString("Ui_Text_7"); visitorSpawn_Text2.text = LittleZooModule.GetVisitDurationMS(nameID, littleZooEnterVisitorSpawnLevel).ToString("f2") + GetL10NString("Ui_Text_67"); //流量标签2 visitorSpawn_Text3.text = "+" + (LittleZooModule.GetVisitDurationMS(nameID, littleZooEnterVisitorSpawnLevel, 1)).ToString("f2"); //流量标签3 visitorSpawn_Button_NeedGoldText.text = MinerBigInt.ToDisplay(EnterVisitorSpawnLevelConsumeCoins.ToString()); visitorSpawn_LvText.text = littleZooEnterVisitorSpawnLevel.ToString(); visitorSpawn_Button_buttonLvUpText.text = GetL10NString("Ui_Text_7"); buttonIcon_1.gameObject.SetActive(true); buttonIcon_2.gameObject.SetActive(true); buttonIcon_3.gameObject.SetActive(true); if (!SetGradeBool_Tickets()) { SwitchButtonUnClickable(tickets_Button, false); } else { SwitchButtonUnClickable(tickets_Button, true); } if (!SetGradeBool_VisitorSeat()) { SwitchButtonUnClickable(visitorSeat_Button, false); } else { SwitchButtonUnClickable(visitorSeat_Button, true); } if (!SetGradeBool_VisitorSpawn()) { SwitchButtonUnClickable(visitorSpawn_Button, false); } else { SwitchButtonUnClickable(visitorSpawn_Button, true); } if (littleZooTicketsLevel >= TicketsMaxGrade) { setGradeBool = false; tickets_Button_NeedGoldText.text = GetL10NString("Ui_Text_47"); //升级模式需要的金钱 tickets_Button_buttonLvUpText.text = GetL10NString("Ui_Text_46"); //升级模式要升的级数 //lvText.text = Config.buildupConfig.getInstace().getCell(nameID).lvmax.ToString(); //等级text lvText.text = string.Format(GetL10NString("Ui_Text_2"), GetL10NString("Ui_Text_126")); tickets_Text3.text = GetL10NString("Ui_Text_47"); //价格变化标签 buttonIcon_1.gameObject.SetActive(false); SwitchButtonUnClickable(tickets_Button, false); } if (littleZooVisitorSeatLevel >= VisitorSeatMaxGrade) { setGradeBool = false; visitorSeat_Button_NeedGoldText.text = GetL10NString("Ui_Text_47"); //升级模式需要的金钱 visitorSeat_Button_buttonLvUpText.text = GetL10NString("Ui_Text_46"); //升级模式要升的级数 visitorSeat_Text3.text = GetL10NString("Ui_Text_47"); //数量变化标签 SwitchButtonUnClickable(visitorSeat_Button, false); buttonIcon_2.gameObject.SetActive(false); } if (littleZooEnterVisitorSpawnLevel >= EnterVisitorSpawnMaxGrade) { setGradeBool = false; visitorSpawn_Button_NeedGoldText.text = GetL10NString("Ui_Text_47"); //升级模式需要的金钱 visitorSpawn_Button_buttonLvUpText.text = GetL10NString("Ui_Text_46"); //升级模式要升的级数 visitorSpawn_Text3.text = GetL10NString("Ui_Text_47"); //速度变化标签 buttonIcon_3.gameObject.SetActive(false); SwitchButtonUnClickable(visitorSpawn_Button, false); } if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true) { SwitchButtonUnClickable(visitorSeat_Button, false); SwitchButtonUnClickable(visitorSpawn_Button, false); } }