コード例 #1
0
 //初期値共通まとめ関数
 private void InitStart()
 {
     psf  = PlayerStateFlg.WAIT;
     pasf = PlayerAnimStateFlg.WAIT;
     mat.SetTexture("_MainTex", filmushi_normal);
     nowtime         = 0.0f;
     deadtime        = 0.0f;
     waitnowtime     = 0.0f;
     touchtime       = 0.0f;
     groundRotation  = 0.0f;
     touchtimeflg    = false;
     animwalkflg     = false;
     animclearflg    = false;
     animfurimukiflg = false;
     animjumpflg     = false;
     animwaitflg     = false;
     animwait2flg    = false;
     animdieflg      = false;
     switchwaitflg   = true;
     tapflg          = false;
     onetapflg       = false;
     swipeflg        = false;
     jumpflg         = false;
     enemycolflg     = false;
     playendflg      = true;
 }
コード例 #2
0
 //プレイヤーが振り向く
 private void furimuki()
 {
     animfurimukiflg = true;
     if (animfurimukiflg == true)
     {
         nowscale    = tf.localScale;
         nowscale.x *= -1.0f;
         pasf        = PlayerAnimStateFlg.WAIK;
     }
 }
コード例 #3
0
 //タップ、スワイプ検知処理
 private void DetectionTapOld()
 {
     //タップをする
     if (Input.GetMouseButtonDown(0))
     {
         //最初にタップされた座標を取得
         changemousePos = Input.mousePosition;
         tapstartPos    = Camera.main.ScreenToWorldPoint(changemousePos);
         tapstartget    = new Vector2(tapstartPos.x, tapstartPos.y);
         //タップされたらカウントフラグをtrueにする
         touchtimeflg = true;
     }
     //タップされたらカウント開始
     if (touchtimeflg == true)
     {
         touchtime += 1.0f;
     }
     //一定時間が過ぎると処理に入る
     if (touchtime >= touchendtime)
     {
         //カウントフラグをfalseにする
         touchtimeflg = false;
         //カウント経過後にタップされた座標を取得
         changemousePos = Input.mousePosition;
         tapendPos      = Camera.main.ScreenToWorldPoint(changemousePos);
         tapendget      = new Vector2(tapendPos.x, tapendPos.y);
         //最初にタップされた座標とカウント後にタップされた座標がステージ内なら処理に入る。そしてゴールや死亡をしなければこの処理に入る
         if (Physics2D.Raycast(tapstartget, -Vector2.up, 0.001f, BackGround) && Physics2D.Raycast(tapendget, -Vector2.up, 0.001f, BackGround) && playendflg == true)
         {
             //最初にタップされたy座標よりカウント後のタップy座標の方が高ければジャンプ処理に入る
             if (tapstartPos.y < tapendPos.y)
             {
                 swipeflg        = true;
                 animwalkflg     = false;
                 animfurimukiflg = false;
                 touchtime       = 0.0f;
             }
             //最初にタップされたy座標とカウント後のタップy座標が一緒であれば歩行処理に入る
             else if (tapstartPos.y == tapendPos.y)
             {
                 tapflg = true;
             }
             //タップとプレイヤーの位置が一緒の場合は止まる
             if (tapflg == true && onetapflg == false && nowPos.x == tapendPos.x)
             {
                 tapflg    = false;
                 onetapflg = true;
                 touchtime = 0.0f;
                 psf       = PlayerStateFlg.WAIT;
                 pasf      = PlayerAnimStateFlg.WAIT;
             }
             //タップの位置がプレイヤーの位置より右にある場合は右に移動する
             else if (tapflg == true && onetapflg == false && nowPos.x < tapendPos.x)
             {
                 tapflg    = false;
                 onetapflg = true;
                 touchtime = 0.0f;
                 psf       = PlayerStateFlg.RIGHT;
                 //プレイヤーが左を向いていた場合に右に向くように処理する
                 if (nowscale.x < 0.0f)
                 {
                     pasf = PlayerAnimStateFlg.FURIMUKI;
                 }
                 else
                 {
                     pasf = PlayerAnimStateFlg.WAIK;
                 }
             }
             //タップの位置がプレイヤーの位置より左にある場合は左に移動する
             else if (tapflg == true && onetapflg == false && nowPos.x > tapendPos.x)
             {
                 psf       = PlayerStateFlg.LEFT;
                 tapflg    = false;
                 onetapflg = true;
                 touchtime = 0.0f;
                 //プレイヤーが右を向いていた場合に左に向くように処理する
                 if (nowscale.x > 0.0f)
                 {
                     pasf = PlayerAnimStateFlg.FURIMUKI;
                 }
                 else
                 {
                     pasf = PlayerAnimStateFlg.WAIK;
                 }
             }
             //タップが一度押されている場合はプレイヤーは停止する
             else if (tapflg == true && onetapflg == true)
             {
                 psf       = PlayerStateFlg.WAIT;
                 pasf      = PlayerAnimStateFlg.WAIT;
                 touchtime = 0.0f;
                 onetapflg = false;
                 tapflg    = false;
             }
         }
     }
 }
