public static EnemyWalkController Create(WalkingStyle walkingStyle, float enemyBaseSpeed, Rigidbody2D playerRb, Rigidbody2D enemyRb) { EnemyWalkController obj = null; switch (walkingStyle) { case WalkingStyle.ZigZagWideStartLeft: obj = new EnemyWalkStyleZigZagWide(-1); break; case WalkingStyle.ZigZagWideStartRight: obj = new EnemyWalkStyleZigZagWide(1); break; case WalkingStyle.JustDown: obj = new EnemyWalkStyleJustDown(); break; case WalkingStyle.ToPlayer: obj = new EnemyWalkToPlayer(); break; case WalkingStyle.SpaceInvader: obj = new EnemyWalkSpaceInvader(1); break; default: return(null); } obj.enemyBaseSpeed = enemyBaseSpeed; obj.playerRb = playerRb; obj.enemyRb = enemyRb; return(obj); }
private void Start() { player = GameObject.Find("Henchman").gameObject; enemyRb = GetComponent <Rigidbody2D>(); playerRb = player.GetComponent <Rigidbody2D>(); walkController = EnemyWalkController.Create(walkingStyle, enemyBaseSpeed, playerRb, enemyRb); walkController.BeginWalk(); spriteRenderer = GetComponent <SpriteRenderer>(); bulletController = EnemyBulletController.Create(bulletStyle, bulletSpeed, playerRb, enemyRb, bulletPrefab, minDeltaT, maxDeltaT); gameLevelManager = FindObjectOfType <LevelManager>(); }