Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
m-garin committed Mar 15, 2018
1 parent 6a3daab commit dc75953
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Assets/Scripts/InputManager/GhostInputManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Buildings;
using Buildings.Ghost;
using PlacementArea;
using PlacementArea.BuildingsManager;
using UI.BuildingsManager;
using UnityEngine;

namespace InputManager
Expand All @@ -15,7 +15,7 @@ public class GhostInputManager : MonoBehaviour, IGhostInputManager
[SerializeField]
MouseInput input;
[SerializeField]
BuildingsManager buildingsManager;
UIBuildingsManager buildingsManager;

IBuilding buildingGhost;
float elevateZ = -1.2f; //Height above ground level
Expand Down
13 changes: 6 additions & 7 deletions Assets/Scripts/PlacementArea/BuildingPlacementArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ public class BuildingPlacementArea : MonoBehaviour, IPlacementArea
[SerializeField]
TileFactory tileFactory;

ICreatePlacementArea creatPlacementArea;
List<IBuilding> buildings; //already constructed buildings
ITile[,] tiles;
IPlaceChecker placeChecker;
IHighlightTiles highlightTiles;

void Start()
{
buildings = new List<IBuilding>();
//generate area
creatPlacementArea = new CreatePlacementArea();
tiles = creatPlacementArea.Generate(tileFactory, planeCollider, mapSettings.MapWidth, mapSettings.MapHight);
tiles = new CreatePlacementArea().Generate(tileFactory, planeCollider, mapSettings.MapWidth, mapSettings.MapHight);
//set tiles checker
placeChecker = new PlaceChecker(this);
highlightTiles = new HighlightTiles(this);
}

/// <summary>
Expand All @@ -41,6 +39,7 @@ public ITile GetTile(Vector2Int _gridPos)
//check the boundaries
if (_gridPos.x < 0 || _gridPos.y < 0 || _gridPos.x > mapSettings.MapWidth || _gridPos.y > mapSettings.MapHight)
{
Debug.LogError("Out of bounds");
return null;
}

Expand All @@ -58,7 +57,7 @@ public FitStatus Fits(Vector2Int _gridPos, IBuilding _building)
{
return FitStatus.OutOfBounds;
}
placeChecker.Check(_gridPos, _building);
highlightTiles.HighlightTile(_gridPos, _building);

for (int y = _gridPos.y; y < extents.y; y++)
{
Expand All @@ -82,7 +81,7 @@ public void PlaceBuilding(Vector2Int _gridPos, BuildingType _buildingType)
//buildings
IBuilding building = buildingFactory.Create(_buildingType, _gridPos, -0.6f);
buildings.Add(building);
placeChecker.Reset();
highlightTiles.Reset();

Vector2Int extents = new Vector2Int(_gridPos.x + building.Width, _gridPos.y + building.Height);

Expand Down
10 changes: 0 additions & 10 deletions Assets/Scripts/PlacementArea/BuildingsManager.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Scripts/PlacementArea/CreatePlacementArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CreatePlacementArea : ICreatePlacementArea
return tiles;
}

