Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions Assets/Scenes/Bidding.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Auction/AuctionDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vector3> YieldPositions => yieldPositions.Select(t => t.position);
private List<PlayerManager> yieldingPlayers = new();
public int YieldingPlayerCount => yieldingPlayers.Count;

Expand Down
14 changes: 10 additions & 4 deletions Assets/Scripts/Auction/BiddingAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using CollectionExtensions;
using UnityEngine;
using UnityEngine.AI;

Expand All @@ -11,11 +12,11 @@ public class BiddingAI : BiddingPlayer
private NavMeshAgent agent;
[SerializeField]
private Animator animator;
private Dictionary<BiddingPlatform, int> priorities = new Dictionary<BiddingPlatform, int>();
private readonly Dictionary<BiddingPlatform, int> 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;
Expand Down Expand Up @@ -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)
Expand Down
Loading