コード例 #1
0
ファイル: WorldScript.cs プロジェクト: JoshuaDiaz/NewGame2020
    float death_timer = 0.5f;                              // Used to delay before you can click screen to restart after death

    // public FacingDirection AlpClickedWhere()
    // {
    //  return clickedWhere;
    // }

    /**
     * Processes the input for this update.
     */
    void ProcessInput()
    {
        switch (gameMode)
        {
        case GameMode.WALKING:                 ///// GAME MODE /////
            if (alpaca.IsDead())
            {
                death_timer -= Time.deltaTime;
                if (ClickedNow() && death_timer < 0)                          // reset on click
                {
                    clickedWhere = ClickedWhere();
                    SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
                }
                return;
            }

            if (!ClickedNow() && didClick)                      // click just ended
            {
                alpaca.StopWalk();
                ClearHighlights();
                flag             = true;
                lastClickedWhere = clickedWhere;
            }
            else if (ClickedNow())                      // click is happening
            {
                clickPos = Input.mousePosition;
                if (ClickedWhere() == FacingDirection.NONE)
                {
                    return;
                }
                clickedWhere = ClickedWhere();
                HighlightQuadrant();
                if (!alpaca.isAlpacaMoving())
                {
                    MoveOnClick();
                }
            }
            HandleFrontBlockHighlight();
            UpdateInteractability();
            didClick = ClickedNow();
            break;

        case GameMode.COMIC:                 ///// COMIC MODE /////
            if (!comicController.isComicActive())
            {
                gameMode = GameMode.WALKING;
            }
            break;

        case GameMode.MINIGAME:                 ///// MINIGAME MODE /////
            // Exiting MINIGAME mode is handled by the GeneralMinigameController which calls SetMinigameMode()
            break;

        default:
            break;
        }
    }
コード例 #2
0
    /**
     * Processes the input for this update. In charge of:
     *
     * # GAME MODE
     *  - Moving alpaca
     *  - Picking up/setting down blocks
     * # PANNING MODE
     *  - Panning, if in panning mode
     */
    void ProcessInput()
    {
        if ((pan_ctrlr != null && !pan_ctrlr.getIsPanning()) || pan_ctrlr == null)
        {
            ///// GAME MODE /////
            if (alpaca.IsDead())
            {
                death_timer -= Time.deltaTime;
                if (ClickedNow() && death_timer < 0)                  // reset on click
                //Debug.Log("reset on click");
                {
                    clickedWhere = ClickedWhere();
                    SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
                }
                return;
            }

            // if in process of loading of holding/dropping a block,
            // don't process input
            if (control_scheme != 2 && get)
            {
                //Debug.Log("holding");
                tilPickup += Time.deltaTime;
                if (tilPickup > 0.3f)                  // timer reached, actually process
                {
                    alpaca.StopWalk();
                    get = false;
                    AttemptPickUpOrPlaceBlock();
                    lastTimeClicked = 999;
                }
                return;
            }

            if (!ClickedNow() && didClick)              // click just ended
            // if(control_scheme == 0 || control_scheme == 2)
            //  alpaca.StopWalk();
            {
                if (control_scheme == 1)
                {
                    clickPos     = Input.mousePosition;
                    clickedWhere = ClickedWhere();
                    HighlightQuadrant();
                    alpaca.SetFacingDirection(clickedWhere);
                }
                if (control_scheme == 2 || lastTimeClicked < 100)                  //did not pick up block
                {
                    MoveOnClick();
                    map.LoadTryHoldBlock(new Vector3(0, 0, 0), false);
                }
                lastTimeClicked = 0;
                ClearHighlights();
                flag             = true;
                lastClickedWhere = clickedWhere;
            }
            else if (ClickedNow())                // click is happening
            {
                if (control_scheme == 0 || control_scheme == 2)
                {
                    clickPos = Input.mousePosition;
                    if (ClickedWhere() == -1)
                    {
                        return;
                    }
                    clickedWhere = ClickedWhere();
                    HighlightQuadrant();
                }
                lastTimeClicked += Time.deltaTime;
                // attempt to pick up block after certain time
                if (control_scheme != 2 && flag && lastTimeClicked > 0.25f)
                {
                    map.PreviewBlock(alpaca.GetCurrAlpacaDest(clickedWhere));
                    LoadTryHoldBlock(true);
                    flag      = false;
                    get       = true;
                    tilPickup = 0;
                }
            }
            HandleFrontBlockHighlight();
            if (control_scheme == 2 && blockButt != null)
            {
                UpdateBlockButt();
            }
            didClick = ClickedNow();
        }
        else
        {
            ///// PANNING MODE /////
            if (pan_ctrlr != null && ClickedNow())
            {
                clickPos     = Input.mousePosition;
                clickedWhere = ClickedWhere();
                HighlightQuadrant();
                pan_ctrlr.MoveCamera(clickedWhere);
            }
        }
    }