Esempio n. 1
0
    /// <summary>
    /// UI上のオブジェクトの処理
    /// </summary>
    private void Wisp_task()
    {
        //動かさない場合、wispがない場合は処理をはじく
        if (!IsMoveWisp || !m_wisp)
        {
            return;
        }

        int move = m_moveuibutton ? 1 : -1;

        float dt = Time.deltaTime * 60;

        //時間を加算
        m_stageframe += dt * move;

        m_stageframe = Mathf.Clamp(m_stageframe, 0, MaxStageFrame);

        //カウントを加算
        if (m_stageframe < MaxStageFrame)
        {
            movecount += dt * (int)movevec.x * move;
        }

        //int型に変換、範囲外を除外
        int p = Mathf.Clamp(Mathf.RoundToInt(movecount), 0, EllipseHerfFrame - 1);

        //wipsを移動
        int modepos = Mathf.Clamp(Mathf.FloorToInt(movecount / (herfellipsesize / 2f)), 0, (int)m_tempo * 2 - 1);

        switch (m_ellipsemodes[modepos])
        {
        case EllipseMode.Normal:
            m_wisp.transform.position = new Vector3(m_moveposx[p], m_position.y + 0.8f * movevec.y, 0);
            break;

        case EllipseMode.Cross:
            m_wisp.transform.position = new Vector3(m_moveposx[p], m_position.y + m_moveposy[p] * movevec.y, 0);
            break;

        default:
            break;
        }

        //反転処理
        if (Mathf.Abs(p - wasswitch) > 0)
        {
            for (int i = 1; i < (int)m_tempo; ++i)
            {
                if (p == herfellipsesize * i && m_ellipsemodes[modepos] == EllipseMode.Cross)
                {
                    movevec.y *= -1;
                    wasswitch  = p;

                    int x = movebuttonrotatex == 0 ? 1 : movebuttonrotatex == 2 ? -1 : 0;
                    int y = movebuttonrotatex == 1 ? -1 : movebuttonrotatex == 3 ? 1 : 0;
                    x *= move;
                    y *= move;
                    //プレイヤーアクション処理
                    switch (i)
                    {
                    case 1:
                        //移動
                        Debug.Log("move");
                        player.Move(1);
                        break;

                    case 2:
                        //ジャンプ
                        Debug.Log("jump");
                        if (x == 1 || x == -1)
                        {
                            x *= 2;
                        }
                        if (y == 1 || y == -1)
                        {
                            y *= 2;
                        }
                        player.Move(1);
                        break;

                    case 3:
                        //方向転換
                        Debug.Log("turn right");
                        movebuttonrotatex -= move;
                        if (movebuttonrotatex < 0)
                        {
                            movebuttonrotatex = 3;
                        }
                        if (movebuttonrotatex > 3)
                        {
                            movebuttonrotatex = 0;
                        }
                        m_uibutton[0].transform.localRotation = Quaternion.Euler(0, 0, 90 * movebuttonrotatex);
                        player.Turn(movebuttonrotatex);
                        break;
                    }
                }
            }
            if (p == 0 || p == EllipseHerfFrame - 1)
            {
                movevec.y *= -1;
                wasswitch  = p;
            }
        }
        if ((movevec.x * move > 0 && movecount >= EllipseHerfFrame) || (movevec.x * move < 0 && movecount <= 0))
        {
            if (movevec.x * move > 0)
            {
                movecount = EllipseHerfFrame - 1;
            }
            else if (movevec.x * move < 0)
            {
                movecount = 0;
            }

            movevec.x *= -1;
        }
    }
