76 lines
2.9 KiB
C#
76 lines
2.9 KiB
C#
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 ColExplosion : IExplosion
|
|
{
|
|
public void Play(SpecialEventItem item)
|
|
{
|
|
GContext.container.Resolve<DiggingGameManager>().BaseMono.StartCoroutine(PlayCoroutine(item));
|
|
}
|
|
|
|
private IEnumerator PlayCoroutine(SpecialEventItem item)
|
|
{
|
|
List<List<GridItem>> targetGridsLayer = GetColGrids(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<GridItem> 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<DiggingGameManager>();
|
|
var configInit = diggingGameManager.DataModel.digActivityConfig;
|
|
yield return new WaitForSeconds(configInit.ClearBlockAniTime);
|
|
GContext.Publish(new GridPropEffectOver(item.Data.PropId, false));
|
|
}
|
|
|
|
public List<List<GridItem>> GetColGrids(SpecialEventItem item)
|
|
{
|
|
if (item.Data.Config.DiggingType is ColumnClear)
|
|
{
|
|
List<List<GridItem>> gridLayer = new List<List<GridItem>>();
|
|
int count = (item.Data.Config.DiggingType as ColumnClear).Param;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
gridLayer.Add(GetColOne(item, i + 1));
|
|
}
|
|
|
|
return gridLayer;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private List<GridItem> GetColOne(SpecialEventItem item, int value)
|
|
{
|
|
List<GridItem> allGrids = GContext.container.Resolve<DiggingGameManager>().BroadLogic.GetAllGrids();
|
|
List<GridItem> grids = new List<GridItem>();
|
|
for (int i = 0; i < allGrids.Count; i++)
|
|
{
|
|
if (!allGrids[i].Data.IsBorder && !allGrids[i].Data.IsOpen && allGrids[i].Data.Row == item.Data.ParentGird.Row)
|
|
{
|
|
if (allGrids[i].Data.Col == (item.Data.ParentGird.Col - value) || allGrids[i].Data.Col == (item.Data.ParentGird.Col + value))
|
|
grids.Add(allGrids[i]);
|
|
}
|
|
}
|
|
|
|
return grids;
|
|
}
|
|
}
|
|
} |