public string GetStateByCollisionEnter(ObstacleProperty obstacle, string objName = null) { if (obstacle == null) { return(null); } int height = obstacle.height.GetHashCode(); int orientation = Mathf.RoundToInt(Vector2.Angle(gameObject.transform.up, -obstacle.contactPoint.normal.normalized) / 45f); int heightOrderIndex = GetHeightIndex(height); int orientationOrderIndex = GetOrientationIndex(orientation); int finalStateIndex = this.EvaluateByOrder(this.stateProfileMap, heightOrderIndex, orientationOrderIndex); string finalState = (finalStateIndex != -1) ? this.stateProfileMap[finalStateIndex].transitionName : null; if (this.overrideStateProfileMap.TryGetValue(obstacle.type, out overridedStates)) { finalState = GetOverrideState(finalStateIndex, heightOrderIndex, orientationOrderIndex); } if (objName != null && this.overrideStateProfileMap.TryGetValue(objName, out overridedStates)) { finalState = GetOverrideState(finalStateIndex, heightOrderIndex, orientationOrderIndex); } return(finalState); }
public string GetLandStateByCollisionStay(ObstacleProperty obstacle, string objName = null) { int height = obstacle.height.GetHashCode(); int heightOrderIndex = GetHeightIndex(height); string landState = (heightOrderIndex != -1) ? this.stateProfileMap[heightOrderIndex].onLandState : null; if (this.overrideStateProfileMap.TryGetValue(obstacle.type, out overridedStates)) { landState = this.GetOverrideState(heightOrderIndex); } if (objName != null && this.overrideStateProfileMap.TryGetValue(objName, out overridedStates)) { landState = this.GetOverrideState(heightOrderIndex); } return(landState); }