private void Update() { if (IsBlocked || selectionService == null || cameraRayProvider == null) { return; } selectionService.Refresh(); int id = -1; while (selectionService.DetectSelection(out id)) { Ray ray = cameraRayProvider.GetRay(id); Physics.Raycast(ray, out RaycastHit hitInfo, float.MaxValue); //the ray can hit nothing, a target or the game board surface if (hitInfo.transform != null && hitInfo.transform.parent != null) { WhackTarget target = hitInfo.transform.parent.GetComponent <WhackTarget>(); if (target != null) { target.GetHit(); } } } }
private void LoadTargets(List <RoundDefinition.SlotDefinition> slotDefinitions) { for (int i = 0; i < presenters.Count; i++) { presenters[i].ClearTarget(); RoundDefinition.SlotDefinition slotDefinition = slotDefinitions[i]; if (slotDefinition == null) { continue; } WhackTarget targetPrefab = targetTypeCollection.targetTypes[slotDefinition.targetTypeIndex]; WhackTarget newTarget = GameObject.Instantiate <WhackTarget>(targetPrefab, presenters[i].transform); newTarget.transform.eulerAngles = Vector3.zero; presenters[i].SetTarget(newTarget); newTarget.Init(presenters[i], playModel); } }
public void ClearTarget() { GameObject.Destroy(target?.gameObject); this.target = null; }
public void SetTarget(WhackTarget target) { this.target = target; }