Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //isEndがtrueで操作不可
        if (gametime.isEnd == true)
        {
            GetComponent <BoxCollider2D>().enabled = false;//BoxColider2dを無効にする
            //操作の停止
            return;
        }

        float x = CrossPlatformInputManager.GetAxisRaw("Horizontal"); //右左仮想コン

        float y = CrossPlatformInputManager.GetAxisRaw("Vertical");   // 上下仮想コン

        //Vector2 direction = new Vector2(x,y).normalized; //方向を正規化(標準)された
        Vector2 direction = new Vector2(x, y);

        ships.Move(direction);

        Clamp();//移動制限
    }
Ejemplo n.º 2
0
    IEnumerator Start()
    {
        gametime = GameObject.Find("GameTime").GetComponent <GameTime>();//gameTimeコンポーネント

        nScore = GameObject.Find("Score").GetComponent <Score>();

        // Spaceshipコンポーネントを取得
        ships = GetComponent <Ships>();

        // ローカル座標のY軸のマイナス方向に移動する
        ships.Move(transform.up * -1);

        // canShotがfalseの場合、ここでコルーチンを終了させる
        if (ships.canShot == false)
        {
            yield break;
        }

        while (true)//無限ループ
        {
            if (gametime.isEnd == true)
            {
                yield break;//ループから抜け出して生成を止める
            }

            // 子要素を全て取得する
            for (int i = 0; i < transform.childCount; i++)
            {
                Transform shotPosition = transform.GetChild(i);

                // ShotPositionの位置/角度で弾を撃つ
                ships.Shot(shotPosition);
                Debug.Log("e_shots");
            }


            // shotDelay秒待つ
            yield return(new WaitForSeconds(ships.shotDelay));
        }
    }