void OnCollisionStay(Collision collision) { var p = collision.transform.position; WorldGen.inst.DigRocket(Mathf.FloorToInt(p.x), Mathf.FloorToInt(p.y)); CameraFX.inst.Shake(); CameraFX.inst.Flash(RGBA(Color.white, 0.5f)); PooledObject inst = explosionPrefab.Alloc(xform.position) as PooledObject; inst.transform.localScale = new Vector3(1.5f, 1.5f, 1); Release(); }
protected override void WillDestroy() { if (explosionPrefab != null) { var e = explosionPrefab.Alloc(transform.position); e.transform.localScale = Vec(1.25f, 1.25f, 1.25f); } if (wNext) { wNext.WaitAndDestroy(); } if (wPrev) { wPrev.WaitAndDestroy(); } }
// Update is called once per frame void Update() { timeout += Time.deltaTime; flickerTime -= Time.deltaTime; if (flickerTime < 0) { Color c = GetComponent <SpriteRenderer> ().color; if (c.a == 1.0f) { c.a = 0.0f; } else { c.a = 1.0f; } GetComponent <SpriteRenderer> ().color = c; if (timeout < explodeTime - 1.0f) { if (c.a == 1.0f) { flickerTime = 0.1f; } else { flickerTime = 0.5f; } } else { flickerTime = 0.05f; } } if (timeout > explodeTime) { WorldGen.inst.DigGrenade((int)xform.position.x, (int)xform.position.y); CameraFX.inst.Shake(); CameraFX.inst.Flash(RGBA(Color.white, 0.5f)); PooledObject inst = explosionPrefab.Alloc(xform.position) as PooledObject; inst.transform.localScale = new Vector3(3.0f, 3.0f, 1); Release(); } }
IEnumerator DeathSequence() { System.Random rand = new System.Random(); float radius = GetComponent <SphereCollider> ().radius * 0.75f; for (int i = 0; i < 30; i++) { float size = 2; if (i > 15) { yield return(new WaitForSeconds(0.1f)); size = 5; } else if (i > 5) { yield return(new WaitForSeconds(0.2f)); size = 3; } else { yield return(new WaitForSeconds(0.3f)); size = 2; } Vector3 p = xform.position; float xMod = (float)rand.NextDouble() * (radius * 2) - radius; float yMod = (float)rand.NextDouble() * (radius * 2) - radius; CameraFX.inst.Shake(size); PooledObject inst = explosionPrefab.Alloc(p + new Vector3(xMod, yMod, 0)) as PooledObject; inst.transform.localScale = new Vector3(size, size, 1); GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); xform.position += new Vector3(((float)rand.NextDouble() - 0.5f) * 0.5f, ((float)rand.NextDouble() - 0.5f) * 0.5f, 0); } yield return(new WaitForSeconds(0.5f)); Application.LoadLevel("outro"); }
// Update is called once per frame void Update() { if (tripped) { timeout += Time.deltaTime; if (timeout + Time.deltaTime > explodeTime - 0.1f && timeout < explodeTime - 0.1f) { Jukebox.Play("beep1"); } flickerTime -= Time.deltaTime; if (flickerTime < 0) { Color c = GetComponent <SpriteRenderer> ().color; if (c.a == 1.0f) { c.a = 0.0f; } else { c.a = 1.0f; if (timeout < explodeTime - 0.1f) { Jukebox.Play("beep0"); } } GetComponent <SpriteRenderer> ().color = c; if (timeout < explodeTime - 1.0f) { if (c.a == 1.0f) { flickerTime = 0.1f; } else { flickerTime = 0.5f; } } else { flickerTime = 0.05f; } } if (timeout > explodeTime) { CameraFX.inst.Shake(); CameraFX.inst.Flash(RGBA(Color.white, 0.5f)); float dist = 1.0f; Vector3 [] offsets = new Vector3[7]; offsets[0] = new Vector3(dist * 1, 0, 0); offsets[1] = new Vector3(-dist * 1, 0, 0); offsets[2] = new Vector3(0, dist * 1, 0); offsets[3] = new Vector3(dist * 2, 0, 0); offsets[4] = new Vector3(-dist * 2, 0, 0); offsets[5] = new Vector3(0, dist * 2, 0); offsets[6] = new Vector3(0, 0, 0); for (int i = 0; i < offsets.Length; i++) { Vector3 blastPos = xform.position + offsets[i]; PooledObject inst = explosionPrefab.Alloc(xform.position + offsets[i]) as PooledObject; float size = 0.45f; inst.transform.localScale = new Vector3(size, size, size); WorldGen.inst.Dig((int)(blastPos.x + 0.5f), (int)(blastPos.y), 3); } Release(); } } }