public void OnClickForAddSpeed() { GameDataHandler gameDataHandler = uiComponent.handler_GameData; GameBean gameData = uiComponent.handler_Game.GetGameData(); UserDataBean userData = gameDataHandler.GetUserData(); int maxLevel = uiComponent.handler_GameData.GetLevelMaxForSpeed(); gameDataHandler.GetLevelLevelUpDataForSpeed(gameData.levelForSpeed, out float addSpeed, out long preSpeedGold); if (!gameData.HasEnoughGold(preSpeedGold)) { //钱不够 uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001)); return; } bool isLevelUp = gameData.LevelUpForPlayerSpeed(maxLevel, addSpeed); if (!isLevelUp) { //升级失败 uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002)); return; } //支付金币 gameData.PayGold(preSpeedGold); uiComponent.handler_Character.SetCharacterSpeed(CharacterTypeEnum.Player, gameData.GetPlayerSpeed() + userData.speed); uiComponent.handler_Character.RefreshCharacter(CharacterTypeEnum.Player); RefreshUI(); }
public override void Start() { base.Start(); ui_TvAdvertisingHint.text = GameCommonInfo.GetUITextById(101); ColorUtility.TryParseHtmlString("#0b752b", out Color outline); ui_TvAdvertisingHint.outlineColor = outline; }
public void OnClickForAddGoldPrice() { UserDataBean userData = uiComponent.handler_GameData.GetUserData(); GameDataHandler gameDataHandler = uiComponent.handler_GameData; GameBean gameData = uiComponent.handler_Game.GetGameData(); int maxLevel = uiComponent.handler_GameData.GetLevelMaxForGoldPrice(); gameDataHandler.GetLevelUpDataForGoldPrice(gameData.levelForGoldPrice, out int addPrice, out long prePriceGold); if (!gameData.HasEnoughGold(prePriceGold)) { //钱不够 uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001)); return; } bool isLevelUp = gameData.LevelUpForGoldPrice(maxLevel, addPrice); if (!isLevelUp) { //升级失败 uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002)); return; } //支付金币 gameData.PayGold(prePriceGold); RefreshUI(); }
public void Submit(DialogView dialogView, DialogBean dialogBean) { if (dialogView as PickForCharacterDialogView) { PickForCharacterDialogView pickForCharacterDialog = dialogView as PickForCharacterDialogView; UserInfiniteTowersBean infiniteTowersData = new UserInfiniteTowersBean(); List <CharacterBean> listMembers = pickForCharacterDialog.GetPickCharacter(); GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); if (dialogBean.dialogPosition == 0) { //亲自 infiniteTowersData.isSend = false; foreach (CharacterBean itemCharacter in listMembers) { infiniteTowersData.listMembers.Add(itemCharacter.baseInfo.characterId); } gameData.AddInfinteTowersData(infiniteTowersData); //跳转场景 GameCommonInfo.SetInfiniteTowersPrepareData(infiniteTowersData); GameScenesHandler.Instance.ChangeScene(ScenesEnum.GameInfiniteTowersScene); } else if (dialogBean.dialogPosition == 1) { //派遣 infiniteTowersData.isSend = true; //检测 foreach (CharacterBean itemCharacter in listMembers) { WorkerStatusEnum workerStatusEnum = itemCharacter.baseInfo.GetWorkerStatus(); if (workerStatusEnum != WorkerStatusEnum.Rest && workerStatusEnum != WorkerStatusEnum.Work) { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(1142)); return; } } //派遣 foreach (CharacterBean itemCharacter in listMembers) { infiniteTowersData.listMembers.Add(itemCharacter.baseInfo.characterId); itemCharacter.baseInfo.SetWorkerStatus(WorkerStatusEnum.InfiniteTowers); } //计算每层攀登几率 infiniteTowersData.InitSuccessRate(GameItemsHandler.Instance.manager, listMembers); gameData.AddInfinteTowersData(infiniteTowersData); RefreshUI(); } } else { if (dialogBean.dialogPosition == 1) { //重置所有爬塔记录 GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); gameData.CleanInfinteTowers(); RefreshUI(); } } }
/// <summary> /// 创建应聘者数据 /// </summary> public void CreateCandidateData() { GameCommonInfo.InitRandomSeed(); int randomNumber = Random.Range(1, 15); for (int i = 0; i < randomNumber; i++) { CharacterBean characterData = CharacterBean.CreateRandomWorkerData(); GameCommonInfo.DailyLimitData.AddRecruitmentCharacter(characterData); } }
public override void Awake() { base.Awake(); if (ui_PvLevelUp) { ui_PvLevelUp.SetCompleteContent(GameCommonInfo.GetUITextById(4)); ui_PvLevelUp.SetContentOutline(new Color(0, 0, 0, 0.4f), 0.2f); } if (ui_BtLevelUp) { ui_BtLevelUp.onClick.AddListener(OnClickForLevelUp); } }
/// <summary> /// 点击继续 /// </summary> public void OnClickForContinue() { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); foreach (string memberId in infiniteTowersData.listMembers) { CharacterBean characterData = gameData.GetCharacterDataById(memberId); if (characterData.baseInfo.GetWorkerStatus() != WorkerStatusEnum.Rest && characterData.baseInfo.GetWorkerStatus() != WorkerStatusEnum.Work) { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(1141)); return; } } //跳转场景 GameCommonInfo.SetInfiniteTowersPrepareData(infiniteTowersData); GameScenesHandler.Instance.ChangeScene(ScenesEnum.GameInfiniteTowersScene); }
private void Start() { if (ui_BtSpeedAdd) { ui_BtSpeedAdd.onClick.AddListener(OnClickForAddSpeed); } if (ui_BtNumberAdd) { ui_BtNumberAdd.onClick.AddListener(OnClickForAddNumber); } if (ui_BtGoldPriceAdd) { ui_BtGoldPriceAdd.onClick.AddListener(OnClickForAddGoldPrice); } if (ui_BtDamageAdd) { ui_BtDamageAdd.onClick.AddListener(OnClickForAddDamage); } if (ui_TvTitleGoldPrice) { ui_TvTitleGoldPrice.outlineColor = Color.white; ui_TvTitleGoldPrice.text = GameCommonInfo.GetUITextById(1); SetUnderlayOffsetY(ui_TvTitleGoldPrice); } if (ui_TvTitleSpeed) { ui_TvTitleSpeed.outlineColor = Color.white; ui_TvTitleSpeed.text = GameCommonInfo.GetUITextById(2); SetUnderlayOffsetY(ui_TvTitleSpeed); } if (ui_TvTitleNumber) { ui_TvTitleNumber.outlineColor = Color.white; ui_TvTitleNumber.text = GameCommonInfo.GetUITextById(3); SetUnderlayOffsetY(ui_TvTitleNumber); } RefreshUI(); }
public void Submit(DialogView dialogView, DialogBean dialogBean) { if (dialogBean.dialogPosition == 1) { //离开游戏 GameUtil.ExitGame(); } else if (dialogBean.dialogPosition == 2) { //回调主菜单 GameScenesHandler.Instance.ChangeScene(ScenesEnum.MainScene); GameCommonInfo.ClearData(); } else if (dialogBean.dialogPosition == 3) { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); GameDataHandler.Instance.manager.GetGameDataByUserId(gameData.userId); GameCommonInfo.ClearData(); GameScenesHandler.Instance.ChangeScene(ScenesEnum.GameInnScene); } }
public void CreateGoods(List <StoreInfoBean> listData) { if (objGoodsContent == null || objGoodsModel == null || listData == null) { return; } CptUtil.RemoveChildsByActive(objGoodsContent); GameCommonInfo.InitRandomSeed(); for (int i = 0; i < listData.Count; i++) { StoreInfoBean itemData = listData[i]; GameObject objGoods = Instantiate(objGoodsContent, objGoodsModel); ItemTownGoodsMarketCpt itemCpt = objGoods.GetComponent <ItemTownGoodsMarketCpt>(); if (itemCpt != null) { IconBean iconData = BeanUtil.GetIconBeanByName(itemData.icon_key, listGoodsIcon); itemCpt.SetData(itemData, iconData.value); } objGoods.transform.DOScale(new Vector3(0, 0, 0), 0.5f).SetEase(Ease.OutBack).SetDelay(i * 0.01f).From(); } ; }
public void OnClickForAddNumber() { GameBean gameData = uiComponent.handler_Game.GetGameData(); GameDataHandler gameDataHandler = uiComponent.handler_GameData; UserDataBean userData = gameDataHandler.GetUserData(); int maxLevel = uiComponent.handler_GameData.GetLevelMaxForNumber(); gameDataHandler.GetLevelLevelUpDataForNumber(gameData.levelForPirateNumber, out int addNumber, out long preNumberGold); if (!gameData.HasEnoughGold(preNumberGold)) { //钱不够 uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001)); return; } bool isLevelUp = gameData.LevelUpForPlayerPirateNumber(maxLevel, addNumber); if (!isLevelUp) { //升级失败 uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002)); return; } //支付金币 gameData.PayGold(preNumberGold); //生成海盗 for (int i = 0; i < addNumber; i++) { CharacterDataBean playerCharacterData = new CharacterDataBean(CharacterTypeEnum.Player) { life = userData.life + gameData.playerForLife, maxLife = userData.life + gameData.playerForLife, moveSpeed = userData.speed + gameData.GetPlayerSpeed() }; uiComponent.handler_Character.CreateCharacter(playerCharacterData); } RefreshUI(); }
/// <summary> /// 开始新的一天 /// </summary> public void SetNewDay() { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); //初始化世界种子 GameCommonInfo.RandomSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue); GameCommonInfo.InitRandomSeed(); //解除每日 GameCommonInfo.DailyLimitData.InitData(gameData); //初始化时间 SetTimeStatus(true); hour = 6; min = 0; //如果有建筑日则建筑日减一天 InnBuildBean innBuildData = gameData.GetInnBuildData(); if (innBuildData.listBuildDay.Count > 0) { //检测当前日子是否包含在建筑日内 TimeBean timeData = gameData.gameTime; bool isBuildDay = false; foreach (TimeBean itemTime in innBuildData.listBuildDay) { if (itemTime.year == timeData.year && itemTime.month == timeData.month && itemTime.day == timeData.day) { isBuildDay = true; } } if (!isBuildDay) { innBuildData.listBuildDay.Clear(); //检测是1楼还是2楼 if (innBuildData.buildInnWidth != 0 || innBuildData.buildInnHeight != 0) { innBuildData.ChangeInnSize(1, innBuildData.buildInnWidth, innBuildData.buildInnHeight); innBuildData.buildInnWidth = 0; innBuildData.buildInnHeight = 0; } else if (innBuildData.buildInnSecondWidth != 0 || innBuildData.buildInnSecondHeight != 0) { innBuildData.ChangeInnSize(2, innBuildData.buildInnSecondWidth, innBuildData.buildInnSecondHeight); innBuildData.buildInnSecondWidth = 0; innBuildData.buildInnSecondHeight = 0; } InnBuildHandler.Instance.builderForFloor.StartBuild(); InnBuildHandler.Instance.builderForWall.StartBuild(); } } //增加家族成员日子 List <CharacterForFamilyBean> listFamilyData = gameData.GetFamilyData().GetAllFamilyData(); if (!CheckUtil.ListIsNull(listFamilyData)) { for (int i = 0; i < listFamilyData.Count; i++) { CharacterForFamilyBean itemData = listFamilyData[i]; itemData.AddBirthDay(1); } } //通知新的一天 notifyForTime?.Invoke(NotifyTypeEnum.NewDay, -1); SystemUtil.GCCollect(); }
public void Submit(DialogView dialogView, DialogBean dialogBean) { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); //支付金钱 gameData.PayMoney(levelData.price_l, levelData.price_m, levelData.price_s); //扣除时间 int preGameTime = int.Parse(levelData.mark); //扣除时间 GameTimeHandler.Instance.AddHour(preGameTime); //如果有研究菜谱 菜谱增加经验 GameDataHandler.Instance.AddTimeProcess(preGameTime * 60); //判断玩哪个游戏 MiniGameBaseBean miniGameData = null; switch (workerType) { case WorkerEnum.Chef: miniGameData = InitChefGame(); break; case WorkerEnum.Waiter: //设置弹幕游戏数据 miniGameData = InitWaiterGame(); break; case WorkerEnum.Accountant: //设置算账游戏 miniGameData = InitAccountantGame(); break; case WorkerEnum.Accost: //设置辩论游戏 miniGameData = InitAccostGame(); break; case WorkerEnum.Beater: miniGameData = InitBeaterGame(); break; default: break; } miniGameData.preGameTime = preGameTime; miniGameData.gameReason = MiniGameReasonEnum.Improve; if (dialogBean.dialogPosition == 0) { //设置竞技场数据 GameCommonInfo.SetArenaPrepareData(miniGameData); //保存之前的位置 GameCommonInfo.ScenesChangeData.beforeUserPosition = GameControlHandler.Instance.manager.GetControl <BaseControl>(ControlEnum.Normal).transform.position; //跳转到竞技场 GameScenesHandler.Instance.ChangeScene(ScenesEnum.GameArenaScene); } else { bool isWin = characterData.CalculationGuildSendWin(miniGameData.gameType); if (isWin) { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(7021)); AudioHandler.Instance.PlaySound(AudioSoundEnum.Reward); //完成奖励 RewardTypeEnumTools.CompleteReward(miniGameData.GetListUserCharacterData(), miniGameData.listReward); //数据添加 Sprite attributeIcon = IconDataHandler.Instance.manager.GetIconSpriteByName("keyboard_button_up_1"); string attributeRewardContent = ""; foreach (MiniGameCharacterBean miniGameCharacterData in miniGameData.listUserGameData) { switch (miniGameData.gameType) { case MiniGameEnum.Cooking: attributeRewardContent = AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Cook) + " +5"; miniGameCharacterData.characterData.baseInfo.chefInfo.LevelUp(miniGameCharacterData.characterData.attributes); break; case MiniGameEnum.Barrage: attributeRewardContent = AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Speed) + " +5"; miniGameCharacterData.characterData.baseInfo.waiterInfo.LevelUp(miniGameCharacterData.characterData.attributes); break; case MiniGameEnum.Account: attributeRewardContent = AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Account) + " +5"; miniGameCharacterData.characterData.baseInfo.accountantInfo.LevelUp(miniGameCharacterData.characterData.attributes); break; case MiniGameEnum.Debate: attributeRewardContent = AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Charm) + " +5"; miniGameCharacterData.characterData.baseInfo.accostInfo.LevelUp(miniGameCharacterData.characterData.attributes); break; case MiniGameEnum.Combat: attributeRewardContent = AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Force) + " +5"; miniGameCharacterData.characterData.baseInfo.beaterInfo.LevelUp(miniGameCharacterData.characterData.attributes); break; } } ToastHandler.Instance.ToastHint(attributeIcon, attributeRewardContent); //刷新UI ((UITownGuildImprove)uiComponent).RefreshUI(); } else { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(7022)); AudioHandler.Instance.PlaySound(AudioSoundEnum.Passive); } } }
public void Submit(DialogView dialogView, DialogBean dialogBean) { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); if (dialogView as PickForCharacterDialogView) { //判断时间是否过晚 GameTimeHandler.Instance.GetTime(out float hour, out float min); if (hour >= 21 || hour < 6) { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(1034)); return; } //支付金钱 gameData.PayMoney(miniGameData.preMoneyL, miniGameData.preMoneyM, miniGameData.preMoneyS); //扣除时间 GameTimeHandler.Instance.AddHour(miniGameData.preGameTime); //如果有研究菜谱 菜谱增加经验 GameDataHandler.Instance.AddTimeProcess(miniGameData.preGameTime * 60); //设置参赛人员 PickForCharacterDialogView pickForCharacterDialog = dialogView as PickForCharacterDialogView; List <CharacterBean> listCharacter = pickForCharacterDialog.GetPickCharacter(); miniGameData.InitData(listCharacter); //今日不能再参加 GameCommonInfo.DailyLimitData.AddArenaAttendedCharacter(listCharacter); //删除该条数据 GameCommonInfo.DailyLimitData.RemoveArenaDataByType(trophyType, miniGameData); if (arenaJoinType == 1) { //设置竞技场数据 GameCommonInfo.SetArenaPrepareData(miniGameData); //保存之前的位置 GameCommonInfo.ScenesChangeData.beforeUserPosition = GameControlHandler.Instance.manager.GetControl <BaseControl>(GameControlHandler.ControlEnum.Normal).transform.position; //跳转到竞技场 GameScenesHandler.Instance.ChangeScene(ScenesEnum.GameArenaScene); } else if (arenaJoinType == 2) { //刷新UI ((UITownArena)uiComponent).RefreshUI(); CharacterBean character = listCharacter[0]; bool isWin = character.CalculationArenaSendWin(miniGameData.gameType); if (isWin) { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(7011)); AudioHandler.Instance.PlaySound(AudioSoundEnum.Reward); //设置不记录 foreach (RewardTypeBean rewardData in miniGameData.listReward) { if (rewardData.GetRewardType() == RewardTypeEnum.AddArenaTrophyAdvanced || rewardData.GetRewardType() == RewardTypeEnum.AddArenaTrophyElementary || rewardData.GetRewardType() == RewardTypeEnum.AddArenaTrophyIntermediate || rewardData.GetRewardType() == RewardTypeEnum.AddArenaTrophyLegendary) { rewardData.isRecord = false; } } //完成奖励 RewardTypeEnumTools.CompleteReward(listCharacter, miniGameData.listReward); } else { ToastHandler.Instance.ToastHint(TextHandler.Instance.manager.GetTextById(7012)); AudioHandler.Instance.PlaySound(AudioSoundEnum.Passive); } } } else { //弹出选人界面 DialogBean dialogData = new DialogBean(); PickForCharacterDialogView pickForCharacterDialog = DialogHandler.Instance.CreateDialog <PickForCharacterDialogView>(DialogEnum.PickForCharacter, this, dialogData); pickForCharacterDialog.SetPickCharacterMax(1); List <string> listExpelCharacterId = new List <string>(); //排出今日已经参加过的人 List <string> listAttendedCharacterId = GameCommonInfo.DailyLimitData.GetArenaAttendedCharacter(); //排出等级不符合的人 List <CharacterBean> listWorker = gameData.GetAllCharacterData(); foreach (CharacterBean itemWorker in listWorker) { bool isExpel = false; CharacterWorkerBaseBean workerInfo = null; switch (gameType) { case MiniGameEnum.Cooking: workerInfo = itemWorker.baseInfo.GetWorkerInfoByType(WorkerEnum.Chef); break; case MiniGameEnum.Barrage: workerInfo = itemWorker.baseInfo.GetWorkerInfoByType(WorkerEnum.Waiter); break; case MiniGameEnum.Account: workerInfo = itemWorker.baseInfo.GetWorkerInfoByType(WorkerEnum.Accountant); break; case MiniGameEnum.Debate: workerInfo = itemWorker.baseInfo.GetWorkerInfoByType(WorkerEnum.Accost); break; case MiniGameEnum.Combat: workerInfo = itemWorker.baseInfo.GetWorkerInfoByType(WorkerEnum.Beater); break; } int workLevel = workerInfo.GetLevel(); switch (trophyType) { case TrophyTypeEnum.Elementary: if (workLevel != 0 && workLevel != 1) { isExpel = true; } break; case TrophyTypeEnum.Intermediate: if (workLevel != 2 && workLevel != 3) { isExpel = true; } break; case TrophyTypeEnum.Advanced: if (workLevel != 4 && workLevel != 5) { isExpel = true; } break; case TrophyTypeEnum.Legendary: if (workLevel != 6) { isExpel = true; } break; } if (isExpel) { listExpelCharacterId.Add(itemWorker.baseInfo.characterId); } } listExpelCharacterId.AddRange(listAttendedCharacterId); pickForCharacterDialog.SetExpelCharacter(listExpelCharacterId); if (miniGameData.gameType == MiniGameEnum.Combat) { pickForCharacterDialog.SetPickCharacterMax(miniGameData.winBringDownNumber); } } }