Ejemplo n.º 1
0
 public void AddAlly(CardDescriptor cd)
 {
     if (cd != null)
     {
         dgManager.DeployHeroAlly(cd);
     }
 }
Ejemplo n.º 2
0
    public SessionData()
    {
        //DataStore.InitData() has already been called at this point to load data
        difficulty               = Difficulty.NotSet;
        threatLevel              = addtlThreat = 0;
        allyRules                = AllyRules.Normal;
        optionalDeployment       = YesNo.No;
        allyThreatCost           = YesNo.No;
        selectedMissionExpansion = Expansion.Core;
        selectedMissionID        = "core1";
        selectedMissionName      = DataStore.missionCards["Core"][0].name;
        includeImperials         = true;
        includeMercs             = true;

        selectedDeploymentCards = new DeploymentCards[5];
        for (int i = 0; i < 5; i++)
        {
            selectedDeploymentCards[i] = new DeploymentCards();
        }
        selectedAlly = null;

        //ignore "Other" expansion enemy groups by default
        selectedDeploymentCards[3].cards.AddRange(DataStore.deploymentCards.cards.Where(x => x.expansion == "Other"));
        gameVars = new GameVars();
    }
Ejemplo n.º 3
0
 public void AddGroup(CardDescriptor cd)
 {
     if (cd != null)
     {
         dgManager.DeployGroup(cd, true);
     }
 }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 5
0
    public void OnToggle(int index)
    {
        EventSystem.current.SetSelectedGameObject(null);
        Transform grid = transform.Find("Panel/mugshot grid");

        if (!grid.GetChild(index).gameObject.activeInHierarchy)
        {
            return;
        }

        sound.PlaySound(FX.Click);
        if (selectedIndex == index)
        {
            selectedIndex = -1;
            selectedCard  = null;
            nameText.text = "";
        }
        else
        {
            selectedIndex = index;
            selectedCard  = cardSet[index];
            nameText.text = cardSet[index].name;
            Debug.Log(cardSet[index].name);
        }
        //Debug.Log( "selectedIndex: " + selectedIndex );
    }
Ejemplo n.º 6
0
    public void OnToggle(Toggle t)
    {
        EventSystem.current.SetSelectedGameObject(null);
        if (!t.gameObject.activeInHierarchy)
        {
            return;
        }

        sound.PlaySound(FX.Click);

        //get index Toggle (1)
        Regex rx  = new Regex(@"\d{1,2}");
        var   m   = rx.Match(t.name);
        int   idx = int.Parse(m.Value) - 1;
        //Debug.Log( idx );
        CardDescriptor clicked = ownedHeroes[idx];

        if (t.isOn && !selectedHeroes.Contains(clicked))
        {
            selectedHeroes.Add(clicked);
            heroNameText.text = clicked.name;
        }
        else if (!t.isOn && selectedHeroes.Contains(clicked))
        {
            selectedHeroes.Remove(clicked);
            heroNameText.text = "";
        }

        UpdateInteractable();
        //foreach ( CardDescriptor cd in selectedHeroes )
        //	Debug.Log( cd.name );
    }
Ejemplo n.º 7
0
    public void ActivateEnemy(CardDescriptor cd)
    {
        if (cd == null)
        {
            return;
        }

        dgManager.ExhaustGroup(cd.id);
        enemyActivationPopup.Show(cd);
    }
Ejemplo n.º 8
0
    public Resolution ResolveCard (CardDescriptor playerCard, CardDescriptor opponentCard, SkirmishModifiers skirmishModifiers)
    {
        var player = FlattenAttr (playerCard.CardAttributes);
        var opponent = FlattenAttr (opponentCard.CardAttributes);

        return new Resolution {
            OpponentDamageTaken = skirmishModifiers.CalculateDamageTaken (ModifierTarget.Oponnnent, player, opponent),
            PlayerDamageTaken = skirmishModifiers.CalculateDamageTaken (ModifierTarget.Player, opponent, player),
        };
    }
Ejemplo n.º 9
0
 public List<CardDescriptor> GetRandomCards (int number, CardDescriptor.CardRarity rarity)
 {
     var cards = new List<CardDescriptor> ();
     var rnd = new System.Random ();
     for (int i = 0; i < number; i++) {
         var cardsPool = CardInformation.Where (c => c.Rarity == rarity).ToList ();
         var idx = rnd.Next (0, cardsPool.Count () - 1);
         cards.Add (cardsPool [idx]);
     }
     return cards;
 }
