Skip to content

Commit

Permalink
Add max chip amount #723
Browse files Browse the repository at this point in the history
- Add visual feedback for the max cap

- Add chip sprite to bidsigns for consistency
  • Loading branch information
Fueredoriku committed Jun 19, 2024
1 parent fcc530e commit a6c9725
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 18 deletions.
16 changes: 10 additions & 6 deletions Assets/Prefabs/Characters/BidSign.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Transform:
m_Children:
- {fileID: 4581443405367376368}
m_Father: {fileID: 0}
m_RootOrder: -1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!1 &568565037362853658
GameObject:
Expand Down Expand Up @@ -289,8 +289,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 21.4, y: 9.9}
m_SizeDelta: {x: 200, y: 50}
m_AnchoredPosition: {x: 3.5, y: 9.9}
m_SizeDelta: {x: 268, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5640744163071201223
CanvasRenderer:
Expand Down Expand Up @@ -320,7 +320,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0
m_text: 1<sprite name="chip">
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: d9a852cc525d17841bddd69dcb8cc48b, type: 2}
m_sharedMaterial: {fileID: -1782873873408761557, guid: d9a852cc525d17841bddd69dcb8cc48b, type: 2}
Expand All @@ -347,8 +347,8 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 60
m_fontSizeBase: 60
m_fontSize: 50
m_fontSizeBase: 50
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
Expand Down Expand Up @@ -596,6 +596,10 @@ PrefabInstance:
propertyPath: m_Name
value: Chip
objectReference: {fileID: 0}
- target: {fileID: 1652744153996658575, guid: 07a746de7e3746f4d890544bb6e655b4, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
Expand Down
8 changes: 6 additions & 2 deletions Assets/Prefabs/Input/BiddingPlayer.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 71015680234268067, guid: 2872a05bf8e94d541a70726bb35085f3, type: 3}
propertyPath: m_Name
value: BiddingPlayer Variant
value: BiddingPlayer
objectReference: {fileID: 0}
- target: {fileID: 71015680234268071, guid: 2872a05bf8e94d541a70726bb35085f3, type: 3}
propertyPath: m_RootOrder
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 71015680234268071, guid: 2872a05bf8e94d541a70726bb35085f3, type: 3}
propertyPath: m_LocalPosition.x
Expand Down Expand Up @@ -118,11 +118,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c85ae4dc2c19fa34f8629863582cad91, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
playerManager: {fileID: 9008804336744780163}
sign: {fileID: 7513734972606371177}
signMesh: {fileID: 6644921302523891212}
signTarget: {fileID: 5126564517472471787}
chipText: {fileID: 8806784467613749292}
maxChipColor: {r: 0.9607843, g: 0.2784314, b: 0.23921569, a: 1}
signCross: {fileID: 3206215793599913730}
--- !u!114 &9008804336744780163 stripped
MonoBehaviour:
Expand Down
5 changes: 3 additions & 2 deletions Assets/Prefabs/Input/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,7 @@ MonoBehaviour:
tweenDuration: 0.07
chipBox: {fileID: 7552965056758612035}
chipAmount: {fileID: 5281579252922457437}
maxChipColor: {r: 0.9607843, g: 0.2784314, b: 0.23921569, a: 1}
deathScreen: {fileID: 1029316632486890240}
deathText: {fileID: 9172283963218471322}
spectateHintText: {fileID: 5812129328713847385}
Expand Down Expand Up @@ -2695,8 +2696,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 31.4, y: 0}
m_SizeDelta: {x: 70, y: 50}
m_AnchoredPosition: {x: 47.8, y: 0}
m_SizeDelta: {x: 105, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7260709117223012713
CanvasRenderer:
Expand Down
2 changes: 2 additions & 0 deletions Assets/Prefabs/UI/LoadingScreen.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ MonoBehaviour:
- A gun barrel <sprite name="barrel_white"> changes what kind of bullets you shoot!
- A gun extension <sprite name="extension_white"> adds additional effects to your
gun!
- You can't carry more than 20 chips <sprite name="chip">, so be sure to spend
some every now and then!
background: {fileID: 8814292908430132048}
mandatoryDuration: 4
normalRotationSpeed: 60
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Auction/BiddingAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ void Start()

public void SetIdentity(PlayerIdentity identity)
{
chipText.text = identity.chips.ToString();
chipText.text = "<sprite name=\"chip\">" + identity.chips.ToString();
identity.onChipChange += UpdateChipStatus;
chipText.color = playerManager.identity.chips == PlayerIdentity.MaxChips ? Color.red : Color.black;
}

private IEnumerator WaitAndEvaluate()
Expand Down
8 changes: 6 additions & 2 deletions Assets/Scripts/Auction/BiddingPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class BiddingPlayer : NetworkBehaviour
[SerializeField]
protected TMP_Text chipText;
[SerializeField]
private Color maxChipColor;
[SerializeField]
protected TMP_Text signCross;
protected BiddingPlatform currentPlatform = null;

Expand All @@ -29,7 +31,8 @@ private void Start()
public void SetIdentity()
{
playerManager.identity.onChipChange += UpdateChipStatus;
chipText.text = playerManager.identity.chips.ToString();
chipText.text = "<sprite name=\"chip\">" + playerManager.identity.chips.ToString();
chipText.color = playerManager.identity.chips == PlayerIdentity.MaxChips ? maxChipColor : Color.black;
}

public void SetPlayerInput()
Expand Down Expand Up @@ -98,7 +101,8 @@ protected void AnimateSignContent(BiddingPlatform platform)

protected void UpdateChipStatus(int chips)
{
chipText.text = chips.ToString();
chipText.text = "<sprite name=\"chip\">" + chips.ToString();
chipText.color = playerManager.identity.chips == PlayerIdentity.MaxChips ? maxChipColor : Color.black;
}

private void FixedUpdate()
Expand Down
4 changes: 3 additions & 1 deletion Assets/Scripts/Gamestate/PlayerIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PlayerIdentity : MonoBehaviour
public List<Item> Extensions { get; private set; } = new List<Item>();

public int chips { get; private set; } = 0;

public const int MaxChips = 20;
public uint id;

public delegate void ChipEvent(int amount);
Expand Down Expand Up @@ -69,6 +69,7 @@ public void UpdateChip(int amount)
else
{
chips += amount;
chips = Mathf.Min(chips, MaxChips);
}

onChipChange?.Invoke(chips);
Expand All @@ -86,6 +87,7 @@ public void UpdateChip(int amount)
public void UpdateChipSilently(int amount)
{
chips += amount;
chips = Mathf.Min(chips, MaxChips);
}

public void PerformTransaction(Item item)
Expand Down
10 changes: 6 additions & 4 deletions Assets/Scripts/UI/PlayerHUDController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class PlayerHUDController : MonoBehaviour

[SerializeField]
private TMP_Text chipAmount;

[SerializeField]
private Color maxChipColor;
private int chipTween;

private float originalChipY;
Expand Down Expand Up @@ -136,7 +137,7 @@ void Start()
// This keeps the chip counter from conflicting with the timer
chipBox.anchorMin = Vector2.one;
chipBox.anchorMax = Vector2.one;
originalChipX = -chipBox.sizeDelta.x / 2f - 10;
originalChipX = -chipBox.sizeDelta.x / 2f - 40;
// Also scale down the health bar stuff
hudParent.localScale = .6f * Vector3.one;
}
Expand Down Expand Up @@ -207,8 +208,9 @@ public void OnChipChange(int amount)
// TODO replace by not requiring UI stuff on the bidding players
if (!chipAmount)
return;

chipAmount.text = amount.ToString();
bool isMax = amount == PlayerIdentity.MaxChips;
chipAmount.text = isMax ? "MAX" : amount.ToString();
chipAmount.color = isMax ? maxChipColor : Color.white;
if (LeanTween.isTweening(chipTween))
{
LeanTween.cancel(chipTween);
Expand Down

0 comments on commit a6c9725

Please sign in to comment.