コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        //時間を進め、rimitTimeに達していなければ移動し、達した場合は消える
        nowTime += Time.deltaTime;

        if (nowTime > rimitTime)
        {
            Destroy(wepon);
            b.CoolOn();
        }

        //初回以降速度を変更させない
        if (first)
        {
            //プレイヤーの座標に応じて方向を変えて武器が飛んで行く
            if (m.transform.position.x - b.transform.position.x < 0)
            {
                wepon.GetComponent <Rigidbody>().velocity = new Vector3(-weponSpeed, wepon.transform.position.y, wepon.transform.position.z);
            }
            else
            {
                //反転させる
                wepon.transform.localScale = new Vector3(wepon.transform.localScale.x * -1, wepon.transform.localScale.y, wepon.transform.localScale.z - 1);
                wepon.GetComponent <Rigidbody>().velocity = new Vector3(weponSpeed, wepon.transform.position.y, wepon.transform.position.z);
            }
            first = false;
        }
    }
コード例 #2
0
ファイル: BossA_Attack_ef.cs プロジェクト: Pmang/TRGR
    // Update is called once per frame
    void Update()
    {
        maxTime -= Time.deltaTime;

        //3秒経過時に自身を破壊
        if (maxTime < 0)
        {
            this.transform.parent = null;
            Destroy(this.transform.root.gameObject);
            boss.CoolOn();
        }

        //自分の位置を更新
        nowPosithion = boss.transform.position;

        //移動先に応じて画像の向きを変える
        if (boss.transform.localScale.x < 0)
        {
            //画像が反転しているかどうか
            if (transform.localScale.x > 0)
            {
                //そのまま
            }
            else
            {
                //反転する
                transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z - 1);
            }
        }
        else
        {
            //画像が反転しているかどうか
            if (transform.localScale.x < 0)
            {
                //反転する
                transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z - 1);
            }
            else
            {
                //そのまま
            }
        }


        //描画する位置を調整する(つまり移動する)
        Vector3 p = boss.transform.position;

        p = boss.transform.position = new Vector3(p.x + moveSpeed.x, p.y, p.z + moveSpeed.z);

        //エフェクトが消えるまでは他の攻撃はさせない
        boss.isAttack_now = true;

        //移動先に応じてエフェクトの判定を変える
        if (directhion.x < 0)
        {
            //プレイヤーの座標を超えたら停止
            if (nowPosithion.x < boss.endPosithion.x)
            {
                this.transform.parent = null;
                Destroy(this.transform.root.gameObject);
                boss.CoolOn();
            }
            else
            {
                //何もしない
            }
        }

        else
        {
            //プレイヤーの座標を超えたら停止
            if (nowPosithion.x > boss.endPosithion.x)
            {
                this.transform.parent = null;
                Destroy(this.transform.root.gameObject);
                boss.CoolOn();
            }
            else
            {
                //何もしない
            }
        }
    }