Exemple #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        SC_BaseCard bC = target as SC_BaseCard;

        bC.matchHeat = Mathf.Clamp(bC.matchHeat, 1, 20);

        SC_AttackCard aC = bC as SC_AttackCard;

        if (aC)
        {
            aC.matchHeatGain = aC.finisher ? 0 : Mathf.Max(aC.matchHeatGain, 0);
        }

        SC_OffensiveMove oM = bC as SC_OffensiveMove;

        if (oM)
        {
            if (oM.cost.bodyPartDamage.bodyPart == SC_Global.BodyPart.None)
            {
                oM.cost.bodyPartDamage.damage = 0;
            }

            SC_Global.OffensiveBodyPartDamage oBPD = oM.effect.bodyPartDamage;

            if (oBPD.bodyPart == SC_Global.BodyPart.None)
            {
                oBPD.otherBodyPart = SC_Global.BodyPart.None;

                oBPD.damage = 0;

                oBPD.both = false;
            }

            if (oBPD.otherBodyPart == SC_Global.BodyPart.None)
            {
                oBPD.both = false;
            }
        }
    }
Exemple #2
0
    public void Filter()
    {
        filteredCards = new Dictionary <SC_BaseCard, SC_DeckBuilder_SearchCard> ();

        if (moreFiltersPanel.activeSelf)
        {
            ToggleMoreFilters();
        }

        foreach (Transform t in searchCardsParent)
        {
            Destroy(t.gameObject);
        }

        float marginsNbr = (((int)searchCardsParent.rect.width) / ((int)size.x)) - 1;

        float margin = (searchCardsParent.rect.width % size.x) / marginsNbr;

        int i, x, y = x = i = 0;

        foreach (SC_BaseCard c in allCards)
        {
            #region Oracle filter
            if (oracle.text != "" && !c.HasText(oracle.text) && !c.name.ToLower().Contains(oracle.text.ToLower()))
            {
                continue;
            }
            #endregion

            #region Types filters
            if (mainType.value == 1 && (c.GetType().IsSubclassOf(typeof(SC_AttackCard)) != mainTypeToggle.isOn))
            {
                continue;
            }
            else if ((mainType.value == 2 && (c.IsSpecial != mainTypeToggle.isOn)) || (mainType.value == 3 && (c.Is(CardType.Basic) != mainTypeToggle.isOn)))
            {
                continue;
            }

            if ((CheckType(c, firstSubType) != firstSubTypeToggle.isOn) || (CheckType(c, secondSubType) != secondSubTypeToggle.isOn))
            {
                continue;
            }
            #endregion

            #region Aligment filter
            if (alignment.value > 0)
            {
                if (alignment.value == 1)
                {
                    CommonRequirement?r = null;

                    foreach (CommonRequirement cr in c.commonRequirements)
                    {
                        if (cr.valueType == ValueName.Alignment && !cr.opponent)
                        {
                            r = cr;
                        }
                    }

                    if (r == null || c.IsAlignmentCard(false) || c.IsAlignmentCard(true))
                    {
                        continue;
                    }
                }
                else if ((alignment.value == 2 && !c.IsAlignmentCard(true)) || (alignment.value == 3 && !c.IsAlignmentCard(false)))
                {
                    continue;
                }
            }
            #endregion

            #region Common effects filter
            bool skip = false;

            foreach (Toggle t in commonEffects)
            {
                if (t.isOn)
                {
                    string s = t.transform.parent.GetComponentInChildren <TextMeshProUGUI> ().text.Replace(" ", "");

                    if (Enum.TryParse(s, out CommonEffectType ty))
                    {
                        if (!c.Has(ty) && !c.additionalKeywords.Contains(s))
                        {
                            skip = true;

                            continue;
                        }
                    }
                    else if (s == "Discard")
                    {
                        if (!c.Has(CommonEffectType.DiscardChosen) && !c.Has(CommonEffectType.DiscardRandom) && !c.additionalKeywords.Contains(s))
                        {
                            skip = true;

                            continue;
                        }
                    }
                    else
                    {
                        Debug.LogError("WRONG COMMON EFFECT FILTER");
                    }
                }
            }

            if (skip)
            {
                continue;
            }

            #endregion

            #region Match Heat effect filter
            if (matchHeat.isOn)
            {
                if (!c.Has(CommonEffectType.MatchHeatEffect) && ((c as SC_AttackCard)?.matchHeatGain ?? 0) <= 0)
                {
                    continue;
                }
            }
            #endregion

            #region Attack values filters
            SC_AttackCard a = c as SC_AttackCard;

            if (a)
            {
                if (a.cost.stamina < attackCardStaminaCost.Min || a.cost.stamina > attackCardStaminaCost.Max)
                {
                    continue;
                }

                if (attackCardBodyPartsCost.value == 0 || a.cost.bodyPartDamage.bodyPart == (BodyPart)attackCardBodyPartsCost.value || (attackCardBodyPartsCost.value == 6 && a.cost.bodyPartDamage.bodyPart == BodyPart.None))
                {
                    if (a.cost.bodyPartDamage.damage < attackCardBodyPartsCostValue.Min || a.cost.bodyPartDamage.damage > attackCardStaminaCost.Max)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }

                OffensiveBodyPartDamage bpDamage = (a as SC_OffensiveMove)?.effect.bodyPartDamage ?? (a as SC_Submission).effect.bodyPartDamage;

                if (attackCardBodyPartsDamage.value == 0 || bpDamage.bodyPart == (BodyPart)attackCardBodyPartsDamage.value || bpDamage.otherBodyPart == (BodyPart)attackCardBodyPartsDamage.value || (attackCardBodyPartsDamage.value == 6 && bpDamage.bodyPart == BodyPart.None && bpDamage.otherBodyPart == BodyPart.None))
                {
                    if (bpDamage.damage < attackCardBodyPartsDamageValue.Min || bpDamage.damage > attackCardBodyPartsDamageValue.Max)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }

                SC_OffensiveMove o = c as SC_OffensiveMove;

                if (o)
                {
                    if (o.cost.health < offensiveMoveHealthCost.Min || o.cost.health > offensiveMoveHealthCost.Max)
                    {
                        continue;
                    }

                    if (o.effect.stamina < offensiveMoveStaminaDamage.Min || o.effect.stamina > offensiveMoveStaminaDamage.Max)
                    {
                        continue;
                    }

                    if (o.effect.health < offensiveMoveHealthDamage.Min || o.effect.health > offensiveMoveHealthDamage.Max)
                    {
                        continue;
                    }
                }
                else
                {
                    SC_Submission s = c as SC_Submission;

                    if (s.effect.stamina < submissionStaminaReduction.Min || s.effect.stamina > submissionStaminaReduction.Max)
                    {
                        continue;
                    }

                    if (s.effect.breakCost < submissionBreakCost.Min || s.effect.breakCost > submissionBreakCost.Max)
                    {
                        continue;
                    }
                }
            }
            #endregion

            if (c.matchHeat >= matchHeatFilter.Min && c.matchHeat <= matchHeatFilter.Max)
            {
                RectTransform r = Instantiate(Resources.Load <RectTransform> ("Prefabs/DeckBuilder/P_DeckBuilder_SearchCard"), searchCardsParent);

                r.sizeDelta = size;

                r.GetComponent <SC_DeckBuilder_SearchCard> ().Card = c;

                r.GetComponent <Image> ().sprite = Resources.Load <Sprite> (c.Path);

                r.anchoredPosition = new Vector2(x * (size.x + margin), -y * (size.y + margin));

                x = x == ((int)searchCardsParent.rect.width) / ((int)size.x) - 1 ? 0 : x + 1;

                y = x == 0 ? y + 1 : y;

                i++;
            }
        }

        if (!deckPanel.activeSelf)
        {
            resultsCount.text = i.ToString() + " matching card" + (i > 1 ? "s" : "");
            resultsCount.gameObject.SetActive(true);
        }

        y += (x == 0 ? -1 : 0) + 1;

        searchCardsParent.sizeDelta = new Vector2(searchCardsParent.sizeDelta.x, Mathf.Max(deckPanel.activeSelf ? 432 : 834, size.y * y + margin * (y - 1)));
    }