Ejemplo n.º 10
0
    public void LoadMissionPreset()
    {
        var presets = DataStore.missionPresets[DataStore.sessionData.selectedMissionExpansion.ToString().ToLower()];
        var mp      = presets.Where(x => x.id.ToLower() == DataStore.sessionData.selectedMissionID.ToLower()).FirstOr(null);

        if (mp != null)
        {
            //update UI with preset values
            DataStore.sessionData.threatLevel = mp.defaultThreat;
            threatWheelHandler.ResetWheeler(DataStore.sessionData.threatLevel);

            DataStore.sessionData.optionalDeployment = mp.optionalDeployment == "yes" ? YesNo.Yes : YesNo.No;
            deploymentText.text = DataStore.sessionData.optionalDeployment == YesNo.Yes ? DataStore.uiLanguage.uiSetup.yes : DataStore.uiLanguage.uiSetup.no;

            DataStore.sessionData.includeMercs     = mp.factionMerc == "yes" ? true : false;
            DataStore.sessionData.includeImperials = mp.factionImp == "yes" ? true : false;
            mercenaryToggle.isOn = DataStore.sessionData.includeMercs;
            imperialToggle.isOn  = DataStore.sessionData.includeImperials;

            CardDescriptor custom = new CardDescriptor()
            {
                cost = 0, expansion = "Other", name = "Custom Group", faction = "None", id = "DG070", ignored = "", priority = 2, rcost = 0, size = 1, tier = 1
            };

            var allCards = DataStore.deploymentCards.cards.Concat(DataStore.villainCards.cards).ToList();
            allCards.Add(custom);

            DataStore.sessionData.MissionStarting.Clear();
            foreach (var card in mp.initialGroups)
            {
                DataStore.sessionData.MissionStarting.Add(allCards.Where(x => x.id == card).First());
            }
            DataStore.sessionData.MissionReserved.Clear();
            foreach (var card in mp.reserveGroups)
            {
                DataStore.sessionData.MissionReserved.Add(allCards.Where(x => x.id == card).First());
            }
            DataStore.sessionData.MissionIgnored.Clear();
            foreach (var card in mp.ignoredGroups)
            {
                DataStore.sessionData.MissionIgnored.Add(allCards.Where(x => x.id == card).First());
            }

            if (mp.allyGroups.Count > 0)
            {
                DataStore.sessionData.selectedAlly = DataStore.allyCards.cards.Where(x => x.id == mp.allyGroups[0]).First();
            }
            else
            {
                DataStore.sessionData.selectedAlly = null;
            }
        }
    }
Ejemplo n.º 11
0
    public void HandleLanding(bool skipThreatIncrease, bool isOptionalDeployment)
    {
        /*
         * Threat +Threat Level +1
         * Deploy up to 2 new groups
         * “Fuzzy deployment” (see below)
         * DM +1
         */
        if (isOptionalDeployment || skipThreatIncrease)
        {
            landingMessage.SetActive(false);
        }
        else        // if ( !skipThreatIncrease )
        {
            DataStore.sessionData.ModifyThreat(DataStore.sessionData.threatLevel + 1);
            DataStore.sessionData.UpdateDeploymentModifier(1);
            landingMessage.SetActive(true);
        }

        CardDescriptor d1 = DataStore.GetFuzzyDeployable();

        if (d1 != null)
        {
            topLanding.SetActive(true);
            landing1.Init(d1, 3);              //make sure it shows full size
            groupsToDeploy.Add(d1);
            //remove it from dep hand
            DataStore.deploymentHand.Remove(d1);
            //update threat just spent
            DataStore.sessionData.ModifyThreat(-d1.cost);
        }

        CardDescriptor d2 = DataStore.GetFuzzyDeployable();

        if (d2 != null)
        {
            bottomLanding.SetActive(true);
            landing2.Init(d2, 3);              //make sure it shows full size
            groupsToDeploy.Add(d2);
            //remove it from dep hand
            DataStore.deploymentHand.Remove(d2);
            //update threat just spent
            DataStore.sessionData.ModifyThreat(-d2.cost);
        }

        if (d1 == null && d2 == null)
        {
            warning.gameObject.SetActive(true);
            warning.text = DataStore.uiLanguage.uiMainApp.deploymentWarningUC;
        }
    }
