new builder option per draft - first one is gold per kill
This commit is contained in:
parent
4a37d3747c
commit
157b77ebfa
21 changed files with 456 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using TD.Core;
|
||||
using TD.Gameplay.BuilderEffects;
|
||||
using TD.Gameplay.Draft;
|
||||
using TD.Levels;
|
||||
using TD.UI;
|
||||
|
|
@ -524,22 +525,31 @@ namespace TD.Gameplay
|
|||
var goldEntry = goldConfig?.GetWaveEntry(currentWaveIndex + 1);
|
||||
if (goldEntry != null) killReward = goldEntry.GoldPerEnemy;
|
||||
|
||||
// Award kill gold to the tower owner that landed the killing blow.
|
||||
// Award kill gold to the tower owner that landed the killing blow. The builder's
|
||||
// "gold per kill" effect (if granted) is queried live here rather than cached on
|
||||
// the killing tower — see BuilderUpgradeManager's "query, don't snapshot" note.
|
||||
PlayerSlot killerSlot = health.LastHitOwner;
|
||||
int totalReward = killReward;
|
||||
if (killerSlot != PlayerSlot.None && killReward > 0)
|
||||
{
|
||||
var pms = PlayerMatchState.GetForSlot(killerSlot);
|
||||
if (pms != null)
|
||||
{
|
||||
var gpk = BuilderUpgradeManager.GetForClient(pms.OwnerClientId)
|
||||
?.GetEffectDefinition<GoldPerKillEffectDefinition>(BuilderEffectKind.GoldPerKill);
|
||||
totalReward = killReward + (gpk?.BonusGoldPerKill ?? 0);
|
||||
|
||||
PlayerGoldManager.GetForClient(pms.OwnerClientId)
|
||||
?.AwardGold(killReward);
|
||||
?.AwardGold(totalReward);
|
||||
}
|
||||
}
|
||||
|
||||
// Show a "+N" gold popup above the corpse on every peer. Capture the
|
||||
// position here on the server — by the time the RPC fires on clients
|
||||
// the death sequence will be moving the corpse, but the spawn point
|
||||
// is good enough and we want the popup to anchor where the kill happened.
|
||||
if (killReward > 0)
|
||||
ShowGoldRewardClientRpc(health.transform.position, killReward);
|
||||
if (totalReward > 0)
|
||||
ShowGoldRewardClientRpc(health.transform.position, totalReward);
|
||||
|
||||
UnsubscribeEnemy(health);
|
||||
DecrementAndCheckComplete();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue