Tweaked settings and converted client speed to float so its smoother and more natural
This commit is contained in:
+2
-2
@@ -8,8 +8,8 @@ namespace Caisses
|
|||||||
{
|
{
|
||||||
public class Client
|
public class Client
|
||||||
{
|
{
|
||||||
public const int MAX_SHOPPING_TIME = 100; //Original 100
|
public const int MAX_SHOPPING_TIME = 70; //Original 100
|
||||||
public const int MIN_SHOPPING_TIME = 10; //Original 10
|
public const int MIN_SHOPPING_TIME = 5; //Original 10
|
||||||
|
|
||||||
public enum ClientState
|
public enum ClientState
|
||||||
{
|
{
|
||||||
|
|||||||
+21
-16
@@ -12,14 +12,14 @@ namespace Caisses
|
|||||||
const int MAX_CLIENT_SPEED = 5;
|
const int MAX_CLIENT_SPEED = 5;
|
||||||
const int MIN_CLIENT_SPEED = -5;
|
const int MIN_CLIENT_SPEED = -5;
|
||||||
|
|
||||||
private Point _speed;
|
private PointF _speed;
|
||||||
private Point _position;
|
private PointF _position;
|
||||||
private Color _color;
|
private Color _color;
|
||||||
private Size _size;
|
private Size _size;
|
||||||
private Rectangle _area;
|
private Rectangle _area;
|
||||||
|
|
||||||
public Point Speed { get => _speed; set => _speed = value; }
|
public PointF Speed { get => _speed; set => _speed = value; }
|
||||||
public Point Position { get => _position; set => _position = value; }
|
public PointF Position { get => _position; set => _position = value; }
|
||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public Size Size { get => _size; set => _size = value; }
|
public Size Size { get => _size; set => _size = value; }
|
||||||
public Rectangle Area { get => _area; set => _area = value; }
|
public Rectangle Area { get => _area; set => _area = value; }
|
||||||
@@ -28,12 +28,17 @@ namespace Caisses
|
|||||||
{
|
{
|
||||||
Random = random;
|
Random = random;
|
||||||
Position = Entrance;
|
Position = Entrance;
|
||||||
Position = new Point(Random.Next(0, 100), Random.Next(0, 100));
|
//Position = new Point(Random.Next(0, 100), Random.Next(0, 100));
|
||||||
Speed = new Point(Random.Next(MIN_CLIENT_SPEED, MAX_CLIENT_SPEED), Random.Next(MIN_CLIENT_SPEED, MAX_CLIENT_SPEED));
|
Speed = new PointF(NextFloat(MIN_CLIENT_SPEED, MAX_CLIENT_SPEED), NextFloat(MIN_CLIENT_SPEED, MAX_CLIENT_SPEED));
|
||||||
Color = Color.FromArgb(ShoppingTime * 2, 0, 0);
|
Color = Color.FromArgb(ShoppingTime * 2, 0, 0);
|
||||||
int clientWidth = Random.Next(20, 30);
|
int clientWidth = Random.Next(20, 30);
|
||||||
Size = new Size(clientWidth, clientWidth);
|
Size = new Size(clientWidth, clientWidth);
|
||||||
}
|
}
|
||||||
|
static float NextFloat(float min, float max)
|
||||||
|
{
|
||||||
|
double val = (Random.NextDouble() * (max - min) + min);
|
||||||
|
return (float)val;
|
||||||
|
}
|
||||||
public void Update(Size area)
|
public void Update(Size area)
|
||||||
{
|
{
|
||||||
//base.Tick();
|
//base.Tick();
|
||||||
@@ -47,27 +52,27 @@ namespace Caisses
|
|||||||
switch (State)
|
switch (State)
|
||||||
{
|
{
|
||||||
case ClientState.Shopping:
|
case ClientState.Shopping:
|
||||||
g.FillEllipse(new SolidBrush(Color), new Rectangle(Position, Size));
|
g.FillEllipse(new SolidBrush(Color), new RectangleF(Position, Size));
|
||||||
g.DrawString(ShoppingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White),new PointF(Position.X,Position.Y));
|
g.DrawString(ShoppingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White),new PointF(Position.X,Position.Y));
|
||||||
break;
|
break;
|
||||||
case ClientState.Waiting:
|
case ClientState.Waiting:
|
||||||
g.FillEllipse(new SolidBrush(Color.Red), new Rectangle(Position, Size));
|
g.FillEllipse(new SolidBrush(Color.Red), new RectangleF(Position, Size));
|
||||||
g.DrawString(WaitingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y));
|
g.DrawString(WaitingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y));
|
||||||
break;
|
break;
|
||||||
case ClientState.Inline:
|
case ClientState.Inline:
|
||||||
g.FillEllipse(new SolidBrush(Color.Violet), new Rectangle(Position, Size));
|
g.FillEllipse(new SolidBrush(Color.Violet), new RectangleF(Position, Size));
|
||||||
break;
|
break;
|
||||||
case ClientState.Checkout:
|
case ClientState.Checkout:
|
||||||
g.FillEllipse(new SolidBrush(Color.Green), new Rectangle(Position, Size));
|
g.FillEllipse(new SolidBrush(Color.Green), new RectangleF(Position, Size));
|
||||||
g.DrawString(CheckoutTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), new PointF(Position.X, Position.Y));
|
g.DrawString(CheckoutTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), new PointF(Position.X, Position.Y));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Point checkBounds(Point position, Size area)
|
public PointF checkBounds(PointF position, Size area)
|
||||||
{
|
{
|
||||||
Point newPosition = new Point(position.X,position.Y);
|
PointF newPosition = new PointF(position.X,position.Y);
|
||||||
/*
|
/*
|
||||||
if (position.X < 0)
|
if (position.X < 0)
|
||||||
{
|
{
|
||||||
@@ -97,10 +102,10 @@ namespace Caisses
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int diff = Math.Abs(position.X + Speed.X);
|
float diff = Math.Abs(position.X + Speed.X);
|
||||||
newPosition.X = diff;
|
newPosition.X = diff;
|
||||||
//newPosition = new Point(0, position.Y);
|
//newPosition = new Point(0, position.Y);
|
||||||
Speed = new Point(Speed.X * -1,Speed.Y);
|
Speed = new PointF(Speed.X * -1,Speed.Y);
|
||||||
//speed.X += -1;
|
//speed.X += -1;
|
||||||
}
|
}
|
||||||
if (position.Y + Speed.Y > 0 && position.Y + Size.Height + Speed.Y < area.Height)
|
if (position.Y + Speed.Y > 0 && position.Y + Size.Height + Speed.Y < area.Height)
|
||||||
@@ -109,10 +114,10 @@ namespace Caisses
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int diff = Math.Abs(position.Y + Speed.Y);
|
float diff = Math.Abs(position.Y + Speed.Y);
|
||||||
newPosition.Y = diff;
|
newPosition.Y = diff;
|
||||||
//newPosition = new Point(position.X, 0);
|
//newPosition = new Point(position.X, 0);
|
||||||
Speed = new Point(Speed.X,Speed.Y * -1);
|
Speed = new PointF(Speed.X,Speed.Y * -1);
|
||||||
//speed.Y *= -1;
|
//speed.Y *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ namespace Caisses
|
|||||||
TimeOfTheDayInMinuts++;
|
TimeOfTheDayInMinuts++;
|
||||||
if (TimeOfTheDayInMinuts % 60 == 0)
|
if (TimeOfTheDayInMinuts % 60 == 0)
|
||||||
{
|
{
|
||||||
|
if (TimeOfTheDayInMinuts >= 24 * 60)
|
||||||
|
{
|
||||||
|
TimeOfTheDayInMinuts = 0;
|
||||||
|
}
|
||||||
//Its a new Hour so we can send the new clients
|
//Its a new Hour so we can send the new clients
|
||||||
int amountOfNewCLients = ATTENDANCE[TimeOfTheDayInHours];
|
int amountOfNewCLients = ATTENDANCE[TimeOfTheDayInHours];
|
||||||
FillStore(amountOfNewCLients);
|
FillStore(amountOfNewCLients);
|
||||||
|
|||||||
Reference in New Issue
Block a user