备份CatanBuilding瘦身独立工程
This commit is contained in:
3
Assets/Scripts/SandDig/ExplosionEffect/Effect.meta
Normal file
3
Assets/Scripts/SandDig/ExplosionEffect/Effect.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 532e4738173747c692435548ba48a2c6
|
||||
timeCreated: 1724319751
|
||||
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
|
||||
9
Assets/Scripts/SandDig/ExplosionEffect/ExplosionEnum.cs
Normal file
9
Assets/Scripts/SandDig/ExplosionEffect/ExplosionEnum.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Script.RuntimeScript.ExplosionEffect
|
||||
{
|
||||
public enum ExplosionEnum
|
||||
{
|
||||
Row,
|
||||
Col,
|
||||
Bomb
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cce694935a7d4db882bd16fa39c8dfce
|
||||
timeCreated: 1724319628
|
||||
76
Assets/Scripts/SandDig/ExplosionEffect/ExplosionManager.cs
Normal file
76
Assets/Scripts/SandDig/ExplosionEffect/ExplosionManager.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Script.RuntimeScript.ExplosionEffect.Effect;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.ExplosionEffect
|
||||
{
|
||||
public class ExplosionManager
|
||||
{
|
||||
private Dictionary<ExplosionEnum, IExplosion> ExplosionDic;
|
||||
|
||||
private CompositeDisposable _disposable = new CompositeDisposable();
|
||||
|
||||
public ExplosionManager()
|
||||
{
|
||||
ExplosionDic = new Dictionary<ExplosionEnum, IExplosion>
|
||||
{
|
||||
{ ExplosionEnum.Row, new RowExplosion() },
|
||||
{ ExplosionEnum.Col, new ColExplosion() },
|
||||
{ ExplosionEnum.Bomb, new BombExplosion() }
|
||||
};
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
AddEvent();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
CleanEvent();
|
||||
}
|
||||
|
||||
private void AddEvent()
|
||||
{
|
||||
GContext.OnEvent<ExplosionClick>().Subscribe(OnExplosion).AddTo(_disposable);
|
||||
}
|
||||
|
||||
private void CleanEvent()
|
||||
{
|
||||
_disposable.Dispose();
|
||||
}
|
||||
|
||||
private void OnExplosion(ExplosionClick param)
|
||||
{
|
||||
SpecialEventItem item = param.effect as SpecialEventItem;
|
||||
switch (item.Data.Config.DiggingType)
|
||||
{
|
||||
case RowClear:
|
||||
CastExplosion(ExplosionEnum.Row,item);
|
||||
break;
|
||||
case ColumnClear:
|
||||
CastExplosion(ExplosionEnum.Col,item);
|
||||
break;
|
||||
case BombClear:
|
||||
CastExplosion(ExplosionEnum.Bomb,item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void CastExplosion(ExplosionEnum explosionType,SpecialEventItem item)
|
||||
{
|
||||
if (ExplosionDic.TryGetValue(explosionType, out IExplosion explosion))
|
||||
{
|
||||
explosion.Play(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("explosion type not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faf539b5eb4c42678ceaac0f2b6696c0
|
||||
timeCreated: 1724319916
|
||||
7
Assets/Scripts/SandDig/ExplosionEffect/IExplosionData.cs
Normal file
7
Assets/Scripts/SandDig/ExplosionEffect/IExplosionData.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Script.RuntimeScript.ExplosionEffect
|
||||
{
|
||||
public interface IExplosionData
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c454828dba54cc7bd2dafbc7cb30858
|
||||
timeCreated: 1724321298
|
||||
Reference in New Issue
Block a user