Ejemplo n.º 12
0
 void SetThumbnail(CardDescriptor cd)
 {
     //set thumbnail for villain
     if (DataStore.villainCards.cards.Any(x => x.id == cd.id))
     {
         thumbnail.sprite = Resources.Load <Sprite>($"Cards/Villains/{cd.id.Replace( "DG", "M" )}");
     }
     else        //regular enemy
     {
         thumbnail.sprite = Resources.Load <Sprite>($"Cards/Enemies/{cd.expansion}/{cd.id.Replace( "DG", "M" )}");
         thumbnail.GetComponent <Outline>().effectColor = new Color(0, 0.6440244f, 1, 1);
     }
     thumbnail.DOFade(1, .25f);
 }
Ejemplo n.º 13
0
    public void Show(CardDescriptor cd, Action <bool> action = null)
    {
        card = cd;
        dynamicCard.gameObject.SetActive(true);
        dynamicCard.InitCard(cd);
        callback = action;

        gameObject.SetActive(true);
        fader.color = new Color(0, 0, 0, 0);
        fader.DOFade(.95f, .5f);
        cg.DOFade(1, .5f);
        transform.GetChild(1).localScale = new Vector3(.85f, .85f, .85f);
        transform.GetChild(1).DOScale(1, .5f).SetEase(Ease.OutExpo);
    }
Ejemplo n.º 14
0
    /// <summary>
    /// CAN be in dep hand, minus deployed, minus reserved, minus ignored
    /// </summary>
    public static CardDescriptor GetEliteVersion(CardDescriptor cd)
    {
        //starting groups already deployed, no need to filter
        //1) filter to elites only
        //2) the elite version of the card will have the NAME in its name property
        var valid = deploymentCards.cards
                    .Where(x => x.isElite)
                    .Where(x => x.name.Contains(cd.name)).ToList()
                    .MinusDeployed()
                    .MinusReserved()
                    .MinusIgnored();

        return(valid.FirstOr(null));
    }
    public void ResetUI(ChooserMode mode)
    {
        chooserMode = mode;
        if (mode == ChooserMode.Ally)          //reset ally to none
        {
            DataStore.sessionData.selectedAlly = null;
        }

        selectedHero       = null;
        enemyNameText.text = "";

        //reset to show Core expansion
        transform.parent.parent.parent.parent.Find("expansion selector container").Find("Core").GetComponent <Toggle>().isOn = true;
        OnChangeExpansion("Core");
    }
Ejemplo n.º 16
0
    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();
    }
Ejemplo n.º 17
0
    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);
        }
    }
Ejemplo n.º 18
0
    public void Init(CardDescriptor cd)
    {
        cardDescriptor = cd;

        if (DataStore.villainCards.cards.Contains(cd))
        {
            thumb.sprite = Resources.Load <Sprite>($"Cards/Villains/{cd.id.Replace( "DG", "M" )}");
        }
        else
        {
            thumb.sprite = Resources.Load <Sprite>($"Cards/Enemies/{cd.expansion}/{cd.id.Replace( "DG", "M" )}");
        }

        cardName.text        = cd.name;
        cardCost.text        = cd.cost.ToString();
        cardCostHeading.text = DataStore.uiLanguage.uiMainApp.depCostUC + ":";
    }
    public bool IsInGroup(CardDescriptor cd)
    {
        bool found = false;

        for (int i = 0; i < 5; i++)
        {
            if (groupIndex != i)
            {
                if (DataStore.sessionData.selectedDeploymentCards[i].cards.Contains(cd))
                {
                    found = true;
                }
            }
        }

        return(found);
    }
