/// <summary> /// The target handler will call this method when the aim data has been updated and is ready to be /// processed by anything that needs to be aware of any changes. This generally includes a visual /// indicator for the aiming and the active orientation handler. /// </summary> /// <param name="aimData"></param> public void OnUpdateAimData(AimData aimData) { if (UpdateAimData != null) { UpdateAimData(aimData); } }
private void SendAim(AimData data) { try { Aim(data); } catch { Debug.Log("No destination assigned to event: Aim"); } }
protected void SendAim(Vector2 position) { try { // replace 250 with the maximum range of a weapons later. AimData data = new AimData(position, 250); OnAim(data); } catch { Debug.LogError("Could not send delegate to destination!"); } }
public AimData GetCoordsByRay (Ray aimRay) { AimData data = new AimData(); RaycastHit raycastHitData; if (!Physics.Raycast(aimRay, out raycastHitData) || //if was not hit !raycastHitData.collider.transform.IsChildOf(transform)) //if was hit in object that is not child of voxeland return data; data.collider = raycastHitData.collider; #region Terrain block if (raycastHitData.collider.gameObject.name == "LoResChunk") { data.chunk = raycastHitData.collider.transform.parent.GetComponent<Chunk>(); if (data.chunk == null || data.chunk.faces==null || data.chunk.faces.Length==0) return data; if (data.chunk.stage != Chunk.Stage.complete) return data; //can hit only fully built chunks data.hit = true; data.type = AimData.Type.face; data.face = data.chunk.faces[ data.chunk.visibleFaceNums[raycastHitData.triangleIndex/2] ]; data.x = data.face.x + data.chunk.coordX*chunkSize; data.y = data.face.y; data.z = data.face.z + data.chunk.coordZ*chunkSize; data.dir = data.face.dir; data.triIndex = raycastHitData.triangleIndex; return data; } #endregion #region Object block else { Transform parent = raycastHitData.collider.transform.parent; while (parent != null) { if (parent.name=="Chunk" && parent.IsChildOf(transform)) { data.chunk = parent.GetComponent<Chunk>(); break; } parent = parent.parent; } if (data.chunk == null) return data; //aiming other obj data.hit = true; data.type = AimData.Type.obj; Vector3 pos= raycastHitData.collider.transform.localPosition; data.x = (int)pos.x + data.chunk.offsetX; data.y = (int)pos.y; data.z = (int)pos.z + data.chunk.offsetZ; return data; } #endregion }