礼物效果数值增加

This commit is contained in:
SD-20250424WZPW\Administrator 2025-05-06 16:21:22 +08:00
parent 98b055c1c3
commit 6d73f6f76a
3 changed files with 181 additions and 122 deletions

View File

@ -36,16 +36,8 @@ namespace GameLogic
private long m_AllPush = 0; // 当前总值
private int m_AllAddPush = 0;//永久增加推力值
private int aniIndex = 1; // 当前人物动画索引Id
private int texuteIndex = 0; // 当前人物纹理索引Id
private TextureEntry m_CurrentTextureEntry; // 当前播放的 TextureEntry
private int m_CurrentTextureIndex = 0; // 当前播放的纹理索引
private float m_FrameInterval = 0.1f; // 每帧的时间间隔(秒)
private float m_TimeSinceLastFrame = 0f; // 距离上次切换的时间
private bool m_IsPlaying = false; // 是否正在播放
private bool m_Loop = true; // 是否循环播放
private Dictionary<string, List<Buff>> m_Buffs = new Dictionary<string, List<Buff>>(); //自身Buff列表
protected override void OnCreate()
{
@ -83,7 +75,7 @@ namespace GameLogic
public void AddPlayer(UnitPlayerData data)
{
data.teamId = m_Index;
data.teamId = m_Index.ToString();
m_ListUnitPlayDatas.Add(data);
m_AddPush++;
}
@ -95,6 +87,51 @@ namespace GameLogic
private void AddMyPush()
{
// 最终结果值 = 初始推力+玩家数量 + 永久增加推力值
m_AddPush = EventConts.InitPower + m_ListUnitPlayDatas.Count + m_AllAddPush;
foreach (var item in m_Buffs)
{
// 临时准备移除的Buff列表
List<Buff> m_tempBuffList = new List<Buff>();
// 两层遍历,计算Buff效果
foreach (var buff in item.Value)
{
// 增加Buff耗时开销
buff.m_CraeteTimer += 0.05f;
// 计算Buff时常
if (buff.m_CraeteTimer >= buff.m_AllTimer)
{
// 超时移除
m_tempBuffList.Add(buff);
}
else
{
// 增加推力
if (buff.addPower > 0)
{
m_AddPush += buff.addPower;
}
}
}
// 移除超时的Buff
foreach (var buff in m_tempBuffList)
{
Log.Debug("移除Buff列表:" + buff.m_Id);
item.Value.Remove(buff);
}
}
// 减速也不能减到负数
if (m_AddPush <= 0)
{
m_AddPush = 0;
}
m_AllPush += m_AddPush;
}
@ -103,6 +140,40 @@ namespace GameLogic
m_tmpAllValue.text = m_AllPush.ToString();
}
/// <summary>
/// 增加礼物推力效果
/// </summary>
/// <param name="buff"></param>
/// <param name="unitPlayerData"></param>
public void AddBuff(Buff buff, UnitPlayerData unitPlayerData)
{
if (m_Buffs.ContainsKey(unitPlayerData.protCustMessageData.openId))
{
// // 存在相同BuffId,目前设计是增加时常?
// foreach (var item in m_Buffs[unitPlayerData.protCustMessageData.openId])
// {
// // 相同类型
// if (item.m_Id == buff.m_Id)
// {
// // 增加时常
// item.m_AllTimer += buff.m_AllTimer;
// return;
// }
// }
// 累加设计
// 没有该Buff,则新增这个Buff
m_Buffs[unitPlayerData.protCustMessageData.openId].Add(buff);
}
else
{
// 初始化这个列表Buff
m_Buffs.Add(unitPlayerData.protCustMessageData.openId, new List<Buff>());
m_Buffs[unitPlayerData.protCustMessageData.openId].Add(buff);
}
}
/// <summary>
/// 计算百分比大小值
/// </summary>

View File

