private void CheckMatch() { if (currentBug.bugColor == targetColor) { BugUtils.PaintBugOccur(); readyToPaint = false; LinearMove movementCtrl = currentBug.gameObject.AddComponent <LinearMove>(); movementCtrl.Init(true, 5); } }
IEnumerator SpawnBug(BugData data) { yield return(new WaitForSeconds(data.spawnTime)); if (!data.flying) { Transform spawnLocation = data.fromLeft ? leftGroundSpawn : rightGroundSpawn; GameObject bug = Instantiate(groundBugPrefab, spawnLocation.position, Quaternion.identity); Bug bugCtrl = bug.GetComponent <Bug>(); bugCtrl.Init(data); LinearMove movementCtrl = bug.GetComponent <LinearMove>(); movementCtrl.Init(data.fromLeft, data.speed); } else { Transform spawnLocation = data.fromLeft ? leftAirSpawn : rightAirSpawn; GameObject bug = Instantiate(airBugPrefab, spawnLocation.position, Quaternion.identity); Bug bugCtrl = bug.GetComponent <Bug>(); bugCtrl.Init(data); SineMove movementCtrl = bug.GetComponent <SineMove>(); movementCtrl.Init(data.fromLeft, data.speed, spawnLocation.position.y, -1, -1); } }