Skip to content

Commit

Permalink
Add mapping for all auctioneer audio to events
Browse files Browse the repository at this point in the history
  • Loading branch information
Fueredoriku committed Oct 12, 2023
1 parent 4470ccc commit f8cc64d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Assets/Scripts/Auction/AuctionDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ private void OnDestroy()
biddingPlatforms[i].onBiddingExtended -= SetPrioritizedPlatform;
biddingPlatforms[i].onBidPlaced -= ActivateAuctioneerBid;
biddingPlatforms[i].onBiddingEnd -= ActivateAuctioneerSell;
biddingPlatforms[i].onBiddingExtended -= ActivateAuctioneerHaste;
biddingPlatforms[i].onBidDenied -= ActivateAuctioneerMissing;
}
}

Expand Down Expand Up @@ -99,6 +101,8 @@ private IEnumerator PopulatePlatforms()
biddingPlatforms[i].onBiddingExtended += SetPrioritizedPlatform;
biddingPlatforms[i].onBidPlaced += ActivateAuctioneerBid;
biddingPlatforms[i].onBiddingEnd += ActivateAuctioneerSell;
biddingPlatforms[i].onBiddingExtended += ActivateAuctioneerHaste;
biddingPlatforms[i].onBidDenied += ActivateAuctioneerMissing;
}
}

Expand Down Expand Up @@ -168,4 +172,14 @@ private void ActivateAuctioneerSell(BiddingPlatform biddingPlatform)
{
auctioneer.Sell();
}

private void ActivateAuctioneerHaste(BiddingPlatform platform)
{
auctioneer.Haste();
}

private void ActivateAuctioneerMissing(BiddingPlatform platform)
{
auctioneer.Missing();
}
}
14 changes: 14 additions & 0 deletions Assets/Scripts/Auction/Auctioneer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,18 @@ public void Sell()
audioSource.clip = sold.RandomElement();
audioSource.Play();
}

public void Haste()
{
audioSource.Stop();
audioSource.clip = haste.RandomElement();
audioSource.Play();
}

public void Missing()
{
audioSource.Stop();
audioSource.clip = missingChips.RandomElement();
audioSource.Play();
}
}
7 changes: 4 additions & 3 deletions Assets/Scripts/Auction/BiddingPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class BiddingPlatform : MonoBehaviour
public BiddingEvent onBiddingExtended;
public BiddingEvent onBiddingEnd;
public BiddingEvent onBidPlaced;
public BiddingEvent onBidDenied;

private void OnTriggerEnter(Collider other)
{
Expand Down Expand Up @@ -94,29 +95,29 @@ public bool TryPlaceBid(PlayerIdentity playerIdentity)
return false;
}

if (playerIdentity.chips > chips && playerIdentity != leadingBidder)
if (playerIdentity.chips > chips)
{
// Refund
if (leadingBidder)
{
leadingBidder.UpdateChip(chips);
}
//activeBiddingRound.chips[0] = chips++;
chips++;
playerIdentity.UpdateChip(-chips);
itemCostText.text = chips.ToString();
leadingBidder = playerIdentity;
material.SetColor("_BidderColor", playerIdentity.color);
LeanTween.value(gameObject, UpdateBorder, 0f, 1f, borderTweenDuration);
onBidPlaced(this);

if ((auctionTimer.WaitTime - auctionTimer.ElapsedTime) < bumpTime)
{
auctionTimer.AddTime(bumpTime);
onBiddingExtended(this);
}
onBidPlaced(this);
return true;
}
onBidDenied(this);
return false;
}

Expand Down

0 comments on commit f8cc64d

Please sign in to comment.