@ -51,7 +51,7 @@ namespace GameLogic
public class UnitPlayerData
{
public int teamId;
public string teamId;
public ProtCustMessageData protCustMessageData;
public long m_Score; // 当局积分
public long m_AllWinCount;// 当局胜点

View File

@ -115,7 +115,7 @@ namespace GameLogic
UnitPlayerData unitPlayerData = new UnitPlayerData()
{
protCustMessageData = protCustMessageData,
teamId = -1
teamId = "-1"
};
if (string.IsNullOrEmpty(protCustMessageData.imgURL))
@ -321,119 +321,107 @@ namespace GameLogic
}
// // 处理音效
// if (buff.addPower > 0)
// {
// // GameModule.Audio.Play(TEngine.AudioType.UISound, "数字跳动的音效", false);
// // 加速特效
// m_SpeefEffectTimer += buff.m_AllTimer;
// }
// else
// {
// m_SnowEffectTimer += buff.m_AllTimer;
// }
// // 特殊Buff处理
// if (buff.isZoneTimer)
// {
// // 除了我自己以外,都挂这个Buff
// var d = GetTeamActors();
// var actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
// foreach (var item in d)
// {
// if (item.Value != actor)
// {
// item.Value.AddBuff(buff, unitPlayerData);
// }
// else
// {
// item.Value.ShowGift5Emoji();
// }
// }
// }
// else
// {
// // 减速Buff的处理
// if (buff.addPower < 0)
// {
// // 获取加速最快的星球
// var actors = GetAllRankUnityPlayerData();
// actors.Sort((a, b) =>
// {
// // 减速加速最高的
// // if (a.GetAddPush() > b.GetAddPush())
// // {
// // return -1;
// // }
// // else
// // {
// // return 1;
// // }
// if (a.GetPush() > b.GetPush())
// {
// return -1;
// }
// else
// {
// return 1;
// }
// });
// var actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
// // 减速Buff不能给自己挂
// if (actor != actors[0])
// {
// // 只减速一次
// actors[0].AddAllPush(buff.addPower);
// actors[0].AddBuff(buff, unitPlayerData);
// }
// else
// {
// // 往下依次找
// for (int i = 1; i < actors.Count; i++)
// {
// // 只减速一次
// actors[i].AddAllPush(buff.addPower);
// actors[i].AddBuff(buff, unitPlayerData);
// break;
// }
// }
// 特殊Buff处理
if (buff.isZoneTimer)
{
// 冻结
//// 除了我自己以外,都挂这个Buff
//var d = GetTeamActors();
//var actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
//foreach (var item in d)
//{
// if (item.Value != actor)
// {
// item.Value.AddBuff(buff, unitPlayerData);
// }
// else
// {
// item.Value.ShowGift5Emoji();
// }
//}
}
else
{
// 减速Buff的处理
if (buff.addPower < 0)
{
//// 获取加速最快的星球
//var actors = GetAllRankUnityPlayerData();
//actors.Sort((a, b) =>
//{
// // 减速加速最高的
// // if (a.GetAddPush() > b.GetAddPush())
// // {
// // return -1;
// // }
// // else
// // {
// // return 1;
// // }
// if (a.GetPush() > b.GetPush())
// {
// return -1;
// }
// else
// {
// return 1;
// }
//});
//var actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
//// 减速Buff不能给自己挂
//if (actor != actors[0])
//{
// // 只减速一次
// actors[0].AddAllPush(buff.addPower);
// actors[0].AddBuff(buff, unitPlayerData);
//}
//else
//{
// // 往下依次找
// for (int i = 1; i < actors.Count; i++)
// {
// // 只减速一次
// actors[i].AddAllPush(buff.addPower);
// actors[i].AddBuff(buff, unitPlayerData);
// break;
// }
//}
// var d = GetTeamActors();
// var m_actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
// foreach (var item in d)
// {
// if (item.Value == actor)
// {
// // 自己身上增加总值
// item.Value.AddAllPush(Math.Abs(buff.addPower) / 2);
//var d = GetTeamActors();
//var m_actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
//foreach (var item in d)
//{
// if (item.Value == actor)
// {
// // 自己身上增加总值
// item.Value.AddAllPush(Math.Abs(buff.addPower) / 2);
// if (buff.m_Id == 3)
// {
// item.Value.ShowGift2Emoji();
// }
// else
// {
// // 自己Actor播放表情
// item.Value.ShowGift4Emoji();
// }
// }
// }
// }
// else
// {
// var actor = DataGameSceneManager.Instance.GetTeamActor(unitPlayerData.teamId);
// if (actor != null)
// {
// // actor.m_Go.transform.DOScale(actor.m_Go.transform.localScale.x + 2f, 1f);
// actor.AddBuff(buff, unitPlayerData);
// }
// else
// {
// Log.Error("没有找到自己对应的阵营:{0}", unitPlayerData.teamId);
// }
// }
// }
// if (buff.m_Id == 3)
// {
// item.Value.ShowGift2Emoji();
// }
// else
// {
// // 自己Actor播放表情
// item.Value.ShowGift4Emoji();
// }
// }
//}
}
else
{
var actor = GetTeamActor(unitPlayerData.teamId);
if (actor != null)
{
actor.AddBuff(buff, unitPlayerData);
}
else
{
Log.Error("没有找到自己对应的阵营:{0}", unitPlayerData.teamId);
}
}
}
// if (giftConfig.Id != 1)
// {