// Update is called once per frame
    void Update()
    {
        if (ActionInput.GetButtonDown(ButtonCode.UpArrow))
        {
            nowIndex--;
            nowIndex = (nowIndex + maxIndex) % maxIndex;
            audioSource.PlayOneShot(drumSe);
        }

        if (ActionInput.GetButtonDown(ButtonCode.DownArrow))
        {
            nowIndex++;
            nowIndex %= maxIndex;
            audioSource.PlayOneShot(drumSe);
        }

        if (onSelecteds[nowIndex] != null)
        {
            onSelecteds[nowIndex]();
        }


        if (onCancel != null && ActionInput.GetButtonDown(ButtonCode.Cancel))
        {
            onCancel();
            audioSource.PlayOneShot(cancelSe);
        }


        cursor.transform.localPosition = cursorDefaultPos + Vector3.down * width * (nowIndex + addIndex);
    }
        protected override void Update()
        {
            base.Update();

            if (!actionEnabled)
            {
                return;
            }

            SetLeftDistance();

            if (isDead)
            {
                GoNextScene();
            }

            if (ActionInput.GetButtonDown(ButtonCode.Cancel))
            {
                if (!hukidashiL.isExist)
                {
                    hukidashiL.FlowStart();
                }
            }
            if (ActionInput.GetButtonDown(ButtonCode.Jump))
            {
                if (!hukidashiR.isExist)
                {
                    hukidashiR.FlowStart();
                }
            }
        }
Beispiel #3
0
        public void ScenarioUpdate()
        {
            if (isPrepareTime)
            {
                return;
            }

            /*if (ActionInput.GetButtonDown(ButtonCode.Cancel))
             * {
             *  ScenerioEnd();
             * }*/

            if (isEventing)
            {
                // Warningのアニメーションを表示
                if (!warningText.gameObject.activeSelf)
                {
                    warningText.gameObject.SetActive(true);
                    StartCoroutine(WarningAnimation());
                }
                return;
            }

            // 文字表示が完了しているなら、決定キー後に次の行を表示
            if (ActionInput.GetButtonDown(ButtonCode.Jump))
            {
                if (IsCompleteDisplayText)
                {
                    if (currentLine < scenarios.Length)
                    {
                        SetNextLine();
                    }
                    else
                    {
                        ScenerioEnd();
                    }
                }
                // 完了していないなら文字をすべて表示する
                else
                {
                    timeUntilDisplay = 0;
                }
            }


            int displayCharacterCount = (int)(Mathf.Clamp01((Time.time - timeElapsed) /
                                                            timeUntilDisplay) * currentText.Length);

            if (displayCharacterCount != lastUpdateCharacter)
            {
                uiText.text         = currentText.Substring(0, displayCharacterCount);
                lastUpdateCharacter = displayCharacterCount;

                //by koitan
                audioSource.PlayOneShot(messageSE);
            }
        }
 private void Update()
 {
     if (ActionInput.GetButtonDown(ButtonCode.Jump))
     {
         if (isTrigger)
         {
             hoge();
         }
     }
 }
Beispiel #5
0
 // Update is called once per frame
 void Update()
 {
     if (ActionInput.GetButtonDown(ButtonCode.Jump))
     {
         if (!FadeManager.Instance.isFading)
         {
             FadeManager.Instance.LoadScene("Title", 2.0f);
         }
     }
 }
 OnSelected SetButtonPush(Action onPush)
 {
     return(() =>
     {
         if (ActionInput.GetButtonDown(ButtonCode.Jump))
         {
             onPush();
             audioSource.PlayOneShot(decisionSe);
         }
     });
 }
 OnSelected SetFullScreen()
 {
     return(() =>
     {
         if (ActionInput.GetButtonDown(ButtonCode.RightArrow) || ActionInput.GetButtonDown(ButtonCode.LeftArrow))
         {
             Screen.fullScreen = !Screen.fullScreen;
         }
         titleUi.text = "がめんせってい\nフルスクリーン\u3000< " + ScreenIsFull() + " >\nかいぞうど < " + ScreenSizeString() + " >";
     });
 }
 OnSelected SetScreenSize()
 {
     return(() =>
     {
         if (ActionInput.GetButtonDown(ButtonCode.RightArrow))
         {
             ScreenSizeNum++;
             ScreenSizeNum = (ScreenSizeNum + 4) % 4;
             ScreenSizeChange();
         }
         if (ActionInput.GetButtonDown(ButtonCode.LeftArrow))
         {
             ScreenSizeNum--;
             ScreenSizeNum = (ScreenSizeNum + 4) % 4;
             ScreenSizeChange();
         }
         titleUi.text = "がめんせってい\nフルスクリーン\u3000< " + ScreenIsFull() + " >\nかいぞうど < " + ScreenSizeString() + " >";
     });
 }
