Beispiel #1
0
    internal void MoveClick(string direction)
    {
        bool canMove = S.GameControlInst.MovesLeft > 0;

        if (GameControl.MovesArePlays)
        {
            canMove = S.GameControlInst.PlaysLeft > 0;
        }

        if (canMove)
        {
            GridUnit thisGU   = gameObject.GetComponent <GridUnit>();
            int      gridSize = GridControl.GridSize;
            if ((thisGU.xPosition > gridSize && direction == "right") | (thisGU.xPosition < -gridSize && direction == "left") |
                (thisGU.yPosition > gridSize && direction == "up") | (thisGU.yPosition < -gridSize && direction == "down"))
            {
                Debug.Log("blocked!");
                return;
            }

            thisGU.GridMove(direction);
            S.GameControlInst.AddMoves(-1);
            S.ShopControlInst.GoalCheck("Move X times in one turn");
            S.ShopControlInst.GoalCheck("Don't move X turns in a row");
            S.ShopControlInst.GoalCheck("Don't deal damage or move X turns in a row");
            S.ShopControlInst.GoalCheck("Don't move X turns in a row");
            S.GridControlInst.DestroyAllTargetSquares();

            if (Tutorial.TutorialLevel != 0)
            {
                S.GameControlInst.gameObject.GetComponent <Tutorial>().TutorialTrigger(2);
            }

            StateSavingControl.Save();
        }
        else
        {
            ButtonAnimate moveButton = GameObject.Find("move end button").GetComponent <ButtonAnimate>();
            moveButton.ErrorAnimation();
        }
    }
Beispiel #2
0
 public void ErrorAnimate()
 {
     PlayButton.ErrorAnimation();
 }
