public List <TreeUnit> GetTreeUnits(List <Filter> filters) { List <TreeUnit> dataList = dal.GetUnits(filters) .Select(t => new TreeUnit { ID = t.ID, Code = t.Code, Name = t.Name, text = t.Name, Path = t.Path, UnitTypeID = t.UnitTypeID, UnitTypeName = t.UnitTypeName, ParentID = t.ParentID, CreatedTime = t.CreatedTime, UpdatedTime = t.UpdatedTime }).OrderBy(t => t.ID).ToList(); List <TreeUnit> list = new List <TreeUnit>(); if (dataList.Count > 0) { for (int i = 0; i < dataList.Count; i++) { TreeUnit item = dataList[i]; if (item.ParentID == null) { item = GetUnitChildren(dataList, item); list.Add(item); } } } return(list); }
private TreeUnit GetUnitChildren(List <TreeUnit> dataList, TreeUnit item) { List <TreeUnit> list = new List <TreeUnit>(); for (int i = 0; i < dataList.Count; i++) { TreeUnit childrenItem = dataList[i]; if (childrenItem.ParentID != null && childrenItem.ParentID == item.ID) { childrenItem = GetUnitChildren(dataList, childrenItem); list.Add(childrenItem); } } if (list.Count > 0) { item.expanded = true; item.leaf = false; } else { item.expanded = false; item.leaf = true; } item.children = list; return(item); }
/// <summary> /// 加载现有基本信息(Contact+sms); /// </summary> /// <param name="advCFile"></param> /// <param name="binPath"></param> /// <param name="pinKind"></param> public static void LoadBasicInfo(AndroidDeviceCaseEvidence advCFile, string pinKind) { var fiUnit = ServiceProvider.Current.GetInstance <ICommonForensicService>().GetForensicInfoUnit(advCFile); if (fiUnit == null) { return; } var csService = ServiceProvider.Current.GetInstance <ICaseService>(); if (csService == null) { Logger.WriteCallerLine($"{nameof(ICaseService)} is not registered."); return; } if (fiUnit.Children.FirstOrDefault(p => p is IHavePinKind havePin && havePin.ContentId == pinKind) is ITreeUnit preUnit) { fiUnit.Children.Remove(preUnit); //var fsTabService = ServiceProvider.Current.GetInstance<FSTabService>(); } TreeUnit newUnit = null; try { using (var fs = File.OpenRead($"{csService.CurrentCase.Path}/{advCFile.BasePath}/{advCFile[pinKind]}")) { var bf = new BinaryFormatter(); var dbModels = (List <ForensicInfoDbModel>)bf.Deserialize(fs); //显示; if (pinKind == PinKindsDefinitions.AndBasicCalllog) { newUnit = new MultiDbModelsUnit <CalllogDbModel>(dbModels?.Select(p => p as CalllogDbModel).ToList(), pinKind, fiUnit); } else if (pinKind == PinKindsDefinitions.AndBasicSmses) { newUnit = new MultiDbModelsUnit <SmsDbModel>( dbModels?.Select(p => p as SmsDbModel).ToList(), PinKindsDefinitions.AndBasicSmses, fiUnit, sms => (sms.relationship_account, sms.relationship_name)); } else if (pinKind == PinKindsDefinitions.AndBasicContact) { newUnit = new MultiDbModelsUnit <ContactDbModel>(dbModels?.Select(p => p as ContactDbModel).ToList(), pinKind, fiUnit); } if (newUnit != null) { newUnit.Label = $"{FindResourceString(pinKind)}({dbModels?.Count ?? 0})"; fiUnit.Children.Add(newUnit); } } } catch (Exception ex) { EventLogger.Logger.WriteCallerLine(ex.Message); } }
public List <TreeUnit> GetCurrentTreeUnits(int unitID) { List <Filter> filters = new List <Filter>() { new Filter() { property = "Path", value = "/" + unitID + "/" } }; List <TreeUnit> dataList = dal.GetUnits(filters) .Select(t => new TreeUnit { ID = t.ID, Code = t.Code, Name = t.Name, text = t.Name, Path = t.Path, UnitTypeID = t.UnitTypeID, UnitTypeName = t.UnitTypeName, ParentID = t.ParentID, CreatedTime = t.CreatedTime, UpdatedTime = t.UpdatedTime }).OrderBy(t => t.ID).ToList(); List <TreeUnit> list = new List <TreeUnit>(); if (dataList.Count > 0) { for (int i = 0; i < dataList.Count; i++) { TreeUnit item = dataList[i]; if (item.ID == unitID) { item = GetUnitChildren(dataList, item); list.Add(item); } } } return(list); }
public TreeUnit GetNearestTreeWithVector3(Vector3 v) { List <TreeUnit> trees = FindObjectsOfType <TreeUnit>().ToList(); TreeUnit nearestTree = null; float minDistance = Mathf.Infinity; foreach (var item in trees) { if (item.curPeasant <= 0) { if (Vector3.Distance(item.transform.position, v) < minDistance) { minDistance = Vector3.Distance(item.transform.position, v); nearestTree = item; } } } return(nearestTree); }
/// <summary> /// 单独种类容器集合(未分拣)构造方法; /// </summary> /// <param name="dbModels">模型集合</param> /// <param name="pinKind">节点类型</param> /// <param name="parent"></param> /// <param name="idFunc">标识分类器</param> /// <param name="childKind"></param> public MultiDbModelsUnit(IEnumerable <TDbModel> dbModels, string pinKind, TreeUnit parent, Func <TDbModel, (string id, string name)> idFunc = null) :
private void LoadExt4Units() { var adDev = BlDevice as AndroidDevice; var mbrInfo = adDev.MgrInfo.MBRInfo; var efiInfo = adDev.MgrInfo.EFIInfo; var comma = ServiceProvider.Current?.GetInstance <ILanguageService>()?.FindResourceString("Comma"); Action <TreeUnit, object, string[]> adfAct = (unit, ob, ignored) => { foreach (var prop in ob.GetType().GetFields()) { if (!(ignored?.Contains(prop.Name) ?? false) && !prop.Name.ToLower().Contains("unknown")) { var propName = FindResourceString(prop.Name); if (string.IsNullOrEmpty(propName)) { propName = prop.Name; } unit.InfoWord += $"{propName}{comma}{prop.GetValue(ob).ToString()}{Environment.NewLine}"; } } }; Action <TreeUnit, object, string[]> adpAct = (unit, ob, ignored) => { foreach (var prop in ob.GetType().GetProperties()) { if (!(ignored?.Contains(prop.Name) ?? false) && !prop.Name.ToLower().Contains("unknown")) { var propName = FindResourceString(prop.Name); if (string.IsNullOrEmpty(propName)) { propName = prop.Name; } unit.InfoWord += $"{propName}{comma}{prop.GetValue(ob).ToString()}{Environment.NewLine}"; } } }; Func <string, string> frs = e => FindResourceString(e); if (mbrInfo != null) { var mbrUnit = new TreeUnit { Label = frs("MBRInfo"), Level = 0 }; var nstMbrInfo = mbrInfo.StMbrInfo; if (nstMbrInfo != null) { var stMbrInfo = nstMbrInfo.Value; adfAct(mbrUnit, stMbrInfo, null); } Units.Add(mbrUnit); } if (efiInfo != null) { var efiUnit = new TreeUnit { Label = frs("EFIInfo"), Level = 0 }; var nstefiInfo = efiInfo.StEFIInfo; if (nstefiInfo.HasValue) { var eInfo = nstefiInfo.Value; adfAct(efiUnit, eInfo, null); } Units.Add(efiUnit); } var ptbUnit = new TreeUnit { Label = ServiceProvider.Current?.GetInstance <ILanguageService>()?.FindResourceString("PartitionTable"), Level = 0 }; foreach (var p in adDev.Children) { var punit = new TreeUnit { Label = p.Name, Level = 1 }; if (p is AndroidPartition) { var adPart = p as AndroidPartition; var stPartInfo = adPart.TabPartInfo.StPartInfo; if (stPartInfo.HasValue) { var bpInfo = stPartInfo.Value; adfAct(punit, bpInfo, null); } //加载超级块信息; var spUnit = new TreeUnit { Label = frs("SuperBlockInfo"), Level = 2 }; var superBlockInfo = adPart.TabPartInfo.SuperBlockInfo.StSuperBlock; if (superBlockInfo.HasValue) { adfAct(spUnit, superBlockInfo, null); } punit.Children.Add(spUnit); //加载块组描述符表; var groupDecs = adPart.TabPartInfo.Ext4GroupDecs; var groupCount = 0; if (groupDecs != null) { var gpsUnit = new TreeUnit { Label = frs("GroupDescTable"), Level = 3 }; groupDecs.ForEach(q => { var groupUnit = new TreeUnit { Label = frs("GroupDesc") + groupCount++, Level = 4 }; adfAct(groupUnit, q, new string[] { "Next", "Pre" }); gpsUnit.Children.Add(groupUnit); }); punit.Children.Add(gpsUnit); } } //else if(p is Partition) { // var part = p as Partition; // adpAct(punit, part, null); //} ptbUnit.Children.Add(punit); } Units.Add(ptbUnit); }
public void NotifySelectionUnitChanged(TreeUnit unit) { SelectedUnit = unit; InfoWords = unit.InfoWord; //SelectedUnitChanged?.Invoke(this, unit); }
private void Update() { if (healthBar) { UpdateHealthBar(); } if (Manager.manager.isPause) { return; } switch (_property.state) { case State.None: Unit u = GetNearestEnemy(10); if (u) { ActTo(u); } break; case State.Move: if (Vector3.Distance(transform.position, targetVector) > 1) { MoveTo(targetVector); } else { anim.SetBool("Move", false); StopMove(); _property.state = State.None; } break; case State.MoveFarm: if (targetFarm) { if (Vector3.Distance(transform.position, targetFarm.transform.position) > 1) { MoveTo(targetFarm.transform.position); } else { StopMove(); _property.state = State.GetFarm; tToGetSecond = 0; } } break; case State.GetFarm: tToGetSecond += Time.deltaTime; if (tToGetSecond >= tToGet) { tToGetSecond = 0; curContain++; if (curContain >= maxContain) { _property.state = State.BackCityHallFarm; } } break; case State.BackCityHallFarm: if (cityHall) { if (Vector3.Distance(transform.position, cityHall.transform.position) > 1) { MoveTo(cityHall.transform.position); } else { StopMove(); _property.state = State.PutFarm; } } else { StopMove(); } break; case State.PutFarm: if (_property.colorTeam == Team.Red) { Manager.manager.resourcesGame._food += curContain; } curContain = 0; Manager.manager.UpdateresourcesGame(); _property.state = State.MoveFarm; break; case State.MoveTree: if (targetTree) { if (Vector3.Distance(transform.position, targetTree.transform.position) > 2) { MoveTo(targetTree.transform.position); } else { StopMove(); _property.state = State.GetTree; tToGetSecond = 0; } } break; case State.GetTree: if (targetTree) { tToGetSecond += Time.deltaTime; if (tToGetSecond >= tToGet) { tToGetSecond = 0; curContain++; targetTree.OnDecreamentWood(); if (curContain >= maxContain) { _property.state = State.BackCityHallTree; } } } else { TreeUnit tree = GetNearestTreeWithVector3(transform.position); if (tree) { ActTo(tree); } else { _property.state = State.None; } } break; case State.BackCityHallTree: if (cityHall) { if (Vector3.Distance(transform.position, cityHall.transform.position) > 1) { MoveTo(cityHall.transform.position); } else { StopMove(); _property.state = State.PutTree; } } else { StopMove(); } break; case State.PutTree: if (_property.colorTeam == Team.Red) { Manager.manager.resourcesGame._wood += curContain; } curContain = 0; Manager.manager.UpdateresourcesGame(); _property.state = State.MoveTree; break; case State.MoveFight: if (targetAttack) { if (Vector3.Distance(transform.position, targetAttack.transform.position) > 3) { MoveTo(targetAttack.transform.position); } else { StopMove(); _property.state = State.Fight; } } break; case State.Fight: if (targetAttack) { if (Attack1()) { Attack2(targetAttack); } } else { StopMove(); _property.state = State.None; } break; } }
public ExtTreeUnit(TData data, TreeUnit parent, string pinKind = null) : base(pinKind ?? $"{data.GetType().Name}Unit", parent) { this.Data = data; }
public PinTreeUnit(string pinKind, TreeUnit parent) : base(parent) { this.ContentId = pinKind; }
public override void ActTo(Unit unit) { if (unit == null) { return; } Property p = unit._property; if (unit._property.colorTeam != _property.colorTeam && unit._property.colorTeam != Team.None) { if (targetTree) { targetTree.curPeasant = 0; } targetAttack = unit; _property.state = State.MoveFight; } else { if (p._name == "Tree") { if (targetTree) { targetTree.curPeasant = 0; } TreeUnit tree = GetNearestTreeWithVector3(unit.transform.position); if (!tree) { return; } if (GetComponent <PeasantSoldier>()) { targetTree = tree; targetTree.curPeasant++; _property.state = State.MoveTree; } } else if (p._name == "Farm") { if (targetTree) { targetTree.curPeasant = 0; } FarmConstruct farm = GetNearestFarmWithVector3(unit.transform.position); if (!farm) { return; } if (GetComponent <PeasantSoldier>()) { targetFarm = farm; targetFarm.curPeasant++; _property.state = State.MoveFarm; } } } }