Beispiel #9
0
    // Update is called once per frame
    void Update()
    {
        if (ActionInput.GetButtonDown(ButtonCode.Cancel))
        {
            if (GetIsGround() == false)
            {
                return;
            }
            pauseUI.SetActive(!pauseUI.activeSelf);

            if (pauseUI.activeSelf)
            {
                player.GetComponent <PlayerRB>().enabled = false;
                Time.timeScale = 0f;
            }
            else
            {
                player.GetComponent <PlayerRB>().enabled = true;
                Time.timeScale = 1f;
            }
        }
    }
        // Update is called once per frame
        void Update()
        {
            // Debug.Log(isMoving);
            // 後でプレイヤー部分とステージステート部分を分けたい

            if (!actionEnabled)
            {
                return;
            }

            if (transform.position.x - prevPos.x > 0)
            {
                dir = 1f;
            }
            else if (transform.position.x - prevPos.x < 0)
            {
                dir = -1f;
            }
            animator.SetFloat("MoveSpeed", (isMoving) ? 10 : 0);
            transform.localScale = new Vector3(
                defaultScaleX * dir, transform.localScale.y, transform.localScale.z);

            if (isMoving != prevIsMoving)
            {
                SwitchArrow(!isMoving);
                if (!isMoving)
                {
                    ShowStageName();
                }
            }

            prevPos      = transform.position;
            prevIsMoving = isMoving;


            if (dir == 1f)
            {
                arrow.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
            }
            else
            {
                arrow.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
            }

            if (isMoving)
            {
                //audioSource.PlayOneShot(walkingSE);
                return;
            }
            // あまりよくない
            if (ActionInput.actionEnabled != prevActionEnabled)
            {
                SwitchArrow(ActionInput.actionEnabled);
            }

            prevActionEnabled = ActionInput.actionEnabled;

            if (IsStageSpriteEnabled())
            {
                if (ActionInput.GetButtonDown(ButtonCode.Jump))
                {
                    StartCoroutine(GoNextStage(sceneWaitTime));
                    return;
                }
                else if (ActionInput.GetButtonDown(ButtonCode.Cancel))
                {
                    BlindStageSprite();
                    SwitchArrow(true);
                }
            }

            if (ActionInput.GetButtonDown(ButtonCode.Jump))
            {
                if (!menuCtrl.isDisplayed)
                {
                    SwitchArrow(false);
                    if (nowStageState.stageId == lastStageId)
                    {
                        RocketExplanation();
                        return;
                    }
                    else
                    {
                        DisplayStageSprite();
                    }
                }
            }


            if (IsStageSpriteEnabled())
            {
                return;
            }

            if (menuCtrl != null)
            {
                if (menuCtrl.isDisplayed)
                {/*
                  * if (ActionInput.GetButtonDown(ButtonCode.Cancel))
                  * {
                  * menuCtrl.EndMenu();
                  * }*/
                    return;
                }

                if (Input.GetKeyDown(KeyCode.P))
                {
                    menuCtrl.StartMenu();
                }
            }

            MoveDirection moveDir;

            if (ActionInput.GetButtonDown(ButtonCode.UpArrow))
            {
                if (!nowStageState.canMove.up)
                {
                    return;
                }
                if (nowStageState.nextStage.upStage == null)
                {
                    return;
                }

                moveDir = MoveDirection.UP;
            }
            else if (ActionInput.GetButtonDown(ButtonCode.RightArrow))
            {
                if (!nowStageState.canMove.right)
                {
                    return;
                }
                if (nowStageState.nextStage.rightStage == null)
                {
                    return;
                }

                moveDir = MoveDirection.RIGHT;
            }
            else if (ActionInput.GetButtonDown(ButtonCode.DownArrow))
            {
                if (!nowStageState.canMove.down)
                {
                    return;
                }
                if (nowStageState.nextStage.downStage == null)
                {
                    return;
                }

                moveDir = MoveDirection.DOWN;
            }
            else if (ActionInput.GetButtonDown(ButtonCode.LeftArrow))
            {
                if (!nowStageState.canMove.left)
                {
                    return;
                }
                if (nowStageState.nextStage.leftStage == null)
                {
                    return;
                }

                moveDir = MoveDirection.LEFT;
            }
            else
            {
                return;
            }

            MoveAction(moveDir);
            ChangeStageState(moveDir);
        }
            public override void menuUpdate()
            {
                if (ActionInput.GetButtonDown(ButtonCode.DownArrow))
                {
                    index     = (++index) % itemNum;
                    isChanged = true;
                }
                else if (ActionInput.GetButtonDown(ButtonCode.UpArrow))
                {
                    index     = (--index + itemNum) % itemNum;
                    isChanged = true;
                }
                else if (ActionInput.GetButtonDown(ButtonCode.Jump))
                {
                    switch (index)
                    {
                    case (int)ItemAudio.BACK:
                        menuCtrl.EndFrogUI(menuCtrl.frogUIAudio, menuCtrl.frogTweenAudio, true);
                        menuCtrl.EndBackUI(menuCtrl.backUIAudio, menuCtrl.backTweenAudio);
                        menuCtrl.menuState = new Menu(1, 3, menuCtrl);
                        break;

                    case (int)ItemAudio.BGM:
                        //menuCtrl.menuState = new Audio(menuCtrl);
                        //menuCtrl.menuState.menuStart();
                        break;

                    case (int)ItemAudio.SE:
                        //menuCtrl.menuState = new Title();
                        break;
                    }
                }

                switch (index)
                {
                case (int)ItemAudio.BACK:
                    if (isChanged)
                    {
                        menuCtrl.TextApeal(menuCtrl.backTextAudio);
                        menuCtrl.EndTextApeal(menuCtrl.bgmText);
                        menuCtrl.EndTextApeal(menuCtrl.seText);
                        isChanged = false;
                    }
                    break;

                case (int)ItemAudio.BGM:
                    if (isChanged)
                    {
                        menuCtrl.TextApeal(menuCtrl.bgmText);
                        menuCtrl.EndTextApeal(menuCtrl.backTextAudio);
                        menuCtrl.EndTextApeal(menuCtrl.seText);
                        isChanged = false;
                    }
                    break;

                case (int)ItemAudio.SE:
                    if (isChanged)
                    {
                        menuCtrl.TextApeal(menuCtrl.seText);
                        menuCtrl.EndTextApeal(menuCtrl.backTextAudio);
                        menuCtrl.EndTextApeal(menuCtrl.bgmText);
                        isChanged = false;
                    }
                    break;
                }
            }
            public override void menuUpdate()
            {
                if (ActionInput.GetButtonDown(ButtonCode.DownArrow))
                {
                    index     = (++index) % itemNum;
                    isChanged = true;
                }
                else if (ActionInput.GetButtonDown(ButtonCode.UpArrow))
                {
                    index     = (--index + itemNum) % itemNum;
                    isChanged = true;
                }
                else if (ActionInput.GetButtonDown(ButtonCode.Jump))
                {
                    switch (index)
                    {
                    case (int)Item.BACK:
                        menuCtrl.EndMenu();
                        menuCtrl.menuState = null;
                        break;

                    case (int)Item.AUDIO:
                        menuCtrl.menuState = new Audio(menuCtrl);
                        menuCtrl.menuState.menuStart();
                        break;

                    case (int)Item.TITLE:
                        SceneManager.LoadScene("Title");
                        //menuCtrl.menuState = new Title();
                        break;
                    }
                }

                switch (index)
                {
                case (int)Item.BACK:
                    if (isChanged)
                    {
                        menuCtrl.TextApeal(menuCtrl.backText);
                        menuCtrl.EndTextApeal(menuCtrl.audioText);
                        menuCtrl.EndTextApeal(menuCtrl.titleText);
                        isChanged = false;
                    }
                    break;

                case (int)Item.AUDIO:
                    if (isChanged)
                    {
                        menuCtrl.TextApeal(menuCtrl.audioText);
                        menuCtrl.EndTextApeal(menuCtrl.backText);
                        menuCtrl.EndTextApeal(menuCtrl.titleText);
                        isChanged = false;
                    }
                    break;

                case (int)Item.TITLE:
                    if (isChanged)
                    {
                        menuCtrl.TextApeal(menuCtrl.titleText);
                        menuCtrl.EndTextApeal(menuCtrl.backText);
                        menuCtrl.EndTextApeal(menuCtrl.audioText);
                        isChanged = false;
                    }
                    timer.TimeUpdate(Time.deltaTime);
                    if (timer.IsTimeout())
                    {
                        Debug.Log("涙でてる");
                        Instantiate(menuCtrl.tearObject, menuCtrl.tearPosition[0].position,
                                    Quaternion.identity);

                        Instantiate(menuCtrl.tearObject, menuCtrl.tearPosition[1].position,
                                    Quaternion.identity);

                        timer.TimeReset();
                    }
                    break;
                }
            }
    // Update is called once per frame
    void Update()
    {
        AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (ActionInput.GetButton(ButtonCode.RightArrow) && !isSquat)
        {
            power.x += accelVx * Time.deltaTime * 60;
            if (power.x > maxVx)
            {
                power.x -= accelVx * Time.deltaTime * 60;
                power.x  = Mathf.Max(power.x, maxVx);
            }
            else
            {
                power.x = Mathf.Min(power.x, maxVx);
            }
            direction = 1;
        }
        else if (ActionInput.GetButton(ButtonCode.LeftArrow) && !isSquat)
        {
            power.x -= accelVx * Time.deltaTime * 60;
            if (power.x < -maxVx)
            {
                power.x += accelVx * Time.deltaTime * 60;
                power.x  = Mathf.Min(power.x, -maxVx);
            }
            else
            {
                power.x = Mathf.Max(power.x, -maxVx);
            }
            direction = -1;
        }
        else
        {
            if (isGround)
            {
                if (power.x > 0)
                {
                    power.x -= accelVx * 2 * Time.deltaTime * 60;
                    power.x  = Mathf.Max(0, power.x);
                }
                else if (power.x < 0)
                {
                    power.x += accelVx * 2 * Time.deltaTime * 60;
                    power.x  = Mathf.Min(0, power.x);
                }
            }
            else
            {
                //スピードが早すぎるときは減速しない
                if (Mathf.Abs(power.x) < maxVx * 2)
                {
                    if (power.x > 0)
                    {
                        power.x -= accelVx * Time.deltaTime * 60;
                        power.x  = Mathf.Max(0, power.x);
                    }
                    else if (power.x < 0)
                    {
                        power.x += accelVx * Time.deltaTime * 60;
                        power.x  = Mathf.Min(0, power.x);
                    }
                }
            }
        }

        //スピードが早いときは減速しない
        if (Mathf.Abs(power.x) < maxVx)
        {
            if (power.x > maxVx)
            {
                power.x -= accelVx * Time.deltaTime * 60;
                power.x  = Mathf.Max(power.x, maxVx);
            }
            else if (power.x < -maxVx)
            {
                power.x += accelVx * Time.deltaTime * 60;
                power.x  = Mathf.Min(power.x, -maxVx);
            }
        }

        //風
        if (wind != null)
        {
            //power.x += -Mathf.Cos((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 00.5f;
            gravity = defaultGravity - Mathf.Sin((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 0.02f;
        }



        transform.localScale = new Vector3(
            defaultScaleX * direction, transform.localScale.y, transform.localScale.x);

        isSquat = stateInfo.IsName("squat");

        if (ActionInput.GetButton(ButtonCode.DownArrow))
        {
            animator.SetBool("squat", true);
        }
        else
        {
            animator.SetBool("squat", false);
        }

        if (isContactRight)
        {
            power.x = Mathf.Min(power.x, 0);
        }

        if (isContactLeft)
        {
            power.x = Mathf.Max(power.x, 0);
        }

        if (ActionInput.GetButtonDown(ButtonCode.Jump) && jumpEnabled)
        {
            if (!isGround)
            {
                airJumpTimes--;
                if (airJumpTimes <= 0)
                {
                    jumpEnabled = false;
                }
            }
            isJumping  = true;
            jumpFrames = defaultJumpFrames;
            power.y    = maxVy;
            isGround   = false;
            animator.SetBool("Jump", true); // tada
            //音
            audioSource.PlayOneShot(jumpSE);
            //エフェクト
            JumpEffFire();
        }

        if (isGround)
        {
            airJumpTimes = defaultAirJumpTimes;
            jumpEnabled  = true;
            jumpCooltime = jumpDefaultCooltime;
            isJumping    = false;
            jumpFrames   = defaultJumpFrames;
            power.y      = 0;
            animator.SetBool("Jump", false); // tada
            if (power.magnitude < 0.01f)
            {
                v = Vector2.zero;
            }
            v = Vector3.ProjectOnPlane(power, groundNormal);
            //風
            if (wind != null)
            {
                v.x += -Mathf.Cos((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 0.1f;
            }
            v.x = Mathf.Clamp(v.x, -maxVx * 2, maxVx * 2);
            Debug.DrawRay(groundPoint, groundNormal, Color.red);
            //Debug.DrawRay(groundPoint, v, Color.red);
        }
        else
        {
            //ジャンプ
            if (jumpCooltime > 0)
            {
                jumpCooltime -= Time.deltaTime;
            }
            else
            {
                if (airJumpTimes == 0)
                {
                    jumpEnabled = false;
                }
            }

            if (isJumping && jumpFrames > 0)
            {
                if (ActionInput.GetButtonDown(ButtonCode.Jump))
                {
                    animator.Play("PlayerJump", 0, 0.0f); // tada
                    //音
                    audioSource.PlayOneShot(jumpSE);
                }
                if (ActionInput.GetButton(ButtonCode.Jump))
                {
                    jumpFrames -= Time.deltaTime;
                    power.y     = maxVy;
                    isGround    = false;
                }
                else
                {
                    isJumping = false;
                }
            }
            else
            {
                power.y += gravity * Time.deltaTime * 60;
            }
            power.y = Mathf.Clamp(power.y, -maxVy, maxVy * 2);
            v       = power;
            //風
            if (wind != null)
            {
                v.x += -Mathf.Cos((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 0.25f;
            }
            v.x = Mathf.Clamp(v.x, -maxVx * 2, maxVx * 2);
        }

        isMoving = Mathf.Abs(power.x) > 0;

        //エフェクト
        if ((isGround && !oldIsGround) || (isGround && !asikemuri.isPlaying && isMoving))
        {
            asikemuri.Play();
        }

        if ((!isGround && oldIsGround) || (isGround && asikemuri.isPlaying && !isMoving))
        {
            asikemuri.Stop();
        }

        if (isGround && !oldIsGround)
        {
            LaundEffFire();
        }

        if (isGround && v.magnitude > 0)
        {
            //audioSource.clip = ashiSE;
            //audioSource.Play();
        }
        else
        {
            //audioSource.clip = null;
            //audioSource.Stop();
        }

        //地面に付いてるか保存
        oldIsGround = isGround;
        oldIsMoving = isMoving;

        //rb.velocity = v + rv;
        rb.MovePosition(transform.position + (Vector3)v * Time.deltaTime * 60);
        //rv = Vector2.zero;
        //rv = Vector2.zero;
        //transform.position += (Vector3)v;
        Debug.DrawRay(transform.position, v * Time.deltaTime * 60, Color.white);
        //Debug.Log("速さ:"+v.magnitude);

        // tada
        animator.SetFloat("MoveSpeed", Mathf.Abs(v.x));
    }