From 34839ac53d50c4761900e2b62bfee7a91af457a1 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Tue, 3 Feb 2026 22:13:07 +0100 Subject: [PATCH] Offset auction targets by random vector --- Assets/Scenes/Bidding.unity | 52 ++++++++++++++++++++++++- Assets/Scripts/Auction/AuctionDriver.cs | 4 +- Assets/Scripts/Auction/BiddingAI.cs | 14 +++++-- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Assets/Scenes/Bidding.unity b/Assets/Scenes/Bidding.unity index 4e0945992..460b3b962 100644 --- a/Assets/Scenes/Bidding.unity +++ b/Assets/Scenes/Bidding.unity @@ -279,6 +279,7 @@ MonoBehaviour: m_Dithering: 0 m_ClearDepth: 1 m_AllowXRRendering: 1 + m_AllowHDROutput: 1 m_UseScreenCoordOverride: 0 m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} @@ -1189,6 +1190,37 @@ Transform: m_CorrespondingSourceObject: {fileID: 7770595616075609816, guid: df667c99d94bd994a89241ccaf715e96, type: 3} m_PrefabInstance: {fileID: 288775816} m_PrefabAsset: {fileID: 0} +--- !u!1 &296630949 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 296630950} + m_Layer: 0 + m_Name: YieldPositionLeft + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &296630950 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 296630949} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.37, y: 0, z: -5.58} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6930750696370995859} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &297157268 PrefabInstance: m_ObjectHideFlags: 0 @@ -4004,6 +4036,7 @@ MonoBehaviour: m_Dithering: 0 m_ClearDepth: 1 m_AllowXRRendering: 1 + m_AllowHDROutput: 1 m_UseScreenCoordOverride: 0 m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} @@ -4477,7 +4510,7 @@ GameObject: m_Component: - component: {fileID: 1931707550} m_Layer: 0 - m_Name: YieldPosition + m_Name: YieldPositionRight m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -5209,7 +5242,10 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] - m_AddedGameObjects: [] + m_AddedGameObjects: + - targetCorrespondingSourceObject: {fileID: 4839170055916188716, guid: 37cb7ab9cd0031843a633a455c37e2c4, type: 3} + insertIndex: -1 + addedObject: {fileID: 296630950} m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 37cb7ab9cd0031843a633a455c37e2c4, type: 3} --- !u!4 &6930750696370995859 stripped @@ -5552,6 +5588,18 @@ PrefabInstance: propertyPath: yieldZones.Array.data[1] value: objectReference: {fileID: 1202213204} + - target: {fileID: 320780411405276928, guid: ace884b1bf546300a85f4176788f481b, type: 3} + propertyPath: yieldPositions.Array.size + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 320780411405276928, guid: ace884b1bf546300a85f4176788f481b, type: 3} + propertyPath: yieldPositions.Array.data[0] + value: + objectReference: {fileID: 296630950} + - target: {fileID: 320780411405276928, guid: ace884b1bf546300a85f4176788f481b, type: 3} + propertyPath: yieldPositions.Array.data[1] + value: + objectReference: {fileID: 1931707550} - target: {fileID: 320780411405276928, guid: ace884b1bf546300a85f4176788f481b, type: 3} propertyPath: biddingPlatforms.Array.data[0] value: diff --git a/Assets/Scripts/Auction/AuctionDriver.cs b/Assets/Scripts/Auction/AuctionDriver.cs index 19cfd54b7..4254726d2 100644 --- a/Assets/Scripts/Auction/AuctionDriver.cs +++ b/Assets/Scripts/Auction/AuctionDriver.cs @@ -42,8 +42,8 @@ public class AuctionDriver : NetworkBehaviour [SerializeField] private YieldZone[] yieldZones; [SerializeField] - private Transform yieldPosition; - public Vector3 YieldPosition => yieldPosition.position; + private Transform[] yieldPositions; + public IEnumerable YieldPositions => yieldPositions.Select(t => t.position); private List yieldingPlayers = new(); public int YieldingPlayerCount => yieldingPlayers.Count; diff --git a/Assets/Scripts/Auction/BiddingAI.cs b/Assets/Scripts/Auction/BiddingAI.cs index f0471172f..1a209aa2c 100644 --- a/Assets/Scripts/Auction/BiddingAI.cs +++ b/Assets/Scripts/Auction/BiddingAI.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Data; using System.Linq; +using CollectionExtensions; using UnityEngine; using UnityEngine.AI; @@ -11,11 +12,11 @@ public class BiddingAI : BiddingPlayer private NavMeshAgent agent; [SerializeField] private Animator animator; - private Dictionary priorities = new Dictionary(); + private readonly Dictionary priorities = new(); [SerializeField] private BiddingPlatform currentDestination; [SerializeField] - private Vector3 platformDestinationOffset = Vector3.back * 2; + private Vector2 platformDestinationOffset = new(2, 4); private int platformsEvaluated = 0; private bool shouldEvaluate = true; @@ -84,13 +85,18 @@ private void ChooseDestination() var isOverBudget = spentChips >= budget; var isAlreadyInTheLead = currentDestination.LeadingBidder == playerManager.id; + var offsetX = platformDestinationOffset.x; + var offsetZ = platformDestinationOffset.y; + var offset = new Vector3(Random.Range(-offsetX, offsetX), 0, Random.Range(-offsetZ, offsetZ)); + if (priorities[currentDestination] == -1 || isOverBudget || isAlreadyInTheLead) { - agent.SetDestination(AuctionDriver.Singleton.YieldPosition); + var yieldTarget = AuctionDriver.Singleton.YieldPositions.OrderBy(p => Vector3.Distance(p, transform.position)).First(); + agent.SetDestination(yieldTarget + offset); return; } - agent.SetDestination(currentDestination.transform.position + platformDestinationOffset); + agent.SetDestination(currentDestination.transform.position + offset); var isAlreadyAtThisPlatform = currentDestination == playerManager.SelectedBiddingPlatform; if (isAlreadyAtThisPlatform)