Esempio n. 1
0
    void OnMouseUp()
    {
        if (draggingThis)
        {
            dragging     = false;
            draggingThis = false;
            StartCoroutine(DelayPreviews());  // re-enable previews after 0.25 seconds (so previews don't immediately pop up when releasing a card)
            string cardName         = GetComponent <CardInfo>().cardName;
            bool   targetsPlayers   = GetComponent <CardInfo>().targetsPlayers;
            bool   canTargetSelf    = GetComponent <CardInfo>().canTargetSelf;
            string hit              = DetectHit(targetsPlayers, canTargetSelf);
            bool   returnToPosition = true;

            // if it's your main step
            if (Logic.Instance.currentPlayer == Player.localPlayer && Logic.Instance.mainStepActive && Logic.Instance.currentEvent == null)
            {
                if (cardName == "shootSpring" && hit != null)
                {
                    Player.localPlayer.CmdShoot(hit, transform.GetSiblingIndex());
                    returnToPosition = false;
                }
            }
            // if you're reacting to an event
            else if (Logic.Instance.currentEvent != null)
            {
                VisualContainer vcHand       = Player.localPlayer.visual.transform.Find("Hand").GetComponent <VisualContainer>();
                VisualContainer vcIntentArea = GameObject.Find("Visual/IntentArea").GetComponent <VisualContainer>();

                if (cardName == "grazeSpring" && hit == "PlayArea" && transform.parent.name == "Hand")
                {
                    Player.localPlayer.CmdIntendGraze();
                    transform.GetComponent <HoverPreview>().ThisPreviewEnabled = false;

                    vcHand.Remove(transform);
                    vcHand.Adjust(transform.childCount);
                    vcIntentArea.Add(transform);
                    vcIntentArea.Adjust(transform.childCount);

                    returnToPosition = false;
                }

                if (cardName == "grazeSpring" && hit == "HandArea" && transform.parent.name == "IntentArea")
                {
                    vcIntentArea.Remove(transform);
                    vcIntentArea.Adjust(transform.childCount);
                    vcHand.Add(transform);
                    vcHand.Adjust(transform.childCount);

                    returnToPosition = false;
                }
            }

            if (returnToPosition)
            {
                StartCoroutine(PlayAnimation("ReturnToPosition"));
            }
        }
    }