コード例 #4
0
 private void DetectionTapOld2()
 {
     //タッチ取得
     if (Input.GetMouseButtonDown(0))
     {
         //タッチ座標取得
         Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         //ステージ背景の中かつクリップ上ではない場所をクリックした時検知開始
         if (stageCollider.OverlapPoint(mousePos) && !clipCollider.OverlapPoint(mousePos))
         {
             touchtimeflg = true;
             tapstartPos  = mousePos;
         }
     }
     //タッチ中フラグ
     if (touchtimeflg)
     {
         touchtime += Time.deltaTime;
         //時間超過でタップ判定を消す
         if (touchtime >= touchendtime)
         {
             touchtime    = 0.0f;
             touchtimeflg = false;
             return;
         }
         else
         {
             //現在のタッチ座標取得
             Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
             //タッチ位置より一定以上↑へスワイプした時ジャンプする
             if (mousePos.y > tapstartPos.y + swipeJudgeDistance)
             {
                 swipeflg        = true;
                 animwalkflg     = false;
                 animfurimukiflg = false;
                 touchtime       = 0.0f;
                 touchtimeflg    = false;
             }
             //タッチ位置と近い位置で指が離れた時タップしたと判定する
             else if (Input.GetMouseButtonUp(0) && Vector2.Distance(tapstartPos, mousePos) < swipeJudgeDistance)
             {
                 touchtime    = 0.0f;
                 touchtimeflg = false;
                 //タップ時処理
                 //既にタップ位置へ移動中なら移動を中止する
                 if (onetapflg)
                 {
                     onetapflg = false;
                     psf       = PlayerStateFlg.WAIT;
                     pasf      = PlayerAnimStateFlg.WAIT;
                     tapEffectTransform.GetComponent <Renderer>().enabled = false;
                 }
                 //タップ位置がプレイヤーより右なら右へ移動する
                 else if (tf.position.x < mousePos.x)
                 {
                     onetapflg = true;
                     tapEffectTransform.GetComponent <Renderer>().enabled = true;
                     tapEffectTransform.position = mousePos;
                     tapEffectTransform.Translate(Vector3.back * 5);
                     psf = PlayerStateFlg.RIGHT;
                     //プレイヤーが左を向いていた場合に右に向くように処理する
                     if (nowscale.x < 0.0f)
                     {
                         pasf = PlayerAnimStateFlg.FURIMUKI;
                     }
                     else
                     {
                         pasf = PlayerAnimStateFlg.WAIK;
                     }
                 }
                 //タップ位置がプレイヤーより左なら左へ移動する
                 else
                 {
                     onetapflg = true;
                     tapEffectTransform.GetComponent <Renderer>().enabled = true;
                     tapEffectTransform.position = mousePos;
                     tapEffectTransform.Translate(Vector3.back * 5);
                     psf = PlayerStateFlg.LEFT;
                     //プレイヤーが右を向いていた場合に左に向くように処理する
                     if (nowscale.x > 0.0f)
                     {
                         pasf = PlayerAnimStateFlg.FURIMUKI;
                     }
                     else
                     {
                         pasf = PlayerAnimStateFlg.WAIK;
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
    private void DetectionTapOld3()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //タッチ座標取得
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            //ステージ背景の中かつクリップ上ではない場所をクリックした時検知開始
            if (stageCollider.OverlapPoint(mousePos) && !clipCollider.OverlapPoint(mousePos))
            {
                touchtimeflg = true;
            }
        }
        if (touchtimeflg)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            inputPosBuffer.Add(mousePos);
            Vector2 judgePos = new Vector2();
            if (inputPosBuffer.Count < 10)
            {
                judgePos = inputPosBuffer[0];
            }
            else
            {
                judgePos = inputPosBuffer[inputPosBuffer.Count - 10];
            }
            //タッチ位置より一定以上↑へスワイプした時ジャンプする
            if (mousePos.y > judgePos.y + swipeJudgeDistance)
            {
                swipeflg        = true;
                animwalkflg     = false;
                animfurimukiflg = false;
                inputPosBuffer.Clear();
            }
            //タップ位置がプレイヤーより右なら右へ移動する
            if (tf.position.x < mousePos.x - 0.1f)
            {
                onetapflg = true;
                tapEffectTransform.GetComponent <Renderer>().enabled = true;
                tapEffectTransform.position = mousePos;
                tapEffectTransform.Translate(Vector3.back * 5);
                psf = PlayerStateFlg.RIGHT;
                //プレイヤーが左を向いていた場合に右に向くように処理する
                if (nowscale.x < 0.0f)
                {
                    pasf = PlayerAnimStateFlg.FURIMUKI;
                }
                else
                {
                    pasf = PlayerAnimStateFlg.WAIK;
                }
            }
            //タップ位置がプレイヤーより左なら左へ移動する
            else if (tf.position.x > mousePos.x + 0.1f)
            {
                onetapflg = true;
                tapEffectTransform.GetComponent <Renderer>().enabled = true;
                tapEffectTransform.position = mousePos;
                tapEffectTransform.Translate(Vector3.back * 5);
                psf = PlayerStateFlg.LEFT;
                //プレイヤーが右を向いていた場合に左に向くように処理する
                if (nowscale.x > 0.0f)
                {
                    pasf = PlayerAnimStateFlg.FURIMUKI;
                }
                else
                {
                    pasf = PlayerAnimStateFlg.WAIK;
                }
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            onetapflg = false;
            psf       = PlayerStateFlg.WAIT;
            pasf      = PlayerAnimStateFlg.WAIT;
            tapEffectTransform.GetComponent <Renderer>().enabled = false;

            touchtimeflg = false;
            inputPosBuffer.Clear();
        }
    }
コード例 #6
0
    //移動用入力検知
    private void DetectionTap()
    {
        //死んでたりたら止める
        if (animdieflg)
        {
            psf  = PlayerStateFlg.WAIT;
            pasf = PlayerAnimStateFlg.WAIT;
            tapEffectTransform.GetComponent <Renderer>().enabled = false;

            touchtimeflg = false;
            inputPosBuffer.Clear();
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            //タッチ座標取得
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            //ステージ背景の中かつクリップ上ではない場所をクリックした時検知開始
            if (stageCollider.OverlapPoint(mousePos) && !clipCollider.OverlapPoint(mousePos))
            {
                tapstartPos = mousePos;
                //タッチしたらマーカー表示
                tapEffectTransform.GetComponent <Renderer>().enabled = true;
                tapEffectTransform.position = mousePos;
                tapEffectTransform.Translate(Vector3.back * 5);
                touchtimeflg = true;
            }
        }
        if (touchtimeflg)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            //現在のタッチ座標をバッファへ格納
            inputPosBuffer.Add(mousePos);
            Vector2 judgePos = new Vector2();
            //バッファが大きくなりすぎないように古すぎるものは削除
            if (inputPosBuffer.Count > 10)
            {
                inputPosBuffer.RemoveAt(0);
            }
            //ジャンプのための座標比較用
            judgePos = inputPosBuffer[0];
            //以前のフレームより一定以上↑へスワイプした時ジャンプ中でなければジャンプする
            if (mousePos.y > judgePos.y + swipeJudgeDistance && !animjumpflg)
            {
                swipeflg        = true;
                animwalkflg     = false;
                animfurimukiflg = false;
                inputPosBuffer.Clear();
            }
            //タッチ座標が開始位置より一定以上右なら右へ移動する
            if (tapstartPos.x < mousePos.x - 0.1f)
            {
                //開始位置との距離によってスピードを変える
                if (mousePos.x - tapstartPos.x > maxSpeedDistance)
                {
                    speed = retentionspeed;
                }
                else
                {
                    speed = retentionspeed * (mousePos.x - tapstartPos.x) / maxSpeedDistance;
                }
                tapEffectTransform.localEulerAngles = Vector3.forward * 90;
                psf = PlayerStateFlg.RIGHT;
                //プレイヤーが左を向いていた場合に右に向くように処理する
                if (nowscale.x < 0.0f)
                {
                    pasf = PlayerAnimStateFlg.FURIMUKI;
                }
                else
                {
                    pasf = PlayerAnimStateFlg.WAIK;
                }
            }
            //タッチ座標が開始位置より一定以上左なら左へ移動する
            else if (tapstartPos.x > mousePos.x + 0.1f)
            {
                //開始位置との距離によってスピードを変える
                if (tapstartPos.x - mousePos.x > maxSpeedDistance)
                {
                    speed = retentionspeed;
                }
                else
                {
                    speed = retentionspeed * (tapstartPos.x - mousePos.x) / maxSpeedDistance;
                }
                tapEffectTransform.localEulerAngles = Vector3.back * 90;
                psf = PlayerStateFlg.LEFT;
                //プレイヤーが右を向いていた場合に左に向くように処理する
                if (nowscale.x > 0.0f)
                {
                    pasf = PlayerAnimStateFlg.FURIMUKI;
                }
                else
                {
                    pasf = PlayerAnimStateFlg.WAIK;
                }
            }
            //タッチ位置から動いてなければ止まる
            else
            {
                psf  = PlayerStateFlg.WAIT;
                pasf = PlayerAnimStateFlg.WAIT;
                tapEffectTransform.localEulerAngles = Vector3.zero;
            }
            //離したら止まる
            if (Input.GetMouseButtonUp(0))
            {
                psf  = PlayerStateFlg.WAIT;
                pasf = PlayerAnimStateFlg.WAIT;
                tapEffectTransform.GetComponent <Renderer>().enabled = false;

                touchtimeflg = false;
                inputPosBuffer.Clear();
            }
        }
    }
コード例 #7
0
    // Update is called once per frame
    private void Update()
    {
        //死んだ時のリスタート
        if (fd_out.GetEndFlag())
        {
            var nowScene = SceneManager.GetActiveScene().name;
            SceneManager.LoadScene(nowScene);
        }

        nowPos = tf.position;

        DetectionTap();
        WallControl();
        TransitionMove();
        TransitionAnim();

        anim.SetBool("jumping", animjumpflg);
        anim.SetBool("waiting", animwaitflg);
        anim.SetBool("waiting2", animwait2flg);
        anim.SetBool("dieflg", animdieflg);
        anim.SetBool("clearflg", animclearflg);
        //スワイプの入力検知はここに書く
        if (swipeflg == true)
        {
            if (jumpflg == true)
            {
                mat.SetTexture("_MainTex", filmushi_normal);
                Jump();
                animjumpflg = true;

                soueceAudio.PlaySE((int)AudioList.AUDIO_JUMP);
            }
            swipeflg = false;
        }
        //プレイヤーがステージの外に落下した場合
        if (tf.position.y < -(maxfallout) && !jumpflg && rb2d.velocity.y < 0)
        {
            //PlayerStart();
            print("落下死亡");
            tf.position = Vector3.up * 1000;
            soueceAudio.PlaySE((int)AudioList.AUDIO_DEAD); //落下時の音(仮)
            fd_out.FadeStart();
        }
        //プレイヤーがエネミーに当たった場合
        if (enemycolflg == true)
        {
            animdieflg = true;
            print("敵に当たったので死亡");
            if (deadtime == 1.0f)
            {
                //ふぃるむしが死んだ瞬間がほしい
                soueceAudio.PlaySE((int)AudioList.AUDIO_DEAD);
            }
            if (deadtime >= deadendtime)
            {
                //PlayerStart();
                //deadtime = 0.0f;
                //enemycolflg = false;
                fd_out.FadeStart(); //死んだ一定時間後フェードアウトしてリスタート
            }
            deadtime += 1.0f;
        }
        //プレイヤーが止まっているとき
        if (pasf == PlayerAnimStateFlg.WAIT)
        {
            if (switchwaitflg == true && nowtime > eyestarttime && nowtime < maxtime)
            {
                mat.SetTexture("_MainTex", filmushi_normal);
                if (waitnowtime > 25.0f)
                {
                    switchwaitflg = false;
                    waitnowtime   = 0.0f;
                }
            }
            else if (switchwaitflg == false)
            {
                mat.SetTexture("_MainTex", filmushi_blink);
                if (waitnowtime > 25.0f)
                {
                    switchwaitflg = true;
                    waitnowtime   = 0.0f;
                }
            }
            waitnowtime += 1.0f;
        }
        //もしプレイヤーが5秒止まっている場合
        if (pasf == PlayerAnimStateFlg.WAIT && nowtime >= maxtime)
        {
            if (switchfivewaitflg == true)
            {
                pasf = PlayerAnimStateFlg.FIVEWAIT;
                switchfivewaitflg = false;
            }
            else
            {
                pasf = PlayerAnimStateFlg.FIVEWAIT2;
                switchfivewaitflg = true;
            }
        }
        else if (pasf != PlayerAnimStateFlg.WAIT)
        {
            nowtime = 0.0f;
        }
        if (nowtime <= maxtime)
        {
            nowtime += 1.0f;
        }
        tf.localScale = nowscale;
    }