public ISSCBlockVector CalPlacingPosition(Vector3 hitPoint, Vector3 hittedBlockPosition) { Vector3 dir = hitPoint - hittedBlockPosition; dir = ISMath.Clip2NormalDirectionV2(dir); return(ISSCBGrid.WorldPositionToGridPosition(dir + hittedBlockPosition, moniter.transform.position)); }
static public float Map(float v, ISRange valueRange, ISRange targetedRange) { v = ISMath.Clamp(v, valueRange); float f = targetedRange.length / valueRange.length; return(targetedRange.min + f * v); }
/// <summary> /// Determines whether this position is available in grid. /// </summary> /// <returns><c>true</c> if this position is available; otherwise, <c>false</c>.</returns> /// <param name="position">Position.</param> public bool IsBlockAvailable(ISSCBlockVector position) { bool result = ISMath.Contains(position.x, 0, gridSize.x - 1) && ISMath.Contains(position.y, 0, gridSize.y - 1) && ISMath.Contains(position.z, 0, gridSize.z - 1); return(result); }
IEnumerator Timer() { while (enabled) { curAR = ISMath.Random(attackRange); curSD = ISMath.Random(stoppingDistance); curSD = Mathf.Min(curAR, curSD); SearchEnemy(); yield return(new WaitForSeconds(coreTimerInterval)); } }
IEnumerator Timer() { while (enabled) { currentStopDistance = ISMath.Random(stopRange); currentAttackDistance = ISMath.Random(attackRange); currentStopDistance = Mathf.Min(currentStopDistance, currentAttackDistance); SearchEnemy(); yield return(new WaitForSeconds(coreTimer)); } }
IEnumerator RandomTimer() { while (enabled) // If the Box Collider is selected; { this.currentAttackRange = ISMath.Random(this.attackRange); this.currentStoppingDistance = ISMath.Random(this.stoppingDistance); this.currentStoppingDistance = Mathf.Min(currentAttackRange, currentStoppingDistance); SearchEnemy(); yield return(new WaitForSeconds(this.RandomTimerInterval)); } }
static public Vector3 ClampLength(Vector3 v, ISRange range) { float l = v.magnitude; if (l < range.min) { return(ISMath.ChangeLengthTo(v, range.min)); } if (l > range.max) { return(ISMath.ChangeLengthTo(v, range.max)); } return(v); }
/// <summary> /// Adjust to the attitude base on current setting. /// Editor use this method to generate preview. /// </summary> public void Adjust2AttitudeBaseOnCurrentSetting() { groundMask = 1 << groundLayer; objectPos = CalculateCurrentObjectPosition(); scrollValue = Mathf.Clamp01(scrollValue); float currentGroundHigh = groundHigh; RaycastHit hit; Vector3 emitPos = objectPos; emitPos.y += 9999f; if (groundHighTest && Physics.Raycast(emitPos, -Vector3.up, out hit, Mathf.Infinity, groundMask)) { currentGroundHigh = hit.point.y; } emitPos = transform.position; emitPos.y += 9999f; if (groundHighTest && Physics.Raycast(emitPos, -Vector3.up, out hit, Mathf.Infinity, groundMask)) { currentGroundHigh = Mathf.Max(currentGroundHigh, hit.point.y); } Vector3 rot = transform.eulerAngles; rot.x = ISMath.WrapAngle(rot.x); rot.y = ISMath.WrapAngle(rot.y); wantYAngle = rot.y; objectPos.y = scrollHigh.Evaluate(scrollValue); wantXAngle = scrollXAngle.Evaluate(scrollValue); Quaternion targetRot = Quaternion.Euler(wantXAngle, wantYAngle, 0f); transform.rotation = targetRot; float dist = objectPos.y * Mathf.Tan((90f - wantXAngle) * Mathf.Deg2Rad); Vector3 cameraPosDir = targetRot * (Vector3.forward * dist); Vector3 cameraPos = objectPos - cameraPosDir; cameraPos.y = objectPos.y + currentGroundHigh; transform.position = cameraPos; }
public void Start() { objectPos = CalculateCurrentObjectPosition(); scrollValue = Mathf.Clamp01(scrollValue); objectPos.y = scrollHigh.Evaluate(scrollValue); wantXAngle = scrollXAngle.Evaluate(scrollValue); Vector3 rot = selfT.eulerAngles; rot.x = ISMath.WrapAngle(rot.x); rot.y = ISMath.WrapAngle(rot.y); wantYAngle = rot.y; rot.x = scrollXAngle.Evaluate(scrollValue); wantXAngle = rot.x; selfT.eulerAngles = rot; StartCoroutine(UpdateTransform()); KeyboardControl(keyBoardControl); ScreenEdgeMovementControl(screenEdgeMovementControl); MouseDragControl(mouseDragControl); MouseScrollControl(mouseScrollControl); TouchControl(touchControl); }
public void Rotate(float dir) { wantYAngle += dir; ISMath.WrapAngle(wantYAngle); }
static public bool Contains(float value, ISRange range) { return(ISMath.Contains(value, range.min, range.max)); }