/// <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); }
public void OnClose() { FindObjectOfType <Sound>().PlaySound(FX.Click); fader.DOFade(0, .5f).OnComplete(() => { Transform content = transform.Find("Panel/content"); foreach (Transform tf in content) { Destroy(tf.gameObject); } //handle deployment if (allyToAdd != null) { FindObjectOfType <DeploymentGroupManager>().DeployHeroAlly(allyToAdd); } if (enemyToAdd != null) { if (DataStore.sessionData.gameVars.pauseDeployment) { GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show($"Imperial Deployment is <color=\"red\">PAUSED</color>. The requested group [{enemyToAdd.name}] will not be deployed."); } else { FindObjectOfType <DeploymentGroupManager>().DeployGroup(enemyToAdd); } } gameObject.SetActive(false); callback?.Invoke(); }); cg.DOFade(0, .2f); transform.GetChild(0).DOScale(.85f, .5f).SetEase(Ease.OutExpo); }
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 = ""; } } }
void ContinueGame() { if (DataStore.LoadState()) { //restore deployed enemies and heroes/allies dgManager.RestoreState(); //update UI with loaded state //round # roundText.text = DataStore.uiLanguage.uiMainApp.roundHeading + "\r\n" + DataStore.sessionData.gameVars.round; //toggle pause threat/deployment buttons if (DataStore.sessionData.gameVars.pauseThreatIncrease) { pauseThreatToggle.isOn = true; } if (DataStore.sessionData.gameVars.pauseDeployment) { pauseDeploymentToggle.isOn = true; } fameButton.interactable = DataStore.sessionData.useAdaptiveDifficulty; GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show(DataStore.uiLanguage.uiMainApp.restoredMsgUC); } else { GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show(DataStore.uiLanguage.uiMainApp.restoreErrorMsgUC); } }
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); } }
public void OnRollDefense() { OnOK(); DiceRoller diceRoller = GlowEngine.FindObjectsOfTypeSingle <DiceRoller>(); diceRoller.Show(card, false); }
/// <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); }
void HandleRotation() { if (Input.GetMouseButtonDown(1)) { dragStart = Input.mousePosition; } if (Input.GetMouseButton(1)) { float d = Vector2.Distance(dragStart, Input.mousePosition); float delta = GlowEngine.RemapValue(d, 0, 50, 0, rotateSpeed); if (Input.mousePosition.x < dragStart.x) { rotateAmount = -delta; } else if (Input.mousePosition.x > dragStart.x) { rotateAmount = delta; } else { rotateAmount = 0; } transform.DORotate(new Vector3(0, rotateAmount, 0), rotateDuration, RotateMode.WorldAxisAdd); dragStart = Input.mousePosition; } }
public void OnRollAttack() { OnOK(); DiceRoller diceRoller = GlowEngine.FindObjectsOfTypeSingle <DiceRoller>(); diceRoller.Show(card, true); }
/// <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"); } }
void HandleZoom() { float axis = Input.GetAxis("Mouse ScrollWheel"); float y = cam.transform.localPosition.y; // scroll up if (axis > 0f) { if (y - .2f >= 3f) { targetZoom = cam.transform.localPosition - new Vector3(0, .2f, 0); } } // scroll down else if (axis < 0f) { if (y + .2f <= 6f) { targetZoom = cam.transform.localPosition + new Vector3(0, .2f, 0); } } float fdScalar = GlowEngine.RemapValue(y, 3, 6, focusDistMin, focusDistMax); targetDOF.Set(fdScalar, fdScalar, fdScalar); targetLookAt.y = 26.87f; //30.58 targetLookAt.x = GlowEngine.RemapValue(targetZoom.y, .2f, 6f, 50f, 55f); }
private void Update() { //check if mission can be started bool heroCheck = DataStore.sessionData.selectedDeploymentCards[4].cards.Count > 0; bool difficulty = DataStore.sessionData.difficulty != Difficulty.NotSet; bool allyRules = DataStore.sessionData.allyRules != AllyRules.NotSet; bool factions = DataStore.sessionData.includeImperials || DataStore.sessionData.includeMercs; if (heroCheck && difficulty && allyRules && factions) { startMissionButton.interactable = true; } else { startMissionButton.interactable = false; } if (Input.GetKeyDown(KeyCode.Escape) && !GlowEngine.FindObjectsOfTypeSingle <GroupChooserScreen>().gameObject.activeInHierarchy && !GlowEngine.FindObjectsOfTypeSingle <MissionTextBox>().gameObject.activeInHierarchy && !GlowEngine.FindObjectsOfTypeSingle <HeroChooser>().gameObject.activeInHierarchy && !GlowEngine.FindObjectsOfTypeSingle <CardViewPopup>().gameObject.activeInHierarchy) { OnBack(); } }
/// <summary> /// colorize whole group (START chapter ONLY), fire chapter exploreTrigger /// </summary> public void Colorize(bool onlyStart = false) { Debug.Log("EXPLORING GROUP isExplored?::" + isExplored); if (isExplored) { return; } //isExplored = true; //if it's not the first chapter, set the "on explore" trigger //if ( chapter.dataName != "Start" ) GlowEngine.FindObjectOfType <TriggerManager>().FireTrigger(chapter.exploreTrigger); foreach (Tile t in tileList) { if (onlyStart && t.hexTile.isStartTile) { t.Colorize(); } else if (!onlyStart) { t.Colorize(); } } }
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); } }
private void OnReturn() { if (GlowEngine.FindObjectsOfTypeSingle <EnemyActivationPopup>().gameObject.activeInHierarchy) { GlowEngine.FindObjectsOfTypeSingle <EnemyActivationPopup>().OnReturn(); } }
void HandleDragging() { if (Input.GetMouseButtonDown(0)) { dragOrigin = Input.mousePosition; return; } if (!Input.GetMouseButton(0) || dClickCount > 1) { dragging = false; return; } dragging = true; float scalar = Vector3.Distance(dragOrigin, Input.mousePosition); scalar = GlowEngine.RemapValue(scalar, 0, 30, 0, .7f); //Vector3 pos = cam.ScreenToViewportPoint( Input.mousePosition - dragOrigin ); Vector3 direction = Input.mousePosition - dragOrigin; direction = Vector3.Normalize(direction); Vector3 move = new Vector3(direction.x * scalar, 0, direction.y * scalar); transform.Translate(-move, Space.Self); targetPos = transform.position; dragOrigin = Input.mousePosition; }
private void CheckSwipe() { var duration = (float)_fingerUpTime.Subtract(_fingerDownTime).TotalSeconds; var dirVector = _fingerUp - _fingerDown; if (duration > timeThreshold) { return; } if (dirVector.magnitude < swipeThreshold) { return; } var direction = GlowEngine.VectorToAngle(dirVector); //print( direction ); //if ( direction >= 45 && direction < 135 ) // onSwipeUp.Invoke(); if (direction < 0) //( direction >= 135 && direction < 225 ) { //print( "right" ); onSwipeRight.Invoke(); } //else if ( direction >= 225 && direction < 315 ) // onSwipeDown.Invoke(); else //if ( direction >= 315 && direction < 360 || direction >= 0 && direction < 45 ) { //print( "left" ); onSwipeLeft.Invoke(); } }
public void OnPauseDeploy(Toggle t) { sound.PlaySound(FX.Click); DataStore.sessionData.gameVars.pauseDeployment = t.isOn; string s = t.isOn ? DataStore.uiLanguage.uiMainApp.pauseDepMsgUC : DataStore.uiLanguage.uiMainApp.unPauseDepMsgUC; GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show(s); }
public void OnViewCard() { spaceListen = false; EventSystem.current.SetSelectedGameObject(null); CardViewPopup cardViewPopup = GlowEngine.FindObjectsOfTypeSingle <CardViewPopup>(); cardViewPopup.Show(cardDescriptor, OnReturn); }
public void OnPointerClick() { if (cardDescriptor.isDummy || isHero) { return; } CardViewPopup cardViewPopup = GlowEngine.FindObjectsOfTypeSingle <CardViewPopup>(); cardViewPopup.Show(cardDescriptor); }
public void ActivateScreen() { gameObject.SetActive(true); cg.alpha = 0; cg.DOFade(1, .5f); //reset UI addHeroButton.interactable = true; selectedMissionText.transform.Find("view Button").GetComponent <Button>().interactable = false; selectedMissionText.transform.Find("mission info button").GetComponent <Button>().interactable = false; imperialToggle.isOn = true; mercenaryToggle.isOn = true; adaptiveToggle.isOn = false; threatWheelHandler.ResetWheeler(); addtlThreatWheelHandler.ResetWheeler(); for (int i = 0; i < enemyGroupText.Length; i++) { enemyGroupText[i].text = DataStore.uiLanguage.uiSetup.choose; } enemyGroupText[3].text = "8 " + DataStore.uiLanguage.uiSetup.selected; //button colors to red ColorBlock cb = difficultyButton.colors; cb.normalColor = new Color(1, 0.1568628f, 0, 1); difficultyButton.colors = cb; cb = addHeroButton.colors; cb.normalColor = new Color(1, 0.1568628f, 0, 1); addHeroButton.colors = cb; OnRemoveAlly(); //set the language strings into the UI languageController.SetTranslatedUI(); //check for default state string path = Path.Combine(Application.persistentDataPath, "Defaults", "sessiondata.json"); loadDefaultsButton.interactable = File.Exists(path); //aspect ratio adjustment if (GlowEngine.GetAspectRatio() >= 1.6f) //16:9 or greater { gridLayoutGroup.cellSize = new Vector2(413, 400); } else if (GlowEngine.GetAspectRatio() >= 1.33f) //4:3, 5:4 { gridLayoutGroup.cellSize = new Vector2(313, 400); } //load preset for core1, the default mission LoadMissionPreset(); OnReturnTo(); }
private void Update() { float ypos = GlowEngine.SineAnimation(-.2f, -.08f, .5f); float zpos = GlowEngine.SineAnimation(.35f, .43f, .25f); float zanim = GlowEngine.SineAnimation(-10f, 10f, .4f); float xanim = GlowEngine.SineAnimation(0f, 28f, .6f); float sxanim = GlowEngine.SineAnimation(.73f, 1f, .3f); float syanim = GlowEngine.SineAnimation(.32f, 0.45728f, .6f); shadowWisp.localPosition = new Vector3(0, ypos, zpos); shadowWisp.localScale = new Vector3(sxanim, syanim, 1); shadowWisp.localRotation = Quaternion.Euler(xanim, 0, zanim); }
/// <summary> /// swap token type to delegate event if it's a persistent event /// </summary> TokenType HandlePersistentTokenSwap(string eventName) { IInteraction persEvent = GlowEngine.FindObjectOfType <InteractionManager>().GetInteractionByName(eventName); if (persEvent is PersistentInteraction) { string delname = ((PersistentInteraction)persEvent).eventToActivate; IInteraction delEvent = GlowEngine.FindObjectOfType <InteractionManager>().GetInteractionByName(delname); return(delEvent.tokenType); } return(persEvent.tokenType); }
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(); }
private void Update() { if (networkStatus == NetworkStatus.Busy) { busyIconTF.Rotate(new Vector3(0, 0, Time.deltaTime * 175f)); } else { busyIconTF.localRotation = Quaternion.Euler(0, 0, 0); } //pulse scale if network error or wrong version if (networkStatus == NetworkStatus.Error || networkStatus == NetworkStatus.WrongVersion) { busyIconTF.localScale = GlowEngine.SineAnimation(.9f, 1.1f, 15).ToVector3(); } }
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]]); } }
void Update() { float xScalar = GlowEngine.SineAnimation( lowx, highx, multiplierx); float yScalar = GlowEngine.SineAnimation( lowy, highy, multipliery); float zScalar = GlowEngine.SineAnimation( lowz, highz, multiplierz); world.Rotate(xScalar * Time.deltaTime * scalar, yScalar * Time.deltaTime * scalar, zScalar * Time.deltaTime * scalar); }