using System.Collections; using System.Collections.Generic; using System.Linq; using asap.core; using cfg; using Game; using Script.RuntimeScript.GameLogic; using UnityEngine; namespace Script.RuntimeScript.ExplosionEffect.Effect { public class RowExplosion : IExplosion { public void Play(SpecialEventItem item) { GContext.container.Resolve().BaseMono.StartCoroutine(PlayCoroutine(item)); } private IEnumerator PlayCoroutine(SpecialEventItem item) { List> targetGridsLayer = GetRowGrids(item); int allCount = targetGridsLayer.Where(x => x.Count > 0).Sum(x => x.Count); if (allCount > 0) { GContext.Publish(new EventUISound("audio_ui_sanddig_griddispear")); } for (int i = 0; i < targetGridsLayer.Count; i++) { List layer = targetGridsLayer[i]; for (int j = 0; j < layer.Count; j++) { layer[j].GridEffectType = GridEffectType.PassiveClear; layer[j].PassiveClick(); yield return new WaitForSeconds(SandDigEventConst.ClearBlockDisappearI * 0.001f); } } DiggingGameManager diggingGameManager = GContext.container.Resolve(); var configInit = diggingGameManager.DataModel.digActivityConfig; yield return new WaitForSeconds(configInit.ClearBlockAniTime); GContext.Publish(new GridPropEffectOver(item.Data.PropId, false)); } public List> GetRowGrids(SpecialEventItem item) { if (item.Data.Config.DiggingType is RowClear) { List> gridLayer = new List>(); int count = (item.Data.Config.DiggingType as RowClear).Param; for (int i = 0; i < count; i++) { gridLayer.Add(GetRowOne(item, i + 1)); } return gridLayer; } return null; } private List GetRowOne(SpecialEventItem item, int value) { List allGrids = GContext.container.Resolve().BroadLogic.GetAllGrids(); List grids = new List(); for (int i = 0; i < allGrids.Count; i++) { if (!allGrids[i].Data.IsBorder && !allGrids[i].Data.IsOpen && allGrids[i].Data.Col == item.Data.ParentGird.Col) { if (allGrids[i].Data.Row == (item.Data.ParentGird.Row - value) || allGrids[i].Data.Row == (item.Data.ParentGird.Row + value)) { // DiggingGameManager.LogError("Explosion::: x::" + allGrids[i].Data.Row + " y::" + allGrids[i].Data.Col); grids.Add(allGrids[i]); } } } return grids; } } }