Exemple #3
0
    public void Setup()
    {
        Instance = this;

        deckCards = new Dictionary <SC_BaseCard, SC_DeckBuilder_DeckCard> ();

        size = Resources.Load <RectTransform> ("Prefabs/Cards/P_UI_Card").sizeDelta *searchCardSize;

        dropdownFilters = transform.GetComponentsInChildren <TMP_Dropdown> ();

        minMaxFilters = new MinMaxFilter[] { matchHeatFilter, attackCardStaminaCost, attackCardBodyPartsCostValue,
                                             attackCardBodyPartsDamageValue, offensiveMoveHealthCost, offensiveMoveStaminaDamage, offensiveMoveHealthDamage,
                                             submissionStaminaReduction, submissionBreakCost };

        #region Setup Min Max Filters
        for (int i = 1; i < minMaxFilters.Length; i++)
        {
            minMaxFilters[i].min = 50;
            minMaxFilters[i].max = 0;
        }

        #region Set minimum and maximum attack filter values
        foreach (SC_BaseCard c in allCards)
        {
            SC_AttackCard a = c as SC_AttackCard;

            if (a)
            {
                attackCardStaminaCost.min = Mathf.Min(attackCardStaminaCost.min, a.cost.stamina);
                attackCardStaminaCost.max = Mathf.Max(attackCardStaminaCost.max, a.cost.stamina);

                attackCardBodyPartsCostValue.min = Mathf.Min(attackCardBodyPartsCostValue.min, a.cost.bodyPartDamage.damage);
                attackCardBodyPartsCostValue.max = Mathf.Max(attackCardBodyPartsCostValue.max, a.cost.bodyPartDamage.damage);

                int bpDamage = ((a as SC_OffensiveMove)?.effect.bodyPartDamage ?? (a as SC_Submission).effect.bodyPartDamage).damage;

                attackCardBodyPartsDamageValue.min = Mathf.Min(attackCardBodyPartsDamageValue.min, bpDamage);
                attackCardBodyPartsDamageValue.max = Mathf.Max(attackCardBodyPartsDamageValue.max, bpDamage);

                SC_OffensiveMove o = c as SC_OffensiveMove;

                if (o)
                {
                    offensiveMoveHealthCost.min = Mathf.Min(offensiveMoveHealthCost.min, o.cost.health);
                    offensiveMoveHealthCost.max = Mathf.Max(offensiveMoveHealthCost.max, o.cost.health);

                    offensiveMoveStaminaDamage.min = Mathf.Min(offensiveMoveStaminaDamage.min, o.effect.stamina);
                    offensiveMoveStaminaDamage.max = Mathf.Max(offensiveMoveStaminaDamage.max, o.effect.stamina);

                    offensiveMoveHealthDamage.min = Mathf.Min(offensiveMoveHealthDamage.min, o.effect.health);
                    offensiveMoveHealthDamage.max = Mathf.Max(offensiveMoveHealthDamage.max, o.effect.health);
                }
                else
                {
                    SC_Submission s = c as SC_Submission;

                    submissionStaminaReduction.min = Mathf.Min(submissionStaminaReduction.min, s.effect.stamina);
                    submissionStaminaReduction.max = Mathf.Max(submissionStaminaReduction.max, s.effect.stamina);

                    submissionBreakCost.min = Mathf.Min(submissionBreakCost.min, s.effect.breakCost);
                    submissionBreakCost.max = Mathf.Max(submissionBreakCost.max, s.effect.breakCost);
                }
            }
        }
        #endregion

        foreach (MinMaxFilter m in minMaxFilters)
        {
            m.minInput.text = m.min.ToString();
            m.maxInput.text = m.max.ToString();

            m.minInput.onEndEdit.AddListener((s) => {
                int clamped = Mathf.Clamp(m.Min, m.min, m.Max);

                if (m.Min != clamped)
                {
                    m.minInput.text = clamped.ToString();
                }
            });

            m.maxInput.onEndEdit.AddListener((s) => {
                int clamped = Mathf.Clamp(m.Max, m.Min, m.max);

                if (m.Max != clamped)
                {
                    m.maxInput.text = clamped.ToString();
                }
            });
        }
        #endregion

        commonEffects = commonEffectsParent.GetComponentsInChildren <Toggle> ();

        typeToggles = new Toggle[] { mainTypeToggle, firstSubTypeToggle, secondSubTypeToggle };
    }