void OnJointBreak2D(Joint2D brokenJoint) { // Debug.Log("A joint has just been broken!"); StartCoroutine(SpriteHelper.FadeOut(GetComponent <SpriteRenderer>(), 1.0f)); GetComponent <BoxCollider2D>().enabled = false; Destroy(this.gameObject, 1.0f); // StartCoroutine(SpriteHelper.FadeOut(brokenJoint.connectedBody.GetComponent<SpriteRenderer>(), 1.0f)); // brokenJoint.connectedBody.GetComponent<BoxCollider2D>().enabled = false; // Destroy(brokenJoint.connectedBody, 1.0f); }
void OnTriggerEnter2D(Collider2D collider) { if (collider.tag == "Wubs") { foreach (var star in stars.Where(x => x != null)) { StartCoroutine(SpriteHelper.FadeOut(star.GetComponentInChildren <SpriteRenderer>(), 1.0f)); } if (!collected) { Instantiate(starDust, transform.position, Quaternion.Euler(0, 0, 0), transform.parent); StarController.CollectStar(starSource); collected = true; } Destroy(this.gameObject, 3.75f); } }
// Update is called once per frame void FixedUpdate() { if (transform.position.x < -CloudController.maxX) { transform.position = new Vector3(CloudController.maxX, transform.position.y, transform.position.z); } else if (transform.position.x > CloudController.maxX) { transform.position = new Vector3(-CloudController.maxX, transform.position.y, transform.position.z); } else { transform.position = new Vector3(transform.position.x + (speed * CloudController.direction), transform.position.y, transform.position.z); } if (!clouds.Any(x => { if (x == null) { return(false); } var joint = x.GetComponent <RelativeJoint2D>(); if (joint == null) { return(false); } return(joint.connectedBody != null); })) { // Debug.Log("Cloud cluster inactive!"); foreach (var cloud in clouds.Where(x => x != null)) { StartCoroutine(SpriteHelper.FadeOut(cloud.GetComponent <SpriteRenderer>(), 1.0f)); cloud.GetComponent <BoxCollider2D>().enabled = false; } Destroy(this.gameObject, 1.0f); } }