Skip to content

Commit

Permalink
Merge pull request #130 from Permafrost-Game/enhancement-zone-instruc…
Browse files Browse the repository at this point in the history
…tion

Enhancement zone instruction
  • Loading branch information
JR-Morgan authored Mar 2, 2020
2 parents 1abce42 + e3813ff commit f63e006
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 22 deletions.
1 change: 1 addition & 0 deletions TeamProject/Engine/Engine/PathFinding/PathFindingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private static Queue<Tile> EnqueueNextPath(IPathFindable pathFindable)
catch (PathFindingPathException)
{
//Path is not a valid path
paths.Clear();
pathFindable.Path.Clear();
}

Expand Down
25 changes: 14 additions & 11 deletions TeamProject/Engine/Engine/TileGrid/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,39 @@ public class Tile : GameObject, Engine.Drawing.IDrawable
public new Vector2 Position { get; }
public Temperature temperature;
public bool Heated { get; set; }

public string Type { get; }
///<summary>Default tag, walkable boolean</summary>
private readonly int tag = -1;
public bool Walkable { get; }

private readonly Rectangle sourceRectangle;
private readonly Rectangle destinationRectangle;
public Tile(Texture2D texture, Vector2 position, Vector2 size, bool walkable) : base(position, size)
{
this.Type = texture.Name;
this.Type = texture.Name;

this.Position = position;
this.texture = texture;
this.Walkable = walkable;
temperature = new Temperature(-5/*ZoneManager.GlobalTemperature*/);//TODO fix this

sourceRectangle = new Rectangle(
location: new Point((int) position.X % texture.Width, (int)position.Y % texture.Height),
size: Size.ToPoint()
);
destinationRectangle = new Rectangle((base.Position - Size / 2).ToPoint(), Size.ToPoint());
}

public void Draw(SpriteBatch spriteBatch)
{
//spriteBatch.Draw(texture, new Rectangle(base.Position.ToPoint(), size.ToPoint()), Color.White);
spriteBatch.Draw(
texture: texture,
destinationRectangle: new Rectangle((base.Position - Size /2).ToPoint(), Size.ToPoint()),
sourceRectangle: new Rectangle(
new Point( (Position.X/32) % 2 == 0? 0 : 32, (Position.Y/32) % 2 == 0? 0 : 32),
Size.ToPoint()),
destinationRectangle: destinationRectangle,
sourceRectangle: sourceRectangle,
color: Color.White
);
}

