public void Initialize(bool goingLeft, MagicColor color) { base.Initialize(color); rb.velocity = new Vector2 ( LaunchSpeed.x * (goingLeft ? -1 : 1), LaunchSpeed.y ); destroyInvisible = GetComponent <DestroyWhenChildrenInvisible>(); }
public void Start() { rb = GetComponent <Rigidbody2D>(); col = GetComponent <Collider2D>(); animator = GetComponent <Animator>(); destroyer = GetComponent <DestroyWhenChildrenInvisible>(); col.enabled = false; // so we don't freak out while we're in the walls destroyer.ShouldDestroy = false; Health.Death.AddListener(() => { col.enabled = false; destroyer.ShouldDestroy = true; animator.speed = 0; // stop animations }); var color = (MagicColor)Random.Range(0, 3); Health.Color = color; ColoredPart.ChangeColor(color); transform.position = EnemySpawner.Instance.ButterflySpawnLocations.GetNext().position; }