/// <summary> /// 获取基础游戏数据 /// </summary> /// <param name="miniGameType"></param> /// <returns></returns> public static MiniGameBaseBean GetMiniGameData(MiniGameEnum miniGameType) { MiniGameBaseBean miniGameData = null; switch (miniGameType) { case MiniGameEnum.Cooking: miniGameData = new MiniGameCookingBean(); break; case MiniGameEnum.Barrage: miniGameData = new MiniGameBarrageBean(); break; case MiniGameEnum.Account: miniGameData = new MiniGameAccountBean(); break; case MiniGameEnum.Debate: miniGameData = new MiniGameDebateBean(); break; case MiniGameEnum.Combat: miniGameData = new MiniGameCombatBean(); break; case MiniGameEnum.Birth: miniGameData = new MiniGameBirthBean(); break; } return(miniGameData); }
private void nextMiniGame() { this.currentTask = this.GetCurrentTask(); if (this.currentTask != null) { this.currentType = this.currentTask.getType(); switch (this.currentType) { case MiniGameEnum.ORGANIZE: this.infoMiniGame.setMiniGameInfo("ORGANIZE", "Your desk is a mess! Put each object in the box with the same object's color!!"); break; case MiniGameEnum.STAMP: this.infoMiniGame.setMiniGameInfo("STAMP", "Stamp all the documents before the time runs out!!"); break; case MiniGameEnum.CALCULATE: this.infoMiniGame.setMiniGameInfo("CALCULATE", "Your calculator is broken! Chose the correct answer according to the operation on your calculator!"); break; case MiniGameEnum.REST: break; } this.showInfoMiniGame(); this.infoMiniGame.startInfoMiniGame(); } else { this.timeController.stopTimer(); this.victory.gameObject.SetActive(true); } }
public void InitDataForType(MiniGameEnum gameType, TrophyTypeEnum trophyType, MiniGameBaseBean miniGameData) { this.gameType = gameType; this.miniGameData = miniGameData; this.trophyType = trophyType; SetTitle(miniGameData); SetReward(miniGameData.listReward); SetPrice(miniGameData.preMoneyL, miniGameData.preMoneyM, miniGameData.preMoneyS); SetRuleContent(miniGameData.GetListWinConditions()); SetGameTime(miniGameData.preGameTime); switch (gameType) { case MiniGameEnum.Cooking: break; case MiniGameEnum.Barrage: break; case MiniGameEnum.Account: break; case MiniGameEnum.Debate: break; case MiniGameEnum.Combat: break; } GameUtil.RefreshRectViewHight((RectTransform)transform, true); }
/// <summary> /// 获取游戏类型 /// </summary> /// <param name="data"></param> /// <param name="miniGameType"></param> public static void GetMiniGameType(string data, out MiniGameEnum miniGameType) { miniGameType = MiniGameEnum.Combat; List <PreTypeForMiniGameBean> listPreData = GetListPreData(data); foreach (PreTypeForMiniGameBean itemData in listPreData) { if (itemData.dataType == PreTypeForMiniGameEnum.MiniGameType) { miniGameType = (MiniGameEnum)int.Parse(itemData.data); return; } } }
/// <summary> /// 通过游戏类型获取职业 /// </summary> /// <param name="miniGameType"></param> /// <returns></returns> public static WorkerEnum GetWorkerTypeByMiniGameType(MiniGameEnum miniGameType) { switch (miniGameType) { case MiniGameEnum.Cooking: return(WorkerEnum.Chef); case MiniGameEnum.Barrage: return(WorkerEnum.Waiter); case MiniGameEnum.Account: return(WorkerEnum.Accountant); case MiniGameEnum.Debate: return(WorkerEnum.Accost); case MiniGameEnum.Combat: return(WorkerEnum.Beater); } return(WorkerEnum.Chef); }
/// <summary> /// 计算派遣斗技场是否胜利 /// </summary> /// <param name="gameItemsManager"></param> /// <returns></returns> public bool CalculationGuildSendWin(MiniGameEnum miniGameType) { GetAttributes(out CharacterAttributesBean totalAttributes, out CharacterAttributesBean selfAttributes, out CharacterAttributesBean equipAttributes); int addAttributes = 0; switch (miniGameType) { case MiniGameEnum.Cooking: addAttributes = totalAttributes.cook; break; case MiniGameEnum.Barrage: addAttributes = totalAttributes.speed; break; case MiniGameEnum.Account: addAttributes = totalAttributes.account; break; case MiniGameEnum.Debate: addAttributes = totalAttributes.charm; break; case MiniGameEnum.Combat: addAttributes = totalAttributes.force; break; } float winRate = 0.25f + totalAttributes.lucky * 0.0025f + addAttributes * 0.0025f; if (UnityEngine.Random.Range(0f, 1f) > winRate) { return(false); } else { return(true); } }
/// <summary> /// 创建迷你游戏数据 /// </summary> /// <returns></returns> private List<MiniGameBaseBean> CreateMiniGameData(TrophyTypeEnum type) { List<MiniGameBaseBean> listMiniGameData = new List<MiniGameBaseBean>(); int arenaNumber = UnityEngine.Random.Range(5, 15); for (int i = 0; i < arenaNumber; i++) { MiniGameEnum gameType = MiniGameEnumTools.GetRandomMiniGameTypeForArena(); StoreInfoBean storeInfo = null; MiniGameBaseBean miniGameData = MiniGameEnumTools.GetMiniGameData(gameType); miniGameData.gameReason = MiniGameReasonEnum.Fight; switch (gameType) { case MiniGameEnum.Cooking: storeInfo = GetStoreInfoByTypeAndWorker(type, WorkerEnum.Chef); miniGameData = CreateCookingGameData((MiniGameCookingBean)miniGameData, storeInfo, type); break; case MiniGameEnum.Barrage: storeInfo = GetStoreInfoByTypeAndWorker(type, WorkerEnum.Waiter); miniGameData = CreateBarrageGameData((MiniGameBarrageBean)miniGameData, storeInfo, type); break; case MiniGameEnum.Account: storeInfo = GetStoreInfoByTypeAndWorker(type, WorkerEnum.Accountant); miniGameData = CreateAccountGameData((MiniGameAccountBean)miniGameData, storeInfo, type); break; case MiniGameEnum.Debate: storeInfo = GetStoreInfoByTypeAndWorker(type, WorkerEnum.Accost); miniGameData = CreateDebateGameData((MiniGameDebateBean)miniGameData, storeInfo, type); break; case MiniGameEnum.Combat: storeInfo = GetStoreInfoByTypeAndWorker(type, WorkerEnum.Beater); miniGameData = CreateCombatGameData((MiniGameCombatBean)miniGameData, storeInfo, type); break; } PreTypeForMiniGameEnumTools.GetMiniGameData(miniGameData, storeInfo.pre_data_minigame); //奖励添加 miniGameData.listReward = new List<RewardTypeBean>(); List<RewardTypeBean> listReward = RewardTypeEnumTools.GetListRewardData(storeInfo.reward_data); //固定奖励 List<RewardTypeBean> listFixedReward = new List<RewardTypeBean>(); //随机奖励 List<RewardTypeBean> listRandomReward = new List<RewardTypeBean>(); foreach (RewardTypeBean itemReward in listReward) { switch (itemReward.GetRewardType()) { case RewardTypeEnum.AddMoneyL: case RewardTypeEnum.AddMoneyM: case RewardTypeEnum.AddMoneyS: case RewardTypeEnum.AddArenaTrophyElementary: case RewardTypeEnum.AddArenaTrophyIntermediate: case RewardTypeEnum.AddArenaTrophyAdvanced: case RewardTypeEnum.AddArenaTrophyLegendary: if (miniGameData.winBringDownNumber > 0) { //针对多人战 奖励提升 itemReward.data = long.Parse(itemReward.data) * miniGameData.winBringDownNumber + ""; } listFixedReward.Add(itemReward); break; default: listRandomReward.Add(itemReward); break; } } miniGameData.listReward.AddRange(listFixedReward); if (!CheckUtil.ListIsNull(listRandomReward)) { RewardTypeBean randomReward = RandomUtil.GetRandomDataByList(listRandomReward); miniGameData.listReward.Add(randomReward); } //添加对应的奖杯 switch (type) { case TrophyTypeEnum.Elementary: break; case TrophyTypeEnum.Intermediate: break; case TrophyTypeEnum.Advanced: break; case TrophyTypeEnum.Legendary: break; } //设置游戏时间 if (storeInfo.mark != null) miniGameData.preGameTime = int.Parse(storeInfo.mark); //设置前置金钱 miniGameData.preMoneyL = storeInfo.price_l; miniGameData.preMoneyM = storeInfo.price_m; miniGameData.preMoneyS = storeInfo.price_s; //添加游戏数据 listMiniGameData.Add(miniGameData); } return listMiniGameData; }
public static MiniGameBaseBean GetMiniGameData(MiniGameBaseBean miniGameData, string data, List <CharacterBean> listPickCharacter) { List <PreTypeForMiniGameBean> listPreData = GetListPreData(data); List <CharacterBean> listUserData = new List <CharacterBean>(); List <CharacterBean> listEnemyData = new List <CharacterBean>(); Vector2 minigamePosition = Vector2.zero; //如果没有传入游戏数据则先根据条件生成一个 if (miniGameData == null) { GetMiniGameType(data, out MiniGameEnum miniGameType); miniGameData = MiniGameEnumTools.GetMiniGameData(miniGameType); } foreach (PreTypeForMiniGameBean itemPreData in listPreData) { switch (itemPreData.dataType) { case PreTypeForMiniGameEnum.MiniGameType: MiniGameEnum miniGameType = (MiniGameEnum)int.Parse(itemPreData.data); miniGameData.gameType = miniGameType; break; case PreTypeForMiniGameEnum.GameReason: MiniGameReasonEnum miniGameReason = (MiniGameReasonEnum)int.Parse(itemPreData.data); miniGameData.gameReason = miniGameReason; break; case PreTypeForMiniGameEnum.UserIds: long[] userIds = StringUtil.SplitBySubstringForArrayLong(itemPreData.data, ','); listUserData = NpcInfoHandler.Instance.manager.GetCharacterDataByIds(userIds); break; case PreTypeForMiniGameEnum.EnemyIds: long[] enemyIds = StringUtil.SplitBySubstringForArrayLong(itemPreData.data, ','); listEnemyData = NpcInfoHandler.Instance.manager.GetCharacterDataByIds(enemyIds); break; case PreTypeForMiniGameEnum.MiniGamePosition: float[] arrayPosition = StringUtil.SplitBySubstringForArrayFloat(itemPreData.data, ','); minigamePosition = new Vector2(arrayPosition[0], arrayPosition[1]); break; case PreTypeForMiniGameEnum.TalkMarkIdForWin: miniGameData.gameResultWinTalkMarkId = long.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.TalkMarkIdForLose: miniGameData.gameResultLoseTalkMarkId = long.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.WinLife: miniGameData.winLife = long.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.WinSurvivalTime: miniGameData.winSurvivalTime = float.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.BarrageForLaunchInterval: case PreTypeForMiniGameEnum.BarrageForLaunchSpeed: case PreTypeForMiniGameEnum.BarrageForLaunchTypes: case PreTypeForMiniGameEnum.BarrageForLaunchNumber: case PreTypeForMiniGameEnum.BarrageForBulletType: GetMiniGameDataForBarrage(itemPreData, miniGameData); break; case PreTypeForMiniGameEnum.AccountForWinMoneyL: case PreTypeForMiniGameEnum.AccountForWinMoneyM: case PreTypeForMiniGameEnum.AccountForWinMoneyS: GetMiniGameDataForAccount(itemPreData, miniGameData); break; case PreTypeForMiniGameEnum.CombatForBringDownNumber: case PreTypeForMiniGameEnum.CombatForSurvivalNumber: GetMiniGameDataForCombat(itemPreData, miniGameData); break; case PreTypeForMiniGameEnum.CookingForScore: case PreTypeForMiniGameEnum.CookingForStoryStartId: case PreTypeForMiniGameEnum.CookingForStoryAuditId: case PreTypeForMiniGameEnum.CookingForAuditCharacter: case PreTypeForMiniGameEnum.CookingForCompereCharacter: case PreTypeForMiniGameEnum.CookingForThemeId: case PreTypeForMiniGameEnum.CookingForThemeLevel: case PreTypeForMiniGameEnum.CookingForButtonNumber: case PreTypeForMiniGameEnum.CookingForWinRank: GetMiniGameDataForCook(itemPreData, miniGameData); break; } } if (miniGameData == null) { return(miniGameData); } //如果有传入角色则把传入角色也加入到用户数据中 if (listPickCharacter != null) { listUserData.AddRange(listPickCharacter); } miniGameData.miniGamePosition = minigamePosition; miniGameData.InitData(listUserData, listEnemyData); return(miniGameData); }