Skip to content

Commit

Permalink
💄 Make Triangles bigger on first level
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arutiunian committed Jun 27, 2020
1 parent aee6fc1 commit 6a0b8f0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ MonoBehaviour:
m_StartCorner: 0
m_StartAxis: 1
m_CellSize: {x: 1, y: 1}
m_Spacing: {x: 0.7, y: 1}
m_Spacing: {x: 1, y: 1}
m_Constraint: 0
m_ConstraintCount: 3
--- !u!224 &718848809
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/GameStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class GameStore : MonoBehaviour
public static readonly string INITIAL_REMEMBER_TEXT = "Remember";
public static readonly string AGAIN_REMEMBER_TEXT = "Remember Again!";

public int score { get; private set; } = 0; public int weight { get; private set; } = MIN_WEIGHT;
public int score { get; private set; } = 0;
public int weight { get; private set; } = MIN_WEIGHT;
public int step { get; private set; } = 0;
public int timer { get; private set; } = INITIAL_TIMER;
public bool win { get; private set; } = false;
Expand Down
15 changes: 15 additions & 0 deletions Assets/Scripts/PrepareState.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class PrepareState : BaseGameState
{
Expand All @@ -16,6 +17,8 @@ protected override void DoOnStart()
game.GameOverlay.SetActive(true);
game.ToolbarController.ShowTimer();

SetGridLayoutSpacing();

GameEvents.instance.OnCountEnd += DoOnCountEnd;

Restart();
Expand Down Expand Up @@ -63,4 +66,16 @@ private void DoOnCountEnd()
GameStore.instance.SetReady(true);
GameEvents.instance.TriggerPrepareEnd();
}

private void SetGridLayoutSpacing()
{
if (GameStore.instance.GetAbsoluteWeight() == 0)
{
game.GameGrid.GetComponent<GridLayoutGroup>().spacing = new Vector2(1.3f, 1f);
}
else
{
game.GameGrid.GetComponent<GridLayoutGroup>().spacing = new Vector2(0.7f, 1f);
}
}
}
9 changes: 8 additions & 1 deletion Assets/Scripts/TriangleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ private GameObject[] CreateTrianglesFor(Rotation[] rotations)
private GameObject CreateTriangle(Vector3 pos, Quaternion rot)
{
var triangle = GameObject.Instantiate(template, pos, rot, parent);
triangle.transform.localScale += new Vector3(1.5f, 1.5f, 1);
triangle.transform.localScale += GetTriangleScale();
return triangle;
}

private Vector3 GetTriangleScale() {
if (GameStore.instance.GetAbsoluteWeight() == 0) {
return new Vector3(2f, 2f, 1f);
}
return new Vector3(1.5f, 1.5f, 1f);
}

private void SortTriangles(GameObject[] triangles)
{
Array.Sort(triangles, CompareNames);
Expand Down

0 comments on commit 6a0b8f0

Please sign in to comment.