备份CatanBuilding瘦身独立工程
This commit is contained in:
37
Assets/Scripts/SandDig/DiggingGameInit.cs
Normal file
37
Assets/Scripts/SandDig/DiggingGameInit.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public class DiggingGameInit : MonoBehaviour
|
||||
{
|
||||
public GameObject BroadContainer;
|
||||
public GameObject GridContianer;
|
||||
public GameObject GridPropContianer;
|
||||
public GameObject PropContainer;
|
||||
public Texture2D CursorImg;
|
||||
public CinemachineVirtualCamera CameraVir;
|
||||
public GameObject ShowPropPositon;
|
||||
public Transform FxRoot;
|
||||
bool isStart = false;
|
||||
public async Task OnStart()
|
||||
{
|
||||
isStart = true;
|
||||
await GContext.container.Resolve<DiggingGameManager>().InitGame(this, CameraVir, BroadContainer, GridContianer, GridPropContianer, PropContainer, ShowPropPositon, FxRoot);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (isStart)
|
||||
{
|
||||
GContext.container.Resolve<DiggingGameManager>().Update();
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
GContext.container.Resolve<DiggingGameManager>().Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/DiggingGameInit.cs.meta
Normal file
3
Assets/Scripts/SandDig/DiggingGameInit.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c78dbff8c06549f5a60a008e6ab2f671
|
||||
timeCreated: 1723805753
|
||||
780
Assets/Scripts/SandDig/DiggingGameManager.cs
Normal file
780
Assets/Scripts/SandDig/DiggingGameManager.cs
Normal file
@@ -0,0 +1,780 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Cinemachine;
|
||||
using game;
|
||||
using GameCore;
|
||||
using Script.RuntimeScript.ExplosionEffect;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using Game;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public class DiggingGameManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 沙滩寻宝 测试 log 开启关闭
|
||||
/// </summary>
|
||||
private const bool LogOpen = false;
|
||||
|
||||
private MonoBehaviour _monoBehaviour;
|
||||
public MonoBehaviour BaseMono => _monoBehaviour;
|
||||
|
||||
private DiggingGameModel _dataModel;
|
||||
public DiggingGameModel DataModel => _dataModel;
|
||||
|
||||
private Animation _digAni;
|
||||
|
||||
private CinemachineVirtualCamera _cameraVir;
|
||||
|
||||
|
||||
private GameObject fx_DgSanddig;
|
||||
private GameObject fx_DgSanddighard;
|
||||
/// <summary>
|
||||
/// 通关爆炸动画
|
||||
/// </summary>
|
||||
private GameObject fx_DgSanddisappear;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏状态
|
||||
/// </summary>
|
||||
private SandDigGameState _gameState = SandDigGameState.Normal;
|
||||
public SandDigGameState GameState
|
||||
{
|
||||
get { return _gameState; }
|
||||
set
|
||||
{
|
||||
DiggingGameManager.LogError("沙滩寻宝状态:" + value.ToString());
|
||||
_gameState = value;
|
||||
}
|
||||
}
|
||||
public bool IsCanClick = true;
|
||||
/// <summary>
|
||||
/// 棋盘
|
||||
/// </summary>
|
||||
private GameBroadLogic _broadLogic;
|
||||
public GameBroadLogic BroadLogic => _broadLogic;
|
||||
/// <summary>
|
||||
/// 棋盘格子背景容器
|
||||
/// </summary>
|
||||
private GameObject _broadContainer;
|
||||
public GameObject BroadContainer => _broadContainer;
|
||||
/// <summary>
|
||||
/// 棋盘格子容器
|
||||
/// </summary>
|
||||
private GameObject _gridContianer;
|
||||
public GameObject GridContainer => _gridContianer;
|
||||
/// <summary>
|
||||
/// 棋盘格子中道具容器
|
||||
/// </summary>
|
||||
private GameObject _gridPropContianer;
|
||||
public GameObject GridPropContainer => _gridPropContianer;
|
||||
/// <summary>
|
||||
/// 宝箱道具容器
|
||||
/// </summary>
|
||||
private GameObject _propContainer;
|
||||
public GameObject PropContainer => _propContainer;
|
||||
|
||||
private GameObject _showPropPositon;
|
||||
public GameObject ShowPropPositon => _showPropPositon;
|
||||
GameObject _DgSand_bgend => _bgSandBg?.DgSand_bgend;
|
||||
private Tables _tables;
|
||||
public Tables TableData => _tables;
|
||||
|
||||
/// <summary>
|
||||
/// 爆炸管理器
|
||||
/// </summary>
|
||||
private ExplosionManager _explosionManager;
|
||||
public ExplosionManager ExplosionManager => _explosionManager;
|
||||
|
||||
/// <summary>
|
||||
/// 管卡是否通过
|
||||
/// </summary>
|
||||
public bool ClampIsPass = false;
|
||||
public List<ItemData> itemDatas;
|
||||
//奖励界面是否打开
|
||||
private bool _awardPanelIsOpen = false;
|
||||
|
||||
Sound sanddig_dig_sound;
|
||||
|
||||
AudioClip sanddig_dig_audio;
|
||||
AudioClip sanddig_dighard_audio;
|
||||
|
||||
DgSandBg _bgSandBg;
|
||||
|
||||
Transform _fxRoot;
|
||||
|
||||
public async System.Threading.Tasks.Task InitGame(MonoBehaviour monoBehaviour, CinemachineVirtualCamera camera, GameObject broadContainer, GameObject gridContainer, GameObject gridPropContianer, GameObject propContainer, GameObject showPropPositon, Transform fxRoot)
|
||||
{
|
||||
await _dataModel.InitServerData();
|
||||
IniTable();
|
||||
AddEventLister();
|
||||
AudioLoad();
|
||||
_monoBehaviour = monoBehaviour;
|
||||
_cameraVir = camera;
|
||||
_broadContainer = broadContainer;
|
||||
_gridContianer = gridContainer;
|
||||
_gridPropContianer = gridPropContianer;
|
||||
_propContainer = propContainer;
|
||||
_showPropPositon = showPropPositon;
|
||||
_fxRoot = fxRoot;
|
||||
_explosionManager = new ExplosionManager();
|
||||
_explosionManager.Init();
|
||||
await _dataModel.InitClientData(ClientDataHandleEnum.EnterGame);
|
||||
await LoadGameObject();
|
||||
}
|
||||
async System.Threading.Tasks.Task LoadGameObject()
|
||||
{
|
||||
if (_broadLogic == null)
|
||||
{
|
||||
_broadLogic = new GameBroadLogic();
|
||||
}
|
||||
bool IsPassAll = IsPassAllClamps();
|
||||
DiggingActivityInit digActivityConfig = _dataModel.digActivityConfig;
|
||||
GameObject bg = await _broadLogic.LoadGameObject(digActivityConfig.Bg, _cameraVir.transform);
|
||||
if (bg != null)
|
||||
{
|
||||
_bgSandBg = bg.GetComponent<DgSandBg>();
|
||||
_DgSand_bgend?.SetActive(IsPassAll);
|
||||
}
|
||||
if (!IsPassAll)
|
||||
{
|
||||
Transform boxRoot = _propContainer.transform.Find("Box");
|
||||
int count = boxRoot.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//宝箱加载
|
||||
_ = _broadLogic.LoadGameObject(digActivityConfig.DiggingBoxList[i], boxRoot.GetChild(i));
|
||||
}
|
||||
GameObject dig = await _broadLogic.LoadGameObject(digActivityConfig.Shovel, _monoBehaviour.transform);
|
||||
if (dig != null)
|
||||
{
|
||||
_digAni = dig.GetComponent<Animation>();
|
||||
_digAni.gameObject.SetActive(false);
|
||||
}
|
||||
fx_DgSanddig = await Addressables.LoadAssetAsync<GameObject>(digActivityConfig.DiggingGridFxDg).Task;
|
||||
fx_DgSanddighard = await Addressables.LoadAssetAsync<GameObject>(digActivityConfig.DiggingGridFxDh).Task;
|
||||
fx_DgSanddisappear = await Addressables.LoadAssetAsync<GameObject>(digActivityConfig.DiggingGridFxDs).Task;
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
_explosionManager.Reset();
|
||||
RemoveEventLister();
|
||||
AudioRelease();
|
||||
if (fx_DgSanddig != null)
|
||||
{
|
||||
Addressables.Release(fx_DgSanddig);
|
||||
}
|
||||
if (fx_DgSanddighard != null)
|
||||
{
|
||||
Addressables.Release(fx_DgSanddighard);
|
||||
}
|
||||
if (fx_DgSanddisappear != null)
|
||||
{
|
||||
Addressables.Release(fx_DgSanddisappear);
|
||||
}
|
||||
}
|
||||
private IDisposable _onCloseAwardPanel = null;
|
||||
void AddEventLister()
|
||||
{
|
||||
RemoveEventLister();
|
||||
_onCloseAwardPanel = GContext.OnEvent<RewardPanelClose>().Subscribe(OnCloseAwardPanel);
|
||||
}
|
||||
|
||||
void RemoveEventLister()
|
||||
{
|
||||
_onCloseAwardPanel?.Dispose();
|
||||
_onCloseAwardPanel = null;
|
||||
}
|
||||
async void AudioLoad()
|
||||
{
|
||||
AudioRelease();
|
||||
GContext.Publish(new EventBGMSound(_dataModel.digActivityConfig.Bgm));
|
||||
|
||||
sanddig_dig_audio = await Addressables.LoadAssetAsync<AudioClip>("audio_ui_sanddig_dig").Task;
|
||||
sanddig_dighard_audio = await Addressables.LoadAssetAsync<AudioClip>("audio_ui_sanddig_dighard").Task;
|
||||
sanddig_dig_sound = GContext.container.Resolve<ISoundService>().GetNewUISound(sanddig_dig_audio);
|
||||
}
|
||||
void AudioRelease()
|
||||
{
|
||||
sanddig_dig_sound?.ReturnPool();
|
||||
sanddig_dig_sound = null;
|
||||
if (sanddig_dig_audio != null)
|
||||
{
|
||||
Addressables.Release(sanddig_dig_audio);
|
||||
sanddig_dig_audio = null;
|
||||
}
|
||||
if (sanddig_dighard_audio != null)
|
||||
{
|
||||
Addressables.Release(sanddig_dighard_audio);
|
||||
sanddig_dighard_audio = null;
|
||||
}
|
||||
}
|
||||
public void IniTable()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
}
|
||||
|
||||
public void InitServerData(Dictionary<string, string> userDatas = null)
|
||||
{
|
||||
if (_dataModel == null)
|
||||
{
|
||||
_dataModel = new DiggingGameModel();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_broadLogic != null)
|
||||
{
|
||||
_broadLogic.Update();
|
||||
}
|
||||
switch (_gameState)
|
||||
{
|
||||
case SandDigGameState.Normal:
|
||||
break;
|
||||
case SandDigGameState.LoadJson:
|
||||
break;
|
||||
case SandDigGameState.LoadJsonOver:
|
||||
_gameState = SandDigGameState.Begin;
|
||||
break;
|
||||
case SandDigGameState.Begin: //开始游戏
|
||||
_gameState = SandDigGameState.Going;
|
||||
BeginGame();
|
||||
break;
|
||||
case SandDigGameState.Going: //游戏进行中
|
||||
break;
|
||||
case SandDigGameState.PropEffect: //挖出道具动画阶段
|
||||
break;
|
||||
case SandDigGameState.PropEffectEnd: //道具动画播放结束
|
||||
if (ClampIsPass)
|
||||
{
|
||||
_gameState = SandDigGameState.Pass;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gameState = SandDigGameState.Going;
|
||||
}
|
||||
break;
|
||||
case SandDigGameState.Pass: //通关
|
||||
DiggingGameManager.LogError("执行通关逻辑 !!");
|
||||
_gameState = SandDigGameState.Normal;
|
||||
//数据再 model passClamp 中已经存储,这里显示奖励
|
||||
//GContext.Publish(new ShowData());
|
||||
_awardPanelIsOpen = true;
|
||||
|
||||
_dataModel.NewClampInit();
|
||||
|
||||
break;
|
||||
case SandDigGameState.WaitPassLoading:
|
||||
if (!_awardPanelIsOpen)
|
||||
{
|
||||
ShowLoadingEffect();
|
||||
}
|
||||
break;
|
||||
case SandDigGameState.Loading:
|
||||
break;
|
||||
case SandDigGameState.LoadingOver:
|
||||
//开始
|
||||
_gameState = SandDigGameState.Begin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowFX(string fxName, bool show)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fxName) || _fxRoot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Transform transform = _fxRoot.Find(fxName);
|
||||
if (transform != null)
|
||||
{
|
||||
transform.gameObject.SetActive(show);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowFX(GridEffectType GridEffectType, Transform parent)
|
||||
{
|
||||
GameObject go = null;
|
||||
switch (GridEffectType)
|
||||
{
|
||||
case GridEffectType.ClickDig:
|
||||
case GridEffectType.DoubleClick:
|
||||
if (fx_DgSanddig != null)
|
||||
{
|
||||
Transform tran = parent.Find(fx_DgSanddig.name);
|
||||
if (tran == null)
|
||||
{
|
||||
go = GameObject.Instantiate(fx_DgSanddig, parent);
|
||||
go.name = fx_DgSanddig.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
go = tran.gameObject;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GridEffectType.ClickBigDig:
|
||||
if (fx_DgSanddighard != null)
|
||||
{
|
||||
go = GameObject.Instantiate(fx_DgSanddighard, parent);
|
||||
go.name = fx_DgSanddighard.name;
|
||||
}
|
||||
break;
|
||||
case GridEffectType.PassiveBomb:
|
||||
case GridEffectType.PassiveClear:
|
||||
case GridEffectType.PassClamp:
|
||||
if (fx_DgSanddisappear != null)
|
||||
{
|
||||
go = GameObject.Instantiate(fx_DgSanddisappear, parent);
|
||||
go.name = fx_DgSanddisappear.name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (go != null)
|
||||
{
|
||||
go.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示挖掘动画
|
||||
/// </summary>
|
||||
int digShowCount = 0;
|
||||
public async void ShowDigEffect(ClickDigType type, Vector3 pos)
|
||||
{
|
||||
digShowCount++;
|
||||
pos.z = -2;
|
||||
if (_digAni != null)
|
||||
{
|
||||
_digAni.transform.position = pos;
|
||||
_digAni.gameObject.SetActive(true);
|
||||
DiggingActivityInit digActivityConfig = _dataModel.digActivityConfig;
|
||||
|
||||
if (type == ClickDigType.Smail)
|
||||
{
|
||||
_digAni.Play(digActivityConfig.DiggingShovelFxDg);
|
||||
}
|
||||
else
|
||||
{
|
||||
_digAni.Play(digActivityConfig.DiggingShovelFxDh);
|
||||
}
|
||||
}
|
||||
int delay = 200;
|
||||
if (type == ClickDigType.Smail)
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.ShovelAnimTime - delay);
|
||||
//GContext.Publish(new EventUISound("audio_ui_sanddig_dig"));
|
||||
if (sanddig_dig_sound != null)
|
||||
{
|
||||
sanddig_dig_sound.audioSource.clip = sanddig_dig_audio;
|
||||
sanddig_dig_sound.audioSource.Play();
|
||||
}
|
||||
await System.Threading.Tasks.Task.Delay(delay);
|
||||
}
|
||||
else
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.BigShovelAnimTime - delay);
|
||||
//GContext.Publish(new EventUISound("audio_ui_sanddig_dighard"));
|
||||
if (sanddig_dig_sound != null)
|
||||
{
|
||||
sanddig_dig_sound.audioSource.clip = sanddig_dighard_audio;
|
||||
sanddig_dig_sound.audioSource.Play();
|
||||
}
|
||||
await System.Threading.Tasks.Task.Delay(delay);
|
||||
}
|
||||
digShowCount--;
|
||||
if (digShowCount <= 0 && _digAni != null)
|
||||
{
|
||||
_digAni.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
public void BeginGame()
|
||||
{
|
||||
ClampIsPass = false;
|
||||
if (_broadLogic == null)
|
||||
{
|
||||
_broadLogic = new GameBroadLogic();
|
||||
}
|
||||
else
|
||||
{
|
||||
_broadLogic.Reset();
|
||||
}
|
||||
|
||||
int broadWidth = GetBroadWidth();
|
||||
int broadHeight = GetBroadHeight();
|
||||
Vector3 cameraPos = _cameraVir.transform.position;
|
||||
|
||||
DiggingDisplayInit diplayConfig = TableData.TbDiggingDisplayInit.GetOrDefault(broadHeight);
|
||||
if (diplayConfig != null)
|
||||
{
|
||||
cameraPos.y = diplayConfig.VirtualCameraY;
|
||||
}
|
||||
|
||||
_cameraVir.transform.position = new Vector3(broadWidth * 0.5f, cameraPos.y, cameraPos.z);
|
||||
DiggingGameManager.LogError("当前管卡Id:::" + _dataModel.GetCurClampId() + " 棋盘宽度::" + broadWidth);
|
||||
if (_dataModel.GetCurClampId() > 0)
|
||||
{
|
||||
_broadLogic.InitEvent();
|
||||
_broadLogic.BuildBroadBack();
|
||||
_broadLogic.BuildGrid();
|
||||
_broadLogic.BuildProp();
|
||||
_broadLogic.BuildTempProp();
|
||||
_dataModel.SaveAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCloseAwardPanel(RewardPanelClose data)
|
||||
{
|
||||
//if (data.rewardType != RewardType.Destroy) return;
|
||||
_awardPanelIsOpen = false;
|
||||
if (_gameState == SandDigGameState.WaitPassLoading)
|
||||
{
|
||||
ShowLoadingEffect();
|
||||
}
|
||||
else if (IsPassAllClamps())
|
||||
{
|
||||
//通关所有关卡
|
||||
DiggingGameManager.LogError("通关所有关卡!!!!!!!");
|
||||
_broadLogic.Reset();
|
||||
HidBox();
|
||||
_DgSand_bgend?.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
public void GMSetClamp(int index)
|
||||
{
|
||||
_dataModel.GMSetClamp(index);
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示转场动画
|
||||
/// </summary>
|
||||
private async void ShowLoadingEffect()
|
||||
{
|
||||
_gameState = SandDigGameState.Loading;
|
||||
await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
await System.Threading.Tasks.Task.Delay(500);
|
||||
|
||||
_gameState = SandDigGameState.LoadingOver;
|
||||
GContext.Publish(new EndTransition());
|
||||
|
||||
}
|
||||
|
||||
public int GetActivityId()
|
||||
{
|
||||
return GContext.container.Resolve<FishingEventData>().GetEvent(4, 1);
|
||||
}
|
||||
public FishingEvent GetActivityConfig(int acId)
|
||||
{
|
||||
return GContext.container.Resolve<Tables>().TbFishingEvent.Get(acId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前管卡 是当前活动的第几关
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetCurClampIndex()
|
||||
{
|
||||
List<int> allClamps = _dataModel.digActivityConfig.StageList;
|
||||
int curClampId = _dataModel.GetCurClampId();
|
||||
if (curClampId < 0)
|
||||
{
|
||||
return allClamps.Count - 1;
|
||||
}
|
||||
return allClamps.IndexOf(curClampId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取当前活动所有管卡数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetAllClampCount()
|
||||
{
|
||||
List<int> allClamps = _dataModel.digActivityConfig.StageList;
|
||||
return allClamps.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过全部管卡
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsPassAllClamps()
|
||||
{
|
||||
return _dataModel.GetServerData().ClampId < 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取活动道具id
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetActivityPropId()
|
||||
{
|
||||
return _dataModel.digActivityConfig.TokenID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取棋盘宽度
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetBroadWidth()
|
||||
{
|
||||
BroadData[] allGrid = DataModel.GetAllBroadData();
|
||||
int widthCount = 0;
|
||||
for (int i = 0; i < allGrid.Length; i++)
|
||||
{
|
||||
if ((int)allGrid[i].LocalPos.y == 1)
|
||||
{
|
||||
widthCount++;
|
||||
}
|
||||
}
|
||||
return widthCount + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取棋盘高度
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetBroadHeight()
|
||||
{
|
||||
BroadData[] allGrid = DataModel.GetAllBroadData();
|
||||
int widthCount = 0;
|
||||
for (int i = 0; i < allGrid.Length; i++)
|
||||
{
|
||||
if ((int)allGrid[i].LocalPos.x == 1)
|
||||
{
|
||||
widthCount++;
|
||||
}
|
||||
}
|
||||
return widthCount + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取棋子宽度数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetGridWidth()
|
||||
{
|
||||
GridData[] allGrid = DataModel.GetAllGridData();
|
||||
int minX = 0;
|
||||
int maxX = 0;
|
||||
for (int i = 0; i < allGrid.Length; i++)
|
||||
{
|
||||
if (allGrid[i].LocalPos.x < minX)
|
||||
{
|
||||
minX = (int)Math.Round(allGrid[i].LocalPos.x);
|
||||
}
|
||||
|
||||
if (allGrid[i].LocalPos.x > maxX)
|
||||
{
|
||||
maxX = (int)Math.Round(allGrid[i].LocalPos.x);
|
||||
}
|
||||
}
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取已经获得的目标道具
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<int> GetHasPassPropIds()
|
||||
{
|
||||
return DataModel.GetServerData().PassPropIds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加道具
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public void AddDigCount(int count)
|
||||
{
|
||||
_dataModel.AddDigCount(count);
|
||||
}
|
||||
public void ClearPropContianer()
|
||||
{
|
||||
foreach (Transform child in _propContainer.transform)
|
||||
{
|
||||
if (child && child.name != "Box")
|
||||
GameObject.Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
public void DgSandBox()
|
||||
{
|
||||
DiggingStageReward config = GContext.container.Resolve<Tables>().TbDiggingStageReward.Get(_dataModel.GetServerData().ClampId);
|
||||
Transform boxRoot = _propContainer.transform.Find("Box");
|
||||
int count = boxRoot.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Transform box = boxRoot.GetChild(i);
|
||||
box.gameObject.SetActive(box.name == config.StageBox);
|
||||
}
|
||||
}
|
||||
void HidBox()
|
||||
{
|
||||
Transform boxRoot = _propContainer.transform.Find("Box");
|
||||
int count = boxRoot.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Transform box = boxRoot.GetChild(i);
|
||||
box.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
public int GetCurLevel()
|
||||
{
|
||||
List<int> allClamps = _dataModel.digActivityConfig.StageList;
|
||||
int level = allClamps.Count;
|
||||
int curClampId = _dataModel.GetCurClampId();
|
||||
if (curClampId > 0)
|
||||
{
|
||||
level = allClamps.IndexOf(curClampId) + 1;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
/// <summary>
|
||||
/// 沙滩寻宝打点
|
||||
/// </summary>
|
||||
public void SandDigPoint(GridType gridType, int level, int clickCount)
|
||||
{
|
||||
int type = 0;
|
||||
switch (gridType)
|
||||
{
|
||||
case GridType.Normal:
|
||||
type = 1;
|
||||
break;
|
||||
case GridType.Resource:
|
||||
type = 3;
|
||||
break;
|
||||
case GridType.Special:
|
||||
type = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("beachcomb"))
|
||||
{
|
||||
e.AddContent("grid_type", type) //格子类型 空格子=0,普通格子=1,特殊事件=2,资源道具=3
|
||||
.AddContent("stage_lv", level) //关卡等级
|
||||
.AddContent("click_times", clickCount) //点击次数
|
||||
.AddContent("stage_clear", ClampIsPass ? 1 : 0); //关卡完成情况 未完成=0,完成=1
|
||||
|
||||
if (itemDatas != null && itemDatas.Count > 0 && ClampIsPass == true)
|
||||
{
|
||||
for (int i = 0; i < itemDatas.Count; i++)
|
||||
{
|
||||
if (itemDatas[i].id == 1001)
|
||||
{
|
||||
e.AddContent("reward_hook", itemDatas[i].count);
|
||||
}
|
||||
else if (itemDatas[i].id == 1002)
|
||||
{
|
||||
e.AddContent("reward_cash", itemDatas[i].count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void LogWarning(string value)
|
||||
{
|
||||
if (!LogOpen) return;
|
||||
|
||||
Debug.Log("<color=#ffff00>沙滩寻宝: " + value + "</color>");
|
||||
}
|
||||
|
||||
public static void LogError(string value)
|
||||
{
|
||||
if (!LogOpen) return;
|
||||
Debug.Log("<color=#00ff00>沙滩寻宝: " + value + "</color>");
|
||||
}
|
||||
|
||||
public bool NewInfo()
|
||||
{
|
||||
int id = _dataModel.CurActivityId;
|
||||
int oldId = PlayerPrefs.GetInt("DigGridData", -1);
|
||||
if (id == oldId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
PlayerPrefs.SetInt("DigGridData", id);
|
||||
//PlayerPrefs.Save();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径类型
|
||||
/// </summary>
|
||||
public enum UrlType
|
||||
{
|
||||
Broad,
|
||||
Grid,
|
||||
GridProp,
|
||||
Prop,
|
||||
SpecialEvent
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// grid 动画类型
|
||||
/// </summary>
|
||||
public enum GridEffectType
|
||||
{
|
||||
ClickDig, //普通挖掘
|
||||
ClickBigDig, //挖出道具
|
||||
DoubleClick, //需要点击两次
|
||||
PassiveBomb, //特殊事件触发 爆炸
|
||||
PassiveClear, //特殊事件触发 消除
|
||||
PassClamp, //通关
|
||||
}
|
||||
|
||||
public enum SandDigGameState
|
||||
{
|
||||
Normal,
|
||||
Begin,
|
||||
Going,
|
||||
LoadJson,
|
||||
LoadJsonOver,
|
||||
WaveEffect,
|
||||
PropEffect,
|
||||
PropEffectEnd,
|
||||
Pass, //通关
|
||||
WaitPassLoading, //准备转场
|
||||
Loading, //转场中
|
||||
LoadingOver,
|
||||
}
|
||||
|
||||
public enum GridMeshType
|
||||
{
|
||||
None,
|
||||
Mesh1,
|
||||
Mesh2,
|
||||
}
|
||||
|
||||
public enum ClickDigType
|
||||
{
|
||||
Smail,
|
||||
Big,
|
||||
}
|
||||
|
||||
public enum ClientDataHandleEnum
|
||||
{
|
||||
Init,
|
||||
PassClamp,
|
||||
EnterGame
|
||||
}
|
||||
|
||||
public enum GridType
|
||||
{
|
||||
Normal,
|
||||
Resource,
|
||||
Special,
|
||||
None
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/DiggingGameManager.cs.meta
Normal file
3
Assets/Scripts/SandDig/DiggingGameManager.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 479dba2a4fc84805aeb3cc907d0e2cec
|
||||
timeCreated: 1723804560
|
||||
3
Assets/Scripts/SandDig/ExplosionEffect.meta
Normal file
3
Assets/Scripts/SandDig/ExplosionEffect.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ffbcbc6fd6c434eb79e0cca12cd0b15
|
||||
timeCreated: 1724319452
|
||||
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
|
||||
339
Assets/Scripts/SandDig/GameBroadLogic.cs
Normal file
339
Assets/Scripts/SandDig/GameBroadLogic.cs
Normal file
@@ -0,0 +1,339 @@
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public partial class GameBroadLogic
|
||||
{
|
||||
private List<BroadItem> _allBroads = new List<BroadItem>();
|
||||
private List<GridItem> _allGrids = new List<GridItem>();
|
||||
private List<PropItem> _allProps = new List<PropItem>();
|
||||
private List<GridPropItem> _allGridProps = new List<GridPropItem>();
|
||||
private List<SpecialEventItem> _allSpecialGridProps = new List<SpecialEventItem>();
|
||||
/// <summary>
|
||||
/// 已经加载完成的 grid数量
|
||||
/// </summary>
|
||||
private int _gridLoadedCount = 0;
|
||||
|
||||
public void InitEvent()
|
||||
{
|
||||
AddEvent();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
DiggingGameManager.LogError("管卡重置!!!!!!!!");
|
||||
ClearEffect();
|
||||
|
||||
_allBroads.ForEach(item => { if (item != null) GameObject.Destroy(item.gameObject); });
|
||||
_allGrids.ForEach(item => { if (item != null) GameObject.Destroy(item.gameObject); });
|
||||
_allProps.ForEach(item => { if (item != null) GameObject.Destroy(item.gameObject); });
|
||||
_allGridProps.ForEach(item => { if (item != null) GameObject.Destroy(item.gameObject); });
|
||||
_allSpecialGridProps.ForEach(item => { if (item != null) GameObject.Destroy(item.gameObject); });
|
||||
|
||||
_allBroads.Clear();
|
||||
_allGrids.Clear();
|
||||
_allProps.Clear();
|
||||
_allGridProps.Clear();
|
||||
_allSpecialGridProps.Clear();
|
||||
|
||||
GContext.container.Resolve<DiggingGameManager>().ClearPropContianer();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构建棋盘背景
|
||||
/// </summary>
|
||||
public void BuildBroadBack()
|
||||
{
|
||||
BroadData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllBroadData();
|
||||
Dictionary<int, DiggingCheckerBoardList> DiggingCheckerBoardList = GContext.container.Resolve<Tables>().TbDiggingCheckerBoardList.DataMap;
|
||||
string ResourceTopic = GContext.container.Resolve<DiggingGameManager>().DataModel.ResourceTopic;
|
||||
foreach (var data in allData)
|
||||
{
|
||||
DiggingCheckerBoardList boardList = DiggingCheckerBoardList.GetValueOrDefault(data.ID);
|
||||
LoadAndInstantiateBroad(ResourceTopic + boardList.GenericName, data);
|
||||
}
|
||||
GContext.container.Resolve<DiggingGameManager>().DgSandBox();
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建棋子
|
||||
/// </summary>
|
||||
public void BuildGrid()
|
||||
{
|
||||
List<GridPropData> allGridPropData = new List<GridPropData>();
|
||||
List<GridPropData> allSpecialPropData = new List<GridPropData>();
|
||||
|
||||
GridData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllGridData();
|
||||
Dictionary<int, DiggingCheckerBoardList> DiggingCheckerBoardList = GContext.container.Resolve<Tables>().TbDiggingCheckerBoardList.DataMap;
|
||||
string ResourceTopic = GContext.container.Resolve<DiggingGameManager>().DataModel.ResourceTopic;
|
||||
_gridLoadedCount = 0;
|
||||
//棋子显示
|
||||
for (int i = 0; i < allData.Length; i++)
|
||||
{
|
||||
GridData data = allData[i];
|
||||
//string address = DiggingGameManager.GetUrl(UrlType.Grid, data.ResName);
|
||||
|
||||
// 道具
|
||||
GridPropData gridData = data.ConfigData;
|
||||
if (gridData != null && data.PropId > 0)
|
||||
{
|
||||
gridData.Init(data.PropId, data.Row, data.Col);
|
||||
|
||||
// 普通道具 + 金币
|
||||
if (gridData.Config.DiggingType is Normal || gridData.Config.DiggingType is Resource)
|
||||
{
|
||||
DiggingGameManager.LogError("普通道具:propId::::" + gridData.PropId + " row::" + data.Row + " col::" + data.Col);
|
||||
allGridPropData.Add(gridData);
|
||||
}
|
||||
else // 特殊事件
|
||||
{
|
||||
DiggingGameManager.LogError("特殊事件:propId::::" + gridData.PropId + " row::" + data.Row + " col::" + data.Col);
|
||||
allSpecialPropData.Add(gridData);
|
||||
}
|
||||
gridData.ParentGird = GetGridItemByRowAndCol(data.Row, data.Col);
|
||||
}
|
||||
DiggingCheckerBoardList boardList = DiggingCheckerBoardList.GetValueOrDefault(data.ID);
|
||||
LoadAndInstantiateGrid(ResourceTopic + boardList.GenericName, data);
|
||||
}
|
||||
|
||||
|
||||
//格子下面道具显示
|
||||
for (int i = 0; i < allGridPropData.Count; i++)
|
||||
{
|
||||
GridPropData gridData = allGridPropData[i];
|
||||
//string address = DiggingGameManager.GetUrl(UrlType.GridProp, gridData.Config.ItemGridResource);
|
||||
// 格子下道具绑定格子
|
||||
CheckPropNeedGridData(gridData);
|
||||
LoadAndInstantiateGridProp(ResourceTopic + gridData.Config.ItemGridResource, gridData);
|
||||
}
|
||||
|
||||
//特殊事件显示
|
||||
for (int i = 0; i < allSpecialPropData.Count; i++)
|
||||
{
|
||||
GridPropData spData = allSpecialPropData[i];
|
||||
//string address = DiggingGameManager.GetUrl(UrlType.SpecialEvent, spData.Config.ItemGridResource);
|
||||
//当前格子记录道具数据
|
||||
spData.ParentGird.ConfigData = spData;
|
||||
spData.AddGrid(spData.ParentGird);
|
||||
|
||||
LoadAndInstantiateSpecialEvent(ResourceTopic + spData.Config.ItemGridResource, spData);
|
||||
}
|
||||
}
|
||||
//void ShowAllGridProps()
|
||||
//{
|
||||
// int gridCount = _allGridProps.Count;
|
||||
// for (int i = 0; i < gridCount; i++)
|
||||
// {
|
||||
// _allGridProps[i].SetShowShadow(true);
|
||||
// }
|
||||
//}
|
||||
private void CheakAllGridPrefabLoaded()
|
||||
{
|
||||
GridData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllGridData();
|
||||
if (_gridLoadedCount == allData.Length)
|
||||
{
|
||||
//所有grid 加载完毕
|
||||
BeginWaveEffect();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建模板道具 *** 每一关只有第一次进入管卡才会有数据
|
||||
/// </summary>
|
||||
public void BuildTempProp()
|
||||
{
|
||||
List<PropTempData> props = GContext.container.Resolve<DiggingGameManager>().DataModel.GetOnePropTempData();
|
||||
if (props == null) return;
|
||||
string ResourceTopic = GContext.container.Resolve<DiggingGameManager>().DataModel.ResourceTopic;
|
||||
|
||||
GridPropData gridData;
|
||||
for (int i = 0; i < props.Count; i++)
|
||||
{
|
||||
PropTempData prop = props[i];
|
||||
DiggingGameManager.LogError("随机道具:propId:::" + prop.PropId + " angle:::" + prop.ConfigData.PropDirection + " x::" + prop.x + " y::" + prop.y);
|
||||
gridData = prop.ConfigData;
|
||||
gridData.Init(prop.PropId, prop.x, prop.y);
|
||||
GridData gridScript = GetGridItemByRowAndCol(prop.x, prop.y);
|
||||
gridData.ParentGird = gridScript;
|
||||
//将随机的道具 绑定到格子上
|
||||
GridData modelGridData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetGridData(prop.x, prop.y);
|
||||
if (modelGridData == null)
|
||||
{
|
||||
DiggingGameManager.LogError("数据中不存在 GridData ,位置 x:" + prop.x + " y:" + prop.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
modelGridData.PropId = gridData.PropId;
|
||||
modelGridData.ConfigData = gridData;
|
||||
}
|
||||
|
||||
UrlType urlType;
|
||||
if (gridData.Config.DiggingType is Normal || gridData.Config.DiggingType is Resource)
|
||||
{
|
||||
urlType = UrlType.GridProp;
|
||||
|
||||
//格子下道具绑定格子
|
||||
CheckPropNeedGridData(gridData);
|
||||
}
|
||||
else
|
||||
{
|
||||
urlType = UrlType.SpecialEvent;
|
||||
|
||||
//当前格子记录道具数据
|
||||
gridData.ParentGird.ConfigData = gridData;
|
||||
gridData.AddGrid(gridData.ParentGird);
|
||||
}
|
||||
|
||||
//string address = DiggingGameManager.GetUrl(urlType, gridData.Config.ItemGridResource);
|
||||
|
||||
LoadAndInstantiateTempGridProp(ResourceTopic + gridData.Config.ItemGridResource, gridData, prop, urlType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构建目标道具
|
||||
/// </summary>
|
||||
public void BuildProp()
|
||||
{
|
||||
int broadHight = GContext.container.Resolve<DiggingGameManager>().GetBroadHeight();
|
||||
//背景宝箱位置处理
|
||||
Vector3 taskBoxPosition = GContext.container.Resolve<DiggingGameManager>().DataModel.GetTaskPosPositon();
|
||||
Vector3 posCopy = new Vector3(taskBoxPosition.x, taskBoxPosition.y, taskBoxPosition.z);
|
||||
DiggingDisplayInit config = GContext.container.Resolve<DiggingGameManager>().TableData.TbDiggingDisplayInit.GetOrDefault(broadHight);
|
||||
if (config != null)
|
||||
{
|
||||
posCopy.y = config.PropContainerY;
|
||||
}
|
||||
GContext.container.Resolve<DiggingGameManager>().PropContainer.transform.position = posCopy;
|
||||
string ResourceTopic = GContext.container.Resolve<DiggingGameManager>().DataModel.ResourceTopic;
|
||||
|
||||
//先处理 已经获得的数据
|
||||
List<int> allHaveProps = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllPassIds();
|
||||
|
||||
for (int i = 0; i < allHaveProps.Count; i++)
|
||||
{
|
||||
ShowProp(allHaveProps[i]);
|
||||
}
|
||||
|
||||
//处理道具
|
||||
PropData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllPropData();
|
||||
var TbDiggingItemList = GContext.container.Resolve<DiggingGameManager>().TableData.TbDiggingItemList;
|
||||
foreach (var data in allData)
|
||||
{
|
||||
var item = TbDiggingItemList.Get(data.PropId);
|
||||
//string address = DiggingGameManager.GetUrl(UrlType.Prop, data.ResName);
|
||||
LoadAndInstantiateTaskProp(ResourceTopic + item.ItemBoxResource, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示目标道具
|
||||
/// </summary>
|
||||
/// <param name="propId"></param>
|
||||
private void ShowProp(int propId)
|
||||
{
|
||||
DiggingGameManager.LogError("完成目标道具::" + propId);
|
||||
|
||||
PropData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllPropData();
|
||||
string ResourceTopic = GContext.container.Resolve<DiggingGameManager>().DataModel.ResourceTopic;
|
||||
|
||||
PropData propData;
|
||||
for (int i = 0; i < allData.Length; i++)
|
||||
{
|
||||
propData = allData[i];
|
||||
if (propData.IsOk == false && propData.PropId == propId)
|
||||
{
|
||||
propData.IsOk = true;
|
||||
DiggingItemList propConfig = GContext.container.Resolve<DiggingGameManager>().TableData.TbDiggingItemList.Get(propId);
|
||||
|
||||
//string address = DiggingGameManager.GetUrl(UrlType.GridProp, propConfig.ItemGridResource); //完成的道具 加载的Grid 道具中的资源!
|
||||
LoadAndInstantiateGetedTaskProp(ResourceTopic + propConfig.ItemGridResource, propData, propConfig.ItemFxScale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GridData GetGridItemByRowAndCol(int row, int col)
|
||||
{
|
||||
|
||||
GridData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllGridData();
|
||||
|
||||
for (int i = 0; i < allData.Length; i++)
|
||||
{
|
||||
if (allData[i].Row == row && allData[i].Col == col)
|
||||
{
|
||||
return allData[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格子下道具绑定格子
|
||||
/// </summary>
|
||||
public void CheckPropNeedGridData(GridPropData data)
|
||||
{
|
||||
int rows = data.TempArr.GetLength(0);
|
||||
int cols = data.TempArr.GetLength(1);
|
||||
|
||||
|
||||
// 起始
|
||||
Vector3 startPoint = new Vector3(data.ParentGird.Row, data.ParentGird.Col, 0);
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
for (int j = 0; j < cols; j++)
|
||||
{
|
||||
int value = data.TempArr[i, j];
|
||||
if (value > 0)
|
||||
{
|
||||
// 初始位置
|
||||
Vector3 positionB = new Vector3(j, i, 0); //空间转换
|
||||
// DiggingGameManager.LogError($"positionB::row:: {i}" + " col::" + j + " data.PropDirection::" + data.PropDirection);
|
||||
Vector3 endPosition = startPoint + GetRotatePoint(data.PropDirection, Vector3.zero, positionB);
|
||||
// DiggingGameManager.LogError($"获取Grid::{endPosition.x}" + " col::" + endPosition.y);
|
||||
GridData grid = GetGridItemByRowAndCol((int)Mathf.Round(endPosition.x), (int)Mathf.Round(endPosition.y));
|
||||
if (grid != null)
|
||||
{
|
||||
// DiggingGameManager.LogError("PropId:::" + data.PropId + " x::" + grid.Data.Row + " y::" + grid.Data.Col);
|
||||
//当前格子记录道具数据
|
||||
grid.ConfigData = data;
|
||||
data.AddGrid(grid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取旋转后道具的位置
|
||||
/// </summary>
|
||||
/// <param name="angles"></param>
|
||||
/// <param name="positionA"></param>
|
||||
/// <param name="positionB"></param>
|
||||
/// <returns></returns>
|
||||
private Vector3 GetRotatePoint(int angles, Vector3 positionA, Vector3 positionB)
|
||||
{
|
||||
return RotatePointAroundPivot(positionB, positionA, new Vector3(0, 0, -angles));
|
||||
}
|
||||
|
||||
private Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
|
||||
{
|
||||
Vector3 dir = point - pivot; // 获取点到枢轴的向量
|
||||
dir = Quaternion.Euler(angles) * dir; // 旋转向量
|
||||
point = dir + pivot; // 将点移动回枢轴
|
||||
return point;
|
||||
}
|
||||
|
||||
public List<GridItem> GetAllGrids()
|
||||
{
|
||||
return _allGrids;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameBroadLogic.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameBroadLogic.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77d9f250462947b19b30921f0c28dcba
|
||||
timeCreated: 1723808682
|
||||
82
Assets/Scripts/SandDig/GameBroadLogic_Ani.cs
Normal file
82
Assets/Scripts/SandDig/GameBroadLogic_Ani.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using Script.RuntimeScript.Interface;
|
||||
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public partial class GameBroadLogic
|
||||
{
|
||||
private List<BroadEffectInterface> _effectList = new List<BroadEffectInterface>();
|
||||
|
||||
private BroadEffectState _broadState = BroadEffectState.None;
|
||||
|
||||
public void AddToEffectList(BroadEffectInterface item)
|
||||
{
|
||||
_effectList.Add(item);
|
||||
if (this._broadState == BroadEffectState.None)
|
||||
{
|
||||
this._broadState = BroadEffectState.Check;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
switch (_broadState)
|
||||
{
|
||||
case BroadEffectState.None:
|
||||
break;
|
||||
case BroadEffectState.Check:
|
||||
case BroadEffectState.OverCheck:
|
||||
bool haveEffect = CheckCanPlayEffect(_broadState == BroadEffectState.OverCheck);
|
||||
if (haveEffect == false)
|
||||
{
|
||||
_broadState = BroadEffectState.AllOver;
|
||||
}
|
||||
break;
|
||||
case BroadEffectState.Playing:
|
||||
break;
|
||||
case BroadEffectState.AllOver:
|
||||
_broadState = BroadEffectState.None;
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.PropEffectEnd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckCanPlayEffect(bool overCheck)
|
||||
{
|
||||
if (_effectList.Count > 0)
|
||||
{
|
||||
_effectList.Sort((a, b) => a.PlayEffectPriority.CompareTo(b.PlayEffectPriority));
|
||||
_broadState = BroadEffectState.Playing;
|
||||
DiggingGameManager.LogError("_effectList.Count ::" + _effectList.Count);
|
||||
PlayEffect(_effectList[0], overCheck);
|
||||
if (_effectList.Count > 0)//防止 被ClearEffect 清空
|
||||
_effectList.RemoveAt(0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayEffect(BroadEffectInterface item, bool overCheck)
|
||||
{
|
||||
item.PlayEffect(overCheck);
|
||||
}
|
||||
|
||||
private void ClearEffect()
|
||||
{
|
||||
_effectList.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum BroadEffectState
|
||||
{
|
||||
None,
|
||||
Check,
|
||||
Playing,
|
||||
AllOver,
|
||||
OverCheck,
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameBroadLogic_Ani.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameBroadLogic_Ani.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d92e5d21edf84406b8312e429e83852e
|
||||
timeCreated: 1724065063
|
||||
95
Assets/Scripts/SandDig/GameBroadLogic_BeginEffect.cs
Normal file
95
Assets/Scripts/SandDig/GameBroadLogic_BeginEffect.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public partial class GameBroadLogic
|
||||
{
|
||||
private float _animationDelay = 0.05f;
|
||||
private float _animationDuration = 0.3f;
|
||||
private int _completedAnimations = 0;
|
||||
private int _totalAnimations;
|
||||
private void BeginWaveEffect()
|
||||
{
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.WaveEffect;
|
||||
MonoBehaviour mono = GContext.container.Resolve<DiggingGameManager>().BaseMono;
|
||||
mono.StartCoroutine(PlayWaveAnimation());
|
||||
}
|
||||
|
||||
private IEnumerator PlayWaveAnimation()
|
||||
{
|
||||
|
||||
_completedAnimations = 0;
|
||||
_totalAnimations = GetEffectGridCount();
|
||||
int columns = GContext.container.Resolve<DiggingGameManager>().GetGridWidth();
|
||||
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
for (int i = 0; i < _allGrids.Count; i++)
|
||||
{
|
||||
if (_allGrids[i].Data.IsBorder == false && _allGrids[i].Data.Row == j)
|
||||
{
|
||||
DoTweenCube(_allGrids[i]);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
yield return new WaitForSeconds(_animationDelay);
|
||||
}
|
||||
}
|
||||
private void DoTweenCube(GridItem cube)
|
||||
{
|
||||
Vector3 startPosition = cube.transform.position;
|
||||
Vector3 endPosition = startPosition + new Vector3(0, 0, -1);
|
||||
|
||||
cube.transform.DOMove(endPosition, _animationDuration / 2).SetEase(Ease.OutQuad).OnComplete(() =>
|
||||
{
|
||||
cube.transform.DOMove(startPosition, _animationDuration / 2).SetEase(Ease.InQuad).OnComplete(() =>
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_gridshow"));
|
||||
_completedAnimations++;
|
||||
if (_completedAnimations >= _totalAnimations)
|
||||
{
|
||||
OnAllAnimationsComplete();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保持与上面相同算法 ,防止 格子参数配置错误导致 数量不一样
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
private int GetEffectGridCount()
|
||||
{
|
||||
int count = 0;
|
||||
int columns = GContext.container.Resolve<DiggingGameManager>().GetGridWidth();
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
for (int i = 0; i < _allGrids.Count; i++)
|
||||
{
|
||||
if (_allGrids[i].Data.IsBorder == false && _allGrids[i].Data.Row == j)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
private void OnAllAnimationsComplete()
|
||||
{
|
||||
DiggingGameManager.LogError("开始动画完毕!!");
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.Going;
|
||||
//ShowAllGridProps();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SandDig/GameBroadLogic_BeginEffect.cs.meta
Normal file
11
Assets/Scripts/SandDig/GameBroadLogic_BeginEffect.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d65966aa83bf2741a06e800ed493032
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
255
Assets/Scripts/SandDig/GameBroadLogic_Event.cs
Normal file
255
Assets/Scripts/SandDig/GameBroadLogic_Event.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using System.Collections.Generic;
|
||||
using UniRx;
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public partial class GameBroadLogic
|
||||
{
|
||||
private CompositeDisposable _disposable = null;
|
||||
|
||||
public void AddEvent()
|
||||
{
|
||||
if (_disposable == null)
|
||||
{
|
||||
_disposable = new CompositeDisposable();
|
||||
GContext.OnEvent<EventGridClick>().Subscribe(OnClickGrid).AddTo(_disposable);
|
||||
GContext.OnEvent<GridPropEffectOver>().Subscribe(OnGridPropEffectOver).AddTo(_disposable);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEvent()
|
||||
{
|
||||
_disposable?.Dispose();
|
||||
_disposable = null;
|
||||
}
|
||||
|
||||
#region 点击grid
|
||||
|
||||
private void OnClickGrid(EventGridClick param)
|
||||
{
|
||||
GridData gridData = param.Data;
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
if (gridData.ConfigData != null)
|
||||
{
|
||||
int level = diggingGameManager.GetCurLevel();
|
||||
int clickCount = diggingGameManager.DataModel.GetClickCount();
|
||||
bool boo = false;
|
||||
if (gridData.ConfigData.Config.DiggingType is Normal)
|
||||
{
|
||||
boo = CheckPropOpen(gridData);
|
||||
if (boo)
|
||||
diggingGameManager.SandDigPoint(GridType.Normal, level, clickCount);
|
||||
else
|
||||
diggingGameManager.SandDigPoint(GridType.None, level, clickCount);
|
||||
}
|
||||
else if (gridData.ConfigData.Config.DiggingType is Resource)
|
||||
{
|
||||
boo = CheckResoucePropOpen(gridData);
|
||||
if (boo)
|
||||
diggingGameManager.SandDigPoint(GridType.Resource, level, clickCount);
|
||||
else
|
||||
diggingGameManager.SandDigPoint(GridType.None, level, clickCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
boo = CheckSpecialEventOpen(gridData);
|
||||
if (boo)
|
||||
diggingGameManager.SandDigPoint(GridType.Special, level, clickCount);
|
||||
else
|
||||
diggingGameManager.SandDigPoint(GridType.None, level, clickCount);
|
||||
}
|
||||
if (!param.PassiveClick)
|
||||
{
|
||||
if (boo)
|
||||
{
|
||||
diggingGameManager.ShowDigEffect(ClickDigType.Big, gridData.LocalPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
diggingGameManager.ShowDigEffect(ClickDigType.Smail, gridData.LocalPos);
|
||||
}
|
||||
}
|
||||
param.IsBigDig = boo;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!param.PassiveClick)
|
||||
{
|
||||
diggingGameManager.ShowDigEffect(ClickDigType.Smail, gridData.LocalPos);
|
||||
}
|
||||
}
|
||||
|
||||
diggingGameManager.DataModel.SaveAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查道具开启
|
||||
/// </summary>
|
||||
private bool CheckPropOpen(GridData gridData)
|
||||
{
|
||||
bool isCheckPass = false;
|
||||
for (int i = 0; i < _allGridProps.Count; i++)
|
||||
{
|
||||
if (!_allGridProps[i].Data.AlreadyOpen && _allGridProps[i].Data.IsCanOpen() && _allGridProps[i].Data.Config.DiggingType is Normal)
|
||||
{
|
||||
GContext.container.Resolve<DiggingGameManager>().DataModel.AddProp(_allGridProps[i].Data.PropId);
|
||||
PropData targetProp = UpdatePropState(_allGridProps[i].Data.PropId);
|
||||
isCheckPass = true;
|
||||
PropItem item = GetPropItemById(targetProp);
|
||||
if (item == null)
|
||||
{
|
||||
DiggingGameManager.LogError($"挖出的道具id:{_allGridProps[i].Data.PropId},上面的任务栏没有相应的道具槽位 ,检查去吧!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_allGridProps[i].Data.SetTargetPropItem(item);
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.PropEffect;
|
||||
AddToEffectList(_allGridProps[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (isCheckPass)
|
||||
{
|
||||
CheckClampPass();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新 新获得的道具状态
|
||||
/// </summary>
|
||||
/// <param name="propId"></param>
|
||||
private PropData UpdatePropState(int propId)
|
||||
{
|
||||
PropData[] allData = GContext.container.Resolve<DiggingGameManager>().DataModel.GetAllPropData();
|
||||
PropData propData;
|
||||
for (int i = 0; i < allData.Length; i++)
|
||||
{
|
||||
propData = allData[i];
|
||||
if (propData.IsOk == false && propData.PropId == propId)
|
||||
{
|
||||
propData.IsOk = true;
|
||||
return propData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool CheckResoucePropOpen(GridData gridData)
|
||||
{
|
||||
for (int i = 0; i < _allGridProps.Count; i++)
|
||||
{
|
||||
if (!_allGridProps[i].Data.AlreadyOpen && _allGridProps[i].Data.IsCanOpen() && _allGridProps[i].Data.Config.DiggingType is Resource)
|
||||
{
|
||||
AddToEffectList(_allGridProps[i]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private bool CheckSpecialEventOpen(GridData gridData)
|
||||
{
|
||||
for (int i = 0; i < _allSpecialGridProps.Count; i++)
|
||||
{
|
||||
if (!_allSpecialGridProps[i].Data.AlreadyOpen && _allSpecialGridProps[i].Data.IsCanOpen())
|
||||
{
|
||||
_allSpecialGridProps[i].ShowSandpit();
|
||||
AddToEffectList(_allSpecialGridProps[i]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private PropItem GetPropItemById(PropData propData)
|
||||
{
|
||||
for (int i = 0; i < _allProps.Count; i++)
|
||||
{
|
||||
if (_allProps[i].Data == propData)
|
||||
{
|
||||
return _allProps[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 开启道具,且道具动画播放完毕
|
||||
|
||||
private void OnGridPropEffectOver(GridPropEffectOver param)
|
||||
{
|
||||
int propId = param.propId;
|
||||
DiggingGameManager.LogWarning("道具动画播放完毕:propId::" + propId);
|
||||
|
||||
|
||||
//格子内道具 飞到目标后,自己消失 加载新的模型
|
||||
//ShowProp(propId); 如何这个执行 需要检查 propData.IsOk = true 的逻辑
|
||||
//if (param.isNormal)
|
||||
//{
|
||||
this._broadState = BroadEffectState.OverCheck;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// this._broadState = BroadEffectState.Check;
|
||||
//}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 检查是否通关
|
||||
|
||||
private async void CheckClampPass()
|
||||
{
|
||||
bool allFinded = true;
|
||||
for (int i = 0; i < _allProps.Count; i++)
|
||||
{
|
||||
if (!_allProps[i].Data.IsOk)
|
||||
{
|
||||
allFinded = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allFinded)
|
||||
{
|
||||
DiggingGameManager.LogError("恭喜你 通关了!");
|
||||
GContext.container.Resolve<DiggingGameManager>().DataModel.PassClamp();
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.BigShovelEffectTime);
|
||||
//爆炸所有剩余棋子
|
||||
List<GridItem> allRemainingGrids = new List<GridItem>();
|
||||
for (int i = 0; i < _allGrids.Count; i++)
|
||||
{
|
||||
if (_allGrids[i].Data.IsBorder == false && _allGrids[i].Data.IsOpen == false)
|
||||
{
|
||||
allRemainingGrids.Add(_allGrids[i]);
|
||||
}
|
||||
}
|
||||
int MaxCount = 20;
|
||||
//间隔时间
|
||||
int intervalTime = 100;
|
||||
|
||||
int allRemainingCount = allRemainingGrids.Count;
|
||||
if (allRemainingCount > MaxCount)
|
||||
{
|
||||
int count = allRemainingCount / MaxCount;
|
||||
intervalTime /= (count + 1);
|
||||
}
|
||||
for (int i = 0; i < allRemainingCount; i++)
|
||||
{
|
||||
allRemainingGrids[i].PlayPassClampEffect();
|
||||
await System.Threading.Tasks.Task.Delay(intervalTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
3
Assets/Scripts/SandDig/GameBroadLogic_Event.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameBroadLogic_Event.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 388ad0b34c064727ba1ef4adf05f8b60
|
||||
timeCreated: 1724064170
|
||||
329
Assets/Scripts/SandDig/GameBroadLogic_LoadEntity.cs
Normal file
329
Assets/Scripts/SandDig/GameBroadLogic_LoadEntity.cs
Normal file
@@ -0,0 +1,329 @@
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using System.Text;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using asap.core;
|
||||
using System.Threading.Tasks;
|
||||
using cfg;
|
||||
|
||||
namespace Script.RuntimeScript
|
||||
{
|
||||
public partial class GameBroadLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// 上面宝箱上的任务道具加载
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="data"></param>
|
||||
private void LoadAndInstantiateTaskProp(string address, PropData data)
|
||||
{
|
||||
//DiggingGameManager.LogError("开始 上面宝箱上的任务道具加载::: id:" + data.PropId);
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject propEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().PropContainer.transform, false);
|
||||
propEntity.name = address;
|
||||
|
||||
PropItem propScript = propEntity.AddComponent<PropItem>();
|
||||
propScript.Data = data;
|
||||
Vector3 LocalPos = data.LocalPos;
|
||||
LocalPos.z = 0;
|
||||
//LocalPos.y += 0.5f;
|
||||
propScript.transform.localPosition = LocalPos;
|
||||
_allProps.Add(propScript);
|
||||
if (data.IsOk) //已经获得的道具 隐藏起来
|
||||
{
|
||||
propScript.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 已经完成的任务道具加载
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="data"></param>
|
||||
private void LoadAndInstantiateGetedTaskProp(string address, PropData propData, float ItemFxScale)
|
||||
{
|
||||
DiggingGameManager.LogError("开始已经完成的任务道具加载:::id::" + propData.PropId);
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
DiggingGameManager.LogError("已经完成的任务道具加载:::id::" + propData.PropId);
|
||||
GameObject propEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().PropContainer.transform, false);
|
||||
propEntity.name = address;
|
||||
PropSparkItem propSparkItem = propEntity.AddComponent<PropSparkItem>();
|
||||
propSparkItem.Init(ItemFxScale);
|
||||
Vector3 LocalPos = propData.LocalPos;
|
||||
LocalPos.z = 0;
|
||||
//LocalPos.y += 0.5f;
|
||||
//LocalPos.z += SandDigEventConst.TargetPropOffsetZ;
|
||||
propEntity.transform.localPosition = LocalPos;
|
||||
propEntity.transform.localScale = Vector3.one * SandDigEventConst.GetScale;
|
||||
propEntity.transform.localEulerAngles = Vector3.zero;
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 棋盘背景格子加载
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="data"></param>
|
||||
private void LoadAndInstantiateBroad(string address, BroadData data)
|
||||
{
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject broadEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().BroadContainer.transform, false);
|
||||
BroadItem broadScript = broadEntity.AddComponent<BroadItem>();
|
||||
broadScript.Data = data;
|
||||
_allBroads.Add(broadScript);
|
||||
|
||||
broadEntity.transform.localPosition = data.LocalPos;
|
||||
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 棋子显示
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="data"></param>
|
||||
private void LoadAndInstantiateGrid(string address, GridData data)
|
||||
{
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject gridEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().GridContainer.transform, false);
|
||||
StringBuilder strB = new StringBuilder();
|
||||
strB.Append("grid _");
|
||||
strB.Append(data.Row);
|
||||
strB.Append("_");
|
||||
strB.Append(data.Col);
|
||||
gridEntity.name = strB.ToString();
|
||||
GridItem gridScript = gridEntity.AddComponent<GridItem>();
|
||||
gridScript.Data = data;
|
||||
_allGrids.Add(gridScript);
|
||||
gridEntity.transform.localPosition = data.LocalPos;
|
||||
gridEntity.SetActive(!data.IsOpen);
|
||||
if (!data.IsOpen && data.DoubleClick)
|
||||
{
|
||||
if (data.hasClickCount > 0)
|
||||
{
|
||||
gridScript.SetMash(GridMeshType.Mesh2);
|
||||
}
|
||||
}
|
||||
|
||||
_gridLoadedCount++;
|
||||
CheakAllGridPrefabLoaded();
|
||||
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格子下配置的普通道具显示
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="gridData"></param>
|
||||
private void LoadAndInstantiateGridProp(string address, GridPropData gridData)
|
||||
{
|
||||
//DiggingGameManager.LogError("开始格子下道具实体:::id::" + gridData.PropId);
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject gridPropEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().GridPropContainer.transform, false);
|
||||
GridPropItem gridPropScript = gridPropEntity.AddComponent<GridPropItem>();
|
||||
|
||||
int columns = GContext.container.Resolve<DiggingGameManager>().GetGridWidth();
|
||||
var showTime = GContext.container.Resolve<Tables>().TbGlobalConfig.DiggingPropShowTime;
|
||||
columns = columns - 3;
|
||||
if (columns < 0)
|
||||
{
|
||||
columns = 0;
|
||||
}
|
||||
if (columns >= showTime.Count)
|
||||
{
|
||||
columns = showTime.Count - 1;
|
||||
}
|
||||
gridPropScript.Init(gridData, showTime[columns]);
|
||||
|
||||
_allGridProps.Add(gridPropScript);
|
||||
|
||||
gridPropEntity.transform.localPosition = new Vector3(gridData.ParentGird.Row, gridData.ParentGird.Col, 0);
|
||||
gridPropEntity.transform.localEulerAngles = new Vector3(0, 0, -gridData.PropDirection);
|
||||
|
||||
gridPropEntity.SetActive(!gridData.IsCanOpen());
|
||||
gridPropEntity.name = address;
|
||||
//DiggingGameManager.LogError("格子下道具实体:::id::" + gridData.PropId + " x::" + gridPropEntity.transform.localPosition.x + " y:::" + gridPropEntity.transform.localPosition);
|
||||
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格子下模板道具加载
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="gridData"></param>
|
||||
/// <param name="prop"></param>
|
||||
/// <param name="urlType"></param>
|
||||
private void LoadAndInstantiateTempGridProp(string address, GridPropData gridData, PropTempData prop, UrlType urlType)
|
||||
{
|
||||
//DiggingGameManager.LogError("开始创建道具模板实体, id:::" + gridData.PropId);
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject gridPropEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().GridPropContainer.transform, false);
|
||||
//DiggingGameManager.LogError("创建道具模板实体,位置 x:" + prop.x + " y:" + prop.y + " id:::" + gridData.PropId);
|
||||
gridPropEntity.name = address;
|
||||
|
||||
if (urlType == UrlType.GridProp)
|
||||
{
|
||||
GridPropItem gridPropScript = gridPropEntity.AddComponent<GridPropItem>();
|
||||
|
||||
int columns = GContext.container.Resolve<DiggingGameManager>().GetGridWidth();
|
||||
var showTime = GContext.container.Resolve<Tables>().TbGlobalConfig.DiggingPropShowTime;
|
||||
columns = columns - 3;
|
||||
if (columns < 0)
|
||||
{
|
||||
columns = 0;
|
||||
}
|
||||
if (columns >= showTime.Count)
|
||||
{
|
||||
columns = showTime.Count - 1;
|
||||
}
|
||||
gridPropScript.Init(gridData, showTime[columns]);
|
||||
|
||||
_allGridProps.Add(gridPropScript);
|
||||
|
||||
gridPropEntity.transform.localEulerAngles = new Vector3(0, 0, -gridData.PropDirection);
|
||||
|
||||
}
|
||||
else if (urlType == UrlType.SpecialEvent)
|
||||
{
|
||||
SpecialEventItem spPropScript = gridPropEntity.AddComponent<SpecialEventItem>();
|
||||
spPropScript.Data = gridData;
|
||||
_allSpecialGridProps.Add(spPropScript);
|
||||
}
|
||||
|
||||
gridPropEntity.transform.localPosition = new Vector3(gridData.ParentGird.Row, gridData.ParentGird.Col, 0);
|
||||
gridPropEntity.SetActive(!gridData.IsCanOpen());
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 特殊事件显示
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="spData"></param>
|
||||
private void LoadAndInstantiateSpecialEvent(string address, GridPropData spData)
|
||||
{
|
||||
//DiggingGameManager.LogError("开始特殊事件实体::: id:" + spData.PropId);
|
||||
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject gridPropEntity = GameObject.Instantiate(obj.Result, GContext.container.Resolve<DiggingGameManager>().GridPropContainer.transform, false);
|
||||
gridPropEntity.name = address;
|
||||
|
||||
SpecialEventItem spPropScript = gridPropEntity.AddComponent<SpecialEventItem>();
|
||||
spPropScript.Data = spData;
|
||||
_allSpecialGridProps.Add(spPropScript);
|
||||
|
||||
gridPropEntity.transform.localPosition = new Vector3(spData.ParentGird.Row, spData.ParentGird.Col, 0);
|
||||
|
||||
gridPropEntity.SetActive(!spData.IsCanOpen());
|
||||
|
||||
//DiggingGameManager.LogError("特殊事件实体::: id:" + spData.PropId + " x::" + gridPropEntity.transform.localPosition.x + " y:::" + gridPropEntity.transform.localPosition);
|
||||
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
}
|
||||
public async Task<GameObject> LoadGameObject(string address, Transform parent)
|
||||
{
|
||||
TaskCompletionSource<GameObject> taskCompletion = new TaskCompletionSource<GameObject>();
|
||||
AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(address);
|
||||
handle.Completed += (AsyncOperationHandle<GameObject> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
GameObject gridPropEntity = GameObject.Instantiate(obj.Result, parent);
|
||||
gridPropEntity.name = address;
|
||||
|
||||
//DiggingGameManager.LogError("特殊事件实体::: id:" + spData.PropId + " x::" + gridPropEntity.transform.localPosition.x + " y:::" + gridPropEntity.transform.localPosition);
|
||||
taskCompletion.SetResult(gridPropEntity);
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
taskCompletion.SetResult(null);
|
||||
DiggingGameManager.LogError("Failed to load asset: " + address);
|
||||
}
|
||||
};
|
||||
return await taskCompletion.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SandDig/GameBroadLogic_LoadEntity.cs.meta
Normal file
11
Assets/Scripts/SandDig/GameBroadLogic_LoadEntity.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ac9a334913915741a339552ce85bfa5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Scripts/SandDig/GameScript.meta
Normal file
3
Assets/Scripts/SandDig/GameScript.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf0f279c65a3416f94513586fd1cb33f
|
||||
timeCreated: 1723804966
|
||||
10
Assets/Scripts/SandDig/GameScript/BroadItem.cs
Normal file
10
Assets/Scripts/SandDig/GameScript/BroadItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class BroadItem : MonoBehaviour
|
||||
{
|
||||
public BroadData Data { get; set; }
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/BroadItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/BroadItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d566f746e59488297aa129450b536f0
|
||||
timeCreated: 1723866882
|
||||
8
Assets/Scripts/SandDig/GameScript/DgSandBg.cs
Normal file
8
Assets/Scripts/SandDig/GameScript/DgSandBg.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DgSandBg : MonoBehaviour
|
||||
{
|
||||
public GameObject DgSand_bgend;
|
||||
}
|
||||
11
Assets/Scripts/SandDig/GameScript/DgSandBg.cs.meta
Normal file
11
Assets/Scripts/SandDig/GameScript/DgSandBg.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e4560b2d8650954bac0c77068c3538d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
304
Assets/Scripts/SandDig/GameScript/GridItem.cs
Normal file
304
Assets/Scripts/SandDig/GameScript/GridItem.cs
Normal file
@@ -0,0 +1,304 @@
|
||||
using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class GridItem : MonoBehaviour
|
||||
{
|
||||
|
||||
public GridData Data { get; set; }
|
||||
public GridEffectType GridEffectType { get; set; }
|
||||
GridEffectType Passive;
|
||||
private LayerMask _clickableLayer;
|
||||
|
||||
private GameObject _baseObj;
|
||||
private Animation _baseAni;
|
||||
|
||||
Transform fx_root;
|
||||
|
||||
/// <summary>
|
||||
/// 两个mesh 用来处理 点击两次的情况
|
||||
/// </summary>
|
||||
private GameObject _mesh1;
|
||||
private GameObject _mesh2;
|
||||
|
||||
private string[] _moveEffectNames = new string[] { "gridshake1", "gridshake2", "gridshake3" };
|
||||
private string _moveEffctName = string.Empty;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_clickableLayer = LayerMask.GetMask("Default");
|
||||
|
||||
_baseObj = transform.Find("AnimationRoot")?.gameObject;
|
||||
|
||||
if (_baseObj)
|
||||
{
|
||||
_mesh1 = _baseObj.FindChildGameObject("Mesh1");
|
||||
_mesh2 = _baseObj.FindChildGameObject("Mesh2");
|
||||
}
|
||||
|
||||
_baseAni = this.GetComponent<Animation>();
|
||||
|
||||
fx_root = transform.Find("fx_root");
|
||||
if (fx_root != null)
|
||||
{
|
||||
fx_root.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
SetMash(GridMeshType.Mesh1);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Data != null && Data.IsOpen == false && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, Mathf.Infinity, _clickableLayer))
|
||||
{
|
||||
if (hit.collider.gameObject == gameObject)
|
||||
{
|
||||
OnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 这个方法会被 overlay 相机影响
|
||||
// private void OnMouseDown()
|
||||
// {
|
||||
// DiggingGameManager.LogError("x::" + Data.Row + " y::" + Data.Col + " Data.IsBorder::" + Data.IsBorder);
|
||||
// OnClick();
|
||||
// }
|
||||
|
||||
public async void OnClick()
|
||||
{
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
if (diggingGameManager.GameState != SandDigGameState.Going)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!diggingGameManager.IsCanClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int digCount = diggingGameManager.DataModel.GetDigCount();
|
||||
|
||||
if (digCount <= 0)
|
||||
{
|
||||
int propId = diggingGameManager.GetActivityPropId();
|
||||
if (propId > 0)
|
||||
{
|
||||
cfg.Item item = GContext.container.Resolve<Tables>().GetItemData(propId);
|
||||
string itemName = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_75", itemName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
diggingGameManager.DataModel.UseDig();
|
||||
}
|
||||
if (!Data.IsBorder)
|
||||
{
|
||||
diggingGameManager.IsCanClick = false;
|
||||
if (Data.DoubleClick && Data.hasClickCount < 1)
|
||||
{
|
||||
int level = diggingGameManager.GetCurLevel();
|
||||
int clickCount = diggingGameManager.DataModel.GetClickCount();
|
||||
diggingGameManager.SandDigPoint(GridType.None, level, clickCount);
|
||||
Data.IsOpen = false;
|
||||
Data.hasClickCount++;
|
||||
Passive = GridEffectType.DoubleClick;
|
||||
|
||||
GridEffectType = GridEffectType.DoubleClick;
|
||||
|
||||
diggingGameManager.DataModel.SaveAll();
|
||||
|
||||
diggingGameManager.ShowDigEffect(ClickDigType.Smail, Data.LocalPos);
|
||||
|
||||
PlayEffect();
|
||||
await Task.Delay(SandDigEventConst.ShovelAnimTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.IsOpen = true;
|
||||
EventGridClick eventGridClick = new EventGridClick(Data, false);
|
||||
GContext.Publish(eventGridClick);
|
||||
bool isBig = eventGridClick.IsBigDig;
|
||||
//DiggingGameManager.LogError("大挖不:::" + isBig);
|
||||
GridEffectType = isBig ? GridEffectType.ClickBigDig : GridEffectType.ClickDig;
|
||||
PlayEffect();
|
||||
if (isBig)
|
||||
await Task.Delay(SandDigEventConst.BigShovelAnimTime);
|
||||
else
|
||||
await Task.Delay(SandDigEventConst.ShovelAnimTime);
|
||||
if (isBig)
|
||||
{
|
||||
await Task.Delay(2000);
|
||||
}
|
||||
}
|
||||
diggingGameManager.IsCanClick = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 被动爆炸 触发点击
|
||||
/// </summary>
|
||||
public void PassiveClick()
|
||||
{
|
||||
if (gameObject.activeSelf && !Data.IsBorder)
|
||||
{
|
||||
if (Data.DoubleClick && Data.hasClickCount < 1)
|
||||
{
|
||||
Data.IsOpen = false;
|
||||
Data.hasClickCount++;
|
||||
Passive = GridEffectType;
|
||||
GridEffectType = GridEffectType.DoubleClick;
|
||||
PlayEffect();
|
||||
GContext.container.Resolve<DiggingGameManager>().DataModel.SaveAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.IsOpen = true;
|
||||
PlayEffect();
|
||||
GContext.Publish(new EventGridClick(Data, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayPassClampEffect()
|
||||
{
|
||||
GridEffectType = GridEffectType.PassClamp;
|
||||
PlayEffect();
|
||||
}
|
||||
|
||||
private void PlayEffect()
|
||||
{
|
||||
StartCoroutine(IEPlayEffect());
|
||||
}
|
||||
// public const int BigShovelEffectTime = 833;//特效出现延迟
|
||||
//public const int BigShovelBlockAnimTime = 866;//块消失动画播放时间
|
||||
//public const int BigShovelBlockDisappearTime = 1133;//块消失时间
|
||||
IEnumerator PlayBigEffect(int EffectTime)
|
||||
{
|
||||
yield return new WaitForSeconds(EffectTime * 0.001f);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
}
|
||||
IEnumerator PlayBigAni(int BigShovelBlockAnimTime)
|
||||
{
|
||||
yield return new WaitForSeconds(BigShovelBlockAnimTime * 0.001f);
|
||||
_baseAni?.Play("griddisappear");
|
||||
}
|
||||
IEnumerator IEPlayEffect()
|
||||
{
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
var configInit = diggingGameManager.DataModel.digActivityConfig;
|
||||
if (GridEffectType == GridEffectType.ClickDig)
|
||||
{
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
//普通挖掘效果
|
||||
StartCoroutine(PlayBigEffect(SandDigEventConst.ShovelEffectTime));
|
||||
StartCoroutine(PlayBigAni(SandDigEventConst.ShovelBlockAnimTime));
|
||||
|
||||
//_digEffect.SetActive(true);
|
||||
//SetMash(GridMeshType.None);
|
||||
yield return new WaitForSeconds(SandDigEventConst.ShovelBlockDisappearTime * 0.001f);
|
||||
//_digEffect.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.ClickBigDig)
|
||||
{
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
//挖到了道具的特殊特效
|
||||
StartCoroutine(PlayBigEffect(SandDigEventConst.BigShovelEffectTime));
|
||||
StartCoroutine(PlayBigAni(SandDigEventConst.BigShovelBlockAnimTime));
|
||||
yield return new WaitForSeconds(SandDigEventConst.BigShovelBlockDisappearTime * 0.001f);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.DoubleClick)
|
||||
{
|
||||
//挖两次才能打开的格子特效
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
float time = SandDigEventConst.ShovelEffectTime * 0.001f;
|
||||
if (Passive == GridEffectType.PassiveBomb)
|
||||
{
|
||||
time = configInit.BombBlockAniTime;
|
||||
}
|
||||
else if (Passive == GridEffectType.PassiveClear)
|
||||
{
|
||||
time = configInit.BombBlockAniTime;
|
||||
}
|
||||
yield return new WaitForSeconds(time);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
SetMash(GridMeshType.Mesh2);
|
||||
yield return new WaitForSeconds(1);
|
||||
fx_root.gameObject.SetActive(false);
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.PassiveBomb)
|
||||
{
|
||||
yield return new WaitForSeconds(configInit.BombBlockAniTime);
|
||||
//随机晃动
|
||||
System.Random random = new System.Random();
|
||||
int randomNumber = random.Next(0, _moveEffectNames.Length);
|
||||
_moveEffctName = _moveEffectNames[randomNumber];
|
||||
_baseAni?.Play(_moveEffctName);
|
||||
//yield return new WaitForSeconds(1);
|
||||
//特效触发
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
//SetMash(GridMeshType.None);
|
||||
yield return new WaitForSeconds(SandDigEventConst.BombBlockDisappearTime * 0.001f);
|
||||
_baseAni.Stop();
|
||||
fx_root.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.PassiveClear)
|
||||
{
|
||||
yield return new WaitForSeconds(configInit.ClearBlockAniTime);
|
||||
//随机晃动
|
||||
System.Random random = new System.Random();
|
||||
int randomNumber = random.Next(0, _moveEffectNames.Length);
|
||||
_moveEffctName = _moveEffectNames[randomNumber];
|
||||
_baseAni?.Play(_moveEffctName);
|
||||
//特效触发
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
//SetMash(GridMeshType.None);
|
||||
yield return new WaitForSeconds(SandDigEventConst.ClearBlockDisappearTime * 0.001f);
|
||||
_baseAni.Stop();
|
||||
fx_root.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.PassClamp)
|
||||
{
|
||||
//挖通关了 ,清屏
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMash(GridMeshType type)
|
||||
{
|
||||
_mesh1?.SetActive(false);
|
||||
_mesh2?.SetActive(false);
|
||||
if (type == GridMeshType.Mesh1)
|
||||
{
|
||||
_mesh1?.SetActive(true);
|
||||
}
|
||||
else if (type == GridMeshType.Mesh2)
|
||||
{
|
||||
_mesh2?.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/GridItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/GridItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 405c66376b2f4e8a9fbc9fc8e7bef9c6
|
||||
timeCreated: 1723805058
|
||||
175
Assets/Scripts/SandDig/GameScript/GridPropItem.cs
Normal file
175
Assets/Scripts/SandDig/GameScript/GridPropItem.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using Script.RuntimeScript.Interface;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class GridPropItem : MonoBehaviour, BroadEffectInterface
|
||||
{
|
||||
public int PlayEffectPriority { set; get; } = 1;
|
||||
/// <summary>
|
||||
/// 飞行动画
|
||||
/// </summary>
|
||||
private MoveWithCurve _effectScript;
|
||||
/// <summary>
|
||||
/// 展示动画
|
||||
/// </summary>
|
||||
private Animation _showEffect;
|
||||
GameObject DgSand;
|
||||
GameObject DgSandShadow;
|
||||
Transform fx_diggingitem_drop;
|
||||
public DiggingItemProp EffectType { get; set; }
|
||||
private GridPropData _data;
|
||||
Vector3 PositionRootLocalPos;
|
||||
public GridPropData Data
|
||||
{
|
||||
get { return _data; }
|
||||
set
|
||||
{
|
||||
_data = value;
|
||||
EffectType = _data.Config.DiggingType;
|
||||
}
|
||||
}
|
||||
bool isNormal = true;
|
||||
public async void Init(GridPropData data, float time)
|
||||
{
|
||||
Data = data;
|
||||
isNormal = EffectType is Normal;
|
||||
_effectScript = this.gameObject.GetComponent<MoveWithCurve>();
|
||||
PositionRootLocalPos = transform.Find("PositionRoot").localPosition;
|
||||
Transform animationRoot = transform.Find("PositionRoot/AnimationRoot");
|
||||
_showEffect = animationRoot.GetComponent<Animation>();
|
||||
if (isNormal)
|
||||
{
|
||||
DgSand = animationRoot.GetChild(0).gameObject;
|
||||
DgSandShadow = animationRoot.GetChild(1).gameObject;
|
||||
|
||||
fx_diggingitem_drop = animationRoot.Find("fx_diggingitem_drop");
|
||||
if (fx_diggingitem_drop != null)
|
||||
{
|
||||
fx_diggingitem_drop.localScale = Vector3.one * Data.Config.ItemFxScale;
|
||||
}
|
||||
SetShowShadow(true);
|
||||
if (_showEffect != null)
|
||||
{
|
||||
_showEffect.transform.localScale = Vector3.zero;
|
||||
await Awaiters.Seconds(time);
|
||||
_showEffect?.Play("propshow");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetShowShadow(bool value)
|
||||
{
|
||||
if (isNormal)
|
||||
{
|
||||
DgSand.SetActive(!value);
|
||||
DgSandShadow.SetActive(value);
|
||||
}
|
||||
}
|
||||
public async void PlayEffect(bool overCheck)
|
||||
{
|
||||
int upDelay = SandDigEventConst.UpDelay;
|
||||
if (overCheck)
|
||||
{
|
||||
upDelay = SandDigEventConst.InUpDelay;
|
||||
}
|
||||
await System.Threading.Tasks.Task.Delay(upDelay);
|
||||
if (EffectType is Normal)
|
||||
{
|
||||
SetShowShadow(false);
|
||||
PlayNormalEffect(PlayNormalPropFly);
|
||||
}
|
||||
else if (EffectType is Resource)
|
||||
{
|
||||
PlayResourceEffect(PlayResourcePropFly);
|
||||
}
|
||||
}
|
||||
|
||||
private async void PlayNormalPropFly()
|
||||
{
|
||||
_showEffect?.Play("propshake");
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
diggingGameManager.ShowFX(Data.Config.Fx, false);
|
||||
diggingGameManager.ShowFX(Data.Config.Fx, true);
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.UpWaitTime + SandDigEventConst.ShovelEffectTime);
|
||||
|
||||
if (Data.TargetPropItem == null)
|
||||
{
|
||||
DiggingGameManager.LogWarning("没找到目标 ,原地消失");
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
_effectScript.SetStartPosition(_effectScript.transform.position);
|
||||
_effectScript.EndPoint = Data.TargetPropItem.transform.position;
|
||||
//_effectScript.EndPoint.z += SandDigEventConst.TargetPropOffsetZ;
|
||||
_effectScript.Begin(() =>
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemdrop"));
|
||||
//隐藏目标道具
|
||||
Data.TargetPropItem.gameObject.SetActive(false);
|
||||
if (fx_diggingitem_drop != null)
|
||||
{
|
||||
fx_diggingitem_drop.gameObject.SetActive(true);
|
||||
}
|
||||
PropSparkItem propSparkItem = gameObject.AddComponent<PropSparkItem>();
|
||||
propSparkItem.Init(Data.Config.ItemFxScale);
|
||||
GContext.Publish(new GridPropEffectOver(Data.PropId, true));
|
||||
});
|
||||
this.transform.DOScale(SandDigEventConst.GetScale, 0.5f);
|
||||
}
|
||||
|
||||
private async void PlayResourcePropFly()
|
||||
{
|
||||
_showEffect?.Play("scale");
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.ResourceEffectTime + SandDigEventConst.ShovelEffectTime);
|
||||
|
||||
this.gameObject.SetActive(false);
|
||||
GContext.Publish(new GridPropEffectOver(Data.PropId, true));
|
||||
|
||||
Vector3 worldPosition = this.transform.position;
|
||||
Vector3 screenPosition = ConvertTools.WorldToScreenPoint(worldPosition);
|
||||
screenPosition.z = 0;
|
||||
|
||||
Resource res = (EffectType as Resource);
|
||||
DiggingGameManager.LogError("添加道具:" + res.ItemID + " count:" + res.Param + " pos::" + screenPosition.ToString());
|
||||
GContext.Publish(new EventSandDigAddItem(res.ItemID, res.Param, screenPosition));
|
||||
}
|
||||
|
||||
|
||||
private void PlayNormalEffect(Action effectOver)
|
||||
{
|
||||
this.transform.DORotate(new Vector3(0, 0, 0), SandDigEventConst.UpTime)
|
||||
.SetLoops(-1, LoopType.Incremental)
|
||||
.SetEase(Ease.Linear);
|
||||
|
||||
Vector3 targetPositon = GContext.container.Resolve<DiggingGameManager>().ShowPropPositon.transform.position;
|
||||
Vector3 toPostion = new Vector3(targetPositon.x, targetPositon.y, SandDigEventConst.UpValue);
|
||||
Vector3 offstPosition = PositionRootLocalPos;
|
||||
offstPosition.x *= SandDigEventConst.UpScale;
|
||||
offstPosition.y *= SandDigEventConst.UpScale;
|
||||
offstPosition.z = 0;
|
||||
toPostion -= offstPosition;
|
||||
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemfly"));
|
||||
|
||||
this.transform.DOMove(toPostion, SandDigEventConst.UpTime).OnComplete(() =>
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemshake"));
|
||||
this.transform.DOKill(); // 停止旋转动画
|
||||
this.transform.rotation = Quaternion.identity; // 角度变为0
|
||||
effectOver.Invoke();
|
||||
}).SetId(this);
|
||||
this.transform.DOScale(new Vector3(SandDigEventConst.UpScale, SandDigEventConst.UpScale, SandDigEventConst.UpScale), SandDigEventConst.UpTime);
|
||||
}
|
||||
|
||||
private void PlayResourceEffect(Action effectOver)
|
||||
{
|
||||
effectOver.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/GridPropItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/GridPropItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ae4a1cbefb74d4c82d94e70d85d5f5e
|
||||
timeCreated: 1723895712
|
||||
78
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs
Normal file
78
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveWithCurve : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public Vector3 EndPoint = new Vector3();
|
||||
[Tooltip("x轴路线形状 起始和结尾 点值必须为0")]
|
||||
public AnimationCurve CurveX;
|
||||
[Tooltip("y轴路线形状 起始和结尾 点值必须为0")]
|
||||
public AnimationCurve CurveY;
|
||||
[Tooltip("z轴路线形状 起始和结尾 点值必须为0")]
|
||||
public AnimationCurve CurveZ;
|
||||
[Tooltip("y轴运动速度 结尾点值必须为1")]
|
||||
public AnimationCurve CurveSpeedY;
|
||||
[Tooltip("z轴运动速度 结尾点值必须为1")]
|
||||
public AnimationCurve CurveSpeedZ;
|
||||
[Tooltip("弧度缩放系数")]
|
||||
public float RadianScale = 1f;
|
||||
|
||||
private float _duration = 0.5f;
|
||||
private float _elapsedTime = 0f;
|
||||
private Vector3 _startPoint = Vector3.zero;
|
||||
|
||||
private bool _begin = false;
|
||||
private Action _effectOver;
|
||||
|
||||
public void Begin(Action callBack)
|
||||
{
|
||||
_begin = true;
|
||||
_elapsedTime = 0;
|
||||
_effectOver = callBack;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
if (CurveX.length > 0)
|
||||
{
|
||||
float startTime = CurveX.keys[0].time;
|
||||
float endTime = CurveX.keys[CurveX.length - 1].time;
|
||||
_duration = endTime - startTime;
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
public void SetStartPosition(Vector3 value)
|
||||
{
|
||||
_startPoint = value;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!_begin) return;
|
||||
_elapsedTime += Time.deltaTime;
|
||||
if (_elapsedTime > _duration)
|
||||
{
|
||||
_elapsedTime = _duration;
|
||||
_begin = false;
|
||||
_effectOver?.Invoke();
|
||||
}
|
||||
|
||||
Vector3 l = Vector3.Lerp(_startPoint, EndPoint, _elapsedTime/_duration);
|
||||
float speedY = CurveSpeedY != null?CurveSpeedY.Evaluate(_elapsedTime):1;
|
||||
float speedZ = CurveSpeedZ != null?CurveSpeedZ.Evaluate(_elapsedTime):1;
|
||||
// 使用曲线计算位置
|
||||
|
||||
float newX = CurveX.Evaluate(_elapsedTime) * RadianScale + l.x;
|
||||
float newY = CurveY.Evaluate(_elapsedTime) * RadianScale * speedY + l.y;
|
||||
float newZ = CurveZ.Evaluate(_elapsedTime) * RadianScale * speedZ + l.z;
|
||||
transform.position = new Vector3(newX, newY, newZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs.meta
Normal file
11
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eee85decfac6d54ab44d0b613ce8308
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs
Normal file
33
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using asap.core;
|
||||
using Game;
|
||||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class PropBoxItem : MonoBehaviour
|
||||
{
|
||||
public GameObject fx_diggingbox_finish;
|
||||
IDisposable disposable;
|
||||
private void OnEnable()
|
||||
{
|
||||
disposable = GContext.OnEvent<EventSandDigNewClamp>().Subscribe(OnPassClamp);
|
||||
}
|
||||
private void OnPassClamp(EventSandDigNewClamp obj)
|
||||
{
|
||||
//if (transform.childCount > 0)
|
||||
//{
|
||||
// fx_diggingbox_finish = transform.GetChild(0).gameObject;
|
||||
fx_diggingbox_finish?.SetActive(false);
|
||||
fx_diggingbox_finish?.SetActive(true);
|
||||
//}
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemfinish"));
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df38683d1998f6d4988725f7723d5b04
|
||||
timeCreated: 1723805031
|
||||
10
Assets/Scripts/SandDig/GameScript/PropItem.cs
Normal file
10
Assets/Scripts/SandDig/GameScript/PropItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class PropItem : MonoBehaviour
|
||||
{
|
||||
public PropData Data { get; set; }
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/PropItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/PropItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dfab24de1004add865226887084c530
|
||||
timeCreated: 1723805031
|
||||
39
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs
Normal file
39
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class PropSparkItem : MonoBehaviour
|
||||
{
|
||||
Transform fx_diggingitem_spark;
|
||||
private void Awake()
|
||||
{
|
||||
fx_diggingitem_spark = transform.Find("PositionRoot/AnimationRoot/fx_diggingitem_spark");
|
||||
}
|
||||
|
||||
public void Init(float ItemFxScale)
|
||||
{
|
||||
if (fx_diggingitem_spark)
|
||||
{
|
||||
fx_diggingitem_spark.localScale = Vector3.one * ItemFxScale;
|
||||
StartCoroutine(PlaySpark());
|
||||
}
|
||||
}
|
||||
IEnumerator PlaySpark()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int seconds = Random.Range(2, 4);
|
||||
yield return new WaitForSeconds(seconds);
|
||||
fx_diggingitem_spark.gameObject.SetActive(true);
|
||||
seconds = Random.Range(2, 4);
|
||||
yield return new WaitForSeconds(seconds);
|
||||
fx_diggingitem_spark.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 949a91166c4618d46803fd57e45eb0f7
|
||||
timeCreated: 1723805031
|
||||
81
Assets/Scripts/SandDig/GameScript/SpecialEventItem.cs
Normal file
81
Assets/Scripts/SandDig/GameScript/SpecialEventItem.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Game;
|
||||
using Script.RuntimeScript.Interface;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class SpecialEventItem : MonoBehaviour, BroadEffectInterface
|
||||
{
|
||||
public int PlayEffectPriority { set; get; } = 0;
|
||||
public GridPropData Data { get; set; }
|
||||
|
||||
private Animation _ani;
|
||||
GameObject animationRoot;
|
||||
GameObject dgSand_sandpit;
|
||||
private void Awake()
|
||||
{
|
||||
animationRoot = this.transform.Find("AnimationRoot").gameObject;
|
||||
dgSand_sandpit = this.transform.Find("SandpitRoot").gameObject;
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
dgSand_sandpit.SetActive(false);
|
||||
animationRoot.SetActive(false);
|
||||
this.gameObject.SetActive(true);
|
||||
}
|
||||
public void ShowSandpit()
|
||||
{
|
||||
dgSand_sandpit.SetActive(true);
|
||||
}
|
||||
public async void PlayEffect(bool overCheck)
|
||||
{
|
||||
int upDelay = SandDigEventConst.BigShovelAnimTime;
|
||||
if (overCheck)
|
||||
{
|
||||
upDelay = SandDigEventConst.InUpDelay;
|
||||
}
|
||||
await System.Threading.Tasks.Task.Delay(upDelay);
|
||||
animationRoot.SetActive(true);
|
||||
if (_ani == null)
|
||||
{
|
||||
_ani = animationRoot.GetComponent<Animation>();
|
||||
}
|
||||
string effectName = string.Empty;
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
var configInit = diggingGameManager.DataModel.digActivityConfig;
|
||||
float time = configInit.SpecRowColAniTime;
|
||||
if (Data.Config.DiggingType is BombClear)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_starfish"));
|
||||
effectName = (Data.Config.DiggingType as BombClear).AppearAnim;
|
||||
//time = SandDigEventConst.BombAnimTime;
|
||||
time = configInit.SpecBombAniTime;
|
||||
}
|
||||
else if (Data.Config.DiggingType is ColumnClear)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_crab"));
|
||||
effectName = (Data.Config.DiggingType as ColumnClear).AppearAnim;
|
||||
}
|
||||
else if (Data.Config.DiggingType is RowClear)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_crab"));
|
||||
effectName = (Data.Config.DiggingType as RowClear).AppearAnim;
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogWarning("特殊事件没有配置动画,请检查!");
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
GContext.Publish(new ExplosionClick(this));
|
||||
if (!string.IsNullOrEmpty(effectName))
|
||||
{
|
||||
_ani.Play(effectName);
|
||||
await Awaiters.Seconds(time);
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd301704dc534d62ba8eb9d1df7834a4
|
||||
timeCreated: 1723805107
|
||||
130
Assets/Scripts/SandDig/HomeSandigButton.cs
Normal file
130
Assets/Scripts/SandDig/HomeSandigButton.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using Script.RuntimeScript;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HomeSandigButton : EventButtonResource
|
||||
{
|
||||
public Button btn_sandig;
|
||||
public TMP_Text txt_sandig;
|
||||
public Image icon_sandig;
|
||||
private Timer _sanddingTime;
|
||||
Tables _tables;
|
||||
int activityId;
|
||||
//4-1
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_sandig.onClick.AddListener(OnClickSandDig);
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
activityId = GContext.container.Resolve<DiggingGameManager>().GetActivityId();
|
||||
if (activityId <= 0)
|
||||
{
|
||||
btn_sandig.gameObject.SetActive(false);
|
||||
txt_sandig.text = string.Empty;
|
||||
return;
|
||||
}
|
||||
var eventData = _tables.TbFishingEvent.GetOrDefault(activityId);
|
||||
if (eventData != null)
|
||||
{
|
||||
var sandInit = _tables.TbDiggingActivityInit.GetOrDefault(eventData.RedirectID);
|
||||
List<string> strings = new List<string>() { sandInit.Icon };
|
||||
strings.AddRange(sandInit.DownloadLabel);
|
||||
CheckResource(strings);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_sandig.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
void OnClickSandDig()
|
||||
{
|
||||
InSandDigAct();
|
||||
}
|
||||
async void InSandDigAct()
|
||||
{
|
||||
activityId = GContext.container.Resolve<DiggingGameManager>().GetActivityId();
|
||||
if (activityId <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var eventData = _tables.TbFishingEvent.GetOrDefault(activityId);
|
||||
if (eventData != null)
|
||||
{
|
||||
var sandInit = _tables.TbDiggingActivityInit.GetOrDefault(eventData.RedirectID);
|
||||
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
bool isCanEnter = await loadResourceService.Loads(sandInit.DownloadLabel);
|
||||
if (isCanEnter)
|
||||
{
|
||||
EnterSandDigAct();
|
||||
}
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, EnterSandDigAct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnterSandDigAct()
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct("SandDigAct"));
|
||||
}
|
||||
private void ShowSandDigTime()
|
||||
{
|
||||
//显示倒计时
|
||||
if (_sanddingTime == null)
|
||||
{
|
||||
activityId = GContext.container.Resolve<DiggingGameManager>().GetActivityId();
|
||||
if (activityId <= 0)
|
||||
{
|
||||
btn_sandig.gameObject.SetActive(false);
|
||||
txt_sandig.text = string.Empty;
|
||||
return;
|
||||
}
|
||||
var eventData = _tables.TbFishingEvent.GetOrDefault(activityId);
|
||||
if (eventData != null)
|
||||
{
|
||||
var sandInit = _tables.TbDiggingActivityInit.GetOrDefault(eventData.RedirectID);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_sandig, sandInit.Icon);
|
||||
}
|
||||
btn_sandig.gameObject.SetActive(true);
|
||||
DateTime endTime = GContext.container.Resolve<FishingEventData>().GetEventEndTime(activityId);
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
double seconds = now.TotalSeconds;
|
||||
_sanddingTime = this.AttachTimer((float)seconds,
|
||||
RefreshSandDig,
|
||||
(elapsed) =>
|
||||
{
|
||||
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
txt_sandig.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}, useRealTime: true);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshSandDig()
|
||||
{
|
||||
_sanddingTime?.Cancel();
|
||||
_sanddingTime = null;
|
||||
btn_sandig.gameObject.SetActive(false);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
_sanddingTime?.Cancel();
|
||||
_sanddingTime = null;
|
||||
}
|
||||
protected override void OnLoadEventResource()
|
||||
{
|
||||
ShowSandDigTime();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SandDig/HomeSandigButton.cs.meta
Normal file
11
Assets/Scripts/SandDig/HomeSandigButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8b184f3d0b21dd449d724c2b5a5c710
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Scripts/SandDig/Interface.meta
Normal file
3
Assets/Scripts/SandDig/Interface.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf88e2e939274e45ab523eba8d87c11d
|
||||
timeCreated: 1724065119
|
||||
10
Assets/Scripts/SandDig/Interface/BroadEffectInterface.cs
Normal file
10
Assets/Scripts/SandDig/Interface/BroadEffectInterface.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using cfg;
|
||||
|
||||
namespace Script.RuntimeScript.Interface
|
||||
{
|
||||
public interface BroadEffectInterface
|
||||
{
|
||||
public int PlayEffectPriority { set; get; }
|
||||
public void PlayEffect(bool overCheck);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01b1559d3c6e4a2c90999768a6af783f
|
||||
timeCreated: 1724065139
|
||||
10
Assets/Scripts/SandDig/Interface/IExplosion.cs
Normal file
10
Assets/Scripts/SandDig/Interface/IExplosion.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.ExplosionEffect
|
||||
{
|
||||
public interface IExplosion
|
||||
{
|
||||
public void Play(SpecialEventItem item);
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/Interface/IExplosion.cs.meta
Normal file
3
Assets/Scripts/SandDig/Interface/IExplosion.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68ae1c0dfc194e15b034c53d3a88a3fd
|
||||
timeCreated: 1724319686
|
||||
131
Assets/Scripts/SandDig/SandDigEventConst.cs
Normal file
131
Assets/Scripts/SandDig/SandDigEventConst.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using Script.RuntimeScript.Interface;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using Vector3 = UnityEngine.Vector3;
|
||||
|
||||
|
||||
public class SandDigEventConst
|
||||
{
|
||||
#region 动画相关
|
||||
|
||||
//大铲子动画时长
|
||||
public const int BigShovelAnimTime = 1166;//动画总时长
|
||||
public const int BigShovelEffectTime = 833;//特效出现延迟
|
||||
public const int BigShovelEffectDisappearDelay = 1500;//特效消失延迟,是相对于出现时间的延迟
|
||||
public const int BigShovelBlockAnimTime = 866;//块消失动画播放时间
|
||||
public const int BigShovelBlockDisappearTime = 1366;//块消失时间
|
||||
|
||||
//小铲子动画时长
|
||||
public const int ShovelAnimTime = 750;//动画总时长
|
||||
public const int ShovelEffectTime = 500;//特效出现延迟
|
||||
public const int ShovelEffectDisappearDelay = 1500;//特效消失延迟,是相对于出现时间的延迟
|
||||
public const int ShovelBlockAnimTime = 533;//块消失动画播放时间
|
||||
public const int ShovelBlockDisappearTime = 1033;
|
||||
|
||||
//炸弹动画时长
|
||||
//public const int BombAnimTime = 1533;//动画总时长
|
||||
//public const int BombBlockAnimTime = 1166;//块开始播放消失动画的延迟,从炸弹动画开始播算起
|
||||
public const int BombBlockDisappearTime = 1666;//块销毁时间,从消失动画开始播算起
|
||||
|
||||
//行列消除器动画时长
|
||||
//public const int ClearAnimTime = 1266;//动画总时长
|
||||
//public const int ClearBlockAnimTime = 866;//块开始播放消失动画的延迟,从消除器动画开始播算起
|
||||
public const int ClearBlockDisappearI = 66;//块的间隔消失时间
|
||||
public const int ClearBlockDisappearTime = 1366;//块销毁时间,从消失动画开始播算起,注意是每个块单独的时间
|
||||
|
||||
//上浮延迟
|
||||
public const int UpDelay = 1500;
|
||||
public const int InUpDelay = 250;
|
||||
//上浮值
|
||||
public const int UpValue = -5;
|
||||
//上浮动画时长
|
||||
public const float UpTime = 0.5f;
|
||||
//上浮缩放值
|
||||
public const float UpScale = 2;
|
||||
//上浮动画结束停留时长(毫秒)
|
||||
public const int UpWaitTime = 800;
|
||||
//资源道具动画时长
|
||||
public const int ResourceEffectTime = 1100;
|
||||
|
||||
//道具获得后 缩放值
|
||||
public const float GetScale = 0.6f;
|
||||
public const float GetScaleTime = 0.6f;
|
||||
|
||||
#endregion
|
||||
|
||||
//挖出道具 飞到目标点后 z 轴突出距离 (防止穿帮)
|
||||
public const float TargetPropOffsetZ = -0.15f;
|
||||
|
||||
}
|
||||
public struct ExplosionClick
|
||||
{
|
||||
public ExplosionClick(BroadEffectInterface effect)
|
||||
{
|
||||
this.effect = effect;
|
||||
}
|
||||
public BroadEffectInterface effect;
|
||||
}
|
||||
|
||||
public struct GridPropEffectOver
|
||||
{
|
||||
public GridPropEffectOver(int value, bool isNormal)
|
||||
{
|
||||
this.propId = value;
|
||||
this.isNormal = isNormal;
|
||||
}
|
||||
public int propId;
|
||||
public bool isNormal;
|
||||
}
|
||||
|
||||
public class EventGridClick
|
||||
{
|
||||
public EventGridClick(GridData data, bool passiveClick = false)
|
||||
{
|
||||
this.Data = data;
|
||||
this.PassiveClick = passiveClick;
|
||||
}
|
||||
public GridData Data;
|
||||
public bool PassiveClick;
|
||||
public bool IsBigDig;
|
||||
}
|
||||
|
||||
|
||||
public struct RefreshHomePanelSandDigBar
|
||||
{
|
||||
public RefreshHomePanelSandDigBar(int add)
|
||||
{
|
||||
this.activityInt = add;
|
||||
}
|
||||
//活动积分
|
||||
public int activityInt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新铲子个数
|
||||
/// </summary>
|
||||
public struct EventSandDigPropUpdate { }
|
||||
|
||||
|
||||
public struct EventSandDigNewClamp
|
||||
{
|
||||
public EventSandDigNewClamp(int clampId)
|
||||
{
|
||||
this.ClampId = clampId;
|
||||
}
|
||||
public int ClampId;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源道具
|
||||
/// </summary>
|
||||
public struct EventSandDigAddItem
|
||||
{
|
||||
public EventSandDigAddItem(int id, int count, Vector3 pos)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Count = count;
|
||||
this.Pos = pos;
|
||||
}
|
||||
public int Id;
|
||||
public int Count;
|
||||
public Vector3 Pos;
|
||||
}
|
||||
|
||||
3
Assets/Scripts/SandDig/SandDigEventConst.cs.meta
Normal file
3
Assets/Scripts/SandDig/SandDigEventConst.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0cb6edf88bb43cb97fe5b835d41b14a
|
||||
timeCreated: 1725886688
|
||||
3
Assets/Scripts/SandDig/model.meta
Normal file
3
Assets/Scripts/SandDig/model.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 299516ae0e564b8e8b90d5aac321ff68
|
||||
timeCreated: 1723804766
|
||||
3
Assets/Scripts/SandDig/model/Data.meta
Normal file
3
Assets/Scripts/SandDig/model/Data.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2edda2340cb3420e83671f9efaaaf3c3
|
||||
timeCreated: 1723805251
|
||||
11
Assets/Scripts/SandDig/model/Data/BroadData.cs
Normal file
11
Assets/Scripts/SandDig/model/Data/BroadData.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class BroadData
|
||||
{
|
||||
public int ID = 201;
|
||||
public Vector3 LocalPos = Vector3.zero;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/BroadData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/BroadData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75757a48f91646249ebf60d91fe6b665
|
||||
timeCreated: 1723866522
|
||||
104
Assets/Scripts/SandDig/model/Data/DinggingSceneData.cs
Normal file
104
Assets/Scripts/SandDig/model/Data/DinggingSceneData.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using Random = System.Random;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class DinggingSceneData
|
||||
{
|
||||
public string BoxPositionJson;
|
||||
public string AllBroadJson;
|
||||
public string AllPropJson;
|
||||
public string AllCubeJson;
|
||||
public string AllTempJson;
|
||||
|
||||
private BroadData[] _allBroadData;
|
||||
private GridData[] _allGridData;
|
||||
private PropData[] _allPropData;
|
||||
private List<List<PropTempData>> _allPropTempData;
|
||||
//任务目标宝箱位置
|
||||
private Vector3 _taskBoxPositon = Vector3.zero;
|
||||
|
||||
|
||||
public void AnalysisData(List<ServerGridData> serverGrid)
|
||||
{
|
||||
_taskBoxPositon = JsonConvert.DeserializeObject<Vector3>(BoxPositionJson);
|
||||
_allBroadData = JsonConvert.DeserializeObject<BroadData[]>(AllBroadJson);
|
||||
_allGridData = JsonConvert.DeserializeObject<GridData[]>(AllCubeJson);
|
||||
_allPropData = JsonConvert.DeserializeObject<PropData[]>(AllPropJson);
|
||||
_allPropTempData = JsonConvert.DeserializeObject<List<List<PropTempData>>>(AllTempJson);
|
||||
|
||||
GridData gData;
|
||||
for (int i = 0; i < _allGridData.Length; i++)
|
||||
{
|
||||
gData = _allGridData[i];
|
||||
gData.Init();
|
||||
for (int j = 0; j < serverGrid.Count; j++)
|
||||
{
|
||||
if (serverGrid[j].Row == gData.Row && serverGrid[j].Col == gData.Col)
|
||||
{
|
||||
gData.IsOpen = serverGrid[j].IsOpen == 1;
|
||||
gData.hasClickCount = serverGrid[j].hasClickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
_allGridData = new GridData[0];
|
||||
_allPropData = new PropData[0];
|
||||
}
|
||||
public GridData GetGridData(int row, int col)
|
||||
{
|
||||
GridData gData;
|
||||
for (int i = 0; i < _allGridData.Length; i++)
|
||||
{
|
||||
gData = _allGridData[i];
|
||||
if (gData.Row == row && gData.Col == col)
|
||||
{
|
||||
return gData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Vector3 GetTaskPosPositon()
|
||||
{
|
||||
return _taskBoxPositon;
|
||||
}
|
||||
|
||||
public BroadData[] GetAllBroadData()
|
||||
{
|
||||
return _allBroadData;
|
||||
}
|
||||
public GridData[] GetAllGridData()
|
||||
{
|
||||
return _allGridData;
|
||||
}
|
||||
|
||||
public PropData[] GetAllPropData()
|
||||
{
|
||||
return _allPropData;
|
||||
}
|
||||
|
||||
public List<PropTempData> GetAllPropTempData(int index)
|
||||
{
|
||||
if (_allPropTempData == null || _allPropTempData.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (index >= _allPropTempData.Count)
|
||||
{
|
||||
index = GetOnePropTempDataIndex();
|
||||
}
|
||||
return _allPropTempData[index];
|
||||
}
|
||||
public int GetOnePropTempDataIndex()
|
||||
{
|
||||
return UnityEngine.Random.Range(0, _allPropTempData.Count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8aa6471ba052426b8ac286d5b4b07e84
|
||||
timeCreated: 1723806234
|
||||
39
Assets/Scripts/SandDig/model/Data/GridData.cs
Normal file
39
Assets/Scripts/SandDig/model/Data/GridData.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class GridData
|
||||
{
|
||||
public int PropId = 0;
|
||||
public bool IsBorder = false;
|
||||
public bool DoubleClick = false;
|
||||
public Vector3 LocalPos = Vector3.zero;
|
||||
public int ID = 1;
|
||||
public int Row = 0;
|
||||
public int Col = 0;
|
||||
public GridPropData ConfigData;
|
||||
|
||||
public bool IsOpen { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 已经点击的个数
|
||||
/// </summary>
|
||||
public int hasClickCount = 0;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Row = (int)LocalPos.x;
|
||||
Col = (int)LocalPos.y;
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
ServerGridData data = new ServerGridData();
|
||||
data.Row = Row;
|
||||
data.Col = Col;
|
||||
data.IsOpen = IsOpen ? 1 : 0;
|
||||
data.hasClickCount = hasClickCount;
|
||||
return data.ToJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/GridData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/GridData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fb9576d851440798d5655c115edabdd
|
||||
timeCreated: 1723805269
|
||||
111
Assets/Scripts/SandDig/model/Data/GridPropData.cs
Normal file
111
Assets/Scripts/SandDig/model/Data/GridPropData.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Script.RuntimeScript.ExplosionEffect;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class GridPropData
|
||||
{
|
||||
public int PropId = 0;
|
||||
public int PropDirection = 0;
|
||||
public int PropRows = 2; // 行数
|
||||
public int PropColumns = 2; // 列数
|
||||
public int[] PropArr;
|
||||
public int[,] TempArr;
|
||||
|
||||
/// <summary>
|
||||
/// 道具配置
|
||||
/// </summary>
|
||||
public DiggingItemList Config = null;
|
||||
|
||||
/// <summary>
|
||||
/// 父Grid
|
||||
/// </summary>
|
||||
public GridData ParentGird { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 需要开启的Grid
|
||||
/// </summary>
|
||||
private List<GridData> _needOpenGrids = new List<GridData>();
|
||||
|
||||
/// <summary>
|
||||
/// 目标
|
||||
/// </summary>
|
||||
private PropItem _targetPropItem;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经被开启
|
||||
/// </summary>
|
||||
public bool AlreadyOpen { get; set; } = false;
|
||||
|
||||
#region 动态赋值数据
|
||||
private int Row = 0;
|
||||
private int Col = 0;
|
||||
#endregion
|
||||
|
||||
public PropItem TargetPropItem
|
||||
{
|
||||
get { return _targetPropItem; }
|
||||
}
|
||||
|
||||
public void Init(int propid,int row,int col)
|
||||
{
|
||||
PropId = propid;
|
||||
Row = row;
|
||||
Col = col;
|
||||
Config = GContext.container.Resolve<DiggingGameManager>().TableData.TbDiggingItemList.Get(PropId);
|
||||
TempArr = GetArray();
|
||||
}
|
||||
|
||||
public void AddGrid(GridData grid)
|
||||
{
|
||||
if (_needOpenGrids.IndexOf(grid) >= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DiggingGameManager.LogWarning("AddGridX::" + grid.Row + " AddGridY::" + grid.Col);
|
||||
_needOpenGrids.Add(grid);
|
||||
}
|
||||
|
||||
public void SetTargetPropItem(PropItem propItem)
|
||||
{
|
||||
_targetPropItem = propItem;
|
||||
}
|
||||
|
||||
|
||||
public bool IsCanOpen()
|
||||
{
|
||||
bool canOpen = true;
|
||||
for (int i = 0; i < _needOpenGrids.Count; i++)
|
||||
{
|
||||
if (!_needOpenGrids[i].IsOpen)
|
||||
{
|
||||
canOpen = false;
|
||||
AlreadyOpen = canOpen;
|
||||
return canOpen;
|
||||
}
|
||||
}
|
||||
|
||||
AlreadyOpen = canOpen;
|
||||
return canOpen;
|
||||
}
|
||||
|
||||
private int[,] GetArray()
|
||||
{
|
||||
var arr = new int[PropRows, PropColumns];
|
||||
for (int i = 0; i < PropRows; i++)
|
||||
{
|
||||
for (int j = 0; j < PropColumns; j++)
|
||||
{
|
||||
arr[i, j] = PropArr[i * PropColumns + j];
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/GridPropData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/GridPropData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a89fdc76de8c4de8ab60308ee52bcfda
|
||||
timeCreated: 1724209029
|
||||
14
Assets/Scripts/SandDig/model/Data/PropData.cs
Normal file
14
Assets/Scripts/SandDig/model/Data/PropData.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class PropData
|
||||
{
|
||||
public int PropId = 0;
|
||||
public Vector3 LocalPos = Vector3.zero;
|
||||
public bool IsOk = false;
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/PropData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/PropData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db73383b55f74e61b1f3a02f6fb15191
|
||||
timeCreated: 1723805279
|
||||
11
Assets/Scripts/SandDig/model/Data/PropTempData.cs
Normal file
11
Assets/Scripts/SandDig/model/Data/PropTempData.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class PropTempData
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
public int PropId;
|
||||
public GridPropData ConfigData;
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/PropTempData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/PropTempData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c58dfc94ed294c468bfdc8e65e0c9952
|
||||
timeCreated: 1724226589
|
||||
72
Assets/Scripts/SandDig/model/Data/SandDigServerData.cs
Normal file
72
Assets/Scripts/SandDig/model/Data/SandDigServerData.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SandDigServerData
|
||||
{
|
||||
public int ClampId = 0;
|
||||
public int ClickCount = 0;
|
||||
/// <summary>
|
||||
/// 已经获得的目标道具
|
||||
/// </summary>
|
||||
public List<int> PassPropIds = new List<int>();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
PassPropIds.Clear();
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ServerGridData
|
||||
{
|
||||
public int Row = 0;
|
||||
public int Col = 0;
|
||||
public int IsOpen = 0;
|
||||
public int hasClickCount = 0;
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SaveDataJson
|
||||
{
|
||||
public int ActivityId = 0;
|
||||
public string SandDigServerData;
|
||||
public string AllGridJson;
|
||||
public int TempIndex = -1;
|
||||
|
||||
//public string AllGridPropsJson;
|
||||
|
||||
public SandDigServerData GetSerializableData()
|
||||
{
|
||||
return JsonConvert.DeserializeObject<SandDigServerData>(SandDigServerData);
|
||||
}
|
||||
|
||||
public ServerGridData[] GetSerializableGridData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(AllGridJson))
|
||||
return new ServerGridData[0];
|
||||
return JsonConvert.DeserializeObject<ServerGridData[]>(AllGridJson);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SaveDigCountJson
|
||||
{
|
||||
public int ActivityId = 0;
|
||||
public int DigCount = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c63d6ecedfd442f83e59df31144fb65
|
||||
timeCreated: 1724898766
|
||||
501
Assets/Scripts/SandDig/model/DiggingGameModel.cs
Normal file
501
Assets/Scripts/SandDig/model/DiggingGameModel.cs
Normal file
@@ -0,0 +1,501 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using Newtonsoft.Json;
|
||||
using Script.RuntimeScript;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
|
||||
public class DiggingGameModel
|
||||
{
|
||||
#region 协议Const区域
|
||||
|
||||
//工具个数
|
||||
private const string DigCountKey = "DigCount";
|
||||
//棋盘管卡数据
|
||||
private const string DigGridDataKey = "DigGridData";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 管卡json中原始数据
|
||||
private DinggingSceneData _dinggingSceneData;
|
||||
#endregion
|
||||
|
||||
#region 服务器数据
|
||||
/// <summary>
|
||||
/// 沙滩寻宝基本数据
|
||||
/// </summary>
|
||||
private SandDigServerData _serverData = null;
|
||||
/// <summary>
|
||||
/// 沙滩寻宝棋盘网格数据
|
||||
/// </summary>
|
||||
private List<ServerGridData> _allServerGridData = new List<ServerGridData>();
|
||||
public int TempIndex = -1;
|
||||
private int _serverDigCount = 0;
|
||||
int redDot = 10;
|
||||
//最新获取 道具个数 *** 已经废弃
|
||||
public int NewAddDigCount = 0;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 本期活动开放的所有管卡
|
||||
/// </summary>
|
||||
private List<int> _allClamps = new List<int>();
|
||||
public List<int> AllClamps => _allClamps;
|
||||
|
||||
private int _curActivityId = 0;
|
||||
public int CurActivityId
|
||||
{
|
||||
get => _curActivityId;
|
||||
}
|
||||
public DiggingActivityInit digActivityConfig;
|
||||
public string ResourceTopic => digActivityConfig.ResourceTopic;
|
||||
#region 数据初始化
|
||||
|
||||
/// <summary>
|
||||
/// 在线时候 活动开启
|
||||
/// </summary>
|
||||
public void ActivityOpen(cfg.FishingEvent t)
|
||||
{
|
||||
if (_curActivityId == t.ID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_curActivityId = t.ID;
|
||||
if (_curActivityId > 0)
|
||||
{
|
||||
digActivityConfig = GContext.container.Resolve<Tables>().TbDiggingActivityInit.Get(t.RedirectID);
|
||||
redDot = GContext.container.Resolve<FishingEventData>().GetRedDot(_curActivityId);
|
||||
}
|
||||
DiggingGameManager.LogError("沙滩寻宝开启");
|
||||
string countJson = PlayFabMgr.Instance.GetLocalData(DigCountKey);
|
||||
string digGridDataJson = PlayFabMgr.Instance.GetLocalData(DigGridDataKey);
|
||||
if (string.IsNullOrEmpty(countJson))
|
||||
{
|
||||
SaveNull();
|
||||
}
|
||||
DoServerData(countJson, digGridDataJson);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入游戏初始化数据
|
||||
/// </summary>
|
||||
/// <param name="userDatas"></param>
|
||||
public async System.Threading.Tasks.Task InitServerData()
|
||||
{
|
||||
_curActivityId = GContext.container.Resolve<DiggingGameManager>().GetActivityId();
|
||||
DiggingGameManager.LogError("沙滩寻宝数据初始化");
|
||||
if (_curActivityId > 0)
|
||||
{
|
||||
FishingEvent fishingEvent = GContext.container.Resolve<Tables>().TbFishingEvent.GetOrDefault(_curActivityId);
|
||||
digActivityConfig = GContext.container.Resolve<Tables>().TbDiggingActivityInit.Get(fishingEvent.RedirectID);
|
||||
}
|
||||
|
||||
string countJson = PlayFabMgr.Instance.GetLocalData(DigCountKey);
|
||||
string digGridDataJson = PlayFabMgr.Instance.GetLocalData(DigGridDataKey);
|
||||
DoServerData(countJson, digGridDataJson);
|
||||
await InitClientData(ClientDataHandleEnum.Init);
|
||||
}
|
||||
private void DoServerData(string countJson, string digGridDataJson)
|
||||
{
|
||||
if (_curActivityId <= 0)
|
||||
{
|
||||
SaveNull();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
redDot = GContext.container.Resolve<FishingEventData>().GetRedDot(_curActivityId);
|
||||
FishingEvent acInfo = GContext.container.Resolve<DiggingGameManager>().GetActivityConfig(_curActivityId);
|
||||
int redirectID = acInfo.RedirectID;
|
||||
|
||||
DiggingActivityInit digActivityConfig = GContext.container.Resolve<Tables>().TbDiggingActivityInit.Get(redirectID);
|
||||
if (digActivityConfig == null)
|
||||
{
|
||||
SaveNull();
|
||||
return;
|
||||
}
|
||||
_allClamps = digActivityConfig.StageList;
|
||||
|
||||
if (!string.IsNullOrEmpty(countJson))
|
||||
{
|
||||
try
|
||||
{
|
||||
SaveDigCountJson data = Newtonsoft.Json.JsonConvert.DeserializeObject<SaveDigCountJson>(countJson);
|
||||
if (data.ActivityId == _curActivityId)
|
||||
{
|
||||
_serverDigCount = data.DigCount;
|
||||
DiggingGameManager.LogError("玩家铲子个数 :::" + _serverDigCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveNull();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SaveNull();
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
_serverData = null;
|
||||
_allServerGridData.Clear();
|
||||
if (!string.IsNullOrEmpty(digGridDataJson))
|
||||
{
|
||||
SaveDataJson data = Newtonsoft.Json.JsonConvert.DeserializeObject<SaveDataJson>(digGridDataJson);
|
||||
if (data.ActivityId == _curActivityId)
|
||||
{
|
||||
_serverData = data.GetSerializableData();
|
||||
_allServerGridData = data.GetSerializableGridData().ToList();
|
||||
TempIndex = data.TempIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveNull();
|
||||
}
|
||||
}
|
||||
if (_serverData == null || (!_allClamps.Contains(_serverData.ClampId) && _serverData.ClampId > 0))
|
||||
{
|
||||
_serverData = new SandDigServerData();
|
||||
_serverData.ClampId = _allClamps[0];
|
||||
_allServerGridData.Clear();
|
||||
}
|
||||
SetRedPoint();
|
||||
//#if UNITY_EDITOR
|
||||
// //测试
|
||||
// _allServerGridData = new List<ServerGridData>();
|
||||
// _allServerGridPropsData = new List<ServerGridPropsData>();
|
||||
// _serverData = new SandDigServerData();
|
||||
// _serverData.ClampId = _allClamps[1];
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
public void GMSetClamp(int index)
|
||||
{
|
||||
if (_curActivityId <= 0 || _serverData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (index >= _allClamps.Count)
|
||||
{
|
||||
index = _allClamps.Count - 1;
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
_serverData.ClampId = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverData.ClampId = _allClamps[index];
|
||||
}
|
||||
NewData();
|
||||
}
|
||||
public async Task<bool> InitClientData(ClientDataHandleEnum handleType)
|
||||
{
|
||||
if (_serverData == null || _serverData.ClampId <= 0)
|
||||
return false;
|
||||
DiggingGameManager.LogError("初始化客户端管卡数据");
|
||||
string JsonPath = $"Clamp{_serverData.ClampId}";// $"Assets/ABPackage/SandDig/ClampJson/Clamp{_serverData.ClampId}";
|
||||
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.LoadJson;
|
||||
AsyncOperationHandle<TextAsset> handle = Addressables.LoadAssetAsync<TextAsset>(JsonPath);
|
||||
TaskCompletionSource<bool> taskCompletion = new TaskCompletionSource<bool>();
|
||||
handle.Completed += (AsyncOperationHandle<TextAsset> obj) =>
|
||||
{
|
||||
if (obj.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
DiggingGameManager.LogError("新管卡数据加载完毕");
|
||||
_dinggingSceneData = JsonConvert.DeserializeObject<DinggingSceneData>(obj.Result.ToString());
|
||||
_dinggingSceneData.AnalysisData(_allServerGridData);
|
||||
// 释放资源
|
||||
Addressables.Release(handle);
|
||||
if (handleType == ClientDataHandleEnum.PassClamp)
|
||||
{
|
||||
//可以切换了
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.WaitPassLoading;
|
||||
}
|
||||
else if (handleType == ClientDataHandleEnum.EnterGame)
|
||||
{
|
||||
GContext.container.Resolve<DiggingGameManager>().GameState = SandDigGameState.LoadJsonOver;
|
||||
}
|
||||
else if (handleType == ClientDataHandleEnum.Init)
|
||||
{
|
||||
InitCheckClampPass();
|
||||
}
|
||||
taskCompletion.SetResult(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
taskCompletion.SetResult(false);
|
||||
DiggingGameManager.LogError("Failed to load asset: " + JsonPath);
|
||||
}
|
||||
};
|
||||
return await taskCompletion.Task;
|
||||
}
|
||||
public void InitCheckClampPass()
|
||||
{
|
||||
List<int> allHaveProps = new List<int>(GetAllPassIds());
|
||||
PropData[] allData = GetAllPropData();
|
||||
bool allFinded = true;
|
||||
|
||||
for (int i = 0; i < allData.Length; i++)
|
||||
{
|
||||
var propData = allData[i];
|
||||
if (!allHaveProps.Contains(propData.PropId))
|
||||
{
|
||||
allFinded = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
allHaveProps.Remove(propData.PropId);
|
||||
}
|
||||
}
|
||||
if (!allFinded)
|
||||
{
|
||||
allFinded = true;
|
||||
GridData[] gridDatas = GetAllGridData();
|
||||
for (int i = 0; i < gridDatas.Length; i++)
|
||||
{
|
||||
GridData gridData = gridDatas[i];
|
||||
if (gridData.IsBorder || gridData.IsOpen)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
allFinded = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allFinded)
|
||||
{
|
||||
DiggingStageReward config = GContext.container.Resolve<Tables>().TbDiggingStageReward.Get(_serverData.ClampId);
|
||||
_serverData.ClampId = config.NextTarget;
|
||||
NewData();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过当前管卡发奖
|
||||
/// </summary>
|
||||
public void PassClamp()
|
||||
{
|
||||
GContext.container.Resolve<DiggingGameManager>().ClampIsPass = true;
|
||||
DiggingStageReward config = GContext.container.Resolve<Tables>().TbDiggingStageReward.Get(_serverData.ClampId);
|
||||
|
||||
var playerData = GContext.container.Resolve<PlayerItemData>();
|
||||
|
||||
DiggingGameManager.LogError("获得的Drop奖励 :::" + config.DropID);
|
||||
GContext.container.Resolve<DiggingGameManager>().itemDatas = playerData.AddItemByDrop(config.DropID, true);
|
||||
|
||||
_serverData.ClampId = config.NextTarget;
|
||||
NewData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在线进入新关卡,数据初始化
|
||||
/// </summary>
|
||||
public void NewData()
|
||||
{
|
||||
TempIndex = -1;
|
||||
_serverData.ClickCount = 0;
|
||||
_serverData.Reset();
|
||||
_allServerGridData.Clear();
|
||||
_dinggingSceneData?.Reset();
|
||||
SaveAll();
|
||||
}
|
||||
public void NewClampInit()
|
||||
{
|
||||
GContext.Publish(new EventSandDigNewClamp(_serverData.ClampId));
|
||||
if (_serverData.ClampId <= 0)
|
||||
{
|
||||
//通关所有关卡
|
||||
DiggingGameManager.LogError("通关所有关卡!!!!!!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
InitClientData(ClientDataHandleEnum.PassClamp);
|
||||
}
|
||||
}
|
||||
|
||||
#region 数据接口
|
||||
|
||||
/// <summary>
|
||||
/// 使用道具
|
||||
/// </summary>
|
||||
public void UseDig()
|
||||
{
|
||||
_serverDigCount--;
|
||||
_serverData.ClickCount++;
|
||||
SaveDigCount();
|
||||
|
||||
GContext.Publish(new EventSandDigPropUpdate());
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加道具
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public void AddDigCount(int count)
|
||||
{
|
||||
_serverDigCount += count;
|
||||
|
||||
SaveDigCount();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获得目标道具
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
public void AddProp(int id)
|
||||
{
|
||||
_serverData.PassPropIds.Add(id);
|
||||
}
|
||||
|
||||
public List<int> GetAllPassIds()
|
||||
{
|
||||
return _serverData.PassPropIds;
|
||||
}
|
||||
|
||||
public DinggingSceneData GetBroadData()
|
||||
{
|
||||
return _dinggingSceneData;
|
||||
}
|
||||
|
||||
public BroadData[] GetAllBroadData()
|
||||
{
|
||||
return _dinggingSceneData.GetAllBroadData();
|
||||
}
|
||||
|
||||
public GridData[] GetAllGridData()
|
||||
{
|
||||
return _dinggingSceneData.GetAllGridData();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取一个格子数据
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="col"></param>
|
||||
/// <returns></returns>
|
||||
public GridData GetGridData(int row, int col)
|
||||
{
|
||||
return _dinggingSceneData.GetGridData(row, col);
|
||||
}
|
||||
|
||||
public PropData[] GetAllPropData()
|
||||
{
|
||||
return _dinggingSceneData.GetAllPropData();
|
||||
}
|
||||
|
||||
public List<PropTempData> GetOnePropTempData()
|
||||
{
|
||||
if (TempIndex < 0)
|
||||
{
|
||||
TempIndex = _dinggingSceneData.GetOnePropTempDataIndex();
|
||||
}
|
||||
return _dinggingSceneData.GetAllPropTempData(TempIndex);
|
||||
}
|
||||
public Vector3 GetTaskPosPositon()
|
||||
{
|
||||
return _dinggingSceneData.GetTaskPosPositon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取道具个数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetDigCount()
|
||||
{
|
||||
return _serverDigCount;
|
||||
}
|
||||
|
||||
|
||||
public SandDigServerData GetServerData()
|
||||
{
|
||||
return _serverData;
|
||||
}
|
||||
|
||||
public int GetCurClampId()
|
||||
{
|
||||
return _serverData.ClampId;
|
||||
}
|
||||
public int GetClickCount()
|
||||
{
|
||||
return _serverData.ClickCount;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 数据存储
|
||||
|
||||
public void SaveDigCount()
|
||||
{
|
||||
SetRedPoint();
|
||||
SaveDigCountJson dataJson = new SaveDigCountJson();
|
||||
dataJson.ActivityId = _curActivityId;
|
||||
dataJson.DigCount = _serverDigCount;
|
||||
string json = JsonConvert.SerializeObject(dataJson);
|
||||
PlayFabMgr.Instance.UpdateUserDataValue(DigCountKey, json);
|
||||
GContext.container.Resolve<FishingEventData>().SaveTransitionData(dataJson.ActivityId, dataJson.DigCount);
|
||||
}
|
||||
void SetRedPoint()
|
||||
{
|
||||
RedPointManager.Instance.SetRedPointState("Home.Digging", _serverData != null && _serverData.ClampId > 0 && _serverDigCount >= redDot);
|
||||
}
|
||||
public void SaveData()
|
||||
{
|
||||
//通用数据 + 任务目标数据
|
||||
SaveDataJson dataJson = new SaveDataJson();
|
||||
dataJson.ActivityId = _curActivityId;
|
||||
dataJson.SandDigServerData = _serverData.ToJson();
|
||||
dataJson.TempIndex = TempIndex;
|
||||
//网格数据
|
||||
GridData[] allGridData = _dinggingSceneData?.GetAllGridData() ?? new GridData[0];
|
||||
string allGridStr = allGridData.Length > 0 ? "[" : string.Empty;
|
||||
|
||||
for (int i = 0; i < allGridData.Length; i++)
|
||||
{
|
||||
if (i == allGridData.Length - 1)
|
||||
{
|
||||
allGridStr += allGridData[i].ToJson() + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
allGridStr += allGridData[i].ToJson() + ",";
|
||||
}
|
||||
}
|
||||
dataJson.AllGridJson = allGridStr;
|
||||
|
||||
string json = JsonConvert.SerializeObject(dataJson);
|
||||
//DiggingGameManager.LogError(json);
|
||||
PlayFabMgr.Instance.UpdateUserDataValue(DigGridDataKey, json);
|
||||
}
|
||||
|
||||
public void SaveAll()
|
||||
{
|
||||
this.SaveDigCount();
|
||||
this.SaveData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空上一期活动数据
|
||||
/// </summary>
|
||||
private void SaveNull()
|
||||
{
|
||||
_serverDigCount = GContext.container.Resolve<FishingEventData>().GetInitWelcomeGift(_curActivityId);
|
||||
SaveDigCount();
|
||||
PlayFabMgr.Instance.UpdateUserDataValue(DigGridDataKey, string.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/DiggingGameModel.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/DiggingGameModel.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6b18e78d9f547e3aa1eef0a1f10b7dd
|
||||
timeCreated: 1723804889
|
||||
Reference in New Issue
Block a user