1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Study;
- using UnityEngine;
- public enum WaypointType { slalom1, slalom2, finish};
- public class SlalomPassed : MonoBehaviour
- {
- public WaypointType type;
- // Only relevant to check finish
- public int routeId;
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.CompareTag("bike"))
- {
- // Set finished in statistics, so success is logged
- var bikePlayer = GameObject.Find("bike");
- var playerStats = bikePlayer.GetComponent<PlayerStats>();
- Debug.Log("Waypoint passed");
- if (type == WaypointType.finish)
- {
- var cm = GameObject.Find("ExperimentManager").GetComponent<ConditionManager>();
- int routeNbr = cm.GetRouteNumber();
- // If type is finish, we need to make sure we only set for right finish
- // because routes are overlapping
- if (routeId == routeNbr)
- {
- playerStats.SetWaypointPassed(type);
- }
- }
- else
- {
- playerStats.SetWaypointPassed(type);
- }
- }
- }
- }
|