Skip to content

Commit

Permalink
stempelkaart ui
Browse files Browse the repository at this point in the history
  • Loading branch information
bozmir committed Dec 20, 2024
1 parent ccb0bf1 commit ba23530
Show file tree
Hide file tree
Showing 18 changed files with 1,422 additions and 4 deletions.
141 changes: 137 additions & 4 deletions Assets/Scenes/Main.unity

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

31 changes: 31 additions & 0 deletions Assets/Scripts/KerstSpecial/StempelTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Expand All @@ -8,10 +9,12 @@ public class StempelTrigger : ZoneTrigger
{
public bool IsCollected = false;
private RaceController controller;
private stempelkaart stempelkaart;

private void Start()
{
controller = FindObjectOfType<RaceController>();
stempelkaart = FindObjectOfType<stempelkaart>(true);
GetComponent<BoxCollider>().isTrigger = true;
}

Expand All @@ -25,7 +28,35 @@ protected override void OnTriggerEnter(Collider other)
StempelTrigger[] triggers = transform.parent.transform.GetComponentsInChildren<StempelTrigger>();
foreach (StempelTrigger trigger in triggers)
trigger.IsCollected = true;



stempelkaart.gameObject.SetActive(true);
stempelkaart.SetStampMarkerEnabled(false);
StartCoroutine(WaitSeconds(10, () =>
{
stempelkaart.gameObject.SetActive(false);
}));
StartCoroutine(WaitSeconds(1, () =>
{
stempelkaart.SetStampMarkerEnabled(true);
string objName = transform.parent.transform.parent.name;
char numberString = objName[objName.Length - 1];
int num = int.Parse(numberString.ToString());
stempelkaart.SetStampEnabled(num, true);
StartCoroutine(WaitSeconds(1, () =>
{
stempelkaart.SetStampMarkerEnabled(false);
}));
}));
}
}

private IEnumerator WaitSeconds(float seconds, Action callBack)
{
yield return new WaitForSeconds(seconds);
callBack?.Invoke();
}

}
}
56 changes: 56 additions & 0 deletions Assets/Scripts/KerstSpecial/stempelkaart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace Netherlands3D.Twin
{
public class stempelkaart : MonoBehaviour
{
[SerializeField] private Sprite vol;
[SerializeField] private GameObject one;
[SerializeField] private GameObject two;
[SerializeField] private GameObject three;
[SerializeField] private Sprite empty;
[SerializeField] private GameObject stamp;

private Image img;


// Start is called before the first frame update
void Start()
{
img = GetComponent<Image>();
img.sprite = empty;

SetStampEnabled(1, false);
SetStampEnabled(2, false);
SetStampEnabled(3, false);
}

public void SetStampEnabled(int num, bool enabled)
{
RectTransform rect = stamp.GetComponent<RectTransform>();
if (num == 1)
{
one.SetActive(enabled);
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, one.GetComponent<RectTransform>().anchoredPosition.y + 30);
}
if (num == 2)
{
two.SetActive(enabled);
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, two.GetComponent<RectTransform>().anchoredPosition.y + 30);
}
if (num == 3)
{
three.SetActive(enabled);
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, three.GetComponent<RectTransform>().anchoredPosition.y + 30);
}
}

public void SetStampMarkerEnabled(bool enabled)
{
stamp.SetActive(enabled);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/KerstSpecial/stempelkaart.cs.meta

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

Loading

0 comments on commit ba23530

Please sign in to comment.