//Depending on the order of the starts of the scripts, certains events are declared after the eventListeners and dont get triggered at the start //So this function is called in the first Update, when all the starts are been called public override void HandleStart() { //gameObject.transform.position = new Vector3(-6, 0, 0); mDurationTime = 5f; nameState = "'Normal' Mode"; mStateID = 0; mBulletType = BulletSpawner.eBulletType.Normal; BasicStart(); }
// Update is called once per frame void OnCollisionEnter2D(Collision2D aCollision) { Vector3 Normal = GetObstacleNormal(aCollision); if (Normal != Vector3.zero) { Assert.AreNotEqual(Spawner, null); BulletSpawner.eBulletType newBulletType = BulletSpawner.eBulletType.Normal; if (StaticFunctions.AreAlmostSameVector(-transform.right, Normal, mSameVectorAngle)) { Spawner.SpawnBullet(newBulletType, mSpeedIncrement, transform.position, StaticFunctions.Rotate2DVector3(Normal, -45.0f)); Spawner.SpawnBullet(newBulletType, mSpeedIncrement, transform.position, StaticFunctions.Rotate2DVector3(Normal, 45.0f)); } else { Vector3 Reflection = StaticFunctions.GetReflectionVector(transform.right, Normal); Spawner.SpawnBullet(newBulletType, mSpeedIncrement, transform.position, Reflection); Spawner.SpawnBullet(newBulletType, mSpeedIncrement, transform.position, -transform.right); } UpdateBounces(); } }