diff --git "a/Assets/Scenes/Start_Men\303\271.unity" "b/Assets/Scenes/Start_Men\303\271.unity" index 8e19808..4d6d8f7 100644 --- "a/Assets/Scenes/Start_Men\303\271.unity" +++ "b/Assets/Scenes/Start_Men\303\271.unity" @@ -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, diff --git a/Assets/Scripts/Engine/Grid/GridTile.cs b/Assets/Scripts/Engine/Grid/GridTile.cs index bd7094e..70ca8f8 100644 --- a/Assets/Scripts/Engine/Grid/GridTile.cs +++ b/Assets/Scripts/Engine/Grid/GridTile.cs @@ -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().material.shader = Shader.Find("Custom/Glow"); - - if (transform.childCount > 0) - { - foreach (Renderer render in GetComponentsInChildren(false)) - { - render.material.shader = Shader.Find("Custom/Glow"); - } - } - } + SetGlowing(true); + return; } } } } - private void OnMouseExit() + public void SetGlowing(bool glowing) { - GetComponent().material.shader = Shader.Find("Standard"); + string shaderName = glowing ? "Custom/Glow" : "Standard"; + + GetComponent().material.shader = Shader.Find(shaderName); if (transform.childCount > 0) { foreach (Renderer render in GetComponentsInChildren(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; @@ -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) @@ -120,4 +136,12 @@ public Vector3 GetOccupantPosition() { return WordPosition; } + + private void Update() + { + if (isBuilding && HasPlayerOccupant()) + { + SetGlowing(true); + } + } } diff --git a/Assets/Scripts/Engine/Occupants/PoliceMan.cs b/Assets/Scripts/Engine/Occupants/PoliceMan.cs index a174886..5a7965a 100644 --- a/Assets/Scripts/Engine/Occupants/PoliceMan.cs +++ b/Assets/Scripts/Engine/Occupants/PoliceMan.cs @@ -116,7 +116,7 @@ public IEnumerator StartPunishingPlayer(Player player) private void UpdateDirection() { TurnsInCurrentDirection++; - if (TurnsInCurrentDirection >= TurnsBeforeChangingDirection) + if (TurnsInCurrentDirection > TurnsBeforeChangingDirection) { TurnsInCurrentDirection = 0; FlipCurrentDirection(); diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 973efa5..6b00e4d 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -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) {