internal Effect CreateEffect(string id) { EntityParam param = new EntityParam(); param.rid = id + "@" + GuidHash.GetString(); return(this._entityManager.CreateEffect(param)); }
public static EntityParam Create(string xml) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); for (int i = 0; i < doc.ChildNodes.Count; ++i) { var child = doc.ChildNodes[i] as XmlElement; if (child != null) { EntityParam param = (EntityParam)Activator.CreateInstance(Type.GetType(child.Name)); if (param != null) { param.ParseXml(child); return(param); } } } } catch (Exception e) { Debug.Log(e.Message); } return(null); }
private void HandleSpawnEntity(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; EntityParam param = e.entityParam; switch (e.entityType) { case "Bio": VEntity entity = CUser.id == param.uid ? this._entityManager.CreatePlayer(param) : this._entityManager.CreateBio(param); if (entity == VPlayer.instance) { //hero.fsm.enableDebug = true; this.camera.target = entity; } break; case "Missile": this._entityManager.CreateMissile(param); break; case "FoxFire": this._entityManager.CreateBio <VFoxFire>(param); break; } }
public void GetParam(string congfig, Action <EntityParamModel> callback) { if (mParams.ContainsKey(congfig)) { if (callback != null) { callback(mParams[congfig]); } } else { AssetLoader.LoadAsset <TextAsset>(congfig, (asset) => { if (asset != null && mParams.ContainsKey(congfig) == false) { var xml = asset.assetObject; if (xml) { var param = EntityParam.Create(xml.text) as EntityParamModel; if (param != null) { mParams.Add(congfig, param); } } asset.Destroy(); } if (callback != null) { callback(mParams.ContainsKey(congfig) ? mParams[congfig] : null); } }); } }
/// <summary> /// 填充数据库类型 /// </summary> /// <param name="nativeType"></param> /// <returns></returns> private void FillDbType(string nativeType, EntityParam prm, DataTable dtDataTypes) { DataRow[] rowArray = dtDataTypes.Select(string.Format("TypeName = '{0}'", nativeType.ToLowerInvariant())); if ((rowArray != null) && (rowArray.Length > 0)) { prm.SqlType = (DbType)rowArray[0]["ProviderDbType"]; return; } if (Regex.IsMatch(nativeType, "int", RegexOptions.IgnoreCase)) { prm.SqlType = DbType.Int64; return; } if (Regex.IsMatch(nativeType, "real|floa|doub", RegexOptions.IgnoreCase)) { prm.SqlType = DbType.Double; return; } if (Regex.IsMatch(nativeType, "numeric", RegexOptions.IgnoreCase)) { prm.SqlType = DbType.Decimal; return; } if (Regex.IsMatch(nativeType, "char|clob|text", RegexOptions.IgnoreCase)) { prm.SqlType = DbType.String; return; } prm.SqlType = DbType.Object; //prm.SqlType=type; //prm.Length=length; }
protected override void InternalOnAddedToBattle(EntityParam param) { base.InternalOnAddedToBattle(param); if (this._data.skills != null) { this.numSkills = this._data.skills.Length; for (int i = 0; i < this.numSkills; i++) { Skill skill = this.skills[i]; skill.OnCreated(this._data.skills[i], this._rid); if (skill.isCommon) { this.commonSkill = skill; skill.Upgrade(); //普攻默认等级1 } } } this.ApplyLevel(0); if (this.canInteractive) { this.collider = this.graphic.CreateCollider(); this.battle.input.RegisterInteractive(this); } this.fsm.Start(); }
public Bio CreateBio(EntityParam param) { Bio entity = this.CreateEntity <Bio>(param); this._idToBio[param.rid] = entity; this._bios.Add(entity); return(entity); }
public T CreateBio <T>(EntityParam param) where T : Bio, new() { T entity = this.CreateEntity <T>(param); this._idToBio[param.rid] = entity; this._bios.Add(entity); return(entity); }
public Effect CreateEffect(EntityParam param) { Effect entity = this.CreateEntity <Effect>(param); this._idToEffect[param.rid] = entity; this._effects.Add(entity); return(entity); }
public Missile CreateMissile(EntityParam param) { Missile entity = this.CreateEntity <Missile>(param); this._idToMissile[param.rid] = entity; this._missiles.Add(entity); return(entity); }
public VPlayer CreatePlayer(EntityParam param) { VPlayer entity = this.CreateEntity <VPlayer>(param); this._idToBio[param.rid] = entity; this._bios.Add(entity); return(entity); }
/// <summary> /// 创建属性的信息类 /// </summary> /// <param name="belong">所属的实体信息</param> /// <param name="getHandle">get委托</param> /// <param name="setHandle">set委托</param> /// <param name="ep">字段标识类</param> /// <param name="fieldType">字段类型</param> /// <param name="fieldName">字段名</param> /// <param name="sourceType">源字段类型</param> public EntityPropertyInfo(EntityInfoHandle belong, GetFieldValueHandle getHandle, SetFieldValueHandle setHandle, EntityParam paramInfo, Type fieldType, string fieldName, FieldInfo belongFieldInfo, PropertyInfo belongPropertyInfo) : base(belong.EntityType, getHandle, setHandle, fieldType, fieldName, belongFieldInfo) { paramInfo.SqlType = belong.DBInfo.CurrentDbAdapter.ToCurrentDbType(paramInfo.SqlType);//转换成本数据库支持的数据类型 this._paramInfo = paramInfo; _belong = belong; _belongPropertyInfo = belongPropertyInfo; }
protected override void InternalOnAddedToBattle(EntityParam param) { base.InternalOnAddedToBattle(param); this.graphic.shadowVisible = this.shadowVisible; this.graphic.animator.Play(this.graphic.id + "_play"); this.graphic.particle.Play(); this.time = 0f; }
public static void Save(EntityParamModel param, string path) { string xml = EntityParam.ToXml(param); if (!string.IsNullOrEmpty(path)) { File.WriteAllText(path, xml, System.Text.Encoding.UTF8); } }
/// <summary> /// 字段 /// </summary> /// <param name="paramName">字段名</param> /// <param name="dbType">数据库类型</param> /// <param name="allowNull">允许空</param> /// <param name="type">类型</param> /// <param name="length">长度</param> /// <returns></returns> public KeyWordAddParamItem AddParam(string paramName, DbType dbType, bool allowNull, EntityPropertyType type, int length) { EntityParam info = new EntityParam("", paramName, "", dbType, type, "", length, false, false); KeyWordAddParamItem item = new KeyWordAddParamItem(info, _tableName, this); return(item); }
/// <summary> /// 填充字段信息 /// </summary> /// <param name="prm">字段信息</param> /// <param name="reader">reader</param> private void FillParam(DBTableInfo table, DataRow row, Dictionary <string, bool> dicPk, DataTable dtData) { string prmName = row["COLUMN_NAME"] as string; if (string.IsNullOrEmpty(prmName)) { return; } foreach (EntityParam ep in table.Params) { if (ep.ParamName == prmName) { return; } } EntityParam prm = new EntityParam(); prm.ParamName = prmName; EntityPropertyType type = EntityPropertyType.Normal; string key = table.Name + ":" + prmName; key = key.ToLower(); bool isPrimary = dicPk.ContainsKey(key); bool isIdentity = IsIdentity(dtData, prmName); if (isPrimary) { type = EntityPropertyType.PrimaryKey; } if (isIdentity) { type = type | EntityPropertyType.Identity; } prm.AllowNull = Convert.ToBoolean(row["IS_NULLABLE"]); prm.PropertyType = type; if (!row.IsNull("CHARACTER_MAXIMUM_LENGTH")) { prm.Length = Convert.ToInt64(row["CHARACTER_MAXIMUM_LENGTH"]); } if (!table.IsView) { prm.Description = row["DESCRIPTION"] as string; } int dbType = 0; if (!row.IsNull("DATA_TYPE")) { dbType = Convert.ToInt32(row["DATA_TYPE"]); } prm.SqlType = GetDbType(dbType); table.Params.Add(prm); }
public void OnDisconnect(ITreeNode node) { EntityParam param = node as EntityParam; if (param != null) { children.Remove(param); } }
public static void SpawnEntity(string type, EntityParam param) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.SPAWN_ENTITY; e.entityType = type; e.entityParam = param; e.BeginInvoke(); }
public static void CreateEntity(string type, EntityParam param) { SyncEvent e = Get(); e.type = SyncEventType.ENTITY_CREATED; e.entityType = type; e.param = param; e.BeginInvoke(); }
/// <summary> /// 添加字段 /// </summary> /// <param name="paramName">字段名</param> /// <param name="dbType">数据库类型</param> /// <param name="allowNull">允许空</param> /// <param name="type">类型</param> /// <param name="length">长度</param> /// <returns></returns> public KeyWordTableParamItem _(string paramName, DbType dbType, bool allowNull, EntityPropertyType type, int length) { EntityParam info = new EntityParam("", paramName, "", dbType, type, "", length, false, false); _tparams.Add(info); return(this); }
/// <summary> /// 填充字段信息 /// </summary> /// <param name="prm">字段信息</param> /// <param name="reader">reader</param> private void FillParam(DBTableInfo table, IDataReader reader, Dictionary <string, bool> pkNames) { string prmName = reader["COLUMN_NAME"] as string; if (string.IsNullOrEmpty(prmName)) { return; } foreach (EntityParam ep in table.Params) { if (ep.ParamName == prmName) { return; } } EntityParam prm = new EntityParam(); prm.ParamName = prmName; EntityPropertyType type = EntityPropertyType.Normal; int isIdentity = 0; if (pkNames.ContainsKey(prmName)) { type = EntityPropertyType.PrimaryKey; //isIdentity = 1; } //if (isIdentity == 1) //{ // type = type | EntityPropertyType.Identity; //} prm.PropertyType = type; prm.Length = Convert.ToInt64(reader["DATA_LENGTH"]); if (!table.IsView) { prm.Description = reader["COMMENTS"] as string; } object val = reader["NULLABLE"]; bool isNull = false; if (!(val is DBNull)) { isNull = val.ToString().Equals("Y", StringComparison.CurrentCultureIgnoreCase); } prm.AllowNull = isNull; string strDBType = reader["DATA_TYPE"] as string; prm.SqlType = GetDbType(strDBType); table.Params.Add(prm); }
/// <summary> /// 初始化序列 /// </summary> /// <param name="seqName"></param> public static string GetInitSequence(string seqName, EntityParam prm, DataBaseOperate oper) { string dbType = oper.DBInfo.CurrentDbAdapter.DBTypeToSQL(prm.SqlType, 4); if (!IsSequenceExists(seqName, oper)) //判断是否已经存在序列 { string sql = "CREATE SEQUENCE \"" + seqName + "\" INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1"; //创建序列 return(sql); } return(null); }
/// <summary> /// 获取创建注释的SQL /// </summary> /// <param name="table">表</param> /// <param name="paramName">字段(如果为空则给表设置注释)</param> /// <param name="description">注释</param> /// <returns></returns> public string GetAddDescriptionSQL(KeyWordTableParamItem table, EntityParam pInfo, DBInfo info) { string description = pInfo == null ? table.Description : pInfo.Description; string descriptionValue = DataAccessCommon.FormatValue(description, DbType.AnsiString, info); if (pInfo == null) { return("comment on table " + FormatTableName(table.TableName) + " is " + descriptionValue); } return("comment on column " + FormatTableName(table.TableName) + "." + FormatParam(pInfo.ParamName) + " is " + descriptionValue); }
/// <summary> /// 获取创建注释的SQL /// </summary> /// <param name="table">表</param> /// <param name="paramName">字段(如果为空则给表设置注释)</param> /// <param name="description">注释</param> /// <returns></returns> public string GetAddDescriptionSQL(KeyWordTableParamItem table, EntityParam pInfo, DBInfo info) { string tableValue = DataAccessCommon.FormatValue(table.TableName, DbType.AnsiString, info); string description = pInfo == null ? table.Description : pInfo.Description; string descriptionValue = DataAccessCommon.FormatValue(description, DbType.AnsiString, info); if (pInfo == null) { return("EXECUTE sp_addextendedproperty N'MS_Description', N" + descriptionValue + ", N'SCHEMA', N'dbo', N'TABLE', N" + tableValue + ", NULL, NULL"); } return("EXECUTE sp_addextendedproperty N'MS_Description', N" + descriptionValue + ", N'SCHEMA', N'dbo', N'TABLE', N" + tableValue + ", N'COLUMN', N'" + pInfo.ParamName + "'"); }
private T CreateEntity <T>(EntityParam param) where T : Entity, new() { bool isNew = this._gPool.Pop(out T entity); this._idToEntity[param.rid] = entity; this._entities.Add(entity); if (isNew) { entity.Init(this._battle); } entity.OnAddedToBattle(param); return(entity); }
/// <summary> /// 获取创建注释的SQL /// </summary> /// <param name="table">表</param> /// <param name="paramName">字段(如果为空则给表设置注释)</param> /// <param name="description">注释</param> /// <returns></returns> public string GetAddDescriptionSQL(KeyWordTableParamItem table, EntityParam pInfo, DBInfo info) { string tableValue = DataAccessCommon.FormatValue(table.TableName, DbType.AnsiString, info); string description = pInfo == null ? table.Description : pInfo.Description; string descriptionValue = DataAccessCommon.FormatValue(description, DbType.AnsiString, info); if (pInfo == null) { return("COMMENT ON TABLE " + FormatTableName(table.TableName) + " IS " + descriptionValue); } return("COMMENT ON COLUMN " + FormatTableName(table.TableName) + "." + FormatParam(pInfo.ParamName) + " IS " + descriptionValue); }
/// <summary> /// 获取创建注释的SQL /// </summary> /// <param name="table">表</param> /// <param name="paramName">字段(如果为空则给表设置注释)</param> /// <param name="description">注释</param> /// <returns></returns> public string GetAddDescriptionSQL(KeyWordTableParamItem table, EntityParam pInfo, DBInfo info) { //string description = pInfo == null ? table.Description : pInfo.Description; //string descriptionValue = DataAccessCommon.FormatValue(description, DbType.AnsiString, info); //if (pInfo == null) //{ // return "alter table " + FormatTableName(table.TableName) + " comment " + descriptionValue; //} //string dbType=DBTypeToSQL(pInfo.SqlType, pInfo.Length); //return "alter table " + FormatTableName(table.TableName) + " modify column " + FormatParam(pInfo.ParamName) + " " + dbType + " comment " + descriptionValue; return(""); }
public void AddChild(EntityParam child) { if (child == null) { return; } child.parent = this; children.Add(child); #if UNITY_EDITOR if (OnAddChild != null) { OnAddChild(child); } #endif }
/// <summary> /// 转换成字段信息 /// </summary> /// <returns></returns> public EntityParam ToParamInfo() { EntityParam ep = new EntityParam(); ep.FieldName = FieldName; ep.Description = Summary; ep.ParamName = ParamName; ep.PropertyName = PropertyName; ep.SqlType = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), DbType).Value; ep.PropertyType = EntityPropertyType; //ep.AllowNull = IsNullProperty(_fInfo.MemberTypeShortName); ep.AllowNull = AllowNull; ep.ReadOnly = ReadOnly; ep.Description = Description; return(ep); }
/// <summary> /// 填充特殊信息指定标签 /// </summary> /// <param name="type"></param> /// <param name="dicParamsInfo"></param> /// <param name="tableAtt"></param> private static void FillAttributeInfo(Type type, EntityInfoHandle classInfo) { object[] atts = type.GetCustomAttributes(true); foreach (object objAtt in atts) { SequenceAttributes satt = objAtt as SequenceAttributes; if (satt != null) { EntityPropertyInfo info = classInfo.PropertyInfo[satt.PropertyName]; if (info == null) { throw new System.MissingMemberException("实体:" + classInfo.EntityType.FullName + " ,不包含属性找不到属性:" + satt.PropertyName); } info.ParamInfo.SequenceName = satt.SequenceName; continue; } EntityParam ep = objAtt as EntityParam; if (ep != null) { EntityPropertyInfo info = classInfo.PropertyInfo[ep.PropertyName]; if (info == null) { throw new System.MissingMemberException("实体:" + classInfo.EntityType.FullName + " ,不包含属性找不到属性:" + ep.PropertyName); } info.ParamInfo = ep; continue; } TableRelationAttribute tra = objAtt as TableRelationAttribute; if (tra != null) { EntityMappingInfo info = classInfo.MappingInfo[tra.PropertyName]; if (info == null) { throw new System.MissingMemberException("实体:" + classInfo.EntityType.FullName + " ,不包含属性找不到属性:" + tra.PropertyName); } info.MappingInfo = tra; continue; } } }