// Start is called before the first frame update void Start() { Vector3 translate = transform.position; Vector3 rotation = UnityEditor.TransformUtils.GetInspectorRotation(this.transform); //Setup our always used values StringParameters rail_id = new StringParameters("Id", id); BoolParameters is_closed = new BoolParameters("IsClosed", isClosed); BoolParameters is_ladder = new BoolParameters("IsLadder", isLadder); BoolParameters link_dest = new BoolParameters("IsLinkDest", isLinkDest); StringParameters layer = new StringParameters("LayerConfigName", layerConfigName); IntParameters rail_priority = new IntParameters("Priority", priority); StringParameters rail_type = new StringParameters("RailType", railType); StringParameters unit_config_name = new StringParameters("UnitConfigName", unitConfigName); //Declare a variable size array and an index for it string[] xml = new string[CalculateObjXmlSize()]; int xml_index = 0; //Create our XMl //Common xml[xml_index++] = header + rail_id.param_name + ": " + rail_id.value; xml[xml_index++] = ObjFactory(is_closed); xml[xml_index++] = ObjFactory(is_ladder); xml[xml_index++] = ObjFactory(link_dest); xml[xml_index++] = ObjFactory(layer); xml[xml_index++] = six_white_space + "Links: {}"; //Likely not required, but it exists on all objects in the final game xml[xml_index++] = six_white_space + "ModelName: null"; xml[xml_index++] = ObjFactory(rail_priority); xml[xml_index++] = six_white_space + "RailPoints:"; //Add RailPoints for (int i = 0; i < rails.Count; i++) { rails[i].AddRailPoint(ref xml, ref xml_index, isVrail); } xml[xml_index++] = ObjFactory(rail_type); //Add rotate, transform, and scale xml[xml_index++] = ObjFactory(new Vector3Parameters("Rotate", rotation)); translate.x = -translate.x; xml[xml_index++] = ObjFactory(new Vector3Parameters("Translate", translate)); xml[xml_index++] = ObjFactory(new Vector3Parameters("Scale", transform.localScale)); xml[xml_index++] = ObjFactory(unit_config_name); //Put XML in a file ExportToXmlFile(ref xml); }
/// <summary> /// This Function is used to Build a xml string on Error occurence /// </summary> /// <param name="number"></param> /// <param name="length">Trap String </param> /// <returns></returns> /// <author>Chandan Srivastava</author> public static string Event_FormatString(string EventString) { try { string EventFormatString; ArrayList EventArray = new ArrayList(); ArrayList MethodArray = new ArrayList(); string[] ParameterArray = null; string StringParameterName = null; string StringParameterValue = null; string StringClassName; string StringModuleName; string StringParameters; string RemaningString; StringBuilder XmlEventString = new StringBuilder(); int x; if (EventString != null && EventString.Length > 0) { if (EventString.IndexOf("#|") > 0) { XmlEventString.Append("<EventLog>"); //EventLog Tag //XmlEventString = "<EventLog>"; //EventLog Tag EventFormatString = EventString; EventArray = StringSplit(EventFormatString, "#|"); for (int i = 0; i <= EventArray.Count - 1; i++) { if (EventArray[i] != null && EventArray[i].ToString().Length > 0) { XmlEventString.Append("<Event>"); //<Event Tag> MethodArray = StringSplit(EventArray[i].ToString(), "~!"); StringClassName = MethodArray[0].ToString(); StringModuleName = MethodArray[1].ToString(); if (MethodArray.Count > 2) { StringParameters = MethodArray[2].ToString(); } else { StringParameters = ""; } XmlEventString.Append("<ClassName>" + StringClassName + "</ClassName>"); //Class Tag XmlEventString.Append("<Method>"); XmlEventString.Append("<MethodName>" + StringModuleName + "</MethodName>"); if (StringParameters.Length > 0) { ParameterArray = StringParameters.Split('^'); XmlEventString.Append("<Parameters>"); for (int j = 0; j <= ParameterArray.Length - 1; j++) { if (ParameterArray[j] != null && ParameterArray[j].ToString().Length > 0) { StringParameterValue = ""; StringParameterName = ""; x = StringParameters.IndexOf("^"); x = ParameterArray[j].ToString().IndexOf("-"); if (x > 0) { StringParameterName = ParameterArray[j].ToString().Substring(0, ParameterArray[j].ToString().IndexOf("-")); x = ParameterArray[j].ToString().IndexOf("-"); StringParameterValue = ParameterArray[j].ToString().Substring(x + 1); } else { StringParameterName = ParameterArray[j].ToString(); StringParameterValue = ""; } char[] invalidChars = { '<', '>', '#', '@', '&', ':' }; if (StringParameterValue.IndexOfAny(invalidChars) != -1) { XmlEventString.Append("<" + StringParameterName + ">" + "<![CDATA[" + StringParameterValue + "]]>" + "</" + StringParameterName + ">"); } else { XmlEventString.Append("<" + StringParameterName + ">" + StringParameterValue + "</" + StringParameterName + ">"); } } } XmlEventString.Append("</Parameters>"); } XmlEventString.Append("</Method>"); XmlEventString.Append("</Event>"); } } XmlEventString.Append("</EventLog>"); } //TextWriter tw = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath("abc.txt")); //tw.WriteLine(XmlEventString.ToString()); //tw.Close(); System.Web.HttpContext.Current.Session["XmlTrapString"] = XmlEventString.ToString(); } return(XmlEventString.ToString()); } catch (Exception ex) { return("<EventLog>None</EventLog>"); } }
public void AddRailPoint(ref string[] xml, ref int xml_index, bool isVrail) { Vector3 translate = transform.position; Vector3 rotation = UnityEditor.TransformUtils.GetInspectorRotation(this.transform); //Setup our always used values IntParameters check_point_index = new IntParameters("CheckPointIndex", checkPointIndex); StringParameters obj_id = new StringParameters("Id", id); BoolParameters link_dest = new BoolParameters("IsLinkDest", isLinkDest); StringParameters layer = new StringParameters("LayerConfigName", layerConfigName); FloatParameters offset_x = new FloatParameters("OffsetX", offsetX); FloatParameters offset_y = new FloatParameters("OffsetY", offsetY); FloatParameters offset_z = new FloatParameters("OffsetZ", offsetZ); StringParameters unit_config_name = new StringParameters("UnitConfigName", unitConfigName); BoolParameters use_offset = new BoolParameters("UseOffset", useOffset); Vector3 control_one = GetControlPoint1(); control_one.x = -control_one.x; Vector3 control_two = GetControlPoint2(); control_two.x = -control_two.x; Vector3Parameters control_point1 = new Vector3Parameters("", control_one); Vector3Parameters control_point2 = new Vector3Parameters("", control_two); //Vrail stuff IntParameters check_point_hp = new IntParameters("CheckPointHP", checkPointHp); IntParameters slope_fill_up = new IntParameters("SlopeFillUp", slopeFillUp); BoolParameters use_rotate_dir = new BoolParameters("UseRotateDir", useRotateDir); //Common if (isVrail) { xml[xml_index++] = four_white_space + header + check_point_hp.param_name + ": " + check_point_hp.value; xml[xml_index++] = ObjFactory(check_point_index); } else { xml[xml_index++] = four_white_space + header + check_point_index.param_name + ": " + check_point_index.value; } xml[xml_index++] = six_white_space + four_white_space + "ControlPoints:"; xml[xml_index++] = four_white_space + four_white_space + header + control_point1.value; xml[xml_index++] = four_white_space + four_white_space + header + control_point2.value; xml[xml_index++] = ObjFactory(obj_id); xml[xml_index++] = ObjFactory(link_dest); xml[xml_index++] = ObjFactory(layer); xml[xml_index++] = four_white_space + six_white_space + "Links: {}"; //Likely not required, but it exists on all objects in the final game if (isVrail) { xml[xml_index++] = four_white_space + six_white_space + "ModelName: RailPoint"; } else { xml[xml_index++] = four_white_space + six_white_space + "ModelName:"; } xml[xml_index++] = ObjFactory(offset_x); xml[xml_index++] = ObjFactory(offset_y); xml[xml_index++] = ObjFactory(offset_z); //Add rotate, transform, and scale xml[xml_index++] = ObjFactory(new Vector3Parameters("Rotate", rotation)); xml[xml_index++] = ObjFactory(new Vector3Parameters("Scale", transform.localScale)); if (isVrail) { xml[xml_index++] = ObjFactory(slope_fill_up); } translate.x = -translate.x; xml[xml_index++] = ObjFactory(new Vector3Parameters("Translate", translate)); xml[xml_index++] = ObjFactory(unit_config_name); xml[xml_index++] = ObjFactory(use_offset); if (isVrail) { xml[xml_index++] = ObjFactory(use_rotate_dir); } }
string ObjFactory(StringParameters inject) { string parameter = four_white_space + six_white_space + inject.param_name + ": " + inject.value; return(parameter); }
// Start is called before the first frame update void Start() { Quaternion rot = transform.rotation; //rot.x = -rot.x; //rot.y = -rot.y; //rot.z = -rot.z; transform.rotation = rot; //transform.rotation.Set(-transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w); Matrix4x4 local = transform.worldToLocalMatrix; Quaternion q = local.rotation; Vector3 rotation_rad = threeaxisrot(-2 * (q.y * q.z - q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z, 2 * (q.x * q.z + q.w * q.y), -2 * (q.x * q.y - q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z); Vector3 rotation; rotation.x = rotation_rad.x * 180.0f / 3.1415926f; rotation.y = rotation_rad.y * 180.0f / 3.1415926f; rotation.z = rotation_rad.z * 180.0f / 3.1415926f; //rotation.x = -rotation.x; if (rotation.x > 180) { rotation.x -= 360; } if (rotation.x < -180) { rotation.x += 360; } if (rotation.y > 180) { rotation.y -= 360; } if (rotation.y < -180) { rotation.y += 360; } if (rotation.z > 180) { rotation.z -= 360; } if (rotation.z < -180) { rotation.z += 360; } //Debug.Log(x_angle); //Debug.Log(y_angle); //Debug.Log(z_angle); //Stolen from https://forum.unity.com/threads/rotation-order.13469/ lol /*Vector3 rotation = threeaxisrot(-2 * (q.x * q.y - q.w * q.z), * q.w * q.w - q.x * q.x + q.y * q.y - q.z * q.z, * 2 * (q.y * q.z + q.w * q.x), * -2 * (q.x * q.z - q.w * q.y), * q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z); * //Angle returned in radians, gotta convert to degrees * rotation.Set(rotation.x * ToDeg, rotation.y * ToDeg, rotation.z * ToDeg); * //transform.Rotate(0, 0, -z_angle, Space.Self); * //transform.Rotate(0, -y_angle, 0, Space.Self); * //transform.Rotate(x_angle, 0, 0, Space.Self); * //Vector3 test = rot_test.eulerAngles; * rotation.x = -rotation.x;*/ Vector3 translate = transform.position; translate.x = -translate.x; Vector3 scale = transform.localScale; //Setup our always used values StringParameters obj_id = new StringParameters("Id", id); BoolParameters link_dest = new BoolParameters("IsLinkDest", isLinkDest); StringParameters layer = new StringParameters("LayerConfigName", layerConfigName); StringParameters unit_config_name = new StringParameters("UnitConfigName", unitConfigName); //Declare a variable size array and an index for it string[] xml = new string[CalculateObjXmlSize()]; int xml_index = 0; //Create our XMl //Common xml[xml_index++] = header + obj_id.param_name + ": " + obj_id.value; xml[xml_index++] = ObjFactory(link_dest); xml[xml_index++] = ObjFactory(layer); //links AddLinks(ref xml, ref xml_index); //Likely not required, but it exists on all objects in the final game xml[xml_index++] = ObjFactory(new StringParameters("ModelName", "null")); //Add rotate, transform, and scale xml[xml_index++] = ObjFactory(new Vector3Parameters("Rotate", rotation)); xml[xml_index++] = ObjFactory(new Vector3Parameters("Translate", translate)); if (isZone) { scale.x /= 10; scale.y /= 10; scale.z /= 10; } if (setScaleToOne) { scale.x = 1; scale.y = 1; scale.z = 1; } xml[xml_index++] = ObjFactory(new Vector3Parameters("Scale", scale)); xml[xml_index++] = ObjFactory(unit_config_name); //Add Unique Params for (int i = 0; i < intParams.Length; i++) { xml[xml_index++] = ObjFactory(intParams[i]); } for (int i = 0; i < boolParams.Length; i++) { xml[xml_index++] = ObjFactory(boolParams[i]); } for (int i = 0; i < stringParams.Length; i++) { xml[xml_index++] = ObjFactory(stringParams[i]); } for (int i = 0; i < floatParams.Length; i++) { xml[xml_index++] = ObjFactory(floatParams[i]); } //Put YAML in a file ExportToXmlFile(ref xml); }
public static string Cut(this StringParameters parameters) { return(parameters.Text.Substring(parameters.Position)); }
private async void Log(DateTime dateTimeStamp, LogLevels level, Type logInitiator, string loggedFrom, string message) { //Always verify the log level before adding a log entry. if (level >= _logLevel) { string methodName; switch (level) { case LogLevels.All: methodName = "Log"; break; case LogLevels.Info: methodName = "LogInfo"; break; case LogLevels.Warn: methodName = "LogWarn"; break; case LogLevels.Error: methodName = "LogError"; break; case LogLevels.Fatal: methodName = "LogFatal"; break; default: methodName = "LogDebug"; break; } StringParameters dsp = null; if (level == LogLevels.All) { dsp = new StringParameters(); dsp.Add(new StringParameter(PARAM_NAME_LEVEL, level.ToString())); } logBase log = new logBase(dateTimeStamp, logInitiator.FullName, loggedFrom, message); FacadeResponse<string> fr; fr = await JsonFacade.SendRequest<string>(string.Format("{0}{1}", _baseAddress, methodName), log, HTTPVerbs.POST, dsp); } }
public async Task<bool> ValidateUserAsync(string username, string password) { if (string.IsNullOrEmpty(_validationAddress)) return false; bool status = false; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", _apiAccessKey)); parameters.Add(new StringParameter("username", username)); parameters.Add(new StringParameter("password", password)); //Status results = JsonFacade.Instance.DownloadData<Status>( // _validationAddress + "/Standard", // parameters, // out err); FacadeResponse<Status> fr; fr = await JsonFacade.RequestData<Status>(_validationAddress + "/Standard", parameters); if (fr.Data != null) status = fr.Data.status; return status; }
public async Task<bool> ValidateUserAsync(string username, string rpxProviderName, bool createAccountIfNeeded) { if (string.IsNullOrEmpty(_validationAddress)) return false; ErrorDetail err; bool status = false; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", _apiAccessKey)); parameters.Add(new StringParameter("username", username)); parameters.Add(new StringParameter("rpxProviderName", rpxProviderName)); //Status results = JsonFacade.Instance.DownloadData<Status>( // _validationAddress + "/OAuth", // parameters, // out err); FacadeResponse<Status> fr; fr = await JsonFacade.RequestData<Status>(_validationAddress + "/OAuth", parameters); if (fr.Data != null) status = fr.Data.status; return status; }
public async Task<string> ResetPassword(string username) { if (string.IsNullOrEmpty(_resetPasswordAddress)) return null; string retVal = string.Empty; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", _apiAccessKey)); parameters.Add(new StringParameter("username", username)); parameters.Add(new StringParameter("daysToExpire", "1")); try { //StringResult results = JsonFacade.Instance.UploadData<StringResult>(_resetPasswordAddress, // null, // out err, // HTTPVerbs.PUT, // parameters); FacadeResponse<StringResult> fr; fr = await JsonFacade.SendRequest<StringResult>(_resetPasswordAddress, null, HTTPVerbs.PUT, parameters); if (fr.Data != null) retVal = fr.Data.result; } catch (Exception) { retVal = null; } return retVal; }
/// <summary> /// Returns a user only if the resetInfo provided is valid. /// </summary> /// <param name="resetInfo"></param> /// <returns></returns> public async Task<string> GetUserAsync(object resetInfo) { if (string.IsNullOrEmpty(_getUserByResetAddress)) return null; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", "moto")); parameters.Add(new StringParameter("resetInfo", resetInfo.ToString())); //StringResult results = JsonFacade.Instance.DownloadData<StringResult>(_getUserByResetAddress, // parameters, // out err); FacadeResponse<StringResult> fr; fr = await JsonFacade.RequestData<StringResult>(_getUserByResetAddress, parameters); string retVal = string.Empty; if (fr.Data != null) { retVal = fr.Data.result; } return retVal; }
public async Task<MembershipUser> GetUserAsync(string username, bool userIsOnline) { if (string.IsNullOrEmpty(_getUserAddress)) return null; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", "moto")); parameters.Add(new StringParameter("username", username)); //personMembership results = JsonFacade.Instance.DownloadData<personMembership>(_getUserAddress, // parameters, // out err); FacadeResponse<personMembership> fr; fr = await JsonFacade.RequestData<personMembership>(_getUserAddress, parameters); MembershipUser mUser = null; if (fr.Data != null) { mUser = new MembershipUser("AthenaMembershipProvider", fr.Data.userID, fr.Data.personID, fr.Data.userID, fr.Data.passwordQuestion, fr.Data.comment, fr.Data.isApproved, fr.Data.isLockedOut, fr.Data.creationDate, fr.Data.lastLoginDate, fr.Data.lastActivityDate, fr.Data.lastPasswordChangedDate, fr.Data.lastLockedoutDate); } return mUser; }
/// <summary> /// Creates a user with only the basic information. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="email">Email is the same as username. This can be left blank.</param> /// <param name="passwordQuestion"></param> /// <param name="passwordAnswer"></param> /// <param name="isApproved">This value is ignored</param> /// <param name="providerUserKey">This value is ignored. However it is filled in when a user is successfully created.</param> /// <returns></returns> public async Task<MembershipUser> CreateUserAsync(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey) { //All users are rejected unless the request is successful. MembershipCreateStatus status; status = MembershipCreateStatus.UserRejected; if (string.IsNullOrEmpty(_createUserAddress)) return null; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", _apiAccessKey)); parameters.Add(new StringParameter("username", username)); parameters.Add(new StringParameter("password", password)); parameters.Add(new StringParameter("passwordQuestion", passwordQuestion)); parameters.Add(new StringParameter("passwordAnswer", passwordAnswer)); FacadeResponse<personMembership> fr; fr = await JsonFacade.SendRequest<personMembership>(_createUserAddress, null, HTTPVerbs.POST, parameters); MembershipUser mUser = null; if (fr.Data != null) { mUser = new MembershipUser("AthenaMembershipProvider", fr.Data.userID, fr.Data.personID, fr.Data.userID, fr.Data.passwordQuestion, fr.Data.comment, fr.Data.isApproved, fr.Data.isLockedOut, fr.Data.creationDate, fr.Data.lastLoginDate, fr.Data.lastActivityDate, fr.Data.lastPasswordChangedDate, fr.Data.lastLockedoutDate); status = (MembershipCreateStatus)fr.Data.membershipCreateStatus; } return mUser; }
public async Task<bool> ChangePasswordAsync(string resetInfo, string username, string newPassword, bool reset) { if (string.IsNullOrEmpty(_changePasswordAddress)) return false; bool status = false; StringParameters parameters = new StringParameters(); parameters.Add(new StringParameter("accessKey", _apiAccessKey)); parameters.Add(new StringParameter("resetInfo", resetInfo)); parameters.Add(new StringParameter("username", username)); parameters.Add(new StringParameter("newPassword", newPassword)); FacadeResponse<Status> fr; fr = await JsonFacade.SendRequest<Status>(_changePasswordAddress, null, HTTPVerbs.PUT, parameters); if (fr.Data.status != null) status = fr.Data.status; return status; }