Ejemplo n.º 20
0
    public void Init (CardDescriptor card, int index)
    {
        this.Inject ();
        hoverOver = GetComponent<HoverOver> ();
        hoverOver.Reset (hoverEnabled: true);
        Card = card;
        Index = index;

        _cardDescription = transform.FindChild ("Card Description");

        transform.FindChild ("Text").GetComponent<Text> ().text = Card.Name;

        transform.FindChild ("Image").GetComponent<Image> ().sprite = cardAssetsProvider.GetSpriteFromPath (Card.CardImage);

        RemoveOldIcons ();
        AddCardAttributeIcons (Card.CardAttributes);
    }
    public void OnChangeExpansion(string expansion)
    {
        EventSystem.current.SetSelectedGameObject(null);

        selectedHero       = null;
        enemyNameText.text = "";

        //disable all toggle buttons
        foreach (Transform c in transform)
        {
            c.gameObject.SetActive(false);
            c.GetComponent <Toggle>().isOn = false;
        }

        //only get card list of chosen expansion
        if (chooserMode == ChooserMode.Hero)
        {
            heroCards = DataStore.heroCards.cards.Where(x => x.expansion == expansion).ToList();
        }
        else if (chooserMode == ChooserMode.Ally)
        {
            heroCards = DataStore.allyCards.cards.Where(x => x.expansion == expansion).ToList();
        }

        Sprite thumbNail = null;

        //activate toggle btns and change label for each card in list
        for (int i = 0; i < heroCards.Count; i++)
        {
            var child = transform.GetChild(i);
            child.gameObject.SetActive(true);

            thumbNail = Resources.Load <Sprite>($"Cards/Allies/{heroCards[i].id.Replace( heroCards[i].id[0], 'M' )}");
            var thumb = child.Find("Image");
            thumb.GetComponent <Image>().sprite = thumbNail;
            if (!heroCards[i].isElite)
            {
                thumb.GetComponent <Image>().color = new Color(1, 1, 1, 1);
            }
            else
            {
                thumb.GetComponent <Image>().color = new Color(1, .5f, .5f, 1);
            }
        }
    }
Ejemplo n.º 22
0
    public void Show(ChooserMode mode, List <CardDescriptor> cards, Action <CardDescriptor> callback)
    {
        gameObject.SetActive(true);
        fader.color = new Color(0, 0, 0, 0);
        fader.DOFade(.95f, 1);
        cg.alpha = 0;
        cg.DOFade(1, .5f);

        closeText.text = DataStore.uiLanguage.uiMainApp.close;

        //hide expansion buttons not owned, skipping Core and Other
        Transform exp = transform.Find("Panel/expansion selector container");

        //toggle Core button ON
        exp.GetChild(0).GetComponent <Toggle>().isOn = true;
        for (int i = 1; i < exp.childCount - 1; i++)
        {
            if (DataStore.ownedExpansions.Contains((Expansion)Enum.Parse(typeof(Expansion), exp.GetChild(i).name)))
            {
                exp.GetChild(i).gameObject.SetActive(true);
            }
            else
            {
                exp.GetChild(i).gameObject.SetActive(false);
            }
        }

        callBack    = callback;
        chooserMode = mode;

        //add custom group IF mode != ally/hero
        CardDescriptor custom = new CardDescriptor()
        {
            cost = 0, expansion = "Other", name = "Custom Group", faction = "None", id = "DG070", ignored = "", priority = 2, rcost = 0, size = 1, tier = 1
        };

        cardDescriptors = new List <CardDescriptor>(cards);
        if (mode == ChooserMode.DeploymentGroups && !cardDescriptors.Any(x => x.id == "DG070"))
        {
            cardDescriptors.Add(custom);
        }

        OnChangeExpansion("Core");
    }
Ejemplo n.º 23
0
    /// <summary>
    /// Takes an enemy, villain, or ally
    /// </summary>
    public void Init(CardDescriptor cd)
    {
        Debug.Log("DEPLOYED: " + cd.name);
        cardDescriptor = cd;
        for (int i = 0; i < cd.size; i++)
        {
            countToggles[i].gameObject.SetActive(true);
        }
        selfButton.interactable = true;

        ToggleExhausted(cd.hasActivated);

        if (DataStore.deploymentCards.cards.Any(x => x.id == cd.id))
        {
            iconImage.sprite = Resources.Load <Sprite>($"Cards/Enemies/{cd.expansion}/{cd.id.Replace( "DG", "M" )}");
        }
        else if (DataStore.villainCards.cards.Any(x => x.id == cd.id))
        {
            iconImage.sprite    = Resources.Load <Sprite>($"Cards/Villains/{cd.id.Replace( "DG", "M" )}");
            outline.effectColor = eliteColor;
        }
        else if (cd.id == "DG070")          //handle custom group
        {
            iconImage.sprite = Resources.Load <Sprite>("Cards/Enemies/Other/M070");
        }
        else        //otherwise it's an ally
        {
            //Debug.Log( "ally" );
            iconImage.sprite = Resources.Load <Sprite>($"Cards/Allies/{cd.id.Replace( "DG", "M" )}");
        }

        if (cd.isElite)
        {
            outline.effectColor = eliteColor;
        }

        SetColorIndex();

        Transform tf = transform.GetChild(0);

        tf.localScale = Vector3.zero;
        tf.DOScale(1, 1f).SetEase(Ease.OutBounce);
    }