Esempio n. 2
0
    /// <summary>
    /// UI上のオブジェクトの処理
    /// </summary>
    private void Wisp_task()
    {
        //動かさない場合、wispがない場合は処理をはじく
        if (!m_data.IsMoveWisp || !m_wisp)
        {
            return;
        }

        //一周のうち何秒地点にいるか
        float a = m_data.Tok_time() % (m_data.Herftime * 2);
        //現在いる地点が半周を超えている場合半周での値に変換する
        float b = a;

        if (a > m_data.Herftime)
        {
            b = m_data.Herftime + (m_data.Herftime - a);
        }
        //x軸上で現在どこにいるかを求める
        float x = m_data.UIscalex / m_data.Herftime * b;
        //UIを細かく分けた際に現在どの地点にいるかを求める
        int c = Mathf.Clamp(Mathf.FloorToInt(x / (m_data.UIscalex / ((int)m_data.tempo * 2))), 0, (int)m_data.tempo * 2 - 1);

        //交点を通過した際に回転方向を変える
        if (m_data.Movewisp)
        {
            if (c > 0 && c < (int)m_data.tempo * 2 - 1 && m_data.ellipsemodes[c] == Mobius_data.EllipseMode.Cross)
            {
                if (a <= m_data.Herftime)
                {
                    if (b >= m_data.Herftime / (int)m_data.tempo * ((c + 1) / 2) && Mathf.Abs(m_data.Tok_time() - changepoint) >= m_data.Herftime / (int)m_data.tempo)
                    {
                        Instantiate(CrossAudio);
                        GameObject go = Instantiate(CrossEffect);
                        go.transform.position = new Vector3(-m_data.UIscalex / 2 - m_data.Position.x + m_data.Pixcellforunitysize_x * 2 * ((c + 1) / 2), m_data.Position.y, 0);
                        Destroy(go.gameObject, 0.3f);

                        changepoint = m_data.Tok_time();
                        switch ((c + 1) / 2)
                        {
                        case 1:
                            m_data.MoveCount(player.Move(1), 1);
                            break;

                        case 2:
                            m_data.MoveCount(player.Jump(1), 2);
                            break;

                        case 3:
                            if (--turnvec < 0)
                            {
                                turnvec = 3;
                            }
                            m_uibutton[0].transform.localRotation = Quaternion.Euler(0, 0, 90 * turnvec);
                            player.Turn(turnvec);
                            m_data.MoveCount(1, 3);
                            break;
                        }
                        wispmovevec *= -1;
                    }
                }
                else
                {
                    if (b <= m_data.Herftime / (int)m_data.tempo * ((c + 1) / 2) && Mathf.Abs(m_data.Tok_time() - changepoint) >= m_data.Herftime / (int)m_data.tempo)
                    {
                        Instantiate(CrossAudio);
                        GameObject go = Instantiate(CrossEffect);
                        go.transform.position = new Vector3(-m_data.UIscalex / 2 - m_data.Position.x + m_data.Pixcellforunitysize_x * 2 * ((c + 1) / 2), m_data.Position.y, 0);
                        Destroy(go.gameObject, 0.3f);

                        changepoint = m_data.Tok_time();
                        switch ((c + 1) / 2)
                        {
                        case 1:
                            m_data.MoveCount(player.Move(1), 1);
                            break;

                        case 2:
                            m_data.MoveCount(player.Jump(1), 2);
                            break;

                        case 3:
                            if (--turnvec < 0)
                            {
                                turnvec = 3;
                            }
                            m_uibutton[0].transform.localRotation = Quaternion.Euler(0, 0, 90 * turnvec);
                            player.Turn(turnvec);
                            m_data.MoveCount(1, 3);
                            break;
                        }
                        wispmovevec *= -1;
                    }
                }
            }
        }
        else
        {
            //巻き戻し時のすり抜け防止措置として、戻った時間分の操作の処理をする
            while (m_data.Tok_action() >= m_data.Tok_time())
            {
                if (m_data.Tok_playermove() == 1)
                {
                    switch (m_data.Tok_playeraction())
                    {
                    case 1:
                        player.Move(-1);
                        break;

                    case 2:
                        player.Jump(-1);
                        break;

                    case 3:
                        if (++turnvec > 3)
                        {
                            turnvec = 0;
                        }
                        m_uibutton[0].transform.localRotation = Quaternion.Euler(0, 0, 90 * turnvec);
                        player.Turn(turnvec);
                        break;
                    }
                }
                wispmovevec *= -1;
                m_data.Delete_ActionRecord();
            }
        }

        //UI上のオブジェクトが上弦にいるか下弦にいるか求める
        int n;

        if (wispmovevec == 1)
        {
            n = 1;
        }
        else
        {
            n = -1;
        }
        if (a > m_data.Herftime)
        {
            n *= -1;
        }

        //UI上のオブジェクトのレイヤー順を求める
        if (c > 0 && c < (int)m_data.tempo * 2 - 1)
        {
            if (c % 2 == 1)
            {
                m_wispspr.sortingOrder = n == 1 ? 5 : 2;
            }
            else
            {
                m_wispspr.sortingOrder = n == 1 ? 2 : 5;
            }
        }

        //現在いる地点の状態によってUI上のオブジェクトの位置を移動させる
        switch (m_data.ellipsemodes[c])
        {
        case Mobius_data.EllipseMode.Normal:
            m_wisp.transform.position = new Vector3(-m_data.UIscalex / 2 + x, m_data.Position.y + 0.8f * n, 0);
            break;

        case Mobius_data.EllipseMode.Cross:
            float y = Mathf.Clamp(Mathf.Sqrt((1 - Mathf.Pow(-m_data.Pixcellforunitysize_x + (m_data.Pixcellforunitysize_x * 2 / (m_data.Herftime / (int)m_data.tempo)) * (b - m_data.Herftime / (int)m_data.tempo * (c / 2)), 2) / Mathf.Pow(m_data.Pixcellforunitysize_x, 2)) * Mathf.Pow(m_data.Pixcellforunitysize_y, 2)), 0, m_data.Pixcellforunitysize_y);
            m_wisp.transform.position = new Vector3(-m_data.UIscalex / 2 + x, m_data.Position.y + y * n, 0);
            break;
        }
    }