备份CatanBuilding瘦身独立工程
This commit is contained in:
101
Assets/Scripts/SandDig/ExplosionEffect/Effect/BombExplosion.cs
Normal file
101
Assets/Scripts/SandDig/ExplosionEffect/Effect/BombExplosion.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
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 BombExplosion : IExplosion
|
||||
{
|
||||
private SpecialEventItem _target;
|
||||
public void Play(SpecialEventItem item)
|
||||
{
|
||||
_target = item;
|
||||
|
||||
GContext.container.Resolve<DiggingGameManager>().BaseMono.StartCoroutine(PlayCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator PlayCoroutine()
|
||||
{
|
||||
List<List<GridItem>> targetGridsLayer = GetBombGrids(_target);
|
||||
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.PassiveBomb;
|
||||
layer[j].PassiveClick();
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
}
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
var configInit = diggingGameManager.DataModel.digActivityConfig;
|
||||
yield return new WaitForSeconds(configInit.BombBlockAniTime);
|
||||
GContext.Publish(new GridPropEffectOver(_target.Data.PropId, false));
|
||||
}
|
||||
|
||||
private List<List<GridItem>> GetBombGrids(SpecialEventItem item)
|
||||
{
|
||||
if (item.Data.Config.DiggingType is BombClear)
|
||||
{
|
||||
Dictionary<Vector2Int, GridItem> gridDic = new Dictionary<Vector2Int, GridItem>();
|
||||
List<GridItem> allGrids = GContext.container.Resolve<DiggingGameManager>().BroadLogic.GetAllGrids();
|
||||
for (int i = 0; i < allGrids.Count; i++)
|
||||
{
|
||||
if (allGrids[i].Data.IsBorder || allGrids[i].Data.IsOpen)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector2Int gridVec = new Vector2Int(allGrids[i].Data.Row, allGrids[i].Data.Col);
|
||||
gridDic[gridVec] = allGrids[i];
|
||||
}
|
||||
|
||||
int layers = (item.Data.Config.DiggingType as BombClear).Param;
|
||||
Vector2Int cellPos = new Vector2Int(item.Data.ParentGird.Row, item.Data.ParentGird.Col);
|
||||
return GetCellsInLayers(cellPos, layers, gridDic);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private List<List<GridItem>> GetCellsInLayers(Vector2Int center, int layers, Dictionary<Vector2Int, GridItem> gridDic)
|
||||
{
|
||||
List<List<GridItem>> cellsInLayers = new List<List<GridItem>>();
|
||||
|
||||
for (int layer = 1; layer <= layers; layer++)
|
||||
{
|
||||
List<GridItem> currentLayer = new List<GridItem>();
|
||||
|
||||
for (int x = -layer; x <= layer; x++)
|
||||
{
|
||||
for (int y = -layer; y <= layer; y++)
|
||||
{
|
||||
if (Math.Abs(x) == layer || Math.Abs(y) == layer)
|
||||
{
|
||||
Vector2Int cellPos = new Vector2Int(center.x + x, center.y + y);
|
||||
if (gridDic.ContainsKey(cellPos))
|
||||
{
|
||||
currentLayer.Add(gridDic[cellPos]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cellsInLayers.Add(currentLayer);
|
||||
}
|
||||
|
||||
return cellsInLayers;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bb24410255641fc94958d6f663dcec1
|
||||
timeCreated: 1724319880
|
||||
@@ -0,0 +1,76 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c988f14402f4189976be3f3b0748936
|
||||
timeCreated: 1724319824
|
||||
@@ -0,0 +1,80 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 972b00d27eed48e58a966182f560f6ed
|
||||
timeCreated: 1724319787
|
||||
Reference in New Issue
Block a user