Example #1
0
    // Play状態の更新関数
    void UpdatePlay()
    {
        // RightArrowで宇宙船を右回転させる
        if (Input.GetKey(KeyCode.RightArrow))
        {
            mySpaceShip.Rotation(-ROTATION_SPEED);
            fire.SetRotationAngle(mySpaceShip.GetRotation());
        }

        // LeftArrowで宇宙船を左回転させる
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            mySpaceShip.Rotation(ROTATION_SPEED);
            fire.SetRotationAngle(mySpaceShip.GetRotation());
        }

        // Spaceで噴射
        if (Input.GetKey(KeyCode.Space) && mySpaceShip.GetFuelRemaining() > 0)
        {
            mySpaceShip.Jet();

            // 炎の傾きをセットする
            fire.SetRotationAngle(mySpaceShip.GetRotation());
            // 炎の位置を宇宙船の下に設定する
            fire.SetFireUnderSpaceShip(mySpaceShip.GetGameObject(), mySpaceShip.GetPosition());

            // 残りの燃料に合わせたカーソルの移動をする
            MoveCursor();

            m_start = true;
        }
        else
        {
            // 慣性の法則に従った動きをさせる
            mySpaceShip.MoveByInertia();
            mySpaceShip.SetChangeVertical();

            fire.BackSetPosition(mySpaceShip.GetPosition());
        }

        if (m_start)
        {
            m_courseTime += Time.deltaTime;
            float verticalSpeed = mySpaceShip.GetVerticalSpeed() + 0.0001f;
            mySpaceShip.SetVerticalSpeed(verticalSpeed);
        }

        // ステータスのテキスト更新
        angleText.text           = "機体の傾き:" + mySpaceShip.GetRotation() % 360;
        landingVelocityText.text = "落下速度:" + mySpaceShip.GetVerticalSpeed() * CORRECTIONTOLOOKVEROCITY;
        if ((mySpaceShip.GetGameObject().transform.up.x != 8.742278E-08 ||
             mySpaceShip.GetGameObject().transform.up.x != -8.742278E-08) &&
            mySpaceShip.GetHorizontalSpeed() != 0)
        {
            horizontalSpeedText.text = "水平速度:" + (mySpaceShip.GetHorizontalSpeed() * CORRECTIONTOLOOKVEROCITY);
        }
        else
        {
            horizontalSpeedText.text = "水平速度:" + 0;
        }
        // 時間 (単位:秒)小数第2位まで表示
        courseTimeText.text = m_courseTime.ToString("f2");
        stageNumText.text   = "ステージ:" + m_stageNum;
        scoreNumText.text   = "スコア:" + m_score;

        // チェックポイントを過ぎた場合 着陸条件を1つでも満たせていなければ"!"を頭上に出す
        if (!checkPoint)
        {
            m_exclamation.transform.position = new Vector2(100, 100);
        }
        else if (mySpaceShip.Landing())
        {
            m_exclamation.transform.position = new Vector2(100, 100);
        }
        else
        {
            Vector2 exclamationPosition = mySpaceShip.GetPosition();
            m_exclamation.transform.position = new Vector2(exclamationPosition.x, exclamationPosition.y + 0.5f);
        }
    }
Example #2
0
    // play状態の開始関数
    void StartPlay(eStatus PrevStatus)
    {
        // 代わった時に1回しかやらないことをする
        checkPoint = false;

        // 宇宙船の初期位置設定
        mySpaceShip = new SpaceShip();
        StageManager.GetInstance();

        // 燃料ゲージの初期設定
        m_gauge = GameObject.Find("gauge");
        m_gauge.transform.position = new Vector3(2.7f, -2.687f);
        m_gaugeOver = GameObject.Find("gauge_over");
        m_gaugeOver.transform.position = new Vector3(3.443f, -2.634f);
        m_cursorStick = GameObject.Find("cursorStick");
        m_cursorPos   = CURSORSTICK_INITIALPOS;
        m_cursorStick.transform.position = m_cursorPos;
        m_cursor = GameObject.Find("cursor");
        m_cursor.transform.position = new Vector2(m_cursorPos.x, m_cursorPos.y + CURSOR_Y_DIFFERENCE);

        // テキスト
        angleText                = GameObject.Find("Canvas/TextAngle").GetComponent <GUIText> ();
        angleText.text           = "機体の傾き:" + mySpaceShip.GetRotation();
        landingVelocityText      = GameObject.Find("Canvas/TextLandingVelocity").GetComponent <GUIText> ();
        landingVelocityText.text = "落下速度:" + (mySpaceShip.GetVerticalSpeed() * CORRECTIONTOLOOKVEROCITY);
        horizontalSpeedText      = GameObject.Find("Canvas/TextHorizontalSpeed").GetComponent <GUIText> ();
        if ((mySpaceShip.GetGameObject().transform.up.x != 8.742278E-08 ||
             mySpaceShip.GetGameObject().transform.up.x != -8.742278E-08) &&
            mySpaceShip.GetHorizontalSpeed() != 0)
        {
            horizontalSpeedText.text = "水平速度:" + (mySpaceShip.GetHorizontalSpeed() * CORRECTIONTOLOOKVEROCITY);
        }
        else
        {
            horizontalSpeedText.text = "水平速度:" + 0;
        }
        // 時間 (単位:秒)小数第2位まで表示
        courseTimeText      = GameObject.Find("Canvas/TextCourseTime").GetComponent <GUIText> ();
        courseTimeText.text = m_courseTime.ToString("f2");

        stageNumText      = GameObject.Find("Canvas/TextStageNum").GetComponent <GUIText> ();
        stageNumText.text = "ステージ:" + m_stageNum;
        scoreNumText      = GameObject.Find("Canvas/TextScore").GetComponent <GUIText> ();
        scoreNumText.text = "スコア:" + m_score;
        rankingText       = GameObject.Find("Canvas/TextRanking").GetComponent <GUIText> ();
        rankingText.text  = "";
        myScoreText       = GameObject.Find("Canvas/TextMyScore").GetComponent <GUIText> ();
        myScoreText.text  = "";

        m_fuel1 = GameObject.Find("Fuel/Fuel1");

        fire = new Fire();
        fire.BackSetPosition(mySpaceShip.GetPosition());

        explode = GameObject.Find("explode");

        m_start        = false;
        m_courseTime   = 0;
        m_stageNum     = 1;
        m_score        = 0;
        m_setFuelCount = 0;
        StageManager.GetInstance().Transit(StageManager.eStage.eStage1);
    }