Skip to content

Commit

Permalink
Second submission tentative
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiocali committed Mar 22, 2020
1 parent 1c3ffd3 commit aadd915
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
7 changes: 4 additions & 3 deletions Assets/Scenes/Start_Menù.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1491,9 +1491,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: "Game Made by:\nAlessio Cal\xEC\nMaria Giulia Canu\nAlessandro Mascherin\nRossella
Scarcia\n\nAssets:\nPolygon - Starter Kit\nSimple Town Lite - Cartoon Assets\nFarland
Skies - Cloudy Crown\nPolygonal's Low Poly Particle Pack"
m_text: "Game Made by:\nAlessio Giuseppe Cal\xEC\nMaria Giulia Canu\nAlessandro
Mascherin\nRossella Scarcia\n\nAssets:\nPolygon - Starter Kit\nSimple Town Lite
- Cartoon Assets\nFarland Skies - Cloudy Crown\nPolygonal's Low Poly Particle
Pack"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 65ff235843264c14882297b799ecbbbb, type: 2}
m_sharedMaterial: {fileID: -2726572748238971982, guid: 65ff235843264c14882297b799ecbbbb,
Expand Down
60 changes: 42 additions & 18 deletions Assets/Scripts/Engine/Grid/GridTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,55 @@ public TileIndex (int x, int y)
private void OnMouseOver()
{

if (isWalkable)
if (!GameManager.Instance.IsPlayerWaitingForInput())
{
var tilesAround = GameManager.Instance.GridMap.GetCardinalAndWalkableTilesAround(Index);
foreach(var tile in tilesAround){
return;
}

if (isWalkable || isBuilding)
{
var tilesAround = GameManager.Instance.GridMap.GetCardinalTilesAround(Index);
foreach(var tile in tilesAround)
{
if (tile.HasPlayerOccupant())
{
if (GameManager.Instance.IsPlayerWaitingForInput())
{
GetComponent<Renderer>().material.shader = Shader.Find("Custom/Glow");

if (transform.childCount > 0)
{
foreach (Renderer render in GetComponentsInChildren<Renderer>(false))
{
render.material.shader = Shader.Find("Custom/Glow");
}
}
}
SetGlowing(true);
return;
}
}
}

}

private void OnMouseExit()
public void SetGlowing(bool glowing)
{
GetComponent<Renderer>().material.shader = Shader.Find("Standard");
string shaderName = glowing ? "Custom/Glow" : "Standard";

GetComponent<Renderer>().material.shader = Shader.Find(shaderName);
if (transform.childCount > 0)
{
foreach (Renderer render in GetComponentsInChildren<Renderer>(false))
{
render.material.shader = Shader.Find("Standard");
render.material.shader = Shader.Find(shaderName);
}
}
}

private void OnMouseExit()
{
SetGlowing(false);
}

private void UpdateBuildingGlowing()
{
if (!isBuilding)
{
return;
}

SetGlowing(Occupants.Count > 0);
}

public TileIndex Index { get; private set; }
private Vector3 WordPosition;

Expand Down Expand Up @@ -93,12 +107,14 @@ public void AddOccupant(Occupant occupant)
if (!Occupants.Contains(occupant))
{
Occupants.Add(occupant);
UpdateBuildingGlowing();
}
}

public void RemoveOccupant(Occupant occupant)
{
Occupants.Remove(occupant);
UpdateBuildingGlowing();
}

public void OnOccupantCollided(Occupant other)
Expand All @@ -120,4 +136,12 @@ public Vector3 GetOccupantPosition()
{
return WordPosition;
}

private void Update()
{
if (isBuilding && HasPlayerOccupant())
{
SetGlowing(true);
}
}
}
2 changes: 1 addition & 1 deletion Assets/Scripts/Engine/Occupants/PoliceMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public IEnumerator StartPunishingPlayer(Player player)
private void UpdateDirection()
{
TurnsInCurrentDirection++;
if (TurnsInCurrentDirection >= TurnsBeforeChangingDirection)
if (TurnsInCurrentDirection > TurnsBeforeChangingDirection)
{
TurnsInCurrentDirection = 0;
FlipCurrentDirection();
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Managers/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void UpdateRuntimeOccupants()

private void SpawnStartingOccupants()
{
SpawnOccupantObjectOnTile(PlayerCharacter[SharedSceneParameter.CharacterSelected], GridMap.GetRandomTileIndex(false, true));
SpawnOccupantObjectOnTile(PlayerCharacter[SharedSceneParameter.CharacterSelected], GridMap.GetHomeTileIndex());

foreach (GameObject objectToSpawn in OccupantsToSpawnOnStart)
{
Expand Down

0 comments on commit aadd915

Please sign in to comment.