Пример #1
0
    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     = "";
            }
        }
    }
Пример #2
0
    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);
        }
    }
Пример #3
0
    /// <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);
    }
Пример #4
0
    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();
    }
Пример #5
0
    /// <summary>
    /// Takes an enemy or villain, applies difficulty modifier, deploys, removes from dep hand, adds to deployed list
    /// </summary>
    public void DeployGroup(CardDescriptor cardDescriptor, bool skipEliteModify = false)
    {
        cardDescriptor.hasActivated = false;
        // EASY: Any time an Elite group is deployed, it has a 15% chance to be downgraded to a normal group without refunding of threat. ( If the respective normal group is still available.)
        if (DataStore.sessionData.difficulty == Difficulty.Easy &&
            !skipEliteModify &&
            cardDescriptor.isElite &&
            GlowEngine.RandomBool(15))
        {
            //see if normal version exists, include dep hand
            var nonE = DataStore.GetNonEliteVersion(cardDescriptor);
            if (nonE != null)
            {
                Debug.Log("DeployGroup EASY mode Elite downgrade: " + nonE.name);
                cardDescriptor = nonE;
                GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show(DataStore.uiLanguage.uiMainApp.eliteDowngradeMsgUC);
            }
        }

        //Hard: Threat increase x1.3 Any time a normal group is deployed, it has a 15 % chance to be upgraded to an Elite group at no additional threat cost. ( If the respective normal group is still available.) Deployment Modifier starts at 2 instead of 0.
        if (DataStore.sessionData.difficulty == Difficulty.Hard &&
            !skipEliteModify &&
            !cardDescriptor.isElite &&
            GlowEngine.RandomBool(15))
        {
            //see if elite version exists, include dep hand
            var elite = DataStore.GetEliteVersion(cardDescriptor);
            if (elite != null)
            {
                Debug.Log("DeployGroup HARD mode Elite upgrade: " + elite.name);
                cardDescriptor = elite;
                GlowEngine.FindObjectsOfTypeSingle <QuickMessage>().Show(DataStore.uiLanguage.uiMainApp.eliteUpgradeMsgUC);
            }
            else
            {
                Debug.Log("SKIPPED: " + cardDescriptor.name);
            }
        }

        if (DataStore.deployedEnemies.Contains(cardDescriptor))
        {
            Debug.Log(cardDescriptor.name + " already deployed");
            return;
        }

        cardDescriptor.currentSize = cardDescriptor.size;
        var go = Instantiate(dgPrefab, gridContainer);

        go.GetComponent <DGPrefab>().Init(cardDescriptor);

        //add it to deployed enemies
        DataStore.deployedEnemies.Add(cardDescriptor);
        //if it's FROM the dep hand, remove it
        //should have already been removed *IF* it's from DeploymentPopup
        //otherwise it just got (up/down)graded to/from Elite
        DataStore.deploymentHand.Remove(cardDescriptor);

        sound.playDeploymentSound(cardDescriptor.id);

        //var rt = gridContainer.GetComponent<RectTransform>();
        //rt.localPosition = new Vector3( 20, -3000, 0 );
    }