Ejemplo n.º 24
0
    public void Init(CardDescriptor cd)
    {
        Debug.Log("DEPLOYED: " + cd.name);
        cardDescriptor = cd;

        if (!cd.isDummy)
        {
            if (DataStore.heroCards.cards.Any(x => x.id == cd.id))
            {
                isHero           = true;
                iconImage.sprite = Resources.Load <Sprite>($"Cards/Heroes/{cd.id}");
            }
            else if (DataStore.allyCards.cards.Any(x => x.id == cd.id))
            {
                isAlly           = true;
                iconImage.sprite = Resources.Load <Sprite>($"Cards/Allies/{cd.id.Replace( "A", "M" )}");
            }

            if (cd.id[0] == 'A')
            {
                outline.effectColor = eliteColor;
            }
        }
        else
        {
            iconImage.sprite = Resources.Load <Sprite>("Cards/Heroes/bonus");
            woundToggle.gameObject.SetActive(false);
        }

        if (cd.heroState == null)
        {
            cd.heroState = new HeroState();
            cd.heroState.Init(DataStore.sessionData.MissionHeroes.Count);
        }

        SetHealth(cd.heroState.heroHealth);
        SetActivation();

        Transform tf = transform.GetChild(0);

        tf.localScale = Vector3.zero;
        tf.DOScale(1, 1f).SetEase(Ease.OutBounce);
    }
Ejemplo n.º 25
0
    void HandleReinforcements()
    {
        /*
         * Threat +Threat Level
         * Reinforce up to 2 groups
         * DM +1
         */
        DataStore.sessionData.ModifyThreat(DataStore.sessionData.threatLevel);
        DataStore.sessionData.UpdateDeploymentModifier(1);

        CardDescriptor r1 = DataStore.GetReinforcement();

        if (r1 != null)
        {
            topPanel.SetActive(true);
            topR1.Init(r1);
            topR2.Init(r1, 1);
            r1.currentSize += 1;
            //update threat just spent
            DataStore.sessionData.ModifyThreat(-r1.rcost);
            //Debug.Log( "new size R1:" + r1.currentSize );
        }
        CardDescriptor r2 = DataStore.GetReinforcement();

        if (r2 != null)
        {
            bottomPanel.SetActive(true);
            bottomR1.Init(r2);
            bottomR2.Init(r2, 1);
            r2.currentSize += 1;
            //update threat just spent
            DataStore.sessionData.ModifyThreat(-r2.rcost);
            //Debug.Log( "new size R2:" + r2.currentSize );
        }

        if (r1 == null && r2 == null)
        {
            warning.gameObject.SetActive(true);
            warning.text = DataStore.uiLanguage.uiMainApp.reinforceWarningUC;
        }
    }
Ejemplo n.º 26
0
    public void Show(Sprite s, CardDescriptor cd, Action action = null)
    {
        gameObject.SetActive(true);
        cg.DOFade(1, .5f);
        fader.color = new Color(0, 0, 0, 0);
        fader.DOFade(.95f, .5f);

        callback     = action;
        image.sprite = s;
        image.transform.localScale = (.85f).ToVector3();
        image.transform.DOScale(1.25f, .5f).SetEase(Ease.OutExpo);

        if (!string.IsNullOrEmpty(cd.ignored))
        {
            ignoreText.text = "<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">F</font></color>" + cd.ignored;
        }
        else
        {
            ignoreText.text = "";
        }
    }
Ejemplo n.º 27
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);
    }
Ejemplo n.º 28
0
    /// <summary>
    /// deploys hero/ally to hero box and adds it to deployed hero list
    /// </summary>
    public void DeployHeroAlly(CardDescriptor cd)
    {
        if (DataStore.deployedHeroes.Contains(cd))
        {
            Debug.Log(cd.name + " already deployed");
            return;
        }

        //a new healthy hero/ally
        cd.heroState = new HeroState();
        cd.heroState.Init(DataStore.sessionData.MissionHeroes.Count);

        var go = Instantiate(hgPrefab, heroContainer);

        go.GetComponent <HGPrefab>().Init(cd);
        if (!DataStore.deployedHeroes.Contains(cd))
        {
            DataStore.deployedHeroes.Add(cd);
        }
        sound.PlaySound(FX.Computer);
    }
