697 lines
24 KiB
C#
697 lines
24 KiB
C#
using cfg.DialogueCfg;
|
||
using Cysharp.Threading.Tasks;
|
||
using Framework;
|
||
using Gameplay;
|
||
using Gameplay.Guide;
|
||
using Gameplay.Level;
|
||
using PhxhSDK;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Random = UnityEngine.Random;
|
||
|
||
/// <summary>
|
||
/// 台词管理器
|
||
/// </summary>
|
||
public class DialogueManager : Singlenton<DialogueManager>, IInitable, IUpdatable
|
||
{
|
||
/// <summary>
|
||
/// 台词播放记录数据
|
||
/// </summary>
|
||
private class DialoguePlayData
|
||
{
|
||
/// <summary>
|
||
/// 台词对应次数字典
|
||
/// </summary>
|
||
public Dictionary<int, int> DicCount;
|
||
/// <summary>
|
||
/// 上一次日期
|
||
/// </summary>
|
||
public DateTime LastTime;
|
||
|
||
public DialoguePlayData()
|
||
{
|
||
DicCount = new();
|
||
}
|
||
|
||
public void SetNewTime(DateTime dateTime)
|
||
{
|
||
LastTime = dateTime;
|
||
DicCount.Clear();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 实际语音id = 角色id * RATIO + 台词id
|
||
/// 实际台词文本key = "Dialogue_{实际语音id}"
|
||
/// </summary>
|
||
private const int RATIO = 1000;
|
||
/// <summary>
|
||
/// 台词播放记录数据key
|
||
/// </summary>
|
||
private const string DIALOGUE_PLAY_DATA = "Dialogue_Play_Data";
|
||
/// <summary>
|
||
/// 角色台词对应的权重字典,key:角色id,value: subKey:台词id,subValue:台词权重
|
||
/// </summary>
|
||
private Dictionary<int, Dictionary<int, float>> dicDialogueWeight;
|
||
/// <summary>
|
||
/// 台词数据字典字典,key:台词类型,value:台词配置数据列表
|
||
/// </summary>
|
||
private Dictionary<E_DialogueType, List<DataDialogueCfg>> dicDialogue;
|
||
/// <summary>
|
||
/// 台词播放记录数据
|
||
/// </summary>
|
||
private DialoguePlayData dialoguePlayData;
|
||
#region 战斗台词
|
||
/// <summary>
|
||
/// 当前播放的战斗台词
|
||
/// </summary>
|
||
private AudioInst curFightAudio;
|
||
/// <summary>
|
||
/// 当前战斗台词优先级
|
||
/// </summary>
|
||
private int curFightDialoguePriority;
|
||
/// <summary>
|
||
/// 当前战斗语音类型
|
||
/// </summary>
|
||
private E_DialogueType curFightDialogueType;
|
||
/// <summary>
|
||
/// 等待播放的获得增益buff语音,value:角色id
|
||
/// </summary>
|
||
private readonly Queue<int> queueWaitGetBuffDialogue = new();
|
||
#endregion
|
||
/// <summary>
|
||
/// 是否初始化
|
||
/// </summary>
|
||
private bool isInit;
|
||
|
||
#region 临时数据
|
||
/// <summary>
|
||
/// 符合条件的台词数据
|
||
/// </summary>
|
||
private readonly List<DataDialogueCfg> listDialogueDataTemp = new();
|
||
private readonly List<float> listDialogueWeight = new();
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 是否正在播放战斗语音
|
||
/// </summary>
|
||
public bool IsPlayingFightDialogue
|
||
{
|
||
get { return null != curFightAudio && curFightAudio.IsPlaying; }
|
||
}
|
||
|
||
public void Init()
|
||
{
|
||
isInit = false;
|
||
|
||
dicDialogueWeight = new();
|
||
dialoguePlayData = StorageMgr.Instance.GetStorage<DialoguePlayData>(DIALOGUE_PLAY_DATA);
|
||
|
||
EventManager.Instance.Register(EventManager.EventName.AllConfigLoad, OnInit);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_SELF_RETREAT, (Action<int>)OnFightRetreat);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_SELECT_UNIT, (Action<int>)OnFightChoose);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_CLICK_MOVE, (Action<int>)OnFightMove);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_CLICK_ATTACK, (Action<int>)OnFightAttack);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_USE_SKILL, (Action<int>)OnFightUseSkill);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_UP_VEHICLE, (Action<int>)OnFightBoardVehicle);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_DOWN_VEHICLE, (Action<int>)OnFightLeaveVehicle);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_GET_P_BUFF, (Action<int>)OnFightGetBuff);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_KILL_ENEMY, (Action<int>)OnFightKillEnemy);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_LET_ENEMY_RETREAT, (Action<int>)OnFightRepelEnemy);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_HAS_SHEILD, (Action<int>)OnFightArmourDown);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_NO_SHEILD, (Action<int>)OnFightArmourBloodZero);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_DEAD, (Action<int>)OnFightKnockedDown);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_ENTER_LOW_MORALE, (Action<int>)OnFightStifleState);
|
||
EventManager.Instance.Register(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_ENTER_RETREAT, (Action<int>)OnFightRetreatState);
|
||
}
|
||
|
||
public void Update(float deltaTime)
|
||
{
|
||
if (null == LevelManager.Instance.CurrentLevel)
|
||
return;
|
||
|
||
if (!LevelManager.Instance.CurrentLevel.IsInBattle())
|
||
return;
|
||
|
||
if (IsPlayingFightDialogue)
|
||
return;
|
||
|
||
if (E_DialogueType.FightUseSkill != curFightDialogueType)
|
||
{
|
||
if (queueWaitGetBuffDialogue.Count > 0)
|
||
queueWaitGetBuffDialogue.Clear();
|
||
|
||
return;
|
||
}
|
||
|
||
while (queueWaitGetBuffDialogue.TryDequeue(out int roleId))
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightGetBuff);
|
||
}
|
||
}
|
||
|
||
public void Release()
|
||
{
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_ENTER_RETREAT, (Action<int>)OnFightRetreatState);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_ENTER_LOW_MORALE, (Action<int>)OnFightStifleState);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_DEAD, (Action<int>)OnFightKnockedDown);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_NO_SHEILD, (Action<int>)OnFightArmourBloodZero);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_BE_ATTACK_AND_HAS_SHEILD, (Action<int>)OnFightArmourDown);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_LET_ENEMY_RETREAT, (Action<int>)OnFightRepelEnemy);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_KILL_ENEMY, (Action<int>)OnFightKillEnemy);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_GET_P_BUFF, (Action<int>)OnFightGetBuff);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_DOWN_VEHICLE, (Action<int>)OnFightLeaveVehicle);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_UP_VEHICLE, (Action<int>)OnFightBoardVehicle);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_USE_SKILL, (Action<int>)OnFightUseSkill);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_CLICK_ATTACK, (Action<int>)OnFightAttack);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_CLICK_MOVE, (Action<int>)OnFightMove);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_SELECT_UNIT, (Action<int>)OnFightChoose);
|
||
EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_AUDIO_SELF_RETREAT, (Action<int>)OnFightRetreat);
|
||
EventManager.Instance.Unregister(EventManager.EventName.AllConfigLoad, OnInit);
|
||
|
||
listDialogueDataTemp.Clear();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 播放台词
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
/// <param name="dialogueType"></param>
|
||
/// <param name="callback"></param>
|
||
/// <returns></returns>
|
||
public async UniTask<AudioInst> PlayDiaogue(int roleId, E_DialogueType dialogueType, Action<string> callback = null)
|
||
{
|
||
if (!isInit)
|
||
{
|
||
DebugUtil.LogError("台词数据没有初始化");
|
||
return null;
|
||
}
|
||
|
||
if (!dicDialogue.TryGetValue(dialogueType, out List<DataDialogueCfg> listDialogueData))
|
||
{
|
||
DebugUtil.LogWarning($"没有{dialogueType}类型的台词数据");
|
||
return null;
|
||
}
|
||
|
||
#region 每日重置次数,后续应该通过跨天事件触发
|
||
DateTime curTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server);
|
||
if (curTime.Hour > TableManager.Instance.Tables.GlobalConfig.DailyChangeHour && // 超过5点
|
||
curTime.Day != dialoguePlayData.LastTime.Day) // 不是同一天
|
||
{
|
||
dialoguePlayData.SetNewTime(curTime);
|
||
}
|
||
#endregion
|
||
|
||
#region 获取需要播放的台词,根据优先级,台词类型,播放次数,条件
|
||
listDialogueDataTemp.Clear();
|
||
int minPriority = int.MaxValue; // 值越小优先级越高
|
||
foreach (DataDialogueCfg cfg in listDialogueData)
|
||
{
|
||
if (cfg.Priority > minPriority) // 优先级不足,排除
|
||
continue;
|
||
|
||
if (cfg.DayPlayCount > 0 && // 0表示无限次
|
||
dialoguePlayData.DicCount.TryGetValue(cfg.Id, out int count) &&
|
||
count >= cfg.DayPlayCount) // 超过播放次数
|
||
continue;
|
||
|
||
if (!IsCheckValid(roleId, cfg)) // 条件不满足,排除
|
||
continue;
|
||
|
||
if (cfg.Priority < minPriority)
|
||
{
|
||
minPriority = cfg.Priority;
|
||
listDialogueDataTemp.Clear();
|
||
}
|
||
listDialogueDataTemp.Add(cfg);
|
||
}
|
||
#endregion
|
||
|
||
if (listDialogueDataTemp.Count <= 0)
|
||
{
|
||
DebugUtil.LogWarning("没有满足条件要播放的台词");
|
||
return null;
|
||
}
|
||
|
||
#region 根据权重随机台词
|
||
DataDialogueCfg playCfg;
|
||
listDialogueWeight.Clear();
|
||
if (dicDialogueWeight.TryGetValue(roleId, out Dictionary<int, float> dicWeight))
|
||
{
|
||
foreach (DataDialogueCfg cfg in listDialogueDataTemp)
|
||
{
|
||
if (dicWeight.TryGetValue(cfg.Id, out float weight))
|
||
listDialogueWeight.Add(weight);
|
||
else
|
||
listDialogueWeight.Add(1f);
|
||
}
|
||
playCfg = listDialogueDataTemp[RandomIndexByWeight()];
|
||
}
|
||
else
|
||
playCfg = listDialogueDataTemp[Random.Range(0, listDialogueDataTemp.Count)];
|
||
#endregion
|
||
|
||
#region 设置其他的权重
|
||
if (dicWeight != null)
|
||
{
|
||
foreach (DataDialogueCfg cfg in listDialogueDataTemp)
|
||
{
|
||
if (dicWeight.TryGetValue(cfg.Id, out float weight) && weight <= 0f)
|
||
dicWeight[cfg.Id] = 0.3f; // TODO 需要全局配置
|
||
else
|
||
dicWeight[cfg.Id] = 1f;
|
||
}
|
||
dicWeight[playCfg.Id] = 0f; // 当前使用的权重置为0
|
||
}
|
||
#endregion
|
||
|
||
#region 记录播放次数
|
||
if (playCfg.DayPlayCount > 0)
|
||
{
|
||
dialoguePlayData.DicCount.TryGetValue(playCfg.Id, out int count);
|
||
dialoguePlayData.DicCount[playCfg.Id] = count + 1;
|
||
}
|
||
#endregion
|
||
|
||
int realId = roleId * RATIO + playCfg.Id;
|
||
string audioKey = GetAudioKey(roleId, playCfg.Id);
|
||
DebugUtil.Log($"角色id:{roleId}, 播放台词id:{playCfg.Id}, 优先级{playCfg.Priority},音频key:{audioKey}"); // 测试Log
|
||
//int audioId = await AudioManager.Instance.PlayAudio(GetAudioKey(roleId, playCfg.Id));
|
||
int audioId = AudioManager.Instance.PlayAudio(GetAudioKey(roleId, playCfg.Id));
|
||
callback?.Invoke(CommonUtils.GetLocalizeText(E_LocalizePrefix.Dialogue, realId));
|
||
|
||
return AudioManager.Instance.GetAudioByID(AudioCriManager.EPlayType.Speak, audioId);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 播放战斗台词
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public async void PlayFightDiaogue(int roleId, E_DialogueType dialogueType)
|
||
{
|
||
#region 初始化校验
|
||
if (!isInit)
|
||
{
|
||
DebugUtil.LogError("台词数据没有初始化");
|
||
return;
|
||
}
|
||
#endregion
|
||
|
||
#region 战斗类型台词校验
|
||
if (!IsFightTriggerType(dialogueType))
|
||
{
|
||
DebugUtil.LogError("不是战斗类型台词");
|
||
return;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取要播放的战斗台词
|
||
if (!dicDialogue.TryGetValue(dialogueType, out List<DataDialogueCfg> listDialogueData))
|
||
{
|
||
DebugUtil.LogWarning($"没有{dialogueType}类型的台词数据");
|
||
return;
|
||
}
|
||
#endregion
|
||
|
||
#region 数据校验
|
||
if (listDialogueData.Count < 1)
|
||
{
|
||
DebugUtil.LogWarning($"没有{dialogueType}类型的台词数据");
|
||
return;
|
||
}
|
||
#endregion
|
||
|
||
DataDialogueCfg cfg = listDialogueData[0];
|
||
|
||
#region 是否正在播放,正在播放比较优先级
|
||
if (curFightAudio != null && curFightAudio.IsPlaying)
|
||
{
|
||
if (curFightDialoguePriority <= cfg.Priority)
|
||
{
|
||
curFightAudio = null;
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 随机概率
|
||
if (!CommonUtils.RandomBool(cfg.TriggerProbability))
|
||
return;
|
||
#endregion
|
||
|
||
curFightAudio?.Stop();
|
||
|
||
string audioKey = GetAudioKey(roleId, cfg.Id);
|
||
DebugUtil.Log($"角色id:{roleId}, 播放台词id:{cfg.Id}, 优先级{cfg.Priority},实际音频key:{audioKey},概率:{cfg.TriggerProbability * 100}%"); // 测试Log
|
||
//int audioId = await AudioManager.Instance.PlayAudio(audioKey);
|
||
int audioId = AudioManager.Instance.PlayAudio(audioKey);
|
||
curFightDialoguePriority = cfg.Priority;
|
||
curFightDialogueType = dialogueType;
|
||
curFightAudio = AudioManager.Instance.GetAudioByID(AudioCriManager.EPlayType.Speak, audioId);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取音频key
|
||
/// </summary>
|
||
/// <param name="roledId"></param>
|
||
/// <param name="numId"></param>
|
||
/// <returns></returns>
|
||
private string GetAudioKey(int roleId, int numId)
|
||
{
|
||
const string KEY = "Voice";
|
||
|
||
string res;
|
||
if(numId < 10)
|
||
res= $"{KEY}_{roleId}_0{numId}";
|
||
else
|
||
res= $"{KEY}_{roleId}_{numId}";
|
||
|
||
return res;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查台词是否有效
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool IsCheckValid(int roleId, DataDialogueCfg dataDialogueCfg)
|
||
{
|
||
foreach (E_DialogueType dialogueType in dataDialogueCfg.DialogueType)
|
||
{
|
||
if (!IsCheckValidByOne(roleId, dialogueType))
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查个单个条件是否有效
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
/// <param name="dataDialogueCfg"></param>
|
||
/// <returns></returns>
|
||
private bool IsCheckValidByOne(int roleId, E_DialogueType dialogueType)
|
||
{
|
||
switch (dialogueType)
|
||
{
|
||
case E_DialogueType.Morning: // 上午
|
||
{
|
||
DateTime dateTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server);
|
||
return dateTime.Hour >= 6 && dateTime.Hour < 16;
|
||
}
|
||
case E_DialogueType.Afternoon:
|
||
{
|
||
DateTime dateTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server);
|
||
return dateTime.Hour >= 16 && dateTime.Hour < 21;
|
||
}
|
||
case E_DialogueType.Evening:
|
||
{
|
||
DateTime dateTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server);
|
||
return dateTime.Hour >= 21 && dateTime.Hour < 23;
|
||
}
|
||
case E_DialogueType.Midnight:
|
||
{
|
||
DateTime dateTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server);
|
||
return dateTime.Hour < 6 || dateTime.Hour >= 23;
|
||
}
|
||
case E_DialogueType.PlayerBirthday:
|
||
{
|
||
DateTime kanbanbanBirth = new(2024, 4, 29); // TODO 测试玩家生日
|
||
return CommonUtils.IsBirth(kanbanbanBirth);
|
||
}
|
||
case E_DialogueType.KanbanbanBirthday:
|
||
{
|
||
CharacterDataInfo characterDataInfo = CharacterDataInfoManager.Instance.GetCharacterInfo((uint)roleId);
|
||
if (null == characterDataInfo)
|
||
{
|
||
DebugUtil.LogError("未获取到角色");
|
||
return false;
|
||
}
|
||
DateTime dateTime = CommonUtils.GetTimeByTimestamp((uint)characterDataInfo.Cfg.BirthDay);
|
||
|
||
return CommonUtils.IsBirth(dateTime);
|
||
}
|
||
case E_DialogueType.Fetters: // 好感度
|
||
{
|
||
CharacterDataInfo characterDataInfo = CharacterDataInfoManager.Instance.GetCharacterInfo((uint)roleId);
|
||
if (null == characterDataInfo)
|
||
{
|
||
DebugUtil.LogError("未获取到角色");
|
||
return false;
|
||
}
|
||
|
||
return characterDataInfo.IsMaxLikely(); // 是否满好感度
|
||
}
|
||
case E_DialogueType.Awaken:
|
||
{
|
||
CharacterDataInfo characterDataInfo = CharacterDataInfoManager.Instance.GetCharacterInfo((uint)roleId);
|
||
if (characterDataInfo == null)
|
||
{
|
||
DebugUtil.LogError("未获取到角色");
|
||
return false;
|
||
}
|
||
|
||
return characterDataInfo.IsMaxAwake(); // 是否满觉醒
|
||
}
|
||
default: // 其余条件默认满足
|
||
return true;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据权重随机一个索引
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private int RandomIndexByWeight()
|
||
{
|
||
float totalWeight = listDialogueWeight.Sum();
|
||
float randomWeight = Random.Range(0, 1f) * totalWeight;
|
||
|
||
totalWeight = 0f;
|
||
for (int i = 0; i < listDialogueWeight.Count; ++i)
|
||
{
|
||
totalWeight += listDialogueWeight[i];
|
||
if (randomWeight <= totalWeight)
|
||
return i;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否触发类型
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool IsTriggerType(E_DialogueType dialogueType)
|
||
{
|
||
return dialogueType switch
|
||
{
|
||
E_DialogueType.MainEnter or
|
||
E_DialogueType.MainClick or
|
||
E_DialogueType.Place or
|
||
E_DialogueType.QuickClick or
|
||
E_DialogueType.DrawGet or
|
||
E_DialogueType.Awakening or
|
||
E_DialogueType.UpLevel or
|
||
E_DialogueType.JoinTeam or
|
||
E_DialogueType.LevelWin or
|
||
E_DialogueType.LevelFailure => true,
|
||
_ => IsFightTriggerType(dialogueType),
|
||
};
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否战斗触发类型
|
||
/// </summary>
|
||
/// <param name="dialogueType"></param>
|
||
/// <returns></returns>
|
||
private bool IsFightTriggerType(E_DialogueType dialogueType)
|
||
{
|
||
return dialogueType switch
|
||
{
|
||
E_DialogueType.FightEnterLevel or
|
||
E_DialogueType.FightBegin or
|
||
E_DialogueType.FightRetreat or
|
||
E_DialogueType.FightChoose or
|
||
E_DialogueType.FightMove or
|
||
E_DialogueType.FightAttack or
|
||
E_DialogueType.FightUseSkill or
|
||
E_DialogueType.FightBoardVehicle or
|
||
E_DialogueType.FightLeaveVehicle or
|
||
E_DialogueType.FightGetBuff or
|
||
E_DialogueType.FightKillEnemy or
|
||
E_DialogueType.FightRepelEnemy or
|
||
E_DialogueType.FightArmourDown or
|
||
E_DialogueType.FightArmourBloodZero or
|
||
E_DialogueType.FightKnockedDown or
|
||
E_DialogueType.FightStifleState or
|
||
E_DialogueType.FightRetreatState => true,
|
||
_ => false
|
||
};
|
||
}
|
||
|
||
#region 回调
|
||
private void OnInit()
|
||
{
|
||
dicDialogue = new();
|
||
|
||
foreach (DataDialogueCfg cfg in TableManager.Instance.Tables.DialogueConfig.DataList)
|
||
{
|
||
foreach (E_DialogueType dialogueType in cfg.DialogueType)
|
||
{
|
||
if (!IsTriggerType(dialogueType))
|
||
continue;
|
||
|
||
if (!dicDialogue.TryGetValue(dialogueType, out List<DataDialogueCfg> listDialogueData))
|
||
{
|
||
listDialogueData = new List<DataDialogueCfg>();
|
||
dicDialogue[dialogueType] = listDialogueData;
|
||
}
|
||
|
||
listDialogueData.Add(cfg);
|
||
}
|
||
}
|
||
|
||
isInit = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色被指挥官技能撤退
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightRetreat(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightRetreat);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选中角色
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightChoose(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightChoose);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 移动角色
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightMove(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightMove);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色攻击
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightAttack(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightAttack);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色使用技能
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightUseSkill(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightUseSkill);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色登乘载具
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightBoardVehicle(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightBoardVehicle);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色离开载具
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightLeaveVehicle(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightLeaveVehicle);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色获得增益
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightGetBuff(int roleId)
|
||
{
|
||
if (IsPlayingFightDialogue && E_DialogueType.FightUseSkill == curFightDialogueType)
|
||
queueWaitGetBuffDialogue.Enqueue(roleId);
|
||
else
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightGetBuff);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色击杀敌人
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightKillEnemy(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightKillEnemy);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色击溃敌人
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightRepelEnemy(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightRepelEnemy);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色被攻击,装甲值降低
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightArmourDown(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightArmourDown);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色被攻击,装甲值降低
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightArmourBloodZero(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightArmourBloodZero);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色被击倒
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightKnockedDown(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightKnockedDown);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色进入被压制状态
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightStifleState(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightStifleState);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色进入溃败撤退状态
|
||
/// </summary>
|
||
/// <param name="roleId"></param>
|
||
private void OnFightRetreatState(int roleId)
|
||
{
|
||
PlayFightDiaogue(roleId, E_DialogueType.FightRetreatState);
|
||
}
|
||
#endregion
|
||
} |