private void OnTriggerStay(Collider other) { if (CooldownCounter > 0) { return; } if (other.CompareTag("Debri")) { Debri debri = other.GetComponentInParent <Debri>(); if (debri.IsGrabbed || debri.Size == Size.Small) { return; } // Compactor Particle System GameObject particleGO = Instantiate(CompactorParticleSystem.gameObject, debri.transform.position, Quaternion.identity) as GameObject; Destroy(particleGO, 1f); CooldownCounter = debri.CompactorCooldown; cooldown.Show(debri.CompactorCooldown); // Show cooldown UI StartCoroutine(SpawnCoroutine(debri.Size, debri.CompactorCooldown)); Destroy(other.transform.parent.gameObject); } }
private void OnTriggerStay(Collider other) { if (CooldownCounter > 0) { return; } IGrabable grabable = other.GetComponentInParent <IGrabable>(); if (grabable != null) { Debri debri = other.GetComponentInParent <Debri>(); if (debri.IsGrabbed) { return; } GameObject particleGO = Instantiate(IncineratorDestruction, debri.transform.position, Quaternion.identity) as GameObject; Destroy(particleGO, 1f); CooldownCounter = debri.IncineratorCooldown; cooldown.Show(debri.IncineratorCooldown); // Show cooldown UI GameManager.Instance.AddScore(debri.Score); GameManager.Instance.DecrementMessValue(grabable.GetMassValue()); // TODO play with random pitch - and maybe with a particle animation SoundEffects.Instance.Play(SfxDestroy, true); Destroy(debri.gameObject); } }
private void drawDebri(Debri d) { var mesh = meshPool.Count > 0 ? meshPool.Pop() : new Mesh(); mesh.Clear(); mesh.vertices = new[] { new Vector3(-5 / pixelsPerUnit, -4.33f / pixelsPerUnit, 0), new Vector3(5 / pixelsPerUnit, -4.33f / pixelsPerUnit, 0), new Vector3(0, 4.33f / pixelsPerUnit, 0) }; mesh.triangles = new[] {0, 1, 2}; mesh.colors = new[] {Color.white, Color.white, Color.white}; var rotation = Quaternion.Euler(0, 0, d.deg); Graphics.DrawMesh(mesh, new Vector3(d.x / pixelsPerUnit, d.y / pixelsPerUnit, 0), rotation, material, 0); }
/// <summary> /// Spawns all objects that should exist when the game starts. /// </summary> public static void SpawnWorld(Team teamA, Team teamB) { const int debriCount = 160; Random random = new Random(); // BLACK HOLE OF DOOM Blackhole blackhole = new Blackhole(new Vector2(6000, 6000)); // Spawn motherships Mothership mothershipA = new Mothership(6000, 1600, teamA); Mothership mothershipB = new Mothership(6000, 10400, teamB); // Fill the void with debri for (int i = 0; i < debriCount; i++) { float dir = (float)(random.NextDouble() * Math.PI * 2); float len = random.Next(2000, 5000); float xpos = 6000 + len * (float)Math.Cos(dir); float ypos = 6000 + len * (float)Math.Sin(dir); Debri debri = new Debri(new Vector2(xpos, ypos)); } }