增加角色创建时自动检测增加环境buff
parent
b7be5b26be
commit
abb7fcccc1
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Gameplay.Level;
|
||||
using Gameplay.Pool;
|
||||
using Gameplay.Vehicle.Impl;
|
||||
using UnityEngine;
|
||||
|
|
@ -21,11 +22,11 @@ namespace Gameplay.Buff
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
DebugUtil.LogError("Buff尚未初始化,请先初始化");
|
||||
return null;
|
||||
}
|
||||
// if (_instance == null)
|
||||
// {
|
||||
// DebugUtil.LogError("Buff尚未初始化,请先初始化");
|
||||
// return null;
|
||||
// }
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,11 +55,11 @@ namespace Gameplay.Buff
|
|||
{
|
||||
DebugUtil.Log("[Init]------BuffManager");
|
||||
}
|
||||
|
||||
public void InitLevelData()
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// 初始化关卡的 天气 地形 白天黑夜数据
|
||||
|
||||
DebugUtil.Log("[Dispose]------BuffManager");
|
||||
_instance = null;
|
||||
}
|
||||
|
||||
public static DataBuff GetBuffConfigById(int id)
|
||||
|
|
@ -204,11 +205,7 @@ namespace Gameplay.Buff
|
|||
_unitList.Remove(unitManager);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DebugUtil.Log("[Dispose]------BuffManager");
|
||||
_instance = null;
|
||||
}
|
||||
|
||||
|
||||
public void LogicUpdate(float dt)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: da3a88c84f474ee1922abbdd5da18b2a
|
||||
timeCreated: 1698305515
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
using System.Collections.Generic;
|
||||
using Framework;
|
||||
using Gameplay.Buff;
|
||||
using Gameplay.Character;
|
||||
using Gameplay.Common;
|
||||
using Gameplay.Level;
|
||||
namespace Code.Scripts.Gameplay.Enviorment
|
||||
{
|
||||
public class EnviormentManager
|
||||
{
|
||||
|
||||
private static EnviormentManager _instance;
|
||||
public static EnviormentManager instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateInstance()
|
||||
{
|
||||
if (_instance != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_instance = new EnviormentManager();
|
||||
}
|
||||
|
||||
private List<int> _enviormentBuffIds = new List<int>();
|
||||
|
||||
private EnviormentManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_InitData();
|
||||
EventManager.Instance.Register<GameUnit>(EventManager.EventName.INFIGHT_UNIT_READY, _OnUnitReady);
|
||||
}
|
||||
|
||||
private void _InitData()
|
||||
{
|
||||
// 初始化关卡的 天气 地形 白天黑夜数据
|
||||
var level = LevelManager.Instance.CurrentLevel;
|
||||
var mapData = level.Map.MapData;
|
||||
var mapEnviorment = mapData.environmentType;
|
||||
var intValue = (int)mapEnviorment;
|
||||
if (TableManager.Instance.Tables.EnviormentConfig.DataMap.TryGetValue(intValue, out var configData))
|
||||
{
|
||||
_enviormentBuffIds.Clear();
|
||||
_enviormentBuffIds.AddRange(configData.BuffIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtil.LogError("无效的enviormentType:{0}", mapEnviorment);
|
||||
}
|
||||
}
|
||||
|
||||
private void _OnUnitReady(GameUnit unit)
|
||||
{
|
||||
switch (unit.gameunitType)
|
||||
{
|
||||
case EGameUnitType.Character:
|
||||
_AddBuffsToCharacter(unit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void _AddBuffsToCharacter(GameUnit unit)
|
||||
{
|
||||
var character = unit as Character;
|
||||
if (character == null) return;
|
||||
if (character.commonData.troopId != ETroopsId.Self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var buffManager = unit.buffManager;
|
||||
for (int i = 0; i < _enviormentBuffIds.Count; i++)
|
||||
{
|
||||
var buffId = _enviormentBuffIds[i];
|
||||
buffManager.AddBuffById(buffId);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
EventManager.Instance.Unregister<GameUnit>(EventManager.EventName.INFIGHT_UNIT_READY, _OnUnitReady);
|
||||
_enviormentBuffIds = null;
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad20e1174bc2499ca52ae8c864f71e57
|
||||
timeCreated: 1698305524
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using cfg.LevelCfg;
|
||||
using System.Collections.Generic;
|
||||
using Code.Scripts.Gameplay.Enviorment;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Framework;
|
||||
using Gameplay.AI;
|
||||
|
|
@ -31,6 +32,7 @@ namespace Gameplay.Level
|
|||
|
||||
public int ID => _id;
|
||||
public Map Map => _map;
|
||||
|
||||
public CharacterManager CharacterManager => _characterManager;
|
||||
|
||||
public float LevelTime { set; get; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Code.Scripts.Gameplay.Enviorment;
|
||||
using Framework;
|
||||
using Gameplay.Area;
|
||||
using Gameplay.Buff;
|
||||
|
|
@ -45,6 +46,10 @@ namespace Gameplay.Level
|
|||
|
||||
PauseManager.CreateInstance();
|
||||
PauseManager.instance.Init();
|
||||
|
||||
|
||||
EnviormentManager.CreateInstance();
|
||||
EnviormentManager.instance.Init();
|
||||
|
||||
await _level.CharacterManager.EnterBattle();
|
||||
_level.LevelTime = 0;
|
||||
|
|
@ -80,6 +85,7 @@ namespace Gameplay.Level
|
|||
BulletManager.instance.Dispose();
|
||||
BoundsManager.instance.Dispose();
|
||||
TireMarkManager.instance.Dispose();
|
||||
EnviormentManager.instance.Dispose();
|
||||
}
|
||||
|
||||
public BattleState(Level level) : base(level)
|
||||
|
|
|
|||
Loading…
Reference in New Issue