礼物效果数值增加

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 long m_AllPush = 0; // 当前总值
private int m_AllAddPush = 0;//永久增加推力值 private int m_AllAddPush = 0;//永久增加推力值
private int aniIndex = 1; // 当前人物动画索引Id
private int texuteIndex = 0; // 当前人物纹理索引Id
private Dictionary<string, List<Buff>> m_Buffs = new Dictionary<string, List<Buff>>(); //自身Buff列表
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; // 是否循环播放
protected override void OnCreate() protected override void OnCreate()
{ {
@ -83,7 +75,7 @@ namespace GameLogic
public void AddPlayer(UnitPlayerData data) public void AddPlayer(UnitPlayerData data)
{ {
data.teamId = m_Index; data.teamId = m_Index.ToString();
m_ListUnitPlayDatas.Add(data); m_ListUnitPlayDatas.Add(data);
m_AddPush++; m_AddPush++;
} }
@ -95,6 +87,51 @@ namespace GameLogic
private void AddMyPush() 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; m_AllPush += m_AddPush;
} }
@ -103,6 +140,40 @@ namespace GameLogic
m_tmpAllValue.text = m_AllPush.ToString(); 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>
/// 计算百分比大小值 /// 计算百分比大小值
/// </summary> /// </summary>

View File

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

View File

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