80 lines
3.0 KiB
C#
80 lines
3.0 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 RowExplosion : IExplosion
|
|
{
|
|
public void Play(SpecialEventItem item)
|
|
{
|
|
GContext.container.Resolve<DiggingGameManager>().BaseMono.StartCoroutine(PlayCoroutine(item));
|
|
}
|
|
|
|
private IEnumerator PlayCoroutine(SpecialEventItem item)
|
|
{
|
|
List<List<GridItem>> 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<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>> GetRowGrids(SpecialEventItem item)
|
|
{
|
|
if (item.Data.Config.DiggingType is RowClear)
|
|
{
|
|
List<List<GridItem>> gridLayer = new List<List<GridItem>>();
|
|
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<GridItem> GetRowOne(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.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;
|
|
}
|
|
|
|
}
|
|
} |