private void FillRandomTiles(int _chance)
void FillRandomTiles(int _chance)
{
for (int y = 0; y < height; y++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

namespace PlacementArea
{
public class PlaceChecker : IPlaceChecker
public class HighlightTiles : IHighlightTiles
{
List<ITile> checkedTiles;
List<ITile> highlightedTiles;
IPlacementArea placementArea;

public PlaceChecker(IPlacementArea _placementArea)
public HighlightTiles(IPlacementArea _placementArea)
{
placementArea = _placementArea;
checkedTiles = new List<ITile>();
highlightedTiles = new List<ITile>();
}

public void Check(Vector2Int _gridPos, IBuilding _building)
public void HighlightTile(Vector2Int _gridPos, IBuilding _building)
{
Reset();
Vector2Int extents = new Vector2Int(_gridPos.x + _building.Width, _gridPos.y + _building.Height);
Expand All @@ -27,17 +27,17 @@ public void Check(Vector2Int _gridPos, IBuilding _building)
{
ITile tile = placementArea.GetTile(new Vector2Int(x, y));
tile.Glow(true);
checkedTiles.Add(tile);
highlightedTiles.Add(tile);
}
}
}

public void Reset()
{
for (int i = checkedTiles.Count - 1; i >= 0; i--)
for (int i = highlightedTiles.Count - 1; i >= 0; i--)
{
checkedTiles[i].Glow(false);
checkedTiles.RemoveAt(i);
highlightedTiles[i].Glow(false);
highlightedTiles.RemoveAt(i);
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Assets/Scripts/PlacementArea/IHighlightTiles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Buildings;
using UnityEngine;

namespace PlacementArea
{
public interface IHighlightTiles
{
void HighlightTile(Vector2Int _gridPos, IBuilding _building);
void Reset();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions Assets/Scripts/PlacementArea/IPlaceChecker.cs

This file was deleted.

10 changes: 10 additions & 0 deletions Assets/Scripts/PlacementArea/Tiles/TileObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ Color PrefabColor
public void Glow(bool _turn)
{
if (prefab != null)
{
if (_turn)
{
if (Empty)
{
PrefabColor = emptyColor;
}
else
{
PrefabColor = occupiedColor;
}
}
else
{
PrefabColor = baseColor;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

namespace PlacementArea.BuildingsManager
{
public interface IBuildingsManager
public interface IUIBuildingsManager
{
void Enable();
void Disable();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using Buildings;
using InputManager;
using PlacementArea;
using PlacementArea.BuildingsManager;
using UI.BuildingManager;
using UnityEngine;

namespace PlacementArea.BuildingsManager
namespace UI.BuildingsManager
{
/// <summary>
/// BuildingsManager class
/// Open windows for building management
/// </summary>
public class BuildingsManager : MonoBehaviour, IBuildingsManager
public class UIBuildingsManager : MonoBehaviour, IUIBuildingsManager
{
[SerializeField]
MouseInput input;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Assets/_Scenes/Builder.unity
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 119296828}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 618, y: -201.5, z: 0}
m_LocalPosition: {x: 460.5, y: -190, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1608600439}
Expand Down Expand Up @@ -1127,7 +1127,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1071015081}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 573, y: -161.5, z: 0}
m_LocalPosition: {x: 415.5, y: -150, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1177027420}
Expand Down Expand Up @@ -1399,7 +1399,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1308484775}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fea776edcd54f4a07ae2ad1f540a0436, type: 3}
m_Script: {fileID: 11500000, guid: e0eb46abb60a74657a3f957ef1320063, type: 3}
m_Name:
m_EditorClassIdentifier:
input: {fileID: 2127886066}
Expand Down Expand Up @@ -1595,7 +1595,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447100563}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 628, y: 211.5, z: 0}
m_LocalPosition: {x: 470.5, y: 200, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1889518330}
Expand Down
21 changes: 12 additions & 9 deletions CityBuilder3D.userprefs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<Properties StartupConfiguration="{F8D7B36B-BD74-F76F-FBFF-95CB72BE723D}|">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/UI/BuildingManager/PopUpView.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/InputManager/GhostInputManager.cs">
<Files>
<File FileName="Assets/Scripts/UI/BuildingManager/InformationPanelView.cs" Line="32" Column="6" />
<File FileName="Assets/Scripts/PlacementArea/BuildingsManager/BuildingsManager.cs" Line="19" Column="9" />
<File FileName="Assets/Scripts/PlacementArea/CreatePlacementArea.cs" Line="5" Column="2" />
<File FileName="Assets/Scripts/PlacementArea/BuildingPlacementArea.cs" Line="84" Column="27" />
<File FileName="Assets/Scripts/PlacementArea/IPlacementArea.cs" Line="13" Column="2" />
<File FileName="Assets/Scripts/InputManager/MouseInput.cs" Line="1" Column="1" />
<File FileName="Assets/Scripts/UI/BuildingManager/UIBuildingsManager.cs" Line="19" Column="28" />
<File FileName="Assets/Scripts/UI/BuildingManager/IUIBuildingsManager.cs" Line="1" Column="1" />
<File FileName="Assets/Scripts/UI/BuildingManager/IInformationPanelView.cs" Line="8" Column="2" />
<File FileName="Assets/Scripts/UI/BuildingManager/PopUpController.cs" Line="41" Column="29" />
<File FileName="Assets/Scripts/UI/BuildingManager/PopUpView.cs" Line="25" Column="9" />
<File FileName="Assets/Scripts/UI/Craft/CraftMenuView.cs" Line="45" Column="36" />
<File FileName="Assets/Scripts/UI/AbstractWindowView.cs" Line="13" Column="1" />
<File FileName="Assets/Scripts/UI/OverlayWindow.cs" Line="20" Column="2" />
<File FileName="Assets/Scripts/UI/BuildingManager/IPopUpView.cs" Line="1" Column="1" />
<File FileName="Assets/Scripts/PlacementArea/Tiles/TileObject.cs" Line="49" Column="31" />
<File FileName="Assets/Scripts/PlacementArea/IHighlightTiles.cs" Line="3" Column="1" />
<File FileName="Assets/Scripts/InputManager/GhostInputManager.cs" Line="42" Column="1" />
<File FileName="Assets/Scripts/PlacementArea/HighlightTiles.cs" Line="40" Column="33" />
<File FileName="CityBuilder3D.csproj" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
Expand Down

0 comments on commit dc75953

Please sign in to comment.