Exemple #1
0
 // Update is called once per frame
 void Update()//コサインの値を変更させて移動
 {
     if (transform.tag == "enemy")
     {
         time += Time.deltaTime;
         if (time >= 2.0f)//2秒間隔
         {
             if (posflg == false)
             {
                 //※必須
                 mother    = obj.GetComponent <oBase>();
                 direction = mother.Playerposition(transform.position);
                 //※必須
                 posflg = true;
             }
             cos += 0.1f;                                                         //コサインの値を増やす
             transform.Translate(movement * direction, Mathf.Cos(cos) * 0.5f, 0); //山なりに移動
             if (transform.position.y <= 0)                                       //自身のY座標が0未満になったとき
             {
                 posflg = false;
                 cos    = 0;//コサインの値を0にする
                 time   = 0;
             }
         }
     }
 }
Exemple #2
0
 IEnumerator Enemymove3()
 {
     if (posflg == false)
     {
         //※必須
         mother    = obj.GetComponent <oBase>();
         direction = mother.Playerposition(transform.position);
         //※必須
         posflg = true;
     }
     for (int i = 0; i <= 10; i++)
     {
         transform.Translate(movement * direction * mother.enemySpeed, 0, 0);
         if (i == 10)
         {
             bulletInstance = Instantiate(bullet) as GameObject;
             bulletInstance.transform.position = new Vector3(transform.position.x + direction, transform.position.y, 0); //弾を配置
             posflg = false;
             time   = 0;
             StopCoroutine("Enemymove3");
             yield break;
         }
         yield return(new WaitForSeconds(0.2f));
         //yield return null;
     }
 }
Exemple #3
0
 // Update is called once per frame
 void Update()//コサインの値を変更させて移動
 {
     pos = transform.position;
     if (transform.tag == "enemy")
     {
         time += Time.deltaTime * mother.enemySpeed;
         if (time >= 2.0f)//2秒間隔
         {
             if (posflg == false)
             {
                 //※必須
                 mother    = obj.GetComponent <oBase>();
                 direction = mother.Playerposition(transform.position);
                 //※必須
                 posflg = true;
             }
             if (cosFlg == true)
             {
                 transform.Translate(0.13f * direction * mother.enemySpeed, -0.33f * mother.enemySpeed, 0);
             }
             else
             {
                 cos += 0.1f * mother.enemySpeed;                                                                             //コサインの値を増やす
                 transform.Translate(movement * direction * mother.enemySpeed, Mathf.Cos(cos) * 0.5f * mother.enemySpeed, 0); //山なりに移動
             }
             if (pos.y > transform.position.y)
             {
                 cosFlg = true;
             }
         }
     }
 }
 // Use this for initialization
 void Start()
 {
     player = GameObject.Find("Player");                         //使うときはPlayerに変える
     BulletAngle(transform.position, player.transform.position); //角度を計算するメソッドに値を入れる
     transform.rotation = Quaternion.Euler(0, 0, angle);         //角度を変える
     parabola(transform.position, player.transform.position);    //
     obj       = GameObject.Find("Reference");
     mother    = obj.GetComponent <oBase>();
     direction = mother.Playerposition(transform.position);
 }
Exemple #5
0
 void att1()//攻撃1
 {
     if (posFlg == false)
     {
         pos       = transform.position;
         direction = mother.Playerposition(pos);
         posFlg    = true;
     }
     if (jumpFlg == false)
     {
         sin += 0.3f;
         transform.Translate(0, Mathf.Sin(sin), 0);
         fallflg = true;
     }
     if (att1Flg == false)
     {
         GameObject bulletInstance = Instantiate(bullet) as GameObject;
         bulletInstance.transform.position = new Vector3(pos.x + 3 * direction, pos.y - 2, pos.z);
         att1Flg = true;
     }
 }
Exemple #6
0
 void oEnemymove9_att2()      //早く回転してから移動
 {
     rotationSpeed = 5;       //回転スピードを変更させる
     time         += Time.deltaTime * mother.enemySpeed;
     if (time >= att2time)    //5秒たったら
     {
         if (posFlg == false) //Playerのポジションをとっていないなら
         {
             //※必須
             direction = mother.Playerposition(transform.position);//Playerの位置を判断
             posFlg    = true;
         }
         enemy9Move.oEnemymove92(direction);//移動
     }
 }
Exemple #7
0
    // Update is called once per frame
    void Update()
    {
        if (transform.tag == "enemy")
        {
            time += Time.deltaTime;
            if (time > 2)//2秒後
            {
                if (posflg == false)
                {
                    //※必須
                    mother    = obj.GetComponent <oBase>();
                    direction = mother.Playerposition(transform.position);
                    posflg    = true;
                    //※必須
                }

                if (f <= 40 && flg == false) //回転の大きさが40以下かつ、フラグがfalseなら
                {
                    f += 0.1f;               //回転の大きさを増やす
                }
                else//回転の大きさが40を超えたら
                {
                    flg = true;                                                                                                                             //減らすためにフラグをtrueにする
                }
                if (flg == true)                                                                                                                            //フラグがtrueなら
                {
                    if (f >= 0)                                                                                                                             //回転の大きさが0以上なら
                    {
                        f -= 0.1f;                                                                                                                          //減らしていく
                        enemyMoveDistance += x;                                                                                                             //移動する値を増やしていく
                        transform.position = new Vector3(transform.position.x + enemyMoveDistance * direction, transform.position.y, transform.position.z); //移動
                    }
                    else
                    {
                        enemyMoveDistance -= x;     //移動する値を減らしていく
                        if (enemyMoveDistance <= 1) //移動距離が0以下になったら
                        {
                            time   = 0;             //時間のカウントを0にする
                            flg    = false;         //フラグをfalseにする
                            posflg = false;         //※必須
                        }
                    }
                }
            }
        }
    }
Exemple #8
0
    // Update is called once per frame
    void Update()
    {
        if (transform.tag == "enemy")
        {
            time2 += Time.deltaTime;
            time  += Time.deltaTime;
            if (time2 > 0.3f)
            {
                Enemymove8();
            }
            if (posflg == false)
            {
                //※必須
                mother    = obj.GetComponent <oBase>();
                direction = mother.Playerposition(transform.position);
                //※必須
                posflg = true;
                posflg = false;//※必須
            }
            if (time >= 0.1f)
            {
                Renderer rend = GetComponent <SpriteRenderer>();
                rend.material.color = color;
                if (alpha >= 0.05f)
                {
                    alpha  -= 0.06f;
                    color.a = alpha;
                }
                else
                {
                    if (direction == 1)
                    {
                        transform.position = new Vector3(player.transform.position.x + 5, player.transform.position.y, player.transform.position.z);
                    }
                    else
                    {
                        transform.position = new Vector3(player.transform.position.x - 5, player.transform.position.y, player.transform.position.z);
                    }
                    time2 = 0.0f;
                    alpha = 1.0f;
                }

                time = 0;
            }
        }
    }
Exemple #9
0
 public void oEnemymove4_pattern3(int enemy) //弾発射
 {
     if (enemy == 2)                         //単発
     {
         direction      = mother.Playerposition(transform.position);
         bulletInstance = Instantiate(bullet) as GameObject;
         if (direction == -1)
         {
             bulletInstance.transform.rotation = Quaternion.Euler(0, 0, 180);
         }
         bulletInstance.transform.position = new Vector3(transform.position.x, transform.position.y, 0);//弾を配置
         enemyAttack = 1;
         lifeCount++;
     }
     else if (enemy == 3)//3連射
     {
         time += Time.deltaTime;
         if (time >= 0.5f)
         {
             time           = 0;
             bulletInstance = Instantiate(bullet) as GameObject;
             if (direction == -1)
             {
                 bulletInstance.transform.rotation = Quaternion.Euler(0, 0, 180);
             }
             bulletInstance.transform.position = new Vector3(transform.position.x, transform.position.y, 0);//弾を配置
             count++;
         }
         if (count == 3)//3発撃ったら
         {
             count       = 0;
             enemyAttack = 1;
             lifeCount++;
         }
     }
 }