Beispiel #3
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            S.ShopControlInst.GoalCheck("Touch the screen no more than than X times");
        }


        if (!Input.GetMouseButton(0) && GridCursorControl.ClickedOffScreen)
        {
            GridCursorControl.ClickedOffScreen = false;
        }

        // Resetting things

        if (S.MenuControlInst.AnyMenuIsUp() |
            S.ShopControlGUIInst.IgnoreClicking |
            GridCursorControl.ClickedOffScreen |
            !AllowInputUmbrella)
        {
            return;
        }

        if (cardScriptClickedOn != null)
        {
            if (!Input.GetMouseButton(0))
            {
                cardScriptClickedOn.cardUI.GlowAnimate(false);
            }
        }

        if (displayCardCanvas.CardDisplay && (!Input.GetMouseButton(0) || !AllowInputUmbrella || !AllowInfoInput))
        {
            S.GameControlGUIInst.Undisplay();
            cardHasBeenClickedOn = false;
            return;
        }

        // This replaces the clickblocker system. Prevents clicking on stuff under canvas elements
        if (eventSystem.IsPointerOverGameObject())
        {
            return;
        }

        if (GridCursorControl.cursorActionSet)
        {
            if (!Input.GetMouseButton(0))
            {
                S.GridCursorControlInst.ReleaseCursor();
                return;
            }
        }

        //////////////////////////////////////
        /// CARDCLICKS
        //////////////////////////////////////

        if (cardHasBeenClickedOn && cardScriptClickedOn != null && !S.DragControlInst.DraggingHand)
        {
            if (!Input.GetMouseButton(0))
            {
                if (S.GameControlInst.CardsToTarget != 0 &&
                    AllowCardTargetInput &&
                    (cardScriptClickedOn.Peeked == S.GameControlInst.CardsToTargetArePeeked) &&
                    (S.GameControlInst.CardsToTargetAreDiscarded == cardScriptClickedOn.Discarded))
                {
                    if (S.GameControlInst.TargetedCards.Contains(cardScriptClickedOn.gameObject))
                    {
                        cardScriptClickedOn.Untarget();
                        S.GameControlInst.TargetedCards.Remove(cardScriptClickedOn.gameObject);
                        cardHasBeenClickedOn = false;
                    }
                    else if (cardScriptClickedOn != S.GameControlInst.TargetCardCallback)
                    {
                        cardScriptClickedOn.Target();
                        S.GameControlInst.TargetedCards.Add(cardScriptClickedOn.gameObject);
                        if (S.GameControlInst.TargetedCards.Count == S.GameControlInst.CardsToTarget)
                        {
                            S.GameControlInst.TargetCardCallback.AfterCardTargetingCallback();
                        }
                        cardHasBeenClickedOn = false;
                    }
                }
                else if (!cardScriptClickedOn.Discarded &&
                         S.GameControlInst.PlaysLeft > 0 &&
                         AllowNewPlayInput &&
                         S.GameControlInst.CardsToTarget == 0)
                {
                    cardScriptClickedOn.Click();
                    cardHasBeenClickedOn = false;
                }
                else
                {
                    playButton.ErrorAnimation();
                    cardHasBeenClickedOn = false;
                }
                cardHasBeenClickedOn = false;
            }
            else
            {
                if (Mathf.Abs(Input.mousePosition.x - cardClickOrigin.x) > .2f &&
                    !cardScriptClickedOn.Discarded &&
                    (AllowInfoInput && Tutorial.TutorialLevel == 0 | Tutorial.TutorialLevel == 7))
                {
                    S.DragControlInst.HandDrag(cardScriptClickedOn, cardClickOrigin);
                    cardHasBeenClickedOn = false;
                    return;
                }
                else if (Mathf.Abs(Input.mousePosition.y - cardClickOrigin.y) > .2f &&
                         cardScriptClickedOn.Discarded && AllowInfoInput)
                {
                    cardHasBeenClickedOn = false;
                }
                else if (Time.time - 0.22f > lastCardClick &&
                         !displayCardCanvas.CardDisplay &&
                         AllowInfoInput && Tutorial.TutorialLevel == 0)
                {
                    S.GameControlGUIInst.Display(cardScriptClickedOn);
                    cardHasBeenClickedOn = false;
                }
                else if (Time.time - .03f > lastCardClick &&
                         AllowInfoInput &&
                         Tutorial.TutorialLevel == 0)
                {
                    cardScriptClickedOn.cardUI.ShineAnimate();
                    S.GameControlGUIInst.DisplayDim();
                }
            }
        }

        //////////////////////////////////////
        /// NEW CLICKS
        //////////////////////////////////////

        if (Input.GetMouseButtonDown(0))
        {
            S.GameControlGUIInst.SetTooltip("");

            // Cancels flashing animation of info'd enemy
            S.GridCursorControlInst.CancelInvoke();

            // S.GameControlGUIInst.ShowDeck(false);

            Vector3 newClickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            currentCursorXPosition = newClickPosition.x;
            currentCursorYPosition = newClickPosition.y;

            float dist = transform.position.z - Camera.main.transform.position.z;
            var   pos  = new Vector3(Input.mousePosition.x, Input.mousePosition.y, dist);
            pos = Camera.main.ScreenToWorldPoint(pos);
            RaycastHit2D[] hits = Physics2D.RaycastAll(pos, Vector2.zero);

            if (Input.GetMouseButtonDown(0))
            {
                registerClick();

                if (hits != null)
                {
                    foreach (RaycastHit2D hit in hits)
                    {
                        if (hit.collider.gameObject.name == "end turn button" && AllowForfeitButtonInput)
                        {
                            if (turnEndedAlready)
                            {
                                return;
                            }
                            turnEndedAlready = true;
                            S.GameControlInst.ButtonSpritesLookClicked();
                            S.GameControlInst.DeselectCards();
                            S.GridControlInst.DestroyAllTargetSquares();
                            if (Tutorial.TutorialLevel != 0)
                            {
                                S.GameControlInst.StartNewTurn(false);
                            }
                            else
                            {
                                S.GameControlInst.EnemyTurn(true);
                            }
                            return;
                        }
                    }
                    foreach (RaycastHit2D hit in hits)
                    {
                        if (hit.collider.gameObject.name == "play end button" && AllowForfeitButtonInput)
                        {
                            if (S.GameControlInst.PlaysLeft == 1)
                            {
                                S.GameControlGUIInst.SetTooltip("You can punch or play a card one more time this turn.");
                            }
                            else
                            {
                                S.GameControlGUIInst.SetTooltip("You can punch or play a card " +
                                                                S.GameControlInst.PlaysLeft.ToString() +
                                                                " more times this turn.");
                            }
                            foreach (GameObject card in S.GameControlInst.Hand)
                            {
                                card.GetComponent <CardUI>().ShineAnimate();
                            }
                            return;
                        }
                    }
                    foreach (RaycastHit2D hit in hits)
                    {
                        if (hit.collider.gameObject.name == "move end button" && AllowForfeitButtonInput)
                        {
                            if (S.GameControlInst.MovesLeft == 1)
                            {
                                S.GameControlGUIInst.SetTooltip("You can move one more time this turn.");
                            }
                            else
                            {
                                S.GameControlGUIInst.SetTooltip("You can move " +
                                                                S.GameControlInst.MovesLeft.ToString() +
                                                                " more times this turn.");
                            }
                            return;
                        }
                    }
                    // foreach(RaycastHit2D hit in hits) {
                    //  if(hit.collider.gameObject.tag == "click blocker" ) {
                    //      return;
                    //  }
                    // }
                    // foreach(RaycastHit2D hit in hits) {
                    //  if(hit.collider.gameObject.name == "Deck" && AllowInfoInput) {
                    //      S.GameControlGUIInst.ShowDeck(true);
                    //      return;
                    //  }
                    // }
                    foreach (RaycastHit2D hit in hits)
                    {
                        if (hit.collider.gameObject.tag == "Card")
                        {
                            clickOnCard(hit.collider.gameObject);
                            return;
                        }
                    }

                    foreach (RaycastHit2D hit in hits)
                    {
                        if (hit.collider.gameObject.tag == "Play board")
                        {
                            return;
                        }
                    }

                    foreach (RaycastHit2D hit in hits)
                    {
                        //AllowInfoInput
                        if (hit.collider.gameObject.name == "Discard pile marker" && AllowInfoInput)
                        {
                            S.GameControlGUIInst.FlipDiscard();
                            return;
                        }
                    }
                }
            }

            if (cardHasBeenClickedOn)
            {
                return;
            }
            // if(S.DragControlInst.DraggingHand) return;
            // if(S.DragControlInst.DraggingGameboard) return;

            Vector3 clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if ((clickPosition.x > GridControl.GridSize + .5f |
                 clickPosition.x <-GridControl.GridSize - .5f |
                                  clickPosition.y> GridControl.GridSize + .5f |
                 clickPosition.y < -GridControl.GridSize - .5f))
            {
                if (GridCursorControl.GridCursorIsActive)
                {
                    GridCursorControl.ClickedOffScreen = true;
                    S.GridCursorControlInst.UnpresentCursor();
                }
                return;
            }

            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.tag == "Target square" && AllowSquareTargetInput)
                {
                    S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.TargetSquare);
                    S.GridCursorControlInst.SetCurrentCursorTarget(hit.collider.gameObject);
                    return;
                }
            }

            S.GameControlInst.DeselectCards();

            S.GridControlInst.DestroyAllTargetSquares();

            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.tag == "Enemy")
                {
                    if (AllowInfoInput)
                    {
                        infoTarget = hit.collider.gameObject;
                    }
                    if (adjCheck(hit.collider.gameObject.transform.position) != "none" &&
                        S.GameControlInst.PlaysLeft > 0 && AllowNewPlayInput)
                    {
                        S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.Punch);
                        S.GridCursorControlInst.SetCurrentCursorTarget(hit.collider.gameObject);
                        return;
                    }
                }
            }

            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.tag == "Player" && AllowInfoInput)
                {
                    infoTarget = hit.collider.gameObject;
                }
            }
            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.tag == "obstacle")
                {
                    GridUnit obstacleGU = hit.collider.gameObject.GetComponent <GridUnit>();
                    GridUnit playerGU   = S.GameControlInst.playerObj.GetComponent <GridUnit>();


                    if (obstacleGU.IsAdjacent(playerGU))
                    {
                        Obstacle hitObstacle = hit.collider.gameObject.GetComponent <Obstacle>();
                        if (hitObstacle.Walkable)
                        {
                            S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.Move);
                            S.GridCursorControlInst.SetCurrentCursorTarget(hit.collider.gameObject);
                        }
                        else
                        {
                            S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.Poke);
                            S.GridCursorControlInst.SetCurrentCursorTarget(hit.collider.gameObject);
                        }
                        return;
                    }

                    infoTarget = hit.collider.gameObject;
                }
            }
            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.name == "stairs" && AllowMoveInput)
                {
                    if (adjCheck(hit.collider.gameObject.transform.position) != "none")
                    {
                        S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.StairMove);
                    }
                    return;
                }
            }
            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.tag == "Gameboard")
                {
                    if (adjCheck(clickPosition) != "none" && AllowMoveInput)
                    {
                        S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.Move);
                        S.GridCursorControlInst.SetMoveDirection(adjCheck(clickPosition));
                    }
                    else if (AllowInfoInput)
                    {
                        S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.None);
                    }
                }
            }
        }

        if (Input.GetMouseButton(0) &&
            CursorHasMovedCheck() &&
            !S.DragControlInst.DraggingGameboard &&
            !S.DragControlInst.DraggingHand &&
            Tutorial.TutorialLevel == 0)
        {
            S.DragControlInst.GameBoardDrag();
            S.GridCursorControlInst.UnpresentCursor();
        }

        if (Input.GetMouseButton(0) &&
            !S.DragControlInst.DraggingGameboard &&
            !S.DragControlInst.DraggingHand &&
            Tutorial.TutorialLevel == 0 &&
            Time.time > lastCursorSetTime + .5f)
        {
            S.GridCursorControlInst.PresentCursor(GridCursorControl.CursorActions.Info, infoTarget);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Main method 2; Executes whatever action is set to happen
    /// </summary>
    public void ReleaseCursor()
    {
        switch (currentCursorAction)
        {
        case CursorActions.Info:
            ShowInfo();
            break;

        case CursorActions.StairMove:
            if (S.GameControlInst.MovesLeft > 0)
            {
                S.GameControlInst.AddMoves(-1);
                S.ShopControlInst.GoalCheck("Move X times in one turn");
                S.ShopControlInst.GoalCheck("Don't move X turns in a row");
                S.ShopControlInst.GoalCheck("Don't deal damage or move X turns in a row");
                S.ShopControlInst.GoalCheck("Don't move X turns in a row");
            }
            else
            {
                ButtonAnimate moveButton =
                    GameObject.Find("move end button").GetComponent <ButtonAnimate>();
                moveButton.ErrorAnimation();
            }
            break;

        case CursorActions.Move:
            if (walkableObstacleToWalkInto != null)
            {
                walkableObstacleToWalkInto.StepIn();
            }
            if (moveDirection != null)
            {
                playerObject.GetComponent <Player>().MoveClick(moveDirection);
            }
            else
            {
                Debug.LogError("there should be a move direction set already. oops");
            }
            break;

        case CursorActions.Poke:
            GridUnit playerGU = playerObject.GetComponent <GridUnit>();
            playerGU.PokeTowards(playerGU.AdjacentPosition(currentCursorTarget.GetComponent <GridUnit>()));
            break;

        case CursorActions.Punch:
            playerObject.GetComponent <Player>().Punch(currentCursorTarget);
            break;

        case CursorActions.TargetSquare:
            TargetSquare square = currentCursorTarget.GetComponent <TargetSquare>();
            if (Tutorial.TutorialLevel != 0)
            {
                if (square.XCoor == 0 && square.YCoor == -2)
                {
                    S.GameControlInst.gameObject.GetComponent <Tutorial>().TutorialTrigger(5);
                }
                else
                {
                    S.GameControlInst.gameObject.GetComponent <Tutorial>().TutorialMessage = "iolksdcbelp";
                    return;
                }
            }
            S.GameControlInst.TargetSquareCallback.TargetSquareCalledThis(square.XCoor, square.YCoor);
            break;

        case CursorActions.None:
            break;

        default:
            Debug.Log("shouldn't be showing info! bug!");
            break;
        }

        UnpresentCursor();
    }