Add initial game code
This commit is contained in:
parent
f80a60e208
commit
1383997ebf
55 changed files with 1355 additions and 0 deletions
62
scripts/AI.cs
Normal file
62
scripts/AI.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
|
||||
public partial class AI
|
||||
{
|
||||
public Structure Parent { get; private set; }
|
||||
|
||||
private Random RandomGenerator;
|
||||
|
||||
public AI(Structure parent)
|
||||
{
|
||||
this.Parent = parent;
|
||||
|
||||
this.RandomGenerator = new Random();
|
||||
}
|
||||
|
||||
public Order Think()
|
||||
{
|
||||
// Change of MOVE order, if mobile and in space
|
||||
if (this.Parent.IsMobile && !this.Parent.IsLanded && Helpers.GetChance(30))
|
||||
{
|
||||
// Chance of local movement
|
||||
if (Helpers.GetChance(95))
|
||||
{
|
||||
// Chance of aimless movement
|
||||
if (Helpers.GetChance(100))
|
||||
{
|
||||
CoordinateVector deltaCoordinates = Helpers.GetRandomCoordinatesFromAU(
|
||||
-0.5M, 0.5M,
|
||||
-0.5M, 0.5M
|
||||
);
|
||||
CoordinateVector newCoordinates = Helpers.CalculateNewCoordinates(this.Parent, deltaCoordinates);
|
||||
|
||||
return new DestinationOrder(Order.OrderType.MOVE_THRUSTERS, newCoordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Chance of aimless movement
|
||||
if (Helpers.GetChance(100))
|
||||
{
|
||||
CoordinateVector deltaCoordinates = Helpers.GetRandomCoordinatesFromLY(
|
||||
-500M, 500M,
|
||||
-500M, 500M
|
||||
);
|
||||
CoordinateVector newCoordinates = Helpers.CalculateNewCoordinates(this.Parent, deltaCoordinates);
|
||||
|
||||
return new DestinationOrder(Order.OrderType.MOVE_WARP, newCoordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TickOrder(Order.OrderType.IDLE, 10);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue