public RefItem Get(string refCode, string refType) { var refItem = new RefItem(); try { using (OggleBoobleMySqContext db = new OggleBoobleMySqContext()) { Ref dbref = db.Refs.Where(r => r.RefType == refType && r.RefCode == refCode).FirstOrDefault(); if (dbref == null) { refItem.Success = "ref not found"; } else { refItem.RefCode = dbref.RefCode; refItem.RefDescription = dbref.RefDescription; refItem.Success = "ok"; } } } catch (Exception ex) { refItem.Success = Helpers.ErrorDetails(ex); } return(refItem); }
private void ShowRefItemsNest(RefItem items, int layer = 0) { //string space = new string(' ', layer * 5); //items._fold = EditorGUILayout.Foldout(items._fold, name, textStyle); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(layer * 30)); EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); //EditorGUILayout.LabelField(new string(' ', layer * 5) + items._object.name, textStyle); //EditorGUILayout.LabelField(new string(' ', layer * 5 + (textStyle.fontSize - GUI.skin.font.fontSize)) + "(" + items._path + ")"); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(AssetPreview.GetMiniThumbnail(items.GetObject)), GUILayout.Height(22), GUILayout.Width(22)); EditorGUILayout.LabelField(items.Name, textStyle); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("(" + items.Path + ")"); GUILayout.Space(5); if (items._refList.Count > 0) { //EditorGUILayout.BeginHorizontal(); //GUILayout.Label(" ", GUILayout.Width(layer * 45)); items._isFold = !EditorGUILayout.Foldout(!items._isFold, name); //EditorGUILayout.EndHorizontal(); if (!items._isFold) { //EditorGUILayout.BeginVertical(GUI.skin.box); for (int i = 0; i < items._refList.Count; i++) { ShowRefItemsNest(items._refList[i], layer + 1); } //EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); Color oldColor = GUI.color; GUI.color = Color.green; if (GUILayout.Button("定位", GUILayout.Width(50))) { EditorGUIUtility.PingObject(items.GetObject); } GUI.color = Color.yellow; if (items.GetObject != _target) { if (GUILayout.Button("查找位置", GUILayout.Width(70))) { FindRefernceTargetPosition(items.GetObject); } } GUI.color = oldColor; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); GUILayout.Space(15); }
public override uint GetReference(object value, ulong offset, out bool alreadyExists) { if (_objectToReferenceIdMap.ContainsKey(value)) { alreadyExists = true; RefItem item = _objectToReferenceIdMap[value]; item.RefCount++; //if (item.Seq == 0) //{ // item.Seq = _referenceCount; // _referenceCount++; //} return(item.Seq); } else { RefItem item = new RefItem() { RefCount = 0, Value = value, Seq = _referenceCount, Offset = offset }; // _referenceIdToObjectMap.Add(seq, item); _objectToReferenceIdMap.Add(value, item); _referenceCount++; alreadyExists = false; return(item.Seq); } }
private static void BeginFindReference() { if (_target == null) { return; } switch (_mode) { case ShowMode.FolderMode: _referenceList = AssetDatabase.GetDependencies(AssetDatabase.GetAssetPath(_target), recursive); _refFolderItem = new RefFolderItem(); for (int i = 0; i < _referenceList.Length; i++) { _refFolderItem.AddRefItem(_referenceList[i]); } break; case ShowMode.ReferenceMode: _refItem = new RefItem(); _refItem.InitRef(_target); break; } }
public string Post(RefItem refItem) { string success = ""; try { using (OggleBoobleMySqContext db = new OggleBoobleMySqContext()) { Ref @ref = new Ref(); @ref.RefType = refItem.RefType; @ref.RefCode = GetUniqueRefCode(refItem.RefDescription, db); @ref.RefDescription = refItem.RefDescription; db.Refs.Add(@ref); db.SaveChanges(); //refModel.RefCode = @ref.RefCode; success = "ok"; } } catch (Exception ex) { success = ex.Message; } return(success); }
bool CheckTerminated(bool d, bool empty, ISubscriber <T> a) { if (bp.IsCancelled()) { item = null; return(true); } if (d) { Exception e = error; if (e != null) { item = null; a.OnError(e); return(true); } else if (empty) { a.OnComplete(); return(true); } } return(false); }
private static ArrayItemExpression ToArrayItemRefExpression(RefItem e) { return(new ArrayItemRefExpression( key: Parse(e.Index), value: Parse(e.RefToGet) )); }
void SerializeItem(RefItem item) { _serializer.StartSerialize("Item"); SerializeOptionalProperty("Index", item.Index); SerializeOptionalProperty("RefToGet", item.RefToGet); _serializer.EndSerialize(); }
public void InitRef(Object o) { _object = o; _path = AssetDatabase.GetAssetPath(o); //计算硬盘占用大小 FileInfo info = new FileInfo(_path); if (info.Exists) { float size = info.Length; if (size < 1024) { _size = size.ToString() + "B"; } else if (size < 1024 * 1024) { _size = System.Math.Round((size / 1024), 2).ToString() + "KB"; } else { _size = System.Math.Round((size / 1024 / 1024), 2).ToString() + "M"; } } string[] paths = AssetDatabase.GetDependencies(_path, false); for (int i = 0; i < paths.Length; i++) { RefItem item = new RefItem(); item.InitRef(AssetDatabase.LoadAssetAtPath(paths[i], typeof(Object))); _refList.Add(item); } }
public RefsKeyItem(StorageKeyEntry keyEntry, EditableRefValue[] refs) : base(keyEntry.StorageKey) { RefItems = new RefItem[refs.Length]; for (int i = 0; i < refs.Length; i++) { RefItems[i] = new RefItem(keyEntry, refs[i]); } }
public void OnNext(T t) { RefItem item = new RefItem(t); Volatile.Write(ref this.item, item); Drain(); }
private void BeginFindReference() { if (_target == null) { return; } _refItem = new RefItem(); _refItem.InitRef(AssetDatabase.GetAssetPath(_target)); }
public void InitRef(string path) { _path = path; string[] paths = AssetDatabase.GetDependencies(_path, false); for (int i = 0; i < paths.Length; i++) { RefItem item = new RefItem(); item.InitRef(paths[i]); _refList.Add(item); } }
public static RefItem CreateForSingleTable(string tableName) { var it = new RefItem() { Level = 1, TableName = tableName, ForeignTableName = tableName, }; return(it); }
public void InitRef(Object o) { _object = o; _path = AssetDatabase.GetAssetPath(o); string[] paths = AssetDatabase.GetDependencies(_path, false); for (int i = 0; i < paths.Length; i++) { RefItem item = new RefItem(); item.InitRef(AssetDatabase.LoadAssetAtPath(paths[i], typeof(Object))); _refList.Add(item); } }
void Drain() { if (!bp.Enter()) { return; } ISubscriber <T> a = actual; int missed = 1; for (;;) { for (;;) { bool d = IsDone(); RefItem item = Volatile.Read(ref this.item); bool empty = item == null; if (CheckTerminated(d, empty, a)) { return; } if (empty) { break; } long r = bp.Requested(); if (r != 0L) { item = Interlocked.Exchange(ref this.item, null); a.OnNext(item.value); if (r != long.MaxValue) { bp.Produced(1); } } } missed = bp.Leave(missed); if (missed == 0) { break; } } }
public override RefState TryGetReference(uint seq, out object value) { RefItem ri = _referenceIdToObjectMap[seq]; if (ri == null) { value = default; return(RefState.None); } value = ri.Value; return(ri.State); }
public override void AddReference(uint seq) { _referenceIdToObjectMap.TryGetValue(seq, out RefItem ri); if (ri == null) { ri = new RefItem() { Seq = seq, State = RefState.Start, RefCount = 0 }; _referenceIdToObjectMap.Add(seq, ri); } }
public override void AddReferenceObject(uint seq, object value) { RefItem ri = _referenceIdToObjectMap[seq]; ri.State = RefState.Created; ri.Value = value; if (_refCallback.ContainsKey(seq)) { List <Func <bool> > callback = _refCallback[seq]; for (int i = 0; i < callback.Count; i++) { callback[i](); } } }
public void Init(Creature owner, RefMob refMob, RefItem refItem, int level, int evolution) { base.Init(refMob, level, evolution); m_owner = owner; m_owner.AddFollower(this); CreatureType = m_owner.CreatureType; m_consumedSP = refItem.consumedSP; if (m_creatureProperty.MoveSpeed == 0f) { EnableNavMeshObstacleAvoidance(false); } Transformation(transform, evolution); switch(refMob.mobAI) { case MobAIType.Normal: m_ai = new MobAINormal(); break; case MobAIType.Rotation: m_ai = new MobAIRotation(); break; case MobAIType.FlyingAround: m_ai = new MobAIFlyingAround(); break; case MobAIType.ItemShuttle: m_ai = new MobAIItemShuttle(); break; case MobAIType.Pickup: m_ai = new MobAIPickup(); ((MobAIPickup)(m_ai)).SetOwner(m_owner); CreatureType = Type.Npc; gameObject.layer = 0; break; case MobAIType.Follow: m_ai = new MobAIFollow(); ((MobAIFollow)(m_ai)).SetOwner(m_owner); CreatureType = Type.ChampNpc; gameObject.layer = 0; StartCoroutine(DecSpEffect()); break; } m_ai.Init(this); }
public string Put(RefItem refItem) { string success = ""; try { using (OggleBoobleMySqContext db = new OggleBoobleMySqContext()) { Ref @ref = db.Refs.Where(r => r.RefCode == refItem.RefCode).First(); @ref.RefDescription = refItem.RefDescription; db.SaveChanges(); success = "ok"; } } catch (Exception ex) { success = ex.Message; } return(success); }
private void _ShowReference(RefItem item) { if (_refItem == null) { return; } EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(AssetDatabase.GetCachedIcon(item._path)), GUILayout.Height(22), GUILayout.Width(22)); EditorGUILayout.LabelField(item._path); if (GUILayout.Button("定位")) { EditorGUIUtility.PingObject(item.GetObject()); } EditorGUILayout.EndHorizontal(); if (item._refList != null && item._refList.Count > 0) { if (item.isShowChild) { item.isShowChild = EditorGUILayout.Foldout(item.isShowChild, "收起"); } else { item.isShowChild = EditorGUILayout.Foldout(item.isShowChild, "展开"); } if (item.isShowChild) { for (int i = 0; i < item._refList.Count; ++i) { _ShowReference(item._refList[i]); } GUILayout.Space(10); } } EditorGUILayout.EndVertical(); }
public static ICollection <RefItem> GetRefs(DALGetRefsInputParams inputParams) { DALGetTablesInputParams.ThrowIfWrong(inputParams); using (var con = new SqlConnection(inputParams.ConnectionString)) using (var cmd = con.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandTimeout = inputParams.RootTableNamesSet.Any() ? COMMAND_TIMEOUT_60 : COMMAND_TIMEOUT_300; cmd.CommandText = string.Format(SQL_GET_REFS_BY_FOREIGN_TABLENAME , inputParams.RootTableNamesSet.Any() ? 0 : 1 , '\'' + string.Join("','", inputParams.RootTableNamesSet.Select(table => table.Replace("'", "''"))) + '\''); con.Open(); var refs = new LinkedList <RefItem>(); using (var rd = cmd.ExecuteReader()) { for (int idx_1 = rd.GetOrdinal("Level"), idx_2 = rd.GetOrdinal("IsSelfRefs"), idx_3 = rd.GetOrdinal("FKName"), idx_4 = rd.GetOrdinal("TableName"), idx_5 = rd.GetOrdinal("Column"), idx_6 = rd.GetOrdinal("ForeignTableName"), idx_7 = rd.GetOrdinal("ForeignColumn"); rd.Read();) { var refItem = new RefItem() { Level = rd.GetInt32(idx_1), IsSelfRefs = (rd.GetInt32(idx_2) != 0), FKName = rd.GetString(idx_3), TableName = rd.GetString(idx_4), Column = rd.GetString(idx_5), ForeignTableName = rd.GetString(idx_6), ForeignColumn = rd.GetString(idx_7), }; refs.AddLast(refItem); } } return(refs); } }
private void ShowRefItemsDirect(RefItem items, int layer = 0) { //string space = new string(' ', layer * 5); //items._fold = EditorGUILayout.Foldout(items._fold, name, textStyle); EditorGUILayout.BeginHorizontal(); //GUILayout.Label(" ", GUILayout.Width(layer * 30)); EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(new string(' ', layer * 5) + items._object.name, textStyle); EditorGUILayout.LabelField(new string(' ', layer * 5 + (textStyle.fontSize - GUI.skin.font.fontSize)) + "(" + items._path + ")"); EditorGUILayout.EndVertical(); if (GUILayout.Button("定位")) { EditorGUIUtility.PingObject(items._object); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); if (items._refList.Count > 0) { items._fold = !EditorGUILayout.Foldout(!items._fold, name); if (!items._fold) { for (int i = 0; i < items._refList.Count; i++) { ShowRefItemsDirect(items._refList[i], layer + 1); } } } GUILayout.Space(15); }
/// <summary> /// Visit item use index (if not null) and array. /// </summary> /// <param name="x"></param> virtual public void VisitRefItem(RefItem x) { VisitElement(x.Index); VisitElement(x.RefToGet); }
public sealed override void VisitRefItem(RefItem x) { throw new InvalidOperationException(); // VisitArrayItem }
public virtual void Init(Creature creature, ItemWeaponData weaponData, RefMob.WeaponDesc weaponDesc) { m_creature = creature; m_gunPoint = creature.WeaponHolder.gameObject; m_refWeaponItem = weaponData.RefItem; m_lastCreated = Time.time; m_firing = false; m_level = 0; m_maxLevel = weaponDesc.maxLevel; m_weaponStat = new WeaponStat(); if (weaponDesc.weaponStat == null) { m_weaponStat.OverrideStat(m_refWeaponItem.weaponStat); } else { m_weaponStat.OverrideStat(weaponDesc.weaponStat); m_weaponStat.OverrideStat(m_refWeaponItem.weaponStat); } for(int i = 0; i <= m_weaponStat.firingCount; ++i) MoreFire(); m_evolution = weaponData.Evolution; if (m_evolution > 0) { for(int i = 1; i <= m_maxLevel; ++i) { if (canCreateMoreFire(i)) MoreFire(); } } for(int i = 0; i < weaponData.Level; ++i) LevelUp(); }
public void SetPrices(Const.ButtonRole role, RefItem refItem) { m_role = role; RefPrice[] normal = null; RefPrice[] gem = null; switch(role) { case Const.ButtonRole.Unlock: if (refItem.unlock != null) { normal = refItem.unlock.conds; gem = refItem.unlock.else_conds; } break; case Const.ButtonRole.Levelup: if (refItem.levelup != null) { normal = refItem.levelup.conds; gem = refItem.levelup.else_conds; } break; case Const.ButtonRole.Evolution: if (refItem.evolution != null) { normal = refItem.evolution.conds; gem = refItem.evolution.else_conds; } break; case Const.ButtonRole.Nothing: break; } m_priceButton.Prices = normal; m_gemButton.Prices = gem; }
public Graph GetRefs([FromUri] DALGetRefsInputParams inputParams) { try { inputParams.TryLoadFromCookies(HttpContext.Current.Request); DALGetRefsInputParams.ThrowIfWrong(inputParams); #region [.check exists root-tables.] if (inputParams.RootTableNamesSet.Any()) { var tableCollection = GetTablesInternal(inputParams); foreach (var rootTableName in inputParams.RootTableNamesSet) { if (!tableCollection.Contains(rootTableName)) { throw (new TableNotExistsException(rootTableName)); } } } #endregion #if USE_CACHE var refs = HttpContext.Current.Cache.Get( inputParams.ConnectionString + '-' + inputParams.RootTableNames , () => DAL.GetRefs(inputParams)); #else var refs = DAL.GetRefs(inputParams); #endif if (!refs.Any()) { if (inputParams.RootTableNamesSet.Any()) { throw (new RefsNotFoundException(inputParams.RootTableNamesSet)); } foreach (var rootTableName in inputParams.RootTableNamesSet) { refs.Add(RefItem.CreateForSingleTable(rootTableName)); } } var nodes = new Dictionary <string, Node>(); var links = new HashSet <Link>(new LinkEqualityComparer()); #region [.create-graph-nodes-&-links.] var node_id = 0; var link_id = 0; if (inputParams.RootTableNamesSet.Any()) { foreach (var rootTableName in inputParams.RootTableNamesSet) { //var linksTotal = refs.Count( it => it.Level <= 2 && it.TableName == rootTableName ); var centerNode = new Node(node_id, rootTableName, true); nodes.Add(centerNode.Name, centerNode); node_id++; } } else { var rootTableName = refs.FirstOrDefault().ForeignTableName; if (rootTableName.IsNullOrWhiteSpace()) { throw (new RefsNotFoundException(inputParams.RootTableNamesSet)); } //var linksTotal = refs.Count( it => it.Level <= 2 && it.TableName == rootTableName ); var centerNode = new Node(node_id, rootTableName, true); nodes.Add(centerNode.Name, centerNode); node_id++; } var tables = (from it in refs select it.TableName ).Concat (from it in refs select it.ForeignTableName ); foreach (var table in tables) { if (!nodes.ContainsKey(table)) { var node = new Node(node_id, table); nodes.Add(node.Name, node); node_id++; } } var grouped_refs = from it in refs group it by it.FKName into g select g; foreach (var g in grouped_refs) { var it = g.First(); var node_1 = nodes[it.ForeignTableName]; var node_2 = nodes[it.TableName]; link_id++; var link = new Link(link_id) { SourceNode = node_1.Id, TargetNode = node_2.Id, SourceFields = from _it in g select _it.ForeignColumn, TargetFields = from _it in g select _it.Column, }; links.Add(link); /*var success = links.Add( link ); * if ( !success ) * System.Diagnostics.Debugger.Break();*/ } #endregion var graph = new Graph() { links = links, nodes = nodes.Values, documents = new string[0], //model.Documents.Select( fi => fi.Name ), linksTotalCount = 0, //model.AllMTSTermLinksCount, nodesTotalCount = 0, //model.AllMTSTermsCount, }; CalcGraphCoords(graph, inputParams.GraphWidth, inputParams.GraphHeight); return(graph); } catch (TableNotExistsException ex) { return(Graph.CreateError("Table with name '" + ex.TableName + "' not exists")); } catch (RefsNotFoundException ex) { var error = ex.RootTableNames.Any() ? ("Reference from table " + ex.RootTableNames.Join('\'', '\'', "','") + " not found") : "Any tables not found"; return(Graph.CreateError(error)); } catch (Exception ex) { return(Graph.CreateError(ex)); } }
public static GameObject GetPrefItemEatEffect(RefItem refItem) { GameObject pref = Resources.Load<GameObject>("Pref/ItemBox/ef " + refItem.codeName + " eat"); if (pref == null) { pref = Resources.Load<GameObject>("Pref/ItemBox/ef item eat"); } return pref; }