Exemplo n.º 1
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (Highlighted)
        {
            print("CLICK: " + gameObject + " CARD: " + CardEventTrigger.SelectedCard);
            //play selected card
            CardGO cardGO = CardEventTrigger.SelectedCard.GetComponent <CardGO>();

            if (cardGO.Card.Ability == Card.Abilities.Scorch)
            {
                if (cardGO.Card.Special)
                {
                    //scorch highest str card(s)
                    Zone[] zones = new Zone[] {
                        Manager.manager.GetZone(Zone.Types.Melee),
                        Manager.manager.GetZone(Zone.Types.Ranged),
                        Manager.manager.GetZone(Zone.Types.Siege),
                        Manager.manager.GetZone(Zone.Types.Melee, false),
                        Manager.manager.GetZone(Zone.Types.Ranged, false),
                        Manager.manager.GetZone(Zone.Types.Siege, false)
                    };

                    /*
                     * List<CardGO> strongest = new List<CardGO>();
                     * foreach (Zone zone in zones)
                     * {
                     *  foreach (CardGO c in zone.Cards)
                     *  {
                     *      if (!c.Card.Special && !((UnitCard)c.Card).Hero)
                     *      {
                     *          if (strongest.Count == 0)
                     *              strongest.Add(c);
                     *          else if (((UnitCard)c.Card).Strength > ((UnitCard)strongest[0].Card).Strength)
                     *          {
                     *              strongest.Clear();
                     *              strongest.Add(c);
                     *          }
                     *          else if (((UnitCard)c.Card).Strength == ((UnitCard)strongest[0].Card).Strength)
                     *              strongest.Add(c);
                     *      }
                     *  }
                     * }
                     * //move strongest to discard
                     * foreach (CardGO go in strongest)
                     * {
                     *  go.Discard();
                     *  print(go.name);
                     * }
                     */
                    ScorchZone(zones);
                }
                else
                {
                    //scorch highest str card(s) in opponents zone
                }
            }
            //else if (cardGO.Card.Ability == Card.Abilities.Bond)

            CardEventTrigger.UnHighlight(CardEventTrigger.SelectedCard.GetComponent <CardEventTrigger>());
            Zone z = GetComponent <Zone>();
            if (cardGO.Card.Ability == Card.Abilities.Bond && z.Cards.Count > 0)
            {
                for (int i = 0; i < z.Cards.Count; i++)
                {
                    if (z.Cards[i].Card.Name == cardGO.Card.Name)
                    {
                        cardGO.MoveTo(z, z.Cards.IndexOf(z.Cards[i]));
                        break;
                    }
                    else if (i == z.Cards.Count - 1)
                    {
                        cardGO.MoveTo(z);
                    }
                }
            }
            else
            {
                cardGO.MoveTo(z);
            }
            Manager.manager.UnHighlightZones();
            if (z.Type == Zone.Types.Melee || z.Type == Zone.Types.Ranged || z.Type == Zone.Types.Siege)
            {
                ((Battlefield)z).RecalcStatsAtEndOfFrame();
            }
            else if (z.Type == Zone.Types.Horn)
            {
                ((HornZone)z).SpecialHorn = cardGO;
                //recalc stats for associated battlefield
                StartCoroutine(((HornZone)z).Battlefield.RecalcStatsAtEndOfFrame());
            }

            //if Cards.count > MAX_CARDS_WITHOUT_OVERLAP
            //change layout group spacing by -10 * (Cards.Count - MAX_CARDS_WITHOUT_OVERLAP)
            //GetComponent<HorizontalLayoutGroup>().spacing = z.RecalcSpacing();
            CardEventTrigger.Deselect(CardEventTrigger.SelectedCard);
        }
    }
Exemplo n.º 2
0
    public override void OnPointerClick(PointerEventData eventData)
    {
        base.OnPointerClick(eventData);

        if (eventData.button == PointerEventData.InputButton.Left)
        {
            if (Highlighted)
            {
                //If no card is selected, select this one
                if (selectedCard == null)
                {
                    Select(this);
                }
                //If this card is already selected, deselect it then unhighlight all selected zones
                else if (IsSelectedCard)
                {
                    if (specialHighlight.Count != 0)
                    {
                        UnHighlightAllSpecial();
                    }
                    Select(null);
                }
                //If another card (in the player's hand) is already selected,
                //deselect that one and select this one
                else
                {
                    if (specialHighlight.Count != 0)
                    {
                        UnHighlightAllSpecial();
                    }
                    Deselect(SelectedCard);
                    Select(this);
                }

                if (IsSelectedCard) //card is being selected
                {
                    Card c = cardGO.Card;
                    //print(GetComponent<CardGO>().InZone);


                    //highlight zones depending on who's turn it is
                    //if it's a spy, reverse
                    //TODO
                    //add enum for P1, P2, and Both (for scorch special cards)
                    bool highlightPlayerOne;
                    if (!c.Special)
                    {
                        if (((UnitCard)c).Ability == Card.Abilities.Spy)
                        {
                            highlightPlayerOne = (Manager.manager.PlayerOnesTurn) ? false : true;
                        }
                        else
                        {
                            highlightPlayerOne = (Manager.manager.PlayerOnesTurn) ? true : false;
                        }
                    }
                    else
                    {
                        highlightPlayerOne = (Manager.manager.PlayerOnesTurn) ? true : false;
                    }

                    //Highlight relevant Zone(s) for Card c
                    Manager.manager.HighlightNewZone(cardGO.Card, highlightPlayerOne);
                    //UnHighlight(this);
                }
                else //card is being deselected
                {
                    Highlight(this);
                }
            }
            else if (SpecialHighlighted)
            {
                if (SelectedCard.cardGO.Card.Ability == Card.Abilities.Decoy)
                {
                    print("DECOY: " + gameObject.name);
                    //play the decoy card in this card's slot, and return this card to hand

                    //print(cardGO.Zone.Cards.IndexOf(cardGO) + ", " + cardGO.Zone.Cards.Count);
                    int index = cardGO.Zone.Cards.IndexOf(cardGO);
                    SelectedCard.cardGO.MoveTo(cardGO.Zone, index);
                    SelectedCard.transform.SetSiblingIndex(index);
                    Battlefield old = (Battlefield)cardGO.Zone;
                    cardGO.ApplyEffects(old, false);
                    ((UnitCard)cardGO.Card).CalcStats(old, cardGO, false);
                    cardGO.MoveTo(Manager.manager.GetZone(Zone.Types.Hand));
                    StartCoroutine(old.RecalcStatsAtEndOfFrame());
                    //reset card effects
                    UnHighlightAllSpecial();
                    Deselect(this);
                }
            }
        }
        else if (eventData.button == PointerEventData.InputButton.Right)
        {
            //display big version of card.
            //set examiningCard = true;
            //lock out highlighting/selecting cards
        }
    }