Skip to content

Commit

Permalink
Level texture alpha values fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
arifemrebulut committed Oct 4, 2022
1 parent c7faee4 commit 54c9a15
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 23 deletions.
Binary file modified Assets/_Game/Art/LevelTextures/Level10-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level2-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level3-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level4-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level5-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level6-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level7-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level8-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/_Game/Art/LevelTextures/Level9-Texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Assets/_Game/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ MonoBehaviour:
levelBorderCube: {fileID: 5290094178444827526, guid: 981cb30fcb25be841b38bd485ea23b55, type: 3}
cameraPositionLerpDuration: 0.2
cameraRotationLerpDuration: 0.2
oldLevelSlideDuration: 2
newLevelSlideDuration: 2
oldLevelSlideDuration: 1
newLevelSlideDuration: 1
levelSuccessConfetti: {fileID: 2004083741}
--- !u!1 &604123958
GameObject:
Expand Down
6 changes: 3 additions & 3 deletions Assets/_Game/Scriptables/ColorNumberPairs.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ MonoBehaviour:
m_Name: ColorNumberPairs
m_EditorClassIdentifier:
pairs:
- color: {r: 1, g: 0, b: 0, a: 0}
- color: {r: 1, g: 0, b: 0, a: 1}
number: 0
- color: {r: 1, g: 1, b: 1, a: 0}
- color: {r: 1, g: 1, b: 1, a: 1}
number: 0
- color: {r: 0, g: 0, b: 0, a: 0}
- color: {r: 0, g: 0, b: 0, a: 1}
number: 0
- color: {r: 0.8, g: 0.654902, b: 0.24705882, a: 1}
number: 2
Expand Down
43 changes: 25 additions & 18 deletions Assets/_Game/Scripts/LevelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void CreateCurrentLevel()
float width = levelTexture.width;
float height = levelTexture.height;

// Offset for centering the level on the x axis
// Offset for centering the level
Vector3 offset = new Vector3(width / 2f, 0f, height / 2f) - new Vector3(0.5f, 0f, 0.5f);

Vector3 instantiatePosition = onStart ? Vector3.zero : nextLevelInstantiatePoint.position;
Expand All @@ -115,29 +115,36 @@ private void CreateCurrentLevel()
{
Color pixelColor = levelTexture.GetPixel(x, y);

if (pixelColor.a == 0) continue;

if (!CompareColors(pixelColor, Color.white))
if (pixelColor.a == 0)
{
GameObject borderCube = Instantiate(levelBorderCube);
borderCube.transform.parent = currentLevel.transform;
borderCube.transform.localPosition = new Vector3(x, 0f, y) - offset;
}
else
{
GameObject roadTile = Instantiate(roadTilePrefab);
if (!CompareColors(pixelColor, Color.white))
{
GameObject roadTile = Instantiate(roadTilePrefab);

roadTile.transform.parent = currentLevel.transform;
roadTile.transform.localPosition = new Vector3(x, 0f, y) - offset;
}
roadTile.transform.parent = currentLevel.transform;
roadTile.transform.localPosition = new Vector3(x, 0f, y) - offset;
}

GameObject prefab = GetPrefabFromColor(pixelColor);
GameObject tile = Instantiate(prefab);
GameObject prefab = GetPrefabFromColor(pixelColor);
GameObject tile = Instantiate(prefab);

tile.transform.parent = currentLevel.transform;
tile.transform.localPosition = new Vector3(x, 0f, y) - offset;
tile.transform.parent = currentLevel.transform;
tile.transform.localPosition = new Vector3(x, 0f, y) - offset;

if (tile.CompareTag("NumberCube"))
{
tile.GetComponent<NumberCube>().number = int.Parse(GetNumberFromColor(pixelColor));
if (tile.CompareTag("NumberCube"))
{
tile.GetComponent<NumberCube>().number = int.Parse(GetNumberFromColor(pixelColor));

GameObject tileGraphic = tile.transform.GetChild(0).gameObject;
tileGraphic.GetComponent<MeshRenderer>().material.color = pixelColor;
tileGraphic.GetComponentInChildren<TextMeshPro>().text = GetNumberFromColor(pixelColor);
GameObject tileGraphic = tile.transform.GetChild(0).gameObject;
tileGraphic.GetComponent<MeshRenderer>().material.color = pixelColor;
tileGraphic.GetComponentInChildren<TextMeshPro>().text = GetNumberFromColor(pixelColor);
}
}
}
}
Expand Down

0 comments on commit 54c9a15

Please sign in to comment.