public void Explode(Bubble bubble) { var x = bubble.X; var y = bubble.Y; var power = bubble.Power; merged.Add(bubble); for (int bubbleSide = 0; bubbleSide < SIDES_COUNT; bubbleSide++) { var link = bubble.GetLinked((BubbleSide)bubbleSide); if (!link) { continue; } if (!merged.Contains(link)) { merged.Add(link); } } CheckMergedFall(); for (int i = merged.Count - 1; i >= 0; i--) { ReleaseBubble(merged[i]); } OnExplosion?.Invoke(new ExplosionInfo() { x = x, y = y, power = power }); }
/// <summary> /// main function, call this to start explosion /// </summary> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback /// </param> public void Explode(OnExplosion callback) { if (DisableQueue && queue.IsProcessing()) { return; } queue.Explode(callback); }
/// <summary> /// explode cracked objects /// Use this method in combination with Crack() /// Purpose of this method is to get higher performance of explosion, Crack() will /// calculate the explosion and prepare all fragments. Calling ExplodeCracked() will /// then start the explosion (flying fragments...) immediately /// </summary> public void ExplodeCracked(OnExplosion callback) { ExploderUtils.Assert(crack, "You must call Crack() first!"); if (cracked) { PostCrackExplode(callback); crack = false; } }
protected void Die(bool pWithExplosion) { if (pWithExplosion) { OnExplosion?.Invoke(this, new ExplosionEventArgs(Position, Radius, Force)); } Remove = true; _textBox.Remove = true; OnExplosion -= Sender.Parent.Parent.CreateExplosion; _timer.Elapsed -= OnTimerExplosionElapsed; }
private void Hero_OnMove(IHero sender, MovingArgs args) { var coloredSender = sender as ColoredConsoleHero; if ((sender.PosX == this.PosX) & (sender.PosY == this.PosY)) { OnExplosion?.Invoke(this, new ExplosionEventArgs() { corpse = sender }); } }
/// <summary> /// callback from queue, do not call this unles you know what you are doing! /// </summary> public void StartExplosionFromQueue(Vector3 pos, int id, OnExplosion callback) { ExploderUtils.Assert(state == State.None, "Wrong state: " + state); mainCentroid = pos; explosionID = id; state = State.Preprocess; ExplosionCallback = callback; #if DBG processingTime = 0.0f; preProcessingTime = 0.0f; postProcessingTime = 0.0f; postProcessingTimeEnd = 0.0f; isolatingIslandsTime = 0.0f; #endif }
private void OnCollision(ColliderComponent other) { var health = other.GetComponent <HealthComponent>(); if (health != null) { health.Damage(); var dir = other.Position - collider.Position; var explosion = Pool.GetObject <Explosion>(PrefabType.PlayerExplosion, transform.position + new Vector3(dir.x, dir.y, 0f) * transform.localScale.x * 0.5f); if (explosion != null) { explosion.Order = Order + 1; } var particles = Pool.GetObject <ParticleSystem>(PrefabType.ExplosionParticles, explosion.transform.position); if (particles != null) { particles.Stop(); particles.Play(); } OnExplosion?.Invoke(Order + 1); } }
/// <summary> /// search and explode objects in radius /// </summary> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback /// </param> public void ExplodeRadius(OnExplosion callback) { core.Enqueue(this, callback, false, null); }
/// <summary> /// explode cracked objects /// Use this method in combination with Crack() /// Purpose of this method is to get higher performance of explosion, Crack() will /// calculate the explosion and prepare all fragments. Calling ExplodeCracked() will /// then start the explosion (flying fragments...) immediately /// </summary> public void ExplodeCracked(OnExplosion callback) { ExploderUtils.Assert(crack, "You must call Crack() first!"); if (cracked) { PostCrackExplode(callback); crack = false; } }
/// <summary> /// explode single object with callback /// </summary> /// <param name="obj">game object to be exploded</param> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback</param> public void ExplodeObject(GameObject obj, OnExplosion callback) { queue.Enqueue(callback, obj); }
/// <summary> /// search and explode objects in radius /// </summary> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback /// </param> public void ExplodeRadius(OnExplosion callback) { queue.Enqueue(callback, null); }
public void ExplodeObjects(OnExplosion callback, params GameObject[] objects) { core.Enqueue(this, callback, false, objects); }
public void Explosion() { OnExplosion?.Invoke(); }
public void AddExplosionHandler(OnExplosion handler) { onExploding += handler; }
/// <summary> /// Créé une explosion à l'emplacement passé par le missille. /// </summary> /// <param name="sender"></param> /// <param name="pExplosionEventArgs"></param> public void CreateExplosion(object sender, ExplosionEventArgs pExplosionEventArgs) { OnExplosion?.Invoke(sender, pExplosionEventArgs); _sndexplosion.Play(); Color empty = new Color(); Vector2 pos = pExplosionEventArgs.ExplosionCircle.Location.ToVector2(); int rad = (int)pExplosionEventArgs.ExplosionCircle.Radius; int force = pExplosionEventArgs.Force; Texture2D particles = new Texture2D(MainGame.graphics.GraphicsDevice, rad * 2, rad * 2); Color[] particlesData = new Color[particles.Width * particles.Height]; bool beginWater = false; int beginWaterPosition = 0; for (int x = (int)(pos.X - rad); x <= (int)(pos.X + rad); x++) { if (x >= 0 && x < MapSize.X) { for (int y = (int)(pos.Y - rad); y <= (int)(pos.Y + rad); y++) { if (y >= 0 && y < MapSize.Y) { if (Math.Pow(pos.X - x, 2) + Math.Pow(pos.Y - y, 2) < Math.Pow(rad, 2)) { if (IsSolid(new Vector2(x, y))) { int x2 = (int)(x + rad - pos.X); int y2 = (int)(y + rad - pos.Y); int index = (x + y * (int)MapSize.X); particlesData[x2 + y2 * rad] = MapColors[index]; MapData[x + y * (int)MapSize.X] = 0; MapColors[x + y * (int)MapSize.X] = empty; } } } } if (pos.Y + rad >= WaterLevel) { if (!IsSolid(new Vector2(x, WaterLevel - 1))) { if (!beginWater) { beginWater = true; beginWaterPosition = x; } } else { if (beginWater) { beginWater = false; WaterPosition.Add(new Rectangle(beginWaterPosition, WaterLevel, x - beginWaterPosition, (int)MapSize.Y - WaterLevel)); } } } } } particles.SetData(particlesData); CreateMapParticles(particles, pos, force); _mapTexture.SetData(MapColors); }
public void ExplodeCracked(OnExplosion callback) { ExplodeCracked(null, callback); }
/// <summary> /// explode cracked objects /// Use this method in combination with Crack() /// Purpose of this method is to get higher performance of explosion, Crack() will /// calculate the explosion and prepare all fragments. Calling ExplodeCracked() will /// then start the explosion (flying fragments...) immediately /// </summary> public void ExplodeCracked(GameObject obj, OnExplosion callback) { core.ExplodeCracked(obj, callback); }
/// <summary> /// crack single object, use in combination with ExplodeCracked(...) /// </summary> /// <param name="obj">object to be cracked</param> /// <param name="callback"></param> public void CrackObject(GameObject obj, OnExplosion callback) { core.Enqueue(this, callback, true, obj); }
/// <summary> /// crack will calculate fragments and prepare object for explosion /// Use this method in combination with ExplodeCracked() /// Purpose of this method is to get higher performance of explosion, Crack() will /// calculate the explosion and prepare all fragments. Calling ExplodeCracked() will /// then start the explosion (flying fragments...) immediately /// </summary> public void CrackRadius(OnExplosion callback) { core.Enqueue(this, callback, true, null); }
public void ExplodePartial(GameObject obj, Vector3 shotDir, Vector3 hitPosition, float bulletSize, OnExplosion callback) { core.ExplodePartial(obj, shotDir, hitPosition, bulletSize, callback); }
void PostCrackExplode(OnExplosion callback) { if (callback != null) { callback(0.0f, ExplosionState.ExplosionStarted); } var count = postList.Count; poolIdx = 0; while (poolIdx < count) { var fragment = pool[poolIdx]; var mesh = postList[poolIdx]; poolIdx++; if (mesh.original != gameObject) { ExploderUtils.SetActiveRecursively(mesh.original, false); } else { ExploderUtils.EnableCollider(mesh.original, false); ExploderUtils.SetVisible(mesh.original, false); } if (mesh.skinnedOriginal && mesh.skinnedOriginal != gameObject) { ExploderUtils.SetActiveRecursively(mesh.skinnedOriginal, false); } else { ExploderUtils.EnableCollider(mesh.skinnedOriginal, false); ExploderUtils.SetVisible(mesh.skinnedOriginal, false); } fragment.Explode(); } if (DestroyOriginalObject) { foreach (var mesh in postList) { if (mesh.original && !mesh.original.GetComponent <Fragment>()) { Object.Destroy(mesh.original); } if (mesh.skinnedOriginal) { Object.Destroy(mesh.skinnedOriginal); } } } if (ExplodeSelf) { if (!DestroyOriginalObject) { ExploderUtils.SetActiveRecursively(gameObject, false); } } if (HideSelf) { ExploderUtils.SetActiveRecursively(gameObject, false); } #if DBG ExploderUtils.Log("Crack finished! " + postList.Count + postList[0].original.transform.gameObject.name); #endif ExplosionCallback = callback; OnExplosionFinished(true); }
/// <summary> /// main function, call this to start explosion /// </summary> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback /// </param> public void Explode(OnExplosion callback) { queue.Explode(callback); }
/// <summary> /// main function, call this to start explosion /// </summary> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback /// </param> public void Explode(OnExplosion callback) { queue.Explode(callback); }
/// <summary> /// callback from queue, do not call this unles you know what you are doing! /// </summary> public void StartExplosionFromQueue(Vector3 pos, int id, OnExplosion callback) { ExploderUtils.Assert(state == State.None, "Wrong state: " + state); mainCentroid = pos; explosionID = id; state = State.Preprocess; ExplosionCallback = callback; #if DBG processingTime = 0.0f; preProcessingTime = 0.0f; postProcessingTime = 0.0f; postProcessingTimeEnd = 0.0f; isolatingIslandsTime = 0.0f; #endif }
void PostCrackExplode(OnExplosion callback) { if (callback != null) { callback(0.0f, ExplosionState.ExplosionStarted); } var count = postList.Count; poolIdx = 0; var diffPos = Vector3.zero; var diffRot = Quaternion.identity; if (postList.Count > 0) { if (postList[0].skinnedOriginal) { diffPos = postList[0].skinnedOriginal.transform.position - crackedPos; diffRot = postList[0].skinnedOriginal.transform.rotation * Quaternion.Inverse(crackedRot); } else { diffPos = postList[0].original.transform.position - crackedPos; diffRot = postList[0].original.transform.rotation * Quaternion.Inverse(crackedRot); } } while (poolIdx < count) { var fragment = pool[poolIdx]; var mesh = postList[poolIdx]; poolIdx++; if (mesh.original != gameObject) { ExploderUtils.SetActiveRecursively(mesh.original, false); } else { ExploderUtils.EnableCollider(mesh.original, false); ExploderUtils.SetVisible(mesh.original, false); } if (mesh.skinnedOriginal && mesh.skinnedOriginal != gameObject) { ExploderUtils.SetActiveRecursively(mesh.skinnedOriginal, false); } else { ExploderUtils.EnableCollider(mesh.skinnedOriginal, false); ExploderUtils.SetVisible(mesh.skinnedOriginal, false); } fragment.transform.position += diffPos; fragment.transform.rotation *= diffRot; fragment.Explode(); } if (settings.DestroyOriginalObject) { foreach (var mesh in postList) { if (mesh.original && !mesh.original.GetComponent<Fragment>()) { Object.Destroy(mesh.original); } if (mesh.skinnedOriginal) { Object.Destroy(mesh.skinnedOriginal); } } } if (settings.ExplodeSelf) { if (!settings.DestroyOriginalObject) { ExploderUtils.SetActiveRecursively(gameObject, false); } } if (settings.HideSelf) { ExploderUtils.SetActiveRecursively(gameObject, false); } #if DBG ExploderUtils.Log("Crack finished! " + postList.Count + postList[0].original.transform.gameObject.name); #endif settings.Callback = callback; OnExplosionFinished(true); }
void PostCrackExplode(OnExplosion callback) { if (callback != null) { callback(0.0f, ExplosionState.ExplosionStarted); } var count = postList.Count; poolIdx = 0; while (poolIdx < count) { var fragment = pool[poolIdx]; var mesh = postList[poolIdx]; poolIdx++; if (mesh.original != gameObject) { ExploderUtils.SetActiveRecursively(mesh.original, false); } else { ExploderUtils.EnableCollider(mesh.original, false); ExploderUtils.SetVisible(mesh.original, false); } if (mesh.skinnedOriginal && mesh.skinnedOriginal != gameObject) { ExploderUtils.SetActiveRecursively(mesh.skinnedOriginal, false); } else { ExploderUtils.EnableCollider(mesh.skinnedOriginal, false); ExploderUtils.SetVisible(mesh.skinnedOriginal, false); } fragment.Explode(); } if (DestroyOriginalObject) { foreach (var mesh in postList) { if (mesh.original && !mesh.original.GetComponent<Fragment>()) { Object.Destroy(mesh.original); } if (mesh.skinnedOriginal) { Object.Destroy(mesh.skinnedOriginal); } } } if (ExplodeSelf) { if (!DestroyOriginalObject) { ExploderUtils.SetActiveRecursively(gameObject, false); } } if (HideSelf) { ExploderUtils.SetActiveRecursively(gameObject, false); } #if DBG ExploderUtils.Log("Crack finished! " + postList.Count + postList[0].original.transform.gameObject.name); #endif ExplosionCallback = callback; OnExplosionFinished(true); }
/// <summary> /// explode single object with callback /// </summary> /// <param name="obj">game object to be exploded</param> /// <param name="callback">callback to be called when explosion calculation is finished /// play your sound effects or particles on this callback</param> public void ExplodeObject(GameObject obj, OnExplosion callback) { core.Enqueue(this, callback, false, obj); }