Ejemplo n.º 29
0
    public void Init(CardDescriptor cd, int add = 0)
    {
        //reset
        for (int i = 0; i < 3; i++)
        {
            reinforceCounts[i].color = Color.red;
            reinforceCounts[i].gameObject.SetActive(false);
        }
        for (int i = 0; i < cd.size; i++)
        {
            reinforceCounts[i].gameObject.SetActive(true);
        }
        nameText.text    = "";
        thumbnail.sprite = null;
        colorPip.color   = Color.white;

        for (int i = 0; i < Mathf.Min(cd.size, cd.currentSize + add); i++)
        {
            reinforceCounts[i].color = Color.green;
        }

        nameText.text = cd.name;

        if (DataStore.villainCards.cards.Contains(cd))
        {
            thumbnail.sprite    = Resources.Load <Sprite>($"Cards/Villains/{cd.id.Replace( "DG", "M" )}");
            outline.effectColor = Color.red;
        }
        else
        {
            thumbnail.sprite = Resources.Load <Sprite>($"Cards/Enemies/{cd.expansion}/{cd.id.Replace( "DG", "M" )}");
            if (cd.name.Contains("Elite"))
            {
                outline.effectColor = Color.red;
            }
        }
        colorPip.color = DataStore.pipColors[cd.colorIndex].ToColor();
    }
    public void OnToggle(int index)
    {
        EventSystem.current.SetSelectedGameObject(null);
        //checking for Active makes sure this code does NOT run when the Toggle is INACTIVE
        if (!buttonToggles[index].gameObject.activeInHierarchy)
        {
            return;
        }

        sound.PlaySound(FX.Click);

        if (buttonToggles[index].isOn)
        {
            selectedHero       = heroCards[index];
            enemyNameText.text = heroCards[index].name;
        }
        else
        {
            if (selectedHero == heroCards[index])
            {
                selectedHero = null;
            }
        }
    }
Ejemplo n.º 31
0
    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;
            }
        }
    }
Ejemplo n.º 32
0
    public void HandleOnslaught(bool skipThreatIncrease)
    {
        /*
         * Threat +Threat Level +2
         * Reinforce up to 2 groups (cost decreased by 1, to a
         * minimum of 1)
         * Deploy as many new groups as possible, decreased cost:
         * Tier I: no change
         * Tier II: cost -1
         * Tier III: cost -2
         * “Fuzzy deployment” (see below)
         * DM = -2
         */

        if (skipThreatIncrease)
        {
            onslaughtMessage.SetActive(false);
        }
        else
        {
            DataStore.sessionData.ModifyThreat(DataStore.sessionData.threatLevel + 2);
            onslaughtMessage.SetActive(true);
        }

        //set deployment modifier to -2, regardless of skipThreatIncrease
        DataStore.sessionData.SetDeploymentModifier(-2);

        CardDescriptor r1 = DataStore.GetReinforcement(true);

        if (r1 != null)
        {
            topOnslaught.SetActive(true);
            onR1Group.SetActive(true);
            on1R1.Init(r1);
            on1R2.Init(r1, 1);
            r1.currentSize += 1;
            DataStore.sessionData.ModifyThreat(-(Mathf.Max(1, r1.rcost - 1)));
        }

        CardDescriptor r2 = DataStore.GetReinforcement(true);

        if (r2 != null)
        {
            onR2Group.SetActive(true);
            on2R1.Init(r2);
            on2R2.Init(r2, 1);
            r2.currentSize += 1;
            DataStore.sessionData.ModifyThreat(-(Mathf.Max(1, r2.rcost - 1)));
        }

        if (r1 == null && r2 == null)
        {
            onslaughtRWarning.gameObject.SetActive(true);
        }

        CardDescriptor dep;

        do
        {
            dep = DataStore.GetFuzzyDeployable(true);
            if (dep != null)
            {
                dep.currentSize = dep.size;
                bottomOnslaught.SetActive(true);
                var go = Instantiate(depPrefab, depGrid.transform);
                go.GetComponent <ReinforcePrefab>().Init(dep);
                groupsToDeploy.Add(dep);
                //remove it from dep hand
                DataStore.deploymentHand.Remove(dep);
                if (dep.tier == 1)
                {
                    DataStore.sessionData.ModifyThreat(-dep.cost);
                }
                else if (dep.tier == 2)
                {
                    DataStore.sessionData.ModifyThreat(-(dep.cost - 1));
                }
                else
                {
                    DataStore.sessionData.ModifyThreat(-(dep.cost - 2));
                }
            }
        }while (dep != null);

        if (depGrid.transform.childCount == 0)
        {
            onslaughtDWarning.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 33
0
    void ParseCard(string item)
    {
        Transform  content = transform.Find("Panel/content");
        GameObject go      = new GameObject("content item");

        go.layer = 5;
        go.transform.SetParent(content);
        go.transform.localScale       = Vector3.one;
        go.transform.localEulerAngles = Vector3.zero;

        TextMeshProUGUI nt = go.AddComponent <TextMeshProUGUI>();

        nt.color    = Color.white;
        nt.fontSize = 27;

        //replace glyphs
        item = item.Replace("{H}", "<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">H</font></color>");
        item = item.Replace("{C}", "<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">C</font></color>");
        item = item.Replace("{J}", "<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">J</font></color>");
        item = item.Replace("{K}", "<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">K</font></color>");
        item = item.Replace("{B}", "<color=\"red\"><font=\"ImperialAssaultSymbols SDF\">B</font></color>");

        //add bullets
        if (item.Contains("{-}"))
        {
            nt.color  = new Color(0, 0.6440244f, 1, 1);
            nt.margin = new Vector4(25, 0, 0, 0);
            item      = item.Replace("{-}", " ■ ");
        }
        //handle rebels
        if (item.Contains("{R1}"))
        {
            item = item.Replace("{R1}", "<color=#00A4FF>" + rebel1.name + "</color>");
        }
        if (item.Contains("{R2}"))
        {
            item = item.Replace("{R2}", "<color=#89A4FF>" + rebel2.name + "</color>");
        }

        //special rules
        if (cardEvent.eventRule == "R8" && item.Contains("{V}"))
        {
            enemyToAdd = HandleR8();
            if (enemyToAdd != null)
            {
                item = item.Replace("{V}", enemyToAdd.name);
                DataStore.sessionData.ModifyThreat(-Math.Min(7, enemyToAdd.cost));
            }
            else
            {
                item = item.Replace("{V}", $"<color=red>{DataStore.uiLanguage.uiMainApp.noneUC}</color>");
            }
        }
        else if (cardEvent.eventRule == "R13")
        {
            if (!DataStore.deployedEnemies.Any(x => x.id == "DG072"))                //vader
            {
                //add to deployment hand
                DataStore.deploymentHand.Add(DataStore.villainCards.cards.Where(x => x.id == "DG072").First());
                //reduce its cost by 2
                DataStore.deploymentHand.Where(x => x.id == "DG072").First().cost -= 2;
            }
        }
        else if (cardEvent.eventRule == "R18" && item.Contains("{CR}"))
        {
            enemyToAdd = HandleR18();
            if (enemyToAdd != null)
            {
                item = item.Replace("{CR}", enemyToAdd.name);
                DataStore.sessionData.ModifyThreat(-Math.Min(5, enemyToAdd.cost));
            }
            else
            {
                item = item.Replace("{CR}", $"<color=red>{DataStore.uiLanguage.uiMainApp.noneUC}</color>");
            }
        }
        else if (cardEvent.eventRule == "R23")
        {
            allyToAdd = HandleR23();
            if (allyToAdd != null)
            {
                item = item.Replace("{A}", "<color=#00A4FF>" + allyToAdd.name);
                DataStore.sessionData.ModifyThreat(allyToAdd.cost / 2);
            }
            else
            {
                item = item.Replace("{A}", $"<color=red>{DataStore.uiLanguage.uiMainApp.noneUC}</color>");
            }
        }

        nt.text = item;
        var rt = go.GetComponent <RectTransform>();

        rt.sizeDelta = new Vector2(900, 100);
    }
Ejemplo n.º 34
0
 public void AddCard(CardDescriptor card)
 {
     Cards.Add(card);
 }