先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
117 lines
4.1 KiB
C#
117 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using asap.core;
|
|
using GameCore;
|
|
using UnityEngine;
|
|
|
|
namespace SideGameFromFishing
|
|
{
|
|
public static class SideGameFromFishingManager
|
|
{
|
|
private static List<ISideGameFishRaidProgress> _fishRaidHandlers;
|
|
private static List<ISideGameBombRaidProgress> _bombRaidHandlers;
|
|
|
|
public static void Init(Type type)
|
|
{
|
|
InitFishRaidProgress(type);
|
|
InitBombRaidProgress(type);
|
|
}
|
|
|
|
private static void InitFishRaidProgress(Type type)
|
|
{
|
|
_fishRaidHandlers ??= new List<ISideGameFishRaidProgress>();
|
|
try
|
|
{
|
|
var res = typeof(ISideGameFishRaidProgress).IsAssignableFrom(type) && type.IsClass && !type.IsAbstract;
|
|
if (!res) return;
|
|
var instance = (ISideGameFishRaidProgress)GContext.container.Resolve((type, string.Empty));
|
|
if (instance == null)
|
|
{
|
|
Debug.LogWarning($"[SideGameFromFishing] FishRaid handler instance is null, type: {type.Name}");
|
|
return;
|
|
}
|
|
if (!_fishRaidHandlers.Contains(instance))
|
|
_fishRaidHandlers.Add(instance);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogError($"[SideGameFromFishing] Error processing FishRaid type {type.Name}: {e.Message}");
|
|
}
|
|
}
|
|
|
|
private static void InitBombRaidProgress(Type type)
|
|
{
|
|
_bombRaidHandlers ??= new List<ISideGameBombRaidProgress>();
|
|
try
|
|
{
|
|
var res = typeof(ISideGameBombRaidProgress).IsAssignableFrom(type) && type.IsClass && !type.IsAbstract;
|
|
if (!res) return;
|
|
var instance = (ISideGameBombRaidProgress)GContext.container.Resolve((type, string.Empty));
|
|
if (instance == null)
|
|
{
|
|
Debug.LogWarning($"[SideGameFromFishing] BombRaid handler instance is null, type: {type.Name}");
|
|
return;
|
|
}
|
|
if (!_bombRaidHandlers.Contains(instance))
|
|
_bombRaidHandlers.Add(instance);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogError($"[SideGameFromFishing] Error processing BombRaid type {type.Name}: {e.Message}");
|
|
}
|
|
}
|
|
|
|
public static void AddFishRaidProgress(int multiple)
|
|
{
|
|
if (_fishRaidHandlers == null) return ;
|
|
foreach (var handler in _fishRaidHandlers)
|
|
{
|
|
var datas = handler.AddFishRaidProgress(multiple);
|
|
if(datas == null) continue;
|
|
foreach (var data in datas)
|
|
{
|
|
GContext.Publish(data);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void AddBombRaidProgress(int multiple)
|
|
{
|
|
if (_bombRaidHandlers == null) return ;
|
|
foreach (var handler in _bombRaidHandlers)
|
|
{
|
|
var datas = handler.AddBombRaidProgress(multiple);
|
|
if(datas == null) continue;
|
|
foreach (var data in datas)
|
|
{
|
|
GContext.Publish(data);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void RegisterBombRaidProgress(ISideGameBombRaidProgress handler)
|
|
{
|
|
_bombRaidHandlers ??= new List<ISideGameBombRaidProgress>();
|
|
if (!_bombRaidHandlers.Contains(handler))
|
|
_bombRaidHandlers.Add(handler);
|
|
}
|
|
|
|
public static void RegisterFishRaidProgress(ISideGameFishRaidProgress handler)
|
|
{
|
|
_fishRaidHandlers ??= new List<ISideGameFishRaidProgress>();
|
|
if (!_fishRaidHandlers.Contains(handler))
|
|
_fishRaidHandlers.Add(handler);
|
|
}
|
|
|
|
public static void UnregisterBombRaidProgress(ISideGameBombRaidProgress handler)
|
|
{
|
|
_bombRaidHandlers?.Remove(handler);
|
|
}
|
|
|
|
public static void UnregisterFishRaidProgress(ISideGameFishRaidProgress handler)
|
|
{
|
|
_fishRaidHandlers?.Remove(handler);
|
|
}
|
|
}
|
|
}
|