void ParseBonus(string id) { bonusNameText.text = ""; bonusText.text = ""; BonusEffect be = DataStore.bonusEffects.Where(x => x.bonusID == id).FirstOr(null); if (be == null || be.effects.Count == 0) { return; } //first choose a random bonus int[] rnd = GlowEngine.GenerateRandomNumbers(be.effects.Count); string e = be.effects[rnd[0]]; //get the bonus name int idx = e.IndexOf(':'); bonusNameText.text = e.Substring(0, idx); bonusText.text = ReplaceGlyphs(e.Substring(idx + 1)).Trim(); //At each activation, there’s a 25% chance that no bonus effect will be applied if (DataStore.sessionData.difficulty == Difficulty.Easy) { if (GlowEngine.RandomBool(25)) { Debug.Log("EASY MODE: applied 25% chance bonus skipped"); bonusNameText.text = ""; bonusText.text = ""; } } }
CardDescriptor HandleR18() { //Randomly select a creature, based on the available groups var clist = DataStore.deploymentCards.cards.Where(x => x.id == "DG017" || x.id == "DG018" || x.id == "DG060" || x.id == "DG061" || x.id == "DG028" || x.id == "DG029" ).ToList() .Owned() .FilterByFaction() .MinusDeployed() .MinusReserved() .MinusIgnored(); if (clist.Count > 0) { int[] rnd = GlowEngine.GenerateRandomNumbers(clist.Count); //if it's in deployment hand, remove it if (DataStore.deploymentHand.Contains(clist[rnd[0]])) { DataStore.deploymentHand.Remove(clist[rnd[0]]); } return(clist[rnd[0]]); } else { return(null); } }
void DoDeployment(bool skipThreatIncrease) { EventSystem.current.SetSelectedGameObject(null); int[] rnd = GlowEngine.GenerateRandomNumbers(6); int roll1 = rnd[0] + 1; rnd = GlowEngine.GenerateRandomNumbers(6); int roll2 = rnd[0] + 1; Debug.Log("ROLLED: " + (roll1 + roll2).ToString()); Debug.Log("DEP MODIFIER: " + DataStore.sessionData.gameVars.deploymentModifier); int total = roll1 + roll2 + DataStore.sessionData.gameVars.deploymentModifier; Debug.Log("TOTAL ROLLED VALUE: " + total); if (total <= 4) { deploymentPopup.Show(DeployMode.Calm, skipThreatIncrease, false); } else if (total > 4 && total <= 7) { deploymentPopup.Show(DeployMode.Reinforcements, skipThreatIncrease, false, DoEvent); } else if (total > 7 && total <= 10) { deploymentPopup.Show(DeployMode.Landing, skipThreatIncrease, false, DoEvent); } else if (total > 10) { deploymentPopup.Show(DeployMode.Onslaught, skipThreatIncrease, false, DoEvent); } }
/// <summary> /// Calculate and return a valid reinforcement, optionally applying a -1 rcost modifier for Onslaught /// </summary> public static CardDescriptor GetReinforcement(bool isOnslaught = false) { //up to 2 groups reinforce, this method handles ONE //get deployed groups that CAN reinforce // -reinforce cost > 0 // - current size < max size // -reinforce cost <= current threat int costModifier = 0; if (isOnslaught) { costModifier = 1; } var valid = deployedEnemies.Where(x => x.rcost > 0 && x.currentSize < x.size && Math.Max(1, x.rcost - costModifier) <= sessionData.gameVars.currentThreat).ToList(); if (valid.Count > 0) { int[] rnd = GlowEngine.GenerateRandomNumbers(valid.Count); //Debug.Log( "GET: " + valid[rnd[0]].currentSize ); return(valid[rnd[0]]); } return(null); }
/// <summary> /// Randomly attaches 2 tiles (random anchor/connector) within a given group, tile=previous tile already on board /// </summary> public void AttachTo(Tile tile, TileGroup tg) { //anchors = white outer transforms //connectors = red inner transforms Transform[] anchorPoints = tile.GetChildren("anchor"); int[] ra = GlowEngine.GenerateRandomNumbers(anchorPoints.Length); int[] rc = GlowEngine.GenerateRandomNumbers(connectorCount); bool success = false; for (int c = 0; c < connectorCount; c++) { for (int a = 0; a < anchorPoints.Length; a++) //white anchors on board { tile.SetAnchor(ra[a]); SetConnector(rc[c]); AttachTo(tile.currentAnchor); Transform[] ap = GetChildren("connector"); success = !tg.CheckCollisionsWithinGroup(ap); if (success) { break; } } if (success) { break; } } if (!success) { Debug.Log("FAILED TO FIND OPEN TILE LOCATION"); throw new System.Exception("FAILED TO FIND OPEN TILE LOCATION"); } }
/// <summary> /// Randomly gets the requested number of cards according to tier /// </summary> static List <CardDescriptor> GetCardsByTier(List <CardDescriptor> haystack, int t1, int t2, int t3) { List <CardDescriptor> retval = new List <CardDescriptor>(); ; if (t1 > 0) { var g = haystack.Where(x => x.tier == 1).ToList(); int[] rands = GlowEngine.GenerateRandomNumbers(g.Count()); for (int i = 0; i < Math.Min(g.Count(), t1); i++) { retval.Add(g[rands[i]]); } } if (t2 > 0) { var g = haystack.Where(x => x.tier == 2).ToList(); int[] rands = GlowEngine.GenerateRandomNumbers(g.Count()); for (int i = 0; i < Math.Min(g.Count(), t2); i++) { retval.Add(g[rands[i]]); } } if (t3 > 0) { var g = haystack.Where(x => x.tier == 3).ToList(); int[] rands = GlowEngine.GenerateRandomNumbers(g.Count()); for (int i = 0; i < Math.Min(g.Count(), t3); i++) { retval.Add(g[rands[i]]); } } return(retval); }
public void OnActivateImperial() { EventSystem.current.SetSelectedGameObject(null); sound.PlaySound(FX.Click); int[] rnd; CardDescriptor toActivate = null; //find a non-exhausted group and activate it, bias to priority 1 var groups = dgManager.GetNonExhaustedGroups(); if (groups.Count > 0) { var p1 = groups.Where(x => x.priority == 1).ToList(); var others = groups.Where(x => x.priority != 1).ToList(); var all = p1.Concat(others).ToList(); //70% chance to priority 1 groups if (p1.Count > 0 && GlowEngine.RandomBool(70)) { rnd = GlowEngine.GenerateRandomNumbers(p1.Count); toActivate = p1[rnd[0]]; } else { rnd = GlowEngine.GenerateRandomNumbers(all.Count); toActivate = all[rnd[0]]; } ActivateEnemy(toActivate); } }
CardDescriptor HandleR8() { /*• If there is a villain in the deployment hand, choose that villain. * • If there are any earned villains, select one of those villains randomly. * • If there are no earned villains, select a villain randomly. * • Threat cost for the villain may not be higher than the current threat amount plus 7. After deployment, decrease threat by the villain’s threat cost, to a maximum of 7. (If the villain is cheaper than 7 threat, decrease threat by that amount.) */ //try from deployment hand, minus deployed int[] rnd; var v = DataStore.deploymentHand .GetVillains() .MinusDeployed() //shouldn't be necessary .Where(x => x.cost <= DataStore.sessionData.threatLevel + 7).ToList(); if (v.Count > 0) { rnd = GlowEngine.GenerateRandomNumbers(v.Count); return(v[rnd[0]]); } //try earned villains, minus deployed v = DataStore.sessionData .EarnedVillains .MinusDeployed() .Where(x => x.cost <= DataStore.sessionData.threatLevel + 7).ToList(); if (v.Count > 0) { rnd = GlowEngine.GenerateRandomNumbers(v.Count); return(v[rnd[0]]); } //else random villain owned+other, minus deployed/ignored/faction v = DataStore.villainCards.cards .OwnedPlusOther() .FilterByFaction() .MinusIgnored() .MinusDeployed() .Where(x => x.cost <= DataStore.sessionData.threatLevel + 7).ToList(); if (v.Count > 0) { rnd = GlowEngine.GenerateRandomNumbers(v.Count); //add it to earned list, per the rules for this event DataStore.sessionData.EarnedVillains.Add(v[rnd[0]]); return(v[rnd[0]]); } //bust return(null); }
public void Show(CardEvent ce, Action cb = null) { gameObject.SetActive(true); fader.color = new Color(0, 0, 0, 0); fader.DOFade(.95f, 1); cg.DOFade(1, .5f); transform.GetChild(0).localScale = new Vector3(.85f, .85f, .85f); transform.GetChild(0).DOScale(1, .5f).SetEase(Ease.OutExpo); callback = cb; cardEvent = ce; eventTitle.text = ce.eventName.ToLower(); eventFlavor.text = ce.eventFlavor; allyToAdd = null; enemyToAdd = null; //pick 2 rebels/allies var hlist = DataStore.deployedHeroes.GetHealthy(); //make sure there are valid heroes/allies to target if (hlist != null && hlist.Count > 0) { int[] rnd = GlowEngine.GenerateRandomNumbers(hlist.Count()); rebel1 = hlist[rnd[0]]; if (hlist.Count > 1) { rebel2 = hlist[rnd[1]]; } else { rebel2 = rebel1; } } else { rebel1 = new CardDescriptor() { name = "None" }; rebel2 = rebel1; } foreach (var s in ce.content) { ParseCard(s); } }
public void OnConfirm() { int c = mWheelHandler.wheelValue; CardDescriptor cd = null; List <CardDescriptor> list = new List <CardDescriptor>(); do { var p = DataStore.deploymentCards.cards .OwnedPlusOther() .MinusDeployed() .MinusInDeploymentHand() .MinusStarting() .MinusReserved() .MinusIgnored() .FilterByFaction() .Concat(DataStore.sessionData.EarnedVillains) .Where(x => x.cost <= c && !list.Contains(x)) .ToList(); if (p.Count > 0) { int[] rnd = GlowEngine.GenerateRandomNumbers(p.Count); cd = p[rnd[0]]; list.Add(cd); c -= cd.cost; } else { cd = null; } } while (cd != null); //deploy any groups picked foreach (var card in list) { FindObjectOfType <DeploymentGroupManager>().DeployGroup(card, true); } string s = DataStore.uiLanguage.uiMainApp.noRandomMatchesUC.Replace("{d}", mWheelHandler.wheelValue.ToString()); if (list.Count == 0) { GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show($"<color=\"orange\">{s}</color>"); } OnCancel(); }
void DoEvent() { EventSystem.current.SetSelectedGameObject(null); //1 in 4 chance to do an event int[] rnd = GlowEngine.GenerateRandomNumbers(4); int roll1 = rnd[0] + 1; if (roll1 == 1 && DataStore.sessionData.gameVars.eventsTriggered < 3) { DataStore.sessionData.gameVars.eventsTriggered++; rnd = GlowEngine.GenerateRandomNumbers(DataStore.cardEvents.Count); //get a random event var ev = DataStore.cardEvents[rnd[0]]; //remove it from the list of events so it won't activate again DataStore.cardEvents.Remove(ev); //activate it eventPopup.Show(ev, () => DataStore.sessionData.SaveSession("Session")); } }
CardDescriptor HandleR23() { //filter ally list by owned expansions + Other, minus anything already deployed var alist = DataStore.allyCards.cards .OwnedPlusOther() .MinusDeployed(); //sanity check for empty list if (alist.Count() == 0) { return(null); } else { int[] rnd = GlowEngine.GenerateRandomNumbers(alist.Count()); return(alist.ToList()[rnd[0]]); } }
CardDescriptor FindRebel() { var hlist = DataStore.deployedHeroes.GetHealthy(); var ulist = DataStore.deployedHeroes.GetUnhealthy(); CardDescriptor r = null; if (hlist != null) { //Debug.Log( "healthy HEROES: " + hlist.Count ); int[] rnd = GlowEngine.GenerateRandomNumbers(hlist.Count()); r = hlist[rnd[0]]; } else if (ulist != null) { //Debug.Log( "UNhealthy HEROES: " + ulist.Count ); int[] rnd = GlowEngine.GenerateRandomNumbers(ulist.Count()); r = ulist[rnd[0]]; } return(r); }
private IEnumerator RollRoutine() { float timer = 0; //show one random face dice[GlowEngine.GenerateRandomNumbers(6)[0]].gameObject.SetActive(true); while (rollTime > 0) { timer += Time.deltaTime; if (timer > .1f) //change every X milliseconds { timer = 0; //hide them all for (int i = 0; i < 6; i++) { dice[i].gameObject.SetActive(false); } //show one random face dice[GlowEngine.GenerateRandomNumbers(6)[0]].gameObject.SetActive(true); FindObjectOfType <Sound>().PlaySound(FX.Click); } rollTime -= Time.deltaTime; yield return(null); } //hide them all for (int i = 0; i < 6; i++) { dice[i].gameObject.SetActive(false); } //finally pick one for the final dice dice[GlowEngine.GenerateRandomNumbers(6)[0]].gameObject.SetActive(true); FindObjectOfType <Sound>().PlaySound(FX.Click); yield return(true); }
IEnumerator AttachTile(TileGroup tg) { //get ALL explored tilegroups in play var tilegroups = (from ch in chapterList where ch.tileGroup.isExplored select ch.tileGroup).ToList(); bool success = false; if (previousGroup != null) { success = tg.AttachTo(previousGroup); //remove so not attempted again below tilegroups.Remove(previousGroup); } else { int randIdx = GlowEngine.GenerateRandomNumbers(tilegroups.Count)[0]; TileGroup randGroup = tilegroups[randIdx]; success = tg.AttachTo(randGroup); //remove so not attempted again below tilegroups.RemoveAt(randIdx); } if (!success) { Debug.Log("***SEARCHING for random tilegroup to attach to..."); foreach (TileGroup _tg in tilegroups) { success = tg.AttachTo(_tg); if (success) { break; } } } yield return(null); }
public void Show(CardDescriptor cd) { EventSystem.current.SetSelectedGameObject(null); //Debug.Log( "Showing: " + cd.name + " / " + cd.id ); //clear values thumbnail.color = new Color(1, 1, 1, 0); bonusNameText.text = ""; bonusText.text = ""; enemyName.text = ""; ignoreText.text = ""; spaceListen = true; colorPip.color = DataStore.pipColors[cd.colorIndex].ToColor(); continueText.text = DataStore.uiLanguage.uiSetup.continueBtn; cardDescriptor = cd; cardInstruction = DataStore.activationInstructions.Where(x => x.instID == cd.id).FirstOr(null); if (cardInstruction == null) { Debug.Log("cardInstruction is NULL: " + cd.id); GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show("EnemyActivationPopup: cardInstruction is NULL: " + cd.id); return; } cardPrefab.InitCard(cd); //== no longer an issue //if ( cardInstruction == null ) //{ // //not all elites have their own instruction, resulting in null found, so get its regular version instruction set by name instead // int idx = cd.name.IndexOf( '(' ); // if ( idx > 0 ) // { // string nonelite = cd.name.Substring( 0, idx ).Trim(); // cardInstruction = DataStore.activationInstructions.Where( x => x.instName == nonelite ).FirstOr( null ); // Debug.Log( "TRYING REGULAR INSTRUCTION" ); // if ( cardInstruction == null ) // { // Debug.Log( "CAN'T FIND INSTRUCTION FOR: " + cd.id + "/" + nonelite ); // return; // } // } //} gameObject.SetActive(true); fader.color = new Color(0, 0, 0, 0); fader.DOFade(.95f, 1); cg.DOFade(1, .5f); transform.GetChild(1).localScale = new Vector3(.85f, .85f, .85f); transform.GetChild(1).DOScale(1, .5f).SetEase(Ease.OutExpo); SetThumbnail(cd); enemyName.text = cd.name.ToLower(); if (!string.IsNullOrEmpty(cd.ignored)) { ignoreText.text = $"<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">F</font></color>" + cd.ignored; } else { ignoreText.text = ""; } if (!cardDescriptor.hasActivated) { //if multiple card instructions, pick 1 int[] rnd = GlowEngine.GenerateRandomNumbers(cardInstruction.content.Count); InstructionOption io = cardInstruction.content[rnd[0]]; CardDescriptor potentialRebel = FindRebel(); if (potentialRebel != null) { rebel1 = potentialRebel.name; } else { rebel1 = DataStore.uiLanguage.uiMainApp.noneUC; } ParseInstructions(io); ParseBonus(cd.id); //save this card's activation state cardDescriptor.hasActivated = true; cardDescriptor.rebelName = rebel1; cardDescriptor.instructionOption = io; cardDescriptor.bonusName = bonusNameText.text; cardDescriptor.bonusText = bonusText.text; } else { CardDescriptor potentialRebel = FindRebel(); if (cardDescriptor.rebelName != null) { rebel1 = cardDescriptor.rebelName; } else if (potentialRebel != null) { rebel1 = potentialRebel.name; } else { rebel1 = DataStore.uiLanguage.uiMainApp.noneUC; } if (cardDescriptor.instructionOption != null) { ParseInstructions(cardDescriptor.instructionOption); } else { InstructionOption io = cardInstruction.content[GlowEngine.GenerateRandomNumbers(cardInstruction.content.Count)[0]]; ParseInstructions(io); cardDescriptor.instructionOption = io; } if (cardDescriptor.bonusName != null && cardDescriptor.bonusText != null) { bonusNameText.text = cardDescriptor.bonusName; bonusText.text = cardDescriptor.bonusText; } else { ParseBonus(cd.id); cardDescriptor.bonusName = bonusNameText.text; cardDescriptor.bonusText = bonusText.text; } } }
public static void CreateDeploymentHand() { var available = deploymentCards.cards .OwnedPlusOther() .FilterByFaction() .MinusIgnored() .MinusStarting() .MinusReserved() .ToList(); //Debug.Log( $"OF {deploymentCards.cards.Count} CARDS, USING {available.Count()}" ); //add earned villains available = available.Concat(sessionData.EarnedVillains).ToList(); //Debug.Log( $"ADD VILLAINS FILTERED TO {available.Count()} CARDS" ); if (sessionData.threatLevel <= 3) { available = GetCardsByTier(available.ToList(), 2, 2, 0); } else if (sessionData.threatLevel == 4) { available = GetCardsByTier(available.ToList(), 1, 2, 1); } else if (sessionData.threatLevel >= 5) { available = GetCardsByTier(available.ToList(), 1, 2, 2); } //if there are any villains and none were added, "help" add one (50% chance) if (sessionData.EarnedVillains.Count > 0 && !available.Any(x => sessionData.EarnedVillains.Contains(x)) && GlowEngine.RandomBool()) { int[] rv = GlowEngine.GenerateRandomNumbers(sessionData.EarnedVillains.Count); var v = sessionData.EarnedVillains[rv[0]]; available = available.Concat(new List <CardDescriptor>() { v }).ToList(); //add any remaining earned villains back into manual deploy list foreach (var cd in sessionData.EarnedVillains) { if (!available.Contains(cd)) { villainsToManuallyAdd.Add(cd); } } //Debug.Log( $"ADDED A VILLAIN (50%): {v.name}" ); } else { //if villain wasn't already added to DH, AND it didn't get helped into hand, add it to manual deployment list foreach (var cd in sessionData.EarnedVillains) { if (!available.Contains(cd)) { //Debug.Log( "VILLAIN *NOT* ADDED TO DH: " + cd.name ); villainsToManuallyAdd.Add(cd); } } } Debug.Log($"DEPLOYMENT HAND SIZE: {available.Count()} CARDS"); //for ( int i = 0; i < available.Count(); i++ ) //{ // Debug.Log( available.ElementAt( i ).name ); //} deploymentHand = available.ToList(); }
void AddRandomTokens(Transform[] usedPositions) { if (chapter.randomInteractionGroup == "None") { return; } //usedPositions = wonky user placed token position InteractionManager im = GlowEngine.FindObjectOfType <InteractionManager>(); //get array of interactions that are in the interaction group IInteraction[] interactionGroupArray = im.randomTokenInteractions .Where(x => x.dataName.EndsWith(chapter.randomInteractionGroup)).ToArray(); //Debug.Log( "EVENTS IN GROUP [" + chapter.randomInteractionGroup + "]: " + interactionGroupArray.Length ); //get all the possible token spawn locations that are NOT near FIXED tokens already placed List <Transform> attachtfs = new List <Transform>(); List <Transform> finalOpenTFS = new List <Transform>(); foreach (Tile t in tileList) { attachtfs.Clear(); attachtfs.AddRange(t.GetChildren("token attach")); var usedInThisTile = from tu in usedPositions where tu.GetComponent <MetaData>().tileID /*tile.hexTile.idNumber*/ == t.hexTile.idNumber select tu; var opentfs = new List <Transform>(); foreach (Transform tf in attachtfs) { float minD = 1000; foreach (Transform utf in usedInThisTile) { float d = Vector3.Distance(utf.position, tf.position); if (d < minD) { minD = d; } } if (minD > 1.1f) { opentfs.Add(tf); } } finalOpenTFS.AddRange(opentfs); } //recreate opentfs as hash with UNIQUE items, no dupes var openhash = new HashSet <Transform>(finalOpenTFS); finalOpenTFS = openhash.Select(x => x).ToList(); //Debug.Log( "REQUESTED EVENTS: " + chapter.randomInteractionGroupCount ); //Debug.Log( "USED POSITIONS: " + usedPositions.Length ); //Debug.Log( "FOUND POSSIBLE POSITIONS: " + attachtfs.Count ); //Debug.Log( "FOUND OPEN POSITIONS: " + finalOpenTFS.Count() ); //sanity check, max number of events based on how many requested and how many actually found in group how many actual open positions int max = Mathf.Min(interactionGroupArray.Length, Mathf.Min(chapter.randomInteractionGroupCount, finalOpenTFS.Count())); //Debug.Log( $"GRABBING {max} EVENTS" ); //generate random indexes to interactions within the group int[] rnds = GlowEngine.GenerateRandomNumbers(max); //randomly get randomInteractionGroupCount number of interactions IInteraction[] igs = new IInteraction[max]; for (int i = 0; i < max; i++) { igs[i] = interactionGroupArray[rnds[i]]; //Debug.Log( $"CHOSE EVENT: {igs[i].dataName} WITH TYPE {igs[i].tokenType}" ); } //create the tokens on random tiles for the interactions we just got int[] rands = GlowEngine.GenerateRandomNumbers(max /*opentfs.Count()*/); for (int i = 0; i < max /*igs.Length*/; i++) { //get tile this transform position belongs to Tile tile = finalOpenTFS[rands[i]].parent.GetComponent <Tile>(); //Debug.Log( "TILE #:" + tile.hexTile.idNumber ); //if the token points to a persistent event, swap the token type with the event it's delegating to //create new token prefab for this interaction GameObject go = null; if (igs[i].tokenType == TokenType.Search) { go = Object.Instantiate(tileManager.searchTokenPrefab, tile.transform); } else if (igs[i].tokenType == TokenType.Person) { if (igs[i].personType == PersonType.Human) { go = Object.Instantiate(tileManager.humanTokenPrefab, tile.transform); } else if (igs[i].personType == PersonType.Elf) { go = Object.Instantiate(tileManager.elfTokenPrefab, tile.transform); } else if (igs[i].personType == PersonType.Hobbit) { go = Object.Instantiate(tileManager.hobbitTokenPrefab, tile.transform); } else if (igs[i].personType == PersonType.Dwarf) { go = Object.Instantiate(tileManager.dwarfTokenPrefab, tile.transform); } } else if (igs[i].tokenType == TokenType.Threat) { go = Object.Instantiate(tileManager.threatTokenPrefab, tile.transform); } else if (igs[i].tokenType == TokenType.Darkness) { go = Object.Instantiate(tileManager.darkTokenPrefab, tile.transform); } else { Debug.Log($"ERROR: TOKEN TYPE SET TO NONE FOR {igs[i].dataName}"); } go.transform.position = new Vector3(finalOpenTFS[rands[i]].position.x, go.transform.position.y, finalOpenTFS[rands[i]].position.z); go.GetComponent <MetaData>().tokenType = HandlePersistentTokenSwap(igs[i].dataName); //igs[i].tokenType; go.GetComponent <MetaData>().personType = igs[i].personType; go.GetComponent <MetaData>().triggeredByName = "None"; go.GetComponent <MetaData>().triggerName = "None"; go.GetComponent <MetaData>().interactionName = igs[i].dataName; go.GetComponent <MetaData>().GUID = System.Guid.NewGuid(); go.GetComponent <MetaData>().isRandom = true; //go.GetComponent<MetaData>().isCreatedFromReplaced = false; //go.GetComponent<MetaData>().hasBeenReplaced = false; tile.tokenStates.Add(new TokenState() { isActive = false, parentTileGUID = tile.hexTile.GUID, localPosition = go.transform.localPosition, metaData = new MetaDataJSON(go.GetComponent <MetaData>()), }); } }
/// <summary> /// Calculate and return a deployable group using "fuzzy" deployment, DOES NOT remove it from deployment hand /// </summary> public static CardDescriptor GetFuzzyDeployable(bool isOnslaught = false) { /* * If the app chooses to deploy a Tier III (=expensive) group, but does not have enough threat by up to 3 points, it still deploys the unit and reduces threat to 0. This way, the deployment of expensive units does not hinge on a tiny amount of missing threat, but doesn’t simply make them cheaper. Example: The app chooses to deploy an AT-ST (threat cost 14). It can deploy even if there is only 11, 12, or 13 threat left */ List <CardDescriptor> tier1Group = new List <CardDescriptor>(); List <CardDescriptor> tier2Group = new List <CardDescriptor>(); CardDescriptor tier3Group = null; List <CardDescriptor> tier23Group = new List <CardDescriptor>(); CardDescriptor validEnemy = null; int[] rnd; int t2modifier = 0; int t3modifier = 0; if (isOnslaught) { t2modifier = 1; t3modifier = 2; } //get tier 1 affordable groups if (deploymentHand.Any(x => x.tier == 1 && x.cost <= sessionData .gameVars.currentThreat)) { tier1Group = deploymentHand.Where(x => x.tier == 1 && x.cost <= sessionData.gameVars.currentThreat).ToList(); } //get tier 2 affordable groups if (deploymentHand.Any(x => x.tier == 2 && x.cost - t2modifier <= sessionData.gameVars.currentThreat)) { tier2Group = deploymentHand.Where(x => x.tier == 2 && x.cost - t2modifier <= sessionData.gameVars.currentThreat) .ToList(); } //concatenate the tier 1 and tier 2 groups tier23Group = tier1Group.Concat(tier2Group).ToList(); //filter list - minus deployed tier23Group = tier23Group.MinusDeployed(); //now get ONE of them randomly IF there are any if (tier23Group.Count > 0) { rnd = GlowEngine.GenerateRandomNumbers(tier23Group.Count); validEnemy = tier23Group[rnd[0]]; } //get a random tier 3 group from deployment hand with cost up to 3 over current threat and NOT DEPLOYED, if one exists if (deploymentHand.Any(x => x.tier == 3 && x.cost - t3modifier <= sessionData.gameVars.currentThreat + 3 && !deployedEnemies.Contains(x) )) { var t3 = deploymentHand.Where(x => x.tier == 3 && x.cost - t3modifier <= sessionData.gameVars.currentThreat + 3 && !deployedEnemies.Contains(x) ).ToList(); rnd = GlowEngine.GenerateRandomNumbers(t3.Count); tier3Group = t3[rnd[0]]; } //if there are valid tier 3 AND tier 1/2 groups, there is a 50/50 chance of either being returned if (validEnemy != null && tier3Group != null) { Debug.Log("ELITE DEPLOYMENT COIN FLIP"); if (GlowEngine.RandomBool()) { return(validEnemy); } else { return(tier3Group); } } //otherwise try to return the tier 3 group, if any picked else if (validEnemy == null && tier3Group != null) { return(tier3Group); } //finally try to return the tier1/2 group, even if it's null return(validEnemy); }