Added Day-night cycle
This commit is contained in:
commit
8ba385b759
@ -160,9 +160,9 @@ namespace Game1
|
||||
|
||||
|
||||
|
||||
spriteBatch.Draw(house, houseUnit.GetRectangle(), Color.White);
|
||||
spriteBatch.Draw(house, houseUnit.GetRectangle(), Time.GetTimeOfDay());
|
||||
spriteBatch.Draw(markers, new Rectangle((int)tractorUnit.getPath().getFinalDest().getCords().X * (input.getSpacingTile()) + Convert.ToInt32(input.getTileSize() / 6), (int)tractorUnit.getPath().getFinalDest().getCords().Y * (input.getSpacingTile()) + Convert.ToInt32(input.getTileSize() / 6), Convert.ToInt32(input.getTileSize() / 1.5), Convert.ToInt32(input.getTileSize() / 1.5)), Color.Red); //Draws the current target of the tractor
|
||||
spriteBatch.Draw(tractor, new Vector2((int)tractorUnit.getPos().X + input.getTileSize() / 2, (int)tractorUnit.getPos().Y + input.getTileSize() / 2), new Rectangle(0, 0, input.getTileSize(), input.getTileSize()), Color.White, tractorUnit.getRotation(), new Vector2(input.getTileSize() / 2, input.getTileSize() / 2), 1.0f, SpriteEffects.None, 1);
|
||||
spriteBatch.Draw(tractor, new Vector2((int)tractorUnit.getPos().X + input.getTileSize() / 2, (int)tractorUnit.getPos().Y + input.getTileSize() / 2), new Rectangle(0, 0, input.getTileSize(), input.getTileSize()), Time.GetTimeOfDay(), tractorUnit.getRotation(), new Vector2(input.getTileSize() / 2, input.getTileSize() / 2), 1.0f, SpriteEffects.None, 1);
|
||||
|
||||
|
||||
|
||||
@ -176,8 +176,9 @@ namespace Game1
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(Bold, "Time: ", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, Time.getDayNight(), new Vector2(60, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, Time.GetTimeOfDayInt().ToString(), new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "Days " + Time.getDays(), new Vector2(60, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "Day Progression: ", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, Time.GetTimeOfDayInt().ToString() + "%", new Vector2(140, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.DarkBlue);
|
||||
|
||||
spriteBatch.DrawString(Bold, "Tractor Properties:", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 62), Color.DarkRed);
|
||||
|
||||
@ -194,6 +195,9 @@ namespace Game1
|
||||
spriteBatch.DrawString(Bold, "Matrix Size: " + input.getSize().X.ToString() + " X " + input.getSize().Y.ToString(), new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 242), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "House Position: " + houseUnit.getVector() / input.getSpacingTile(), new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 262), Color.DarkBlue);
|
||||
|
||||
spriteBatch.DrawString(Bold, "Total Weight: ", new Vector2(700, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 182), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, "(" + tractorUnit.getInventory().getWeight() + "/" + tractorUnit.getInventory().getMaxWeight() + ")", new Vector2(800, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 182), Color.DarkBlue);
|
||||
|
||||
tractorUnit.drawInventory(input, spriteBatch, Bold, inventory.getPredefinedItems());
|
||||
|
||||
InspectTile();
|
||||
@ -213,7 +217,7 @@ namespace Game1
|
||||
for (int j = 0; j < input.getSize().Y; j++)
|
||||
{
|
||||
Rectangle tilePos = new Rectangle(i * (input.getSpacingTile()), j * (input.getSpacingTile()), input.getTileSize(), input.getTileSize());
|
||||
spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).getStatus()], tilePos, Color.White);
|
||||
spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).getStatus()], tilePos, Time.GetTimeOfDay());
|
||||
if (tilePos.Intersects(mousePosition))
|
||||
{
|
||||
spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).getStatus()], tilePos, Color.FromNonPremultiplied(0, 0, 20, 40));
|
||||
|
@ -172,6 +172,44 @@
|
||||
<Version>4.11.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LightGBM">
|
||||
<Version>2.3.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML.CpuMath">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML.FastTree">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML.LightGbm">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.CodeDom">
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Collections.Immutable">
|
||||
<Version>1.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Reflection.Emit.Lightweight">
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
|
||||
<Version>4.7.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Threading.Tasks.Dataflow">
|
||||
<Version>4.11.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -10,8 +10,9 @@ class DayNightCycle
|
||||
private bool Time = true;
|
||||
private int nightTime = 0;
|
||||
private int dayTime = 0;
|
||||
private int lengthOfDay = 6000;
|
||||
private int lengthOfNight = 6000;
|
||||
private int lengthOfDay = 20000;
|
||||
private int lengthOfNight = 20000;
|
||||
private int Days;
|
||||
|
||||
public void updateTime(int Speed)
|
||||
{
|
||||
@ -33,6 +34,7 @@ class DayNightCycle
|
||||
{
|
||||
Time = true;
|
||||
nightTime = 0;
|
||||
Days++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,28 +54,70 @@ class DayNightCycle
|
||||
|
||||
public Color GetTimeOfDay()
|
||||
{
|
||||
int blue;
|
||||
if (nightTime == 0 || dayTime == 0)
|
||||
int blue, red, brightness;
|
||||
if (nightTime == 0 && dayTime == 0)
|
||||
{
|
||||
red = 1;
|
||||
blue = 1;
|
||||
brightness = 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
blue = (6000 / nightTime);
|
||||
if ((float)dayTime / lengthOfDay < 0.5)
|
||||
{
|
||||
blue = (int)(((float)nightTime / lengthOfNight) * 255) + (int)((1.0f - (float)dayTime / lengthOfDay) * 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
blue = (int)(((float)nightTime / lengthOfNight) * 255) + (int)(((float)dayTime / lengthOfDay) * 255);
|
||||
}
|
||||
|
||||
if ((float)nightTime / lengthOfNight < 0.5)
|
||||
{
|
||||
red = (int)((1.0 - (float)nightTime / lengthOfNight) * 255) + (int)(((float)dayTime / lengthOfDay) * 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
red = (int)(((float)nightTime / lengthOfNight) * 255) + (int)(((float)dayTime / lengthOfDay) * 255);
|
||||
}
|
||||
|
||||
if (Time)
|
||||
{
|
||||
brightness = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((float)nightTime / lengthOfNight < 0.5)
|
||||
{
|
||||
brightness = (int)((1.0 - (float)nightTime / lengthOfNight) * 255) + (int)(((float)dayTime / lengthOfDay) * 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
brightness = (int)(((float)nightTime / lengthOfNight) * 255) + (int)(((float)dayTime / lengthOfDay) * 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Color.FromNonPremultiplied(0, 0, blue, 100);
|
||||
return Color.FromNonPremultiplied(red, 255, blue, brightness);
|
||||
}
|
||||
|
||||
public int GetTimeOfDayInt()
|
||||
{
|
||||
if (Time)
|
||||
{
|
||||
return dayTime / 60;
|
||||
return (int)(100 * ((float)(dayTime + nightTime) / (lengthOfDay + lengthOfNight))) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nightTime / 60;
|
||||
return (int)(100 * ((float)(lengthOfDay + nightTime) / (lengthOfDay + lengthOfNight))) + 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getDays()
|
||||
{
|
||||
return Days;
|
||||
}
|
||||
}
|
||||
|
@ -154,4 +154,9 @@ class Tractor
|
||||
{
|
||||
smartTractor.drawInventory(input, spriteBatch, Bold, itemStorageDefined);
|
||||
}
|
||||
|
||||
public Inventory getInventory()
|
||||
{
|
||||
return smartTractor.getInventory();
|
||||
}
|
||||
}
|
||||
|
@ -72,4 +72,9 @@ class AI
|
||||
}
|
||||
return farm;
|
||||
}
|
||||
|
||||
public Inventory getInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
|
@ -74,4 +74,9 @@ class SmartTractor
|
||||
farm.updateFarm(Size);
|
||||
}
|
||||
}
|
||||
|
||||
public Inventory getInventory()
|
||||
{
|
||||
return ai.getInventory();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user