Parking/Assets/Scripts/Driver.cs

84 lines
2.0 KiB
C#
Raw Normal View History

2022-08-25 18:38:38 +02:00
using System;
using Unity.VisualScripting;
using UnityEngine;
2022-08-25 18:38:38 +02:00
namespace Parking
2022-08-25 18:38:38 +02:00
{
public class Driver
{
2022-09-03 21:27:31 +02:00
public readonly ParkingPreference ParkingPreference;
public readonly int Number;
2022-08-31 21:19:20 +02:00
public readonly Size Size;
2022-09-01 22:31:57 +02:00
public DateTime[] Times;
public Spot Spot;
public bool Parked = false;
public GameObject GameObject;
public bool Rejected = false;
2022-09-04 00:35:45 +02:00
public int Priority;
public int UpdateInterval;
2022-09-04 00:35:45 +02:00
public Driver(Size size, int number, ParkingPreference parkingPreference, int priority, int updateInterval)
{
Size = size;
2022-09-03 21:27:31 +02:00
Number = number;
ParkingPreference = parkingPreference;
2022-09-04 00:35:45 +02:00
Priority = priority;
UpdateInterval = updateInterval;
}
2022-09-03 21:27:31 +02:00
public void Reset()
{
Parked = false;
Rejected = false;
if(Spot != null)
Spot.Free = true;
Spot = null;
if(GameObject != null)
GameObject.Destroy(GameObject);
}
}
2022-08-25 18:38:38 +02:00
public class Spot : IComparable<Spot>
2022-08-25 18:38:38 +02:00
{
public Size Size;
public bool Flipped;
public GameObject GameObject;
2022-09-01 22:31:57 +02:00
public bool Free = true;
2022-09-03 21:27:31 +02:00
public bool Reserved = false;
2022-09-04 00:35:45 +02:00
public int ReservedPriority = 0;
public ParkingPreference ParkingDirection = ParkingPreference.Any;
2022-09-05 22:00:15 +02:00
public int Lane = 0;
public bool Perpendicular = true;
public bool AlignToTop = true;
public Spot(Size size, bool flipped)
{
Size = size;
Flipped = flipped;
}
2022-09-04 00:35:45 +02:00
public Spot()
{
}
public int CompareTo(Spot obj)
{
return Size.CompareTo(obj.Size);
}
2022-08-25 18:38:38 +02:00
}
public enum Size
{
A = 0,
B = 1,
C = 2,
D = 3
}
2022-08-25 18:38:38 +02:00
public enum ParkingPreference
{
Any = 0,
Front = 1,
Back = 2
}
2022-08-25 18:38:38 +02:00
}