protected override void Awake() { base.Awake(); coneAngle = SMath.ClampDegree0To360(coneAngle); faceAngle = SMath.ClampDegree0To360(faceAngle); var meshFilter = GetComponent <MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent <MeshFilter>(); } if (_mesh == null) { _mesh = new Mesh(); meshFilter.mesh = _mesh; } _losCamera = LOSManager.instance.losCamera; Vector2 screenSize = SHelper.GetScreenSizeInWorld(_losCamera.unityCamera); _raycastDistance = Mathf.Sqrt(screenSize.x * screenSize.x + screenSize.y * screenSize.y); }
public override void UpdatePreviousInfo () { base.UpdatePreviousInfo (); _previousFaceAngle = SMath.ClampDegree0To360(faceAngle); _previousLightAngle = SMath.ClampDegree0To360(coneAngle); _previousColor = color; _previousObstacleLayer = obstacleLayer; _previousInvertMode = invertMode; _previousDegreeStep = degreeStep; }
/// <summary> /// Checks the a particular degree is within cone area or not. /// </summary> /// <returns><c>true</c>, if degree is within cone areac>false</c> otherwise.</returns> /// <param name="degree">Degree.</param> public bool CheckDegreeWithinCone (float degree) { if (coneAngle == 0) return true; float min = faceAngle - coneAngle / 2; float max = faceAngle + coneAngle / 2; if (degree > max) {return false;} if (min < 0) { min = SMath.ClampDegree0To360(min); } return degree > min; }
/// <summary> /// Checks the a particular degree is within cone area or not. /// </summary> /// <returns><c>true</c>, if degree is within cone areac>false</c> otherwise.</returns> /// <param name="degree">Degree.</param> public bool CheckDegreeWithinCone(float degree) { if (coneAngle == 0) { return(true); } float min = faceAngle - coneAngle / 2; float max = faceAngle + coneAngle / 2; var cc = 0; if (min < 0) { min = SMath.ClampDegree0To360(min); cc += 1; } if (max < 0) { max = SMath.ClampDegree0To360(max); cc += 2; } switch (cc) { case 0: return(degree > min && degree < max); break; case 1: return(degree > min || degree < max); break; case 2: return(degree > min && degree < max); break; case 3: return(degree > min && degree < max); break; } return(degree > min); }
void Start() { angleRange.x = SMath.ClampDegree0To360(angleRange.x); angleRange.y = SMath.ClampDegree0To360(angleRange.y); if (angleRange.x > angleRange.y) { float temp = angleRange.x; angleRange.x = angleRange.y; angleRange.y = temp; } if (coneLight.faceAngle < angleRange.x) { coneLight.faceAngle = angleRange.x; _isIncreasing = true; } else if (coneLight.faceAngle > angleRange.y) { coneLight.faceAngle = angleRange.y; _isIncreasing = false; } }