///<summary>Equality testing</summary>
public override bool Equals(object t)
{
if (t is Tile tile)
Expand All @@ -63,4 +66,4 @@ public override int GetHashCode()
return (base.GetHashCode() + tag);
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion TeamProject/GlobalWarmingGame/GameObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static string MapPath(Vector2 pos)
static TileMap GenerateMap(Vector2 pos)
{
//return TileMapParser.parseTileMap(MapPath(pos), tileSet);
return TileMapGenrator.GenerateTileMap(seed: seed, scale: 0.005f, xOffset: (int)pos.X * 100, yOffset: (int)pos.Y * 100, width: 100, height: 100, tileSet);
return TileMapGenrator.GenerateTileMap(seed: seed, scale: 0.005f, xOffset: (int)pos.X * 99, yOffset: (int)pos.Y * 99, width: 100, height: 100, tileSet);
}

public static void Init(TileSet ts)
Expand Down
Binary file modified TeamProject/GlobalWarmingGame/Icon.bmp
Binary file not shown.
Binary file modified TeamProject/GlobalWarmingGame/Icon.ico
Binary file not shown.
10 changes: 5 additions & 5 deletions TeamProject/GlobalWarmingGame/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GlobalWarmingGame")]
[assembly: AssemblyProduct("GlobalWarmingGame")]
[assembly: AssemblyTitle("Permafrost")]
[assembly: AssemblyProduct("Permafrost")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyDescription("https://permafrost-game.github.io/")]
[assembly: AssemblyCompany("Permafrost")]
[assembly: AssemblyCopyright("Copyright © Permafrost 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
39 changes: 34 additions & 5 deletions TeamProject/GlobalWarmingGame/UI/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Engine;
using Engine.TileGrid;
using GlobalWarmingGame.Action;
using GlobalWarmingGame.Interactions;
using GlobalWarmingGame.Interactions.Interactables;
Expand All @@ -12,6 +13,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static GlobalWarmingGame.Action.InstructionType;

namespace GlobalWarmingGame.UI
{
Expand Down Expand Up @@ -100,20 +102,41 @@ private static List<ButtonHandler<Instruction>> GenerateInstructionOptions(GameO
{
options.Add(new ButtonHandler<Instruction>(new Instruction(WALK_INSTRUCTION_TYPE, activeMember, objectClicked), IssueInstructionCallback));



if (objectClicked is IInteractable interactable)
{
foreach (InstructionType type in interactable.InstructionTypes)
{
options.Add(new ButtonHandler<Instruction>(new Instruction(type, activeMember, objectClicked), IssueInstructionCallback));
}
}
else if (constructingMode)
else if (objectClicked is Tile tile)
{
building = (IBuildable)InteractablesFactory.MakeInteractable(SelectedBuildable, objectClicked.Position);

options.Add(new ButtonHandler<Instruction>(new Instruction(new InstructionType("build", "Build", "Build the " + SelectedBuildable.ToString(), 0, building.CraftingCosts, onComplete: Build),
activeMember,
(GameObject)building), IssueInstructionCallback));
if (tile.Walkable)
{
if (tile.Position.X == 0)
options.Add(new ButtonHandler<Instruction>(new Instruction(TravelInstruction(ZoneTravelWest), activeMember, objectClicked), IssueInstructionCallback));

else if (tile.Position.Y == 0)
options.Add(new ButtonHandler<Instruction>(new Instruction(TravelInstruction(ZoneTravelNorth), activeMember, objectClicked), IssueInstructionCallback));

else if (tile.Position.X >= ((GameObjectManager.ZoneMap.Size.X - 1) * 32f))
options.Add(new ButtonHandler<Instruction>(new Instruction(TravelInstruction(ZoneTravelEast), activeMember, objectClicked), IssueInstructionCallback));

else if (tile.Position.Y >= ((GameObjectManager.ZoneMap.Size.Y - 1) * 32f))
options.Add(new ButtonHandler<Instruction>(new Instruction(TravelInstruction(ZoneTravelSouth), activeMember, objectClicked), IssueInstructionCallback));

else if (constructingMode)
{
building = (IBuildable)InteractablesFactory.MakeInteractable(SelectedBuildable, objectClicked.Position);

options.Add(new ButtonHandler<Instruction>(new Instruction(new InstructionType("build", "Build", "Build the " + SelectedBuildable.ToString(), 0, building.CraftingCosts, onComplete: Build),
activeMember,
(GameObject)building), IssueInstructionCallback));
}
}
}

if (objectClicked is Colonist)
Expand All @@ -129,6 +152,12 @@ private static List<ButtonHandler<Instruction>> GenerateInstructionOptions(GameO
return options;
}

private static InstructionType TravelInstruction(InstructionEvent e) => new InstructionType("travel", "Travel", "Travel to the next zone", onComplete: e);
private static void ZoneTravelNorth(Instruction i = default) => GameObjectManager.MoveZone(new Vector2( 0, -1));
private static void ZoneTravelSouth(Instruction i = default) => GameObjectManager.MoveZone(new Vector2( 0, 1));
private static void ZoneTravelEast (Instruction i = default) => GameObjectManager.MoveZone(new Vector2( 1, 0));
private static void ZoneTravelWest (Instruction i = default) => GameObjectManager.MoveZone(new Vector2(-1, 0));

/// <summary>
/// Adds the instruction to the active member of the instruction.
/// Checks if a instruction has any required resources and if so the instruction will
Expand Down

0 comments on commit f63e006

Please sign in to comment.