Page 374 - MDP2022-3
P. 374

if  (currentPatternCount  <  maxPatternCount[patternIndex])
                            {
                                    Invoke("fire1st",  2);
                            }

                            else
                            {
                                    Invoke("think",  3);
                            }



                    }
                    void  fire2nd()
                    {
                            for(int  i  =  0;  i  <  5;  i++)
                            {
                                    GameObject  bullet  =  objectManager.MakeObj("bulletEnemyB");

                                    bullet.transform.position  =  transform.position;
                                    Rigidbody2D  rigid  =  bullet.GetComponent<Rigidbody2D>();
                                    Vector2  dirVec  =  Player.transform.position  -  transform.position;
                                    Vector2   ranVec   =   new     Vector2(Random.Range(-2.5f,          2.5f),

            Random.Range(0.5f,  2));
                                    dirVec  +=  ranVec;
                                    rigid.AddForce(dirVec.normalized  *  5,  ForceMode2D.Impulse);
                            }
                            currentPatternCount++;



                            if  (currentPatternCount  <  maxPatternCount[patternIndex])
                            {
                                    Invoke("fire2nd",  3.5f);
                            }

                            else
                            {
                                    Invoke("think",  3);
                            }
                    }
                    void  fire3rd()

                    {
                            GameObject  bullet  =  objectManager.MakeObj("bulletEnemyA");
                            bullet.transform.position  =  transform.position;
                            bullet.transform.rotation  =  Quaternion.identity;



                            Rigidbody2D  rigid  =  bullet.GetComponent<Rigidbody2D>();
   369   370   371   372   373   374   375   376   377   378   379