Page 375 - MDP2022-3
P. 375
Vector2 dirVec = new Vector2(Mathf.Cos(Mathf.PI*10 *
currentPatternCount/maxPatternCount[patternIndex]), -1);
rigid.AddForce(dirVec.normalized * 5, ForceMode2D.Impulse);
GameObject bullet2 = objectManager.MakeObj("bulletEnemyA");
bullet2.transform.position = transform.position;
bullet2.transform.rotation = Quaternion.identity;
Rigidbody2D rigid2 = bullet2.GetComponent<Rigidbody2D>();
Vector2 dirVec2 = new Vector2(Mathf.Sin(Mathf.PI * 10 * currentPatternCount /
maxPatternCount[patternIndex]), -1);
rigid2.AddForce(dirVec2.normalized * 5, ForceMode2D.Impulse);
currentPatternCount++;
if (currentPatternCount < maxPatternCount[patternIndex])
{
Invoke("fire3rd", 0.15f);
}
else
{
Invoke("think", 3);
}
}
void fire4th()
{
int roundNumA = 50;
int roundNumB = 45;
int roundNum = currentPatternCount % 2 == 0 ? roundNumA : roundNumB;
for (int i = 0; i < roundNum; i++)
{
GameObject bullet = objectManager.MakeObj("bulletEnemyC");
bullet.transform.position = transform.position;
bullet.transform.rotation = Quaternion.identity;
Rigidbody2D rigid = bullet.GetComponent<Rigidbody2D>();
Vector2 dirVec = new Vector2(Mathf.Cos(Mathf.PI * 2 * i / roundNum),