/// <summary> /// Check and create Unit record /// </summary> /// <param name="unitRecord">object of UnitInfo </param> /// <returns>Unit Nid</returns> public int CheckNCreateUnit(UnitInfo unitInfo) { int RetVal = 0; try { // check unit exists or not RetVal = this.CheckUnitExists(unitInfo); // if unit does not exist then create it. if (RetVal <= 0) { // insert unit if (this.InsertIntoDatabase(unitInfo)) { RetVal = this.GetNidByName(unitInfo.Name); } } // add indicator information into collection unitInfo.Nid = RetVal; this.AddUnitIntoCollection(unitInfo); } catch (Exception) { RetVal = 0; } return RetVal; }
public override Interaction DecideInteraction(IEnumerable<UnitInfo> units) { var candidateUnits = units.Where( (unit) => unit.Id != this.Id && this.UnitClassification == InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification)); UnitInfo optimalInfestableUnit = new UnitInfo(null, Infestation.UnitClassification.Unknown, int.MaxValue, 0, 0); foreach (var unit in candidateUnits) { if (unit.Health < optimalInfestableUnit.Health) { optimalInfestableUnit = unit; } } if (optimalInfestableUnit.Id != null) { return new Interaction(new UnitInfo(this), optimalInfestableUnit, InteractionType.Infest); } return Interaction.PassiveInteraction; }
protected bool getUnitInfo(GameObject selectedObj, out UnitInfo info) { string tag = selectedObj.tag; info = new UnitInfo(); if(tag == "Unit") { Unit selectedUnit = (Unit)selectedObj.GetComponent(tag); info.isSelectable = selectedUnit.isSelectable; info.team = selectedUnit.team; info.isMovable = selectedUnit.isMovable; return true; } else if(tag == "Building") { Building selectedBuilding = (Building)selectedObj.GetComponent(tag); info.isSelectable = selectedBuilding.isSelectable; info.team = selectedBuilding.team; info.isMovable = selectedBuilding.isMovable; return true; } else { return false; } }
/// <summary> /// Imports records from source database to target database/template /// </summary> /// <param name="selectedNids"></param> /// <param name="allSelected">Set true to import all records</param> public override void ImportValues(List<string> selectedNids, bool allSelected) { UnitBuilder UnitBuilderObj = new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries); UnitInfo SourceDBUnit; DataRow Row; int ProgressBarValue = 0; foreach (string Nid in selectedNids) { try { //get unit from source table Row = this.SourceTable.Select(Unit.UnitNId + "=" + Nid)[0]; SourceDBUnit = new UnitInfo(); SourceDBUnit.Name = DICommon.RemoveQuotes( Row[Unit.UnitName].ToString()); SourceDBUnit.GID = Row[Unit.UnitGId].ToString(); SourceDBUnit.Global = Convert.ToBoolean(Row[Unit.UnitGlobal]); SourceDBUnit.Nid=Convert.ToInt32(Row[Unit.UnitNId]); //import into target database UnitBuilderObj.ImportUnit(SourceDBUnit, SourceDBUnit.Nid, this.SourceDBQueries, this.SourceDBConnection); } catch (Exception ex) { ExceptionFacade.ThrowException(ex); } this.RaiseIncrementProgessBarEvent(ProgressBarValue); ProgressBarValue++; } }
public UnitInfo GetInfo (GameObject unit) { if (!info.ContainsKey (unit)) { var inf = new UnitInfo (unit); info [unit] = inf; return inf; } return info [unit]; }
//internal Unit Parse() //{ // if(Node != null ) //} internal UnitInfo Parse() { var rslt = new UnitInfo(); if (Node != null) rslt.Node = this.Node.Parse(); if (this.Parallel != null) rslt.Parallel = this.Parallel.Parse(); return rslt; }
protected override bool CanAttackUnit(UnitInfo unit) { if (unit.Id!=this.Id && InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification)==this.UnitClassification) { return true; } else { return false; } }
protected override bool CanAttackUnit(UnitInfo unit) { bool attackUnit = false; if (this.Id != unit.Id) { if (this.Aggression >= unit.Power) { attackUnit = true; } } return attackUnit; }
public override void OnNext(UnitInfo info) { switch (info.id) { case UnitDefId.Pacman: pacmanPosition = info.position; break; case UnitDefId.Blinky: blinkyPosition = info.position; break; } }
protected override UnitInfo GetOptimalAttackableUnit(IEnumerable<UnitInfo> attackableUnits) { UnitInfo optimalAttackableUnit = new UnitInfo(null, UnitClassification.Unknown, int.MaxValue, 0, 0); foreach (var unit in attackableUnits) { if (unit.Health < optimalAttackableUnit.Health) { optimalAttackableUnit = unit; } } return optimalAttackableUnit; }
private bool shouldMove(UnitInfo unit, int x, int y) { string unitType = unit.UnitTypeName; if (x < 0 || x > 14 || y < 0 || y > 14) return false; int unitCount = 0; for (int i = 0; i < myUnits.Count; i++) { if (myUnits.ElementAt(i).PositionX == unit.PositionX && myUnits.ElementAt(i).PositionY == unit.PositionY) unitCount++; } bool isTown = false; for (int i = 0; i < myCities.Count; i++) { if (myCities.ElementAt(i).PositionX == unit.PositionX && myCities.ElementAt(i).PositionY == unit.PositionY) { isTown = true; break; } } if (isTown && unitCount < 2) return false; int attack = getAttack(unit.PositionX, unit.PositionY); float enemyDefense = getDefense(x, y); for (int i = 0; i < enemyCities.Count; i++) { CityInfo enemyCity = enemyCities.ElementAt(i); if (enemyCity.PositionX == x && enemyCity.PositionY == y) { float szorzo = 1.0f; PlayerInfo enemy = world.Players.Where(player => player.Name == enemyCity.Owner).Single(); if (enemy.Researched.Contains("cölöpkerítés")) szorzo = 1.2f; if (enemy.Researched.Contains("kőfal")) szorzo = 1.4f; enemyDefense *= szorzo; break; } } if (attack > enemyDefense) { return true; } else { return false; } }
protected override bool CanAttackUnit(UnitInfo unit) { //The target’s Power is less than or equal to the Marine’s Aggression if(this.Id == unit.Id) { return false; } if (unit.Power<= this.Aggression) { return true; } else { return false; } }
/// <summary> /// To import unit information from mapped unit /// </summary> /// <param name="unitInfo"></param> /// <param name="NidInSourceDB"></param> /// <param name="NidInTrgDB"></param> /// <param name="sourceQurey"></param> /// <param name="sourceDBConnection"></param> /// <returns></returns> public int ImportMappedUnitInformation(UnitInfo unitInfo, int NidInSourceDB, int NidInTrgDB, DIQueries sourceQurey, DIConnection sourceDBConnection) { int RetVal = -1; UnitInfo TrgUnitInfo; try { //set RetVal to NidInTrgDB RetVal = NidInTrgDB; if (RetVal > 0) { TrgUnitInfo = this.GetUnitInfo(FilterFieldType.NId, RetVal.ToString()); // dont import if target is global but source is local if (TrgUnitInfo.Global & unitInfo.Global == false) { // dont import if target is global but source is local } else { //update the gid,name and global on the basis of nid this.DBConnection.ExecuteNonQuery(DALQueries.Unit.Update.UpdateByNid(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, unitInfo.Name, unitInfo.GID, unitInfo.Global, RetVal)); } } //update/insert icon DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.Unit, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection); } catch (Exception ex) { throw new ApplicationException(ex.Message); } return RetVal; }
public UnitInfo Put(Position pos, UnitInfo unit) { if (unit.type == Unit.TypeEnum.Bread) { grids[unit.pos.R, unit.pos.C] = Board.GridState.Bread; restResource++; } else { if (unit.owner != Unit.OwnerEnum.None) playerInfo[(int)unit.owner][(int)unit.type]++; units[pos.R, pos.C] = new UnitInfo(pos, unit.type, unit.owner); } return GetInfo(pos); }
// Use this for initialization void Start() { playerController = GameObject.FindGameObjectWithTag("Player"); animation.Play("Idle"); animation["Idle"].speed = 0.70f; if (Random.Range(0,2) == 0) { animation["Idle2"].speed = -0.60f; animation.Play("Idle2"); } hasTarget = false; stuckCounter = 0; origin = transform.position; unitInfo = this.GetComponent<UnitInfo>(); previousPosition = transform.position; rigidbody.constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation; }
float maxTargetLength = 10.0f; // Maximum amount of time to have a target before searching for a new one void Awake() { myInfo = GetComponent <UnitInfo>(); weaponsController = GetComponent <WeaponsController>(); myRigidbody = GetComponent <Rigidbody>(); }
/// <summary> /// Function to add new standard rate for the purticular product /// </summary> /// <param name="decProductId"></param> /// <param name="frmStandardRate"></param> public void CallFromStandardRate(decimal decProductId, frmStandardRate frmStandardRate) { try { base.Show(); StandardrateObj = frmStandardRate; StandardrateObj.Enabled = false; ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); UnitBll bllUnit = new UnitBll(); UnitInfo infoUnit = new UnitInfo(); infoProduct = BllProductCreation.ProductViewForStandardRate(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; decProduct = infoProduct.ProductId; infoUnit = bllUnit.unitVieWForStandardRate(decProductId); decUnitId = infoUnit.UnitId; txtUnitName.Text = infoUnit.UnitName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; BatchUnderProductComboFill(decProductId); GridFill(decProductId); } catch (Exception ex) { MessageBox.Show("SRP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Check existance of unit first in collection Then In database /// </summary> /// <param name="unitRecord">object of UnitInfo</param> /// <returns>Unit Nid</returns> public int CheckUnitExists(UnitInfo unitInfo) { int RetVal = 0; //Step 1: check unit exists in Unit collection RetVal = this.CheckUnitInCollection(unitInfo.Name); //Step 2: check unit exists in database. if (RetVal <= 0) { RetVal = this.GetUnitNid(unitInfo.GID, unitInfo.Name); } return RetVal; }
public static void AddMapUnitData(Vector3 pos, UnitInfo unitInfo) { mapUnitData[-(int)pos.y, (int)pos.x] = unitInfo; }
public Squad(UnitInfo unitInfo, int count) { this.unitInfo = unitInfo; this.Count = count; }
// we add it to the bottom, then bubble it up void InsertIntoArray( UnitInfo[] closestunits, UnitInfo newunit, int numexistingunits ) { if( numexistingunits < closestunits.GetUpperBound(0) + 1 ) { closestunits[ numexistingunits ] = newunit; numexistingunits++; } else { closestunits[ numexistingunits - 1 ] = newunit; } // bubble new unit up for( int i = numexistingunits - 2; i >= 0; i-- ) { if( closestunits[ i ].squareddistance > closestunits[ i + 1 ].squareddistance ) { UnitInfo swap = closestunits[ i ]; closestunits[ i ] = closestunits[ i + 1 ]; closestunits[ i + 1 ] = swap; } } // debug; // logfile.WriteLine( "AttackPackCoordinator.InsertIntoArray"); // for( int i = 0; i < numexistingunits; i++ ) // { // logfile.WriteLine(i + ": " + closestunits[ i ].squareddistance ); // } }
// Start is called before the first frame update void Start() { SavedInfo info = GameObject.FindGameObjectWithTag("Info").GetComponent<SavedInfo>(); mapData = info.pickedMap; grid = mapData.grid; units = new GameObject[mapData.enemies.Length]; for (int i = 0; i< mapData.len; i++) { for (int j = 0; j < mapData.wid; j++) { string tile = grid[(i*mapData.len)+j]; string[] specs = tile.Split('/'); int height = int.Parse(specs[1]); switch (specs[0]) { case "dirt": GameObject dirtCube = Instantiate(dirt, new Vector3(i, height, j), dirt.transform.rotation, mapObj.transform); dirtCube.name = "x" + i + "y" + j; break; case "forest": GameObject forestCube = Instantiate(forest, new Vector3(i, height, j), forest.transform.rotation, mapObj.transform); forestCube.name = "x" + i + "y" + j; break; case "stone": GameObject stoneCube = Instantiate(stone, new Vector3(i, height, j), stone.transform.rotation, mapObj.transform); stoneCube.name = "x" + i + "y" + j; break; case "sand": GameObject sandCube = Instantiate(sand, new Vector3(i, height, j), sand.transform.rotation, mapObj.transform); sandCube.name = "x" + i + "y" + j; break; case "water": GameObject waterCube = Instantiate(water, new Vector3(i, height, j), water.transform.rotation, mapObj.transform); waterCube.name = "x" + i + "y" + j; break; default: break; } } } for (int i = 0; i < mapData.enemies.Length; i++) { int x = mapData.enemyLocations[i] / mapData.len; int height = 0; int z = mapData.enemyLocations[i] % mapData.len; RaycastHit hit; if(Physics.Raycast(new Vector3((float)(x), 10, (float)(z)), new Vector3(0, -1, 0), out hit)) { height = (int) (10.0 - hit.distance); } GameObject unit = Instantiate(mapData.enemies[i], new Vector3(x, height+1, z), Quaternion.identity, mapObj.transform); unit.transform.Find("Pointer").gameObject.SetActive(false); this.gameObject.GetComponent<TurnOrder>().currentOrder.Add(unit); units[i] = unit; UnitInfo unIn = unit.GetComponent<UnitInfo>(); unIn.currentTile = hit.transform.gameObject; unIn.faction = "enemy"; unIn.name = mapData.enemyNames[i]; TileTextInfo occTile = hit.transform.gameObject.GetComponent<TileTextInfo>(); occTile.currOcc = unIn; } for (int i = 0; i<mapData.player.Length; i++) { int x = mapData.playerLocations[i] / mapData.len; int height = 0; int z = mapData.playerLocations[i] % mapData.len; RaycastHit hit; if (Physics.Raycast(new Vector3((float)(x), 10, (float)(z)), new Vector3(0, -1, 0), out hit)) { height = (int)(10.0 - hit.distance); } GameObject unit = Instantiate(mapData.player[i], new Vector3(x, height + 1, z), Quaternion.identity, mapObj.transform); unit.transform.Find("Pointer").gameObject.SetActive(false); this.gameObject.GetComponent<TurnOrder>().currentOrder.Add(unit); units[i] = unit; UnitInfo unIn = unit.GetComponent<UnitInfo>(); unIn.currentTile = hit.transform.gameObject; unIn.faction = "player"; unIn.name = mapData.playerNames[i]; TileTextInfo occTile = hit.transform.gameObject.GetComponent<TileTextInfo>(); occTile.currOcc = unIn; } mainCam.transform.position = new Vector3(mapData.wid*1.4f, (mapData.len + mapData.wid)*.5f , mapData.len*1.4f); turnOrder.ShowOrder(); }
protected override InjectAttribute GetInjectPointAttribute(UnitInfo unitInfo) => ParameterByAttributeMatcher <InjectAttribute> .GetParameterAttribute(unitInfo);
public static Vector2[] getMoveUnitMoveStyle(Transform unit) { UnitInfo info = unit.GetComponent <UnitInfo>(); return(info.movePath); }
private void UpdateSkills(int selectedIndex) { InitializeSkillUI(column1Skills); InitializeSkillUI(column2Skills); InitializeSkillUI(column3Skills); SkillColumnInfo skillColumnInfo = GetSkillColumnInfo(selectedIndex); column1Text.GetComponent <Text>().text = skillColumnInfo.column1Name; column2Text.GetComponent <Text>().text = skillColumnInfo.column2Name; column3Text.GetComponent <Text>().text = skillColumnInfo.column3Name; UnitInfo unitInfo = GetUnitInfo(selectedIndex); string unitNameInCode = unitInfo.nameInCode; List <SkillInfo> unitSkills = new List <SkillInfo>(); foreach (SkillInfo skillInfo in skillInfos) { if (skillInfo.owner == unitNameInCode) { unitSkills.Add(skillInfo); } } foreach (SkillInfo unitSkillInfo in unitSkills) { GameObject skillGameObject = GetSkillGameObject(unitSkillInfo.column, unitSkillInfo.requireLevel); skillGameObject.GetComponent <SkillButton>().SetSkillInfo(unitSkillInfo); Skill skill = unitSkillInfo.skill; bool isLearned = SkillDB.IsLearned(unitNameInCode, skill.GetName()); bool haveSkillPoint = GetAvailableSkillPoint(unitNameInCode) > 0; bool isEnhanceable = SkillDB.GetEnhanceLevel(unitNameInCode, skill.GetName()) < maxEnhanceLevel && haveSkillPoint; int totalSkillPointUntilLevel = unitSkillInfo.requireLevel - 1; int usedSkillPointUntilLevel = GetUsedSkillPointUntilLevel(unitNameInCode, unitSkillInfo.requireLevel - 1); bool isLearnable = usedSkillPointUntilLevel >= totalSkillPointUntilLevel && haveSkillPoint; if (!isLearned && !isLearnable) { skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.NotLearnable); } else if (!isLearned && isLearnable) { skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.Learnable); } else if (isLearned && isEnhanceable) { skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.LearnedEnhanceable); } else if (isLearned && !isEnhanceable) { skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.LearnedMaxEnhanced); } else { Debug.LogError("Invalid case"); } } // required level validation is needed }
/// <summary> /// 设置业务平台客户开户初始化 /// </summary> /// <param name="strCustomerInfo">客户信息字符窜</param> /// <param name="strUnitInfo">门店信息字符窜</param> /// <param name="typeId">处理类型typeId=1(总部与门店一起处理);typeId=2(只处理总部,不处理门店);typeId=3(只处理门店,不处理总部)</param> /// <returns></returns> public bool SetBSInitialInfo(string strCustomerInfo, string strUnitInfo, string strMenu, string typeId) { CustomerInfo customerInfo = new CustomerInfo(); #region 获取客户信息 if (!strCustomerInfo.Equals("")) { customerInfo = (JIT.CPOS.BS.Entity.CustomerInfo)cXMLService.Deserialize(strCustomerInfo, typeof(JIT.CPOS.BS.Entity.CustomerInfo)); if (customerInfo == null || customerInfo.ID.Equals("")) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "客户不存在或者没有获取合法客户信息") }); throw new Exception("客户不存在或者没有获取合法客户信息"); } } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "客户信息不存在") }); throw new Exception("客户信息不存在."); } #endregion //获取连接数据库信息 JIT.CPOS.BS.Entity.User.UserInfo userInfo = new JIT.CPOS.BS.Entity.User.UserInfo(); LoggingManager loggingManager = new cLoggingManager().GetLoggingManager(customerInfo.ID); LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); loggingSessionInfo.CurrentLoggingManager = loggingManager; loggingSessionInfo.CurrentUser = userInfo; #region 判断客户是否已经建立总部 typeId = "1";//统一作为1来处理 bool bReturn = false; string strError = string.Empty; string strReturn = string.Empty; // UnitInfo storeInfo = new UnitInfo(); cUserService userServer = new cUserService(loggingSessionInfo); #region 处理用户信息 userInfo.User_Id = BaseService.NewGuidPub(); //用户标识 userInfo.customer_id = customerInfo.ID; //客户标识 userInfo.User_Code = "admin"; userInfo.User_Name = "管理员"; userInfo.User_Gender = "1"; userInfo.User_Password = "******"; userInfo.User_Status = "1"; userInfo.User_Status_Desc = "正常"; userInfo.strDo = "Create"; #endregion #endregion UnitInfo unitInfo = new UnitInfo(); using (TransactionScope scope = new TransactionScope()) { #region 门店 /** * JIT.CPOS.BS.Entity.UnitInfo unitShopInfo = new JIT.CPOS.BS.Entity.UnitInfo();//门店 * if (!strUnitInfo.Equals(""))//把在运营商管理平台创建的门店(code就是商户的code)在这里反序列化 * { * unitShopInfo = (JIT.CPOS.BS.Entity.UnitInfo)cXMLService.Deserialize(strUnitInfo, typeof(JIT.CPOS.BS.Entity.UnitInfo)); * } * else * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "门店信息不存在") * }); * throw new Exception("门店信息不存在."); * } * **/ #region 门店是否存在(在这之前门店并没有插入到运营商管理平台的数据库,只是序列化在字符串里)***** /** * JIT.CPOS.BS.Entity.UnitInfo unitStoreInfo2 = new JIT.CPOS.BS.Entity.UnitInfo(); * try * { * unitStoreInfo2 = new UnitService(loggingSessionInfo).GetUnitById(unitShopInfo.Id); * } * catch (Exception ex) * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "获取门店失败") * }); * throw new Exception("获取门店失败:" + ex.ToString()); * } * if (unitStoreInfo2 == null || !string.IsNullOrEmpty(unitStoreInfo2.Id))//***这里的判断是不是错了,应该是(unitStoreInfo2 != null || !string.IsNullOrEmpty(unitStoreInfo2.Id)) * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "门店信息已经存在") * }); * throw new Exception("门店信息已经存在."); * } * **/ #endregion #endregion #region //创建商户自己的门店类型 T_TypeBLL t_TypeBLL = new T_TypeBLL(loggingSessionInfo); //创建总部类型 T_TypeEntity typeGeneral = new T_TypeEntity(); typeGeneral.type_id = BaseService.NewGuidPub();//去掉了中间的‘-’ typeGeneral.type_code = "总部"; typeGeneral.type_name = "总部"; typeGeneral.type_name_en = "总部"; typeGeneral.type_domain = "UnitType"; typeGeneral.type_system_flag = 1; typeGeneral.status = 1; typeGeneral.type_Level = 1; typeGeneral.customer_id = customerInfo.ID; t_TypeBLL.Create(typeGeneral); //创建门店类型 T_TypeEntity typeShop = new T_TypeEntity(); typeShop.type_id = BaseService.NewGuidPub();//去掉了中间的‘-’ typeShop.type_code = "门店"; typeShop.type_name = "门店"; typeShop.type_name_en = "门店"; typeShop.type_domain = "UnitType"; typeShop.type_system_flag = 1; typeShop.status = 1; typeShop.type_Level = 99;//等到在页面上保存时在根据增加的层级来改变他的层级 typeShop.customer_id = customerInfo.ID; t_TypeBLL.Create(typeShop); //创建在线商城类型 T_TypeEntity typeOnlineShopping = new T_TypeEntity(); typeOnlineShopping.type_id = BaseService.NewGuidPub();//去掉了中间的‘-’ typeOnlineShopping.type_code = "OnlineShopping"; typeOnlineShopping.type_name = "在线商城"; typeOnlineShopping.type_name_en = "OnlineShopping"; typeOnlineShopping.type_domain = "UnitType"; typeOnlineShopping.type_system_flag = 1; typeOnlineShopping.status = 1; typeOnlineShopping.type_Level = -99;//在线商城类型不算在组织类型里,因此排在外面 typeOnlineShopping.customer_id = customerInfo.ID; t_TypeBLL.Create(typeOnlineShopping); #endregion #region 新建角色 RoleModel roleInfo = new RoleModel(); if (typeId.Equals("1")) { roleInfo.Role_Id = BaseService.NewGuidPub(); roleInfo.Def_App_Id = "D8C5FF6041AA4EA19D83F924DBF56F93"; //创建了一个o2o业务系统的角色 roleInfo.Role_Code = "Admin"; roleInfo.Role_Name = "管理员"; roleInfo.Role_Eng_Name = "Admin"; roleInfo.Is_Sys = 1; roleInfo.Status = 1; roleInfo.customer_id = customerInfo.ID; roleInfo.Create_User_Id = userInfo.User_Id; roleInfo.Create_Time = new BaseService().GetCurrentDateTime(); //新加上所处的层级 roleInfo.type_id = typeGeneral.type_id; roleInfo.org_level = (int)typeGeneral.type_Level;//等级 string strerror = ""; strReturn = new RoleService(loggingSessionInfo).SetRoleInfo(roleInfo, out strerror, false);//这里没有创建他的菜单 if (!strReturn.Equals("成功")) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色失败") }); throw new Exception("新建角色失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色成功") }); } } #endregion #region 角色与流程关系 if (typeId.Equals("1")) { bReturn = new cBillService(loggingSessionInfo).SetBatBillActionRole(roleInfo.Role_Id);//不知道有什么作用 if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "创建角色与流程关系失败") }); throw new Exception("创建角色与流程关系失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "角色与流程关系成功") }); } } #endregion //UnitInfo unitInfo = new UnitInfo(); UnitService unitServer = new UnitService(loggingSessionInfo); unitInfo.Id = BaseService.NewGuidPub();//先把总部的标识生成好 #region 插入用户与角色与客户总部关系 IList <UserRoleInfo> userRoleInfoList = new List <UserRoleInfo>(); UserRoleInfo userRoleInfo = new UserRoleInfo();//后面要用到总部的信息 if (typeId.Equals("1") || typeId.Equals("2")) { userRoleInfo.Id = BaseService.NewGuidPub(); userRoleInfo.UserId = userInfo.User_Id; userRoleInfo.RoleId = roleInfo.Role_Id; //admin角色***** userRoleInfo.UnitId = unitInfo.Id; //总部下的*** userRoleInfo.Status = "1"; userRoleInfo.DefaultFlag = 1; userRoleInfoList.Add(userRoleInfo); } loggingSessionInfo.CurrentUserRole = userRoleInfo;//主要是保存总部和员工信息时,会用到 #region 处理新建客户总部 if (typeId.Equals("1") || typeId.Equals("2")) { // unitInfo.TypeId = "2F35F85CF7FF4DF087188A7FB05DED1D";//这里要替换成该商户自己的门店类型标识**** unitInfo.TypeId = typeGeneral.type_id; //*** unitInfo.Code = "总部"; //customerInfo.Code + unitInfo.Name = "总部"; // customerInfo.Name + unitInfo.CityId = customerInfo.city_id; unitInfo.Status = "1"; unitInfo.Status_Desc = "正常"; unitInfo.CustomerLevel = 1; unitInfo.customer_id = customerInfo.ID; unitInfo.Parent_Unit_Id = "-99"; unitInfo.strDo = "Create"; strReturn = unitServer.SetUnitInfo(loggingSessionInfo, unitInfo, false); Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "提交总部:" + strReturn.ToString()) }); } #endregion #region 处理门店,用的是商户的code和名称,id没有用***** /** * storeInfo.Id = unitShopInfo.Id;//(运营商管理平台创建的门店(Shop代表门店***) * if (string.IsNullOrEmpty(unitShopInfo.Id)) * { * storeInfo.Id = BaseService.NewGuidPub(); * } * // storeInfo.TypeId = "EB58F1B053694283B2B7610C9AAD2742"; //整个平台的系统类型(门店类型) * storeInfo.TypeId = typeShop.type_id;//上面创建的门店类型 * storeInfo.Code = customerInfo.Code;//商户的code * storeInfo.Name = customerInfo.Name;//商户的name * storeInfo.Name = customerInfo.Name;//商户的name * * storeInfo.CityId = customerInfo.city_id; * storeInfo.Status = "1"; * storeInfo.Status_Desc = "正常"; * storeInfo.CustomerLevel = 1; * storeInfo.customer_id = customerInfo.ID; * storeInfo.Parent_Unit_Id = unitInfo.Id;//总部下面的一个门店 * storeInfo.strDo = "Create"; * storeInfo.StoreType = "DirectStore";//设置为直营店 * strReturn = unitServer.SetUnitInfo(loggingSessionInfo, storeInfo,false); * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "提交门店:" + strReturn.ToString()) * }); * **/ #endregion //在线商城门店是在存储过程[spBasicSetting]里添加的 //不建立下面的关系,就可以之保留admin的总部角色权限了 /** * UserRoleInfo userRoleInfo1 = new UserRoleInfo(); * userRoleInfo1.Id = BaseService.NewGuidPub(); * userRoleInfo1.UserId = userInfo.User_Id; * userRoleInfo1.RoleId = roleInfo.Role_Id; * userRoleInfo1.UnitId = storeInfo.Id;//还和子门店建立了关系(id为商户的id) * userRoleInfo1.Status = "1"; * userRoleInfo1.DefaultFlag = 0; * userRoleInfoList.Add(userRoleInfo1); * * **/ bReturn = userServer.SetUserInfo(userInfo, null, out strError, false); //保存用户信息(这里会把之前建的会员的角色信息给删除掉),所以要在后面再建立角色和会员的关系 bReturn = userServer.SetUserRoleTableInfo(loggingSessionInfo, userRoleInfoList, userInfo); //只建立了用户和总部之间的关系 if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色用户门店关系失败") }); throw new Exception("新建角色用户门店关系失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色用户门店关系成功") }); } #endregion #region 处理用户信息 if (typeId.Equals("1")) { /** * IList<UserRoleInfo> userRoleInfos = new List<UserRoleInfo>(); * UserRoleInfo userRoleInfo = new UserRoleInfo(); * userRoleInfo.Id = BaseService.NewGuidPub(); * userRoleInfo.RoleId = roleInfo.Role_Id;// 加上管理员权限 * userRoleInfo.UserId = userInfo.User_Id; * userRoleInfo.UnitId = unitShopInfo.Id;//新建的门店标识(运营商管理平台创建的门店(Shop代表门店***),code=customer_code,name=customer_name) * userRoleInfos.Add(userRoleInfo); * loggingSessionInfo.CurrentUserRole = userRoleInfo; * **/ //先给admin键了一个门店的权限*****,可以给去掉,去掉上面一句话就可以了**** if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "保存用户失败") }); throw new Exception("保存用户失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "保存用户成功") }); } } #endregion #region 添加仓库以及仓库与门店关系 /** * JIT.CPOS.BS.Entity.Pos.WarehouseInfo warehouseInfo = new JIT.CPOS.BS.Entity.Pos.WarehouseInfo(); * warehouseInfo.warehouse_id = BaseService.NewGuidPub(); * warehouseInfo.wh_code = storeInfo.Code + "_wh";//建立了刚才见的子门点的仓库 * warehouseInfo.wh_name = storeInfo.Name + "仓库"; * warehouseInfo.is_default = 1; * warehouseInfo.wh_status = 1; * warehouseInfo.CreateUserID = userInfo.User_Id; * warehouseInfo.CreateTime = Convert.ToDateTime(new BaseService().GetCurrentDateTime()); * warehouseInfo.CreateUserName = userInfo.User_Name; * warehouseInfo.Unit = storeInfo; * * PosService posService = new PosService(loggingSessionInfo); * bReturn = posService.InsertWarehouse(warehouseInfo,false); * if (!bReturn) * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建仓库失败") * }); * throw new Exception("新建仓库失败"); * } * else { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建仓库成功") * }); * } * **/ #endregion #region 设置菜单信息 //在存储过程里初始化了 /*** * if (typeId.Equals("1") || typeId.Equals("2")) * { * if (!strMenu.Equals("")) * { * CMenuService menuServer = new CMenuService(loggingSessionInfo); * bReturn = new CMenuService(loggingSessionInfo).SetMenuInfo(strMenu, customerInfo.ID, false); * if (!bReturn) { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建菜单失败") * }); * throw new Exception("新建菜单失败"); } * else { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建菜单成功") * }); * } * } * } * **/ #endregion #region 20131127设置固定标签 TagsBLL tagsServer = new TagsBLL(loggingSessionInfo); bool bReturnTags = tagsServer.setCopyTag(customerInfo.ID); #endregion scope.Complete(); scope.Dispose(); } #region 管理平台--插入客户下的用户信息 if (typeId.Equals("1")) { if (!new cUserService(loggingSessionInfo).SetManagerExchangeUserInfo(loggingSessionInfo, userInfo, 1)) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "提交管理平台用户信息失败") }); strError = "提交管理平台失败"; bReturn = false; return(bReturn); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "提交管理平台用户信息成功") }); } } #endregion #region 管理平台--插入客户下的门店信息(只是提交门店级别的) // bReturn = new UnitService(loggingSessionInfo).SetManagerExchangeUnitInfo(loggingSessionInfo, storeInfo, 1); bReturn = new UnitService(loggingSessionInfo).SetManagerExchangeUnitInfo(loggingSessionInfo, unitInfo, 1); if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "门店插入管理平台失败") }); throw new Exception("门店插入管理平台失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "门店插入管理平台成功") }); } #endregion #region 中间层--插入用户,客户关系 if (typeId.Equals("1")) { userInfo.customer_id = customerInfo.ID; string strResult = cUserService.SetDexUserCertificate(loggingSessionInfo, userInfo); if (!(strResult.Equals("True") || strResult.Equals("true"))) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "插入SSO失败") }); strError = "插入SSO失败"; bReturn = false; return(bReturn); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "插入SSO成功") }); } } #endregion return(true); }
/// <summary> /// Import Unit: check and update UnitName,UnitGID /// </summary> /// <param name="unitGid"></param> /// <param name="unitName"></param> /// <param name="isGlobal"></param> /// <returns></returns> public int ImportUnit(string unitGid, string unitName, bool isGlobal) { int RetVal = -1; UnitInfo TrgUnitInfo = null; UnitInfo UnitInfoObj = new UnitInfo(); string LangCode = this.DBQueries.LanguageCode; try { UnitInfoObj.GID = unitGid; UnitInfoObj.Name = unitName; UnitInfoObj.Global = isGlobal; //check unit already exists in database or not RetVal = this.GetUnitNid(UnitInfoObj.GID, UnitInfoObj.Name); if (RetVal > 0) { if (!this.DBQueries.LanguageCode.StartsWith("_")) { LangCode = "_" + LangCode; } TrgUnitInfo = this.GetUnitInfo(FilterFieldType.NId, RetVal.ToString()); // dont import if target is global but source is local if (TrgUnitInfo.Global & UnitInfoObj.Global == false) { // dont import if target is global but source is local } else { //update the gid,name and global on the basis of nid this.DBConnection.ExecuteNonQuery(DALQueries.Unit.Update.UpdateByNid(this.DBQueries.DataPrefix, LangCode, UnitInfoObj.Name, UnitInfoObj.GID, UnitInfoObj.Global, RetVal)); } } else { if (this.InsertIntoDatabase(UnitInfoObj)) { //get nid RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY")); } } } catch (Exception ex) { throw new ApplicationException(ex.Message); } return RetVal; }
public static Units CreateHeroByUnitInfo(UnitInfo info) { Units result; try { if (info == null) { result = null; } else { EntityVo entityVo = new EntityVo(EntityType.Hero, info.typeId, 0, 0, string.Empty, "Default", 0) { uid = info.unitId, level = info.level, hp = 99999f, mp = 99999f, effectId = string.Empty }; Units unit = MapManager.Instance.GetUnit(info.mainHeroId); if (unit != null) { if (unit.npc_id == "Jiansheng") { entityVo.effectId = "1|Perform_jsbirth_fenshen"; } else if (unit.npc_id == "Houzi") { } } SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility(); Vector3 vector = MoveController.SVectgor3ToVector3(info.position); string userName = (!(unit == null)) ? unit.summonerName : "1"; string summerId = "1"; Units units = spawnUtility.SpawnPvpHero(entityVo, "Hero", (TeamType)info.group, 0, userName, summerId, new Vector3?(vector), UnitType.FenShenHero); if (units != null && unit != null) { units.level = unit.level; units.data.SetMaxHp(unit.hp_max); units.data.SetMaxMp(unit.mp_max); units.data.SetHp(unit.hp); units.data.SetMp(unit.mp); units.SetParentUnit(unit); units.SetMirrorState(true); if (unit.npc_id == "Jiansheng") { units.SetCanAIControl(true); units.SetCanSkill(false); units.effect_id = "2|Perform_jsdead_fenshen"; } else if (unit.npc_id == "Houzi") { units.effect_id = "2|FenShenDeath,2|DashengS2"; units.SetCanAIControl(false); units.SetCanAction(false); units.trans.rotation = unit.trans.rotation; } Units selectedTarget = PlayerControlMgr.Instance.GetSelectedTarget(); if (selectedTarget != null && unit.unique_id == selectedTarget.unique_id) { PlayerControlMgr.Instance.GetPlayer().SetSelectTarget(null); PlayerControlMgr.Instance.GetPlayer().SetAttackTarget(null); PlayerControlMgr.Instance.SetSelectedTarget(null); } units.SetPosition(vector, true); } result = units; } } catch (Exception e) { ClientLogger.LogException(e); result = null; } return(result); }
/// <summary> /// Add unit record into collection /// </summary> /// <param name="unitRecord">object of UnitInfo</param> private void AddUnitIntoCollection(UnitInfo unitInfo) { if (!this.UnitCollection.ContainsKey(unitInfo.Name)) { this.UnitCollection.Add(unitInfo.Name, unitInfo); } }
//유닛 데이터에 추가 public void AddUnit(UnitInfo unit) { Units.Add(unit); }
public Unit(UnitInfo info) { Initialize(info); }
//유닛 데이터에서 삭제 public void DelUnit(UnitInfo unit) { Units.Remove(unit); }
private static bool Equals(ProteinBenchmark benchmark, UnitInfo unifInfo) { return(benchmark.OwningSlotName == unifInfo.OwningSlotName && FileSystemPath.Equal(benchmark.OwningClientPath, unifInfo.OwningClientPath) && benchmark.ProjectID == unifInfo.ProjectID); }
private void GenerateUnitInfoDataFromQueue(DataAggregatorResult result, SlotRun slotRun, ICollection <Unit> unitCollection, Options options, SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId) { Debug.Assert(unitCollection != null); Debug.Assert(options != null); Debug.Assert(slotOptions != null); Debug.Assert(currentUnitInfo != null); result.UnitInfos = new Dictionary <int, UnitInfo>(); bool foundCurrentUnitInfo = false; foreach (var unit in unitCollection.Where(x => x.Slot == slotId)) { var projectInfo = unit.ToProjectInfo(); if (projectInfo.EqualsProject(currentUnitInfo) && unit.AssignedDateTime.GetValueOrDefault().Equals(currentUnitInfo.DownloadTime)) { foundCurrentUnitInfo = true; } // Get the Log Lines for this queue position from the reader var unitRun = GetUnitRun(slotRun, unit.Id, projectInfo); if (unitRun == null) { string message = String.Format(CultureInfo.CurrentCulture, "Could not find log section for Slot {0} {1}. Cannot update log data for this unit.", slotId, projectInfo); Logger.WarnFormat(Constants.ClientNameFormat, ClientName, message); } UnitInfo unitInfo = BuildUnitInfo(unit, options, slotOptions, unitRun); if (unitInfo != null) { result.UnitInfos.Add(unit.Id, unitInfo); if (unit.StateEnum == FahUnitStatus.Running) { result.CurrentUnitIndex = unit.Id; } } } // if no running WU found if (result.CurrentUnitIndex == -1) { // look for a WU with Ready state var unit = unitCollection.FirstOrDefault(x => x.Slot == slotId && x.StateEnum == FahUnitStatus.Ready); if (unit != null) { result.CurrentUnitIndex = unit.Id; } } // if the current unit has already left the UnitCollection then find the log section and update here if (!foundCurrentUnitInfo) { // Get the Log Lines for this queue position from the reader var unitRun = GetUnitRun(slotRun, currentUnitInfo.QueueIndex, currentUnitInfo); if (unitRun != null) { // create a clone of the current UnitInfo object so we're not working with an // instance that is referenced by a SlotModel that is bound to the grid - Issue 277 UnitInfo currentClone = currentUnitInfo.DeepClone(); UpdateUnitInfoFromLogData(currentClone, unitRun); result.UnitInfos.Add(currentClone.QueueIndex, currentClone); } } }
/// <summary> /// Function to fil Controls based on the ProductName /// </summary> /// <param name="decProductId"></param> public void FillControlsByProductName(decimal decProductId) { try { PriceListInfo InfoPriceList = new PriceListInfo(); ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); PriceListBll BllPriceList = new PriceListBll(); ProductBatchInfo infoProductBatch = new ProductBatchInfo(); infoProduct = BllProductCreation.ProductView(decProductId); txtProductCode.Text = infoProduct.ProductCode; infoProductBatch = BllProductCreation.BarcodeViewByProductCode(txtProductCode.Text); decProductId = infoProductBatch.ProductId; decBatchId = infoProductBatch.BatchId; InfoPriceList = BllPriceList.PriceListViewByBatchIdORProduct(decBatchId); batchcombofill(); txtBarcode.Text = infoProductBatch.Barcode; cmbItem.Text = infoProduct.ProductName; cmbGodown.SelectedValue = infoProduct.GodownId; cmbRack.SelectedValue = infoProduct.RackId; UnitComboFill(); UnitInfo infoUnit = new UnitInfo(); infoUnit = new UnitBll().unitVieWForStandardRate(decProductId); cmbUnit.SelectedValue = infoUnit.UnitId; if (InfoPriceList.PricinglevelId != 0) { cmbPricingLevel.SelectedValue = InfoPriceList.PricinglevelId; } else { cmbPricingLevel.SelectedIndex = 0; } ComboTaxFill(); cmbTax.SelectedValue = infoProduct.TaxId; if (txtProductCode.Text.Trim() != string.Empty && cmbItem.SelectedIndex != -1) { decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces; decimal dcRate = BllProductCreation.ProductRateForSales(decProductId, Convert.ToDateTime(txtDate.Text), decBatchId, decNodecplaces); txtRate.Text = dcRate.ToString(); try { if (decimal.Parse(txtQuantity.Text) == 0) txtQuantity.Text = "1"; } catch { txtQuantity.Text = "1"; } txtQuantity.Focus(); } TaxAmountCalculation(); isAfterFillControls = true; } catch (Exception ex) { MessageBox.Show("POS:27" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected Unit GetUnit(UnitInfo unitInfo) { return this.GetUnit(unitInfo.Id); //return this.containedUnits.FirstOrDefault((unit) => unit.Id == unitInfo.Id); }
/// <summary> /// Aggregate Data and return UnitInfo Dictionary. /// </summary> public DataAggregatorResult AggregateData(ClientRun clientRun, UnitCollection unitCollection, Info info, Options options, SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId) { if (clientRun == null) { throw new ArgumentNullException("clientRun"); } if (unitCollection == null) { throw new ArgumentNullException("unitCollection"); } if (options == null) { throw new ArgumentNullException("options"); } if (slotOptions == null) { throw new ArgumentNullException("slotOptions"); } if (currentUnitInfo == null) { throw new ArgumentNullException("currentUnitInfo"); } var result = new DataAggregatorResult(); result.CurrentUnitIndex = -1; SlotRun slotRun = null; if (clientRun.SlotRuns.ContainsKey(slotId)) { slotRun = clientRun.SlotRuns[slotId]; } result.StartTime = clientRun.Data.StartTime; result.Arguments = clientRun.Data.Arguments; result.ClientVersion = clientRun.Data.ClientVersion; result.UserID = clientRun.Data.UserID; result.MachineID = clientRun.Data.MachineID; result.Status = slotRun != null ? slotRun.Data.Status : SlotStatus.Unknown; if (Logger.IsDebugEnabled) { foreach (var s in clientRun.Where(x => x.LineType == LogLineType.Error)) { Logger.DebugFormat(Constants.ClientNameFormat, ClientName, String.Format("Failed to parse log line: {0}", s)); } } GenerateUnitInfoDataFromQueue(result, slotRun, unitCollection, options, slotOptions, currentUnitInfo, slotId); result.Queue = BuildQueueDictionary(unitCollection, info, slotOptions, slotId); if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex) && result.UnitInfos[result.CurrentUnitIndex].LogLines != null) { result.CurrentLogLines = result.UnitInfos[result.CurrentUnitIndex].LogLines; } else if (slotRun != null) { result.CurrentLogLines = slotRun.ToList(); } else { result.CurrentLogLines = clientRun.ToList(); } return(result); }
protected override Type GetInjectPointType(UnitInfo unitInfo) => (unitInfo.Id as ParameterInfo)?.ParameterType;
void Awake() { Instance = this; }
void commonTargeting(UnitInfo tgt, in SpatialEntityId entityId, in CommanderStatus.Component commander, out TargetInfo targetInfo)
/// <summary> /// fill Items into the purticular controls for Update or delete /// </summary> public void FillControls() { try { StandardRateInfo infoStandardRate = new StandardRateInfo(); standardRateBll BllStandaredRate = new standardRateBll(); infoStandardRate = BllStandaredRate.StandardRateView(decStandardRate); dtpFromDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableFrom.ToString()); dtpToDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableTo.ToString()); dtpFromDate.Text = infoStandardRate.ApplicableFrom.ToString(); dtpToDate.Text = infoStandardRate.ApplicableTo.ToString(); txtRate.Text = infoStandardRate.Rate.ToString(); decProduct = infoStandardRate.ProductId; decUnitId = infoStandardRate.UnitId; ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); infoProduct = BllProductCreation.ProductViewForStandardRate(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; decStandardRateId = infoStandardRate.StandardRateId; UnitInfo infoUnit = new UnitInfo(); UnitBll bllUnit = new UnitBll(); infoUnit = bllUnit.UnitView(decUnit); txtUnitName.Text = infoUnit.UnitName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; BatchInfo infoBatch = new BatchInfo(); BatchBll BllBatch = new BatchBll(); decBatchId = infoStandardRate.BatchId; infoBatch = BllBatch.BatchView(decBatchId); cmbBatch.SelectedValue = infoBatch.BatchId; } catch (Exception ex) { MessageBox.Show("SRP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected override Unit GetUnit(UnitInfo unitInfo) { return(this.GetUnit(unitInfo.Id)); }
// Use this for initialization void Start() { unitInfo = this.GetComponent<UnitInfo>(); }
public Interaction(UnitInfo sourceUnitInfo, UnitInfo targetUnitInfo, InteractionType type) { this.SourceUnit = sourceUnitInfo; this.TargetUnit = targetUnitInfo; this.InteractionType = type; }
public bool Compare(UnitInfo rhs) { return pos == rhs.pos && type == rhs.type && owner == rhs.owner; }
protected override Type GetInjectPointType(UnitInfo unitInfo) => (unitInfo.Id as PropertyInfo)?.PropertyType;
/// <summary> /// Returns instance of UnitInfo. /// </summary> /// <param name="filterClause"></param> /// <param name="filterText"></param> /// <param name="selectionType"></param> /// <returns></returns> public UnitInfo GetUnitInfo(FilterFieldType filterClause, string filterText) { string Query = string.Empty; UnitInfo RetVal = new UnitInfo(); DataTable UnitTable; try { Query = this.DBQueries.Unit.GetUnit(filterClause, filterText); UnitTable = this.DBConnection.ExecuteDataTable(Query); //set unit info if (UnitTable != null) { if (UnitTable.Rows.Count > 0) { RetVal.GID = UnitTable.Rows[0][Unit.UnitGId].ToString(); RetVal.Name = UnitTable.Rows[0][Unit.UnitName].ToString(); RetVal.Nid = Convert.ToInt32(UnitTable.Rows[0][Unit.UnitNId].ToString()); RetVal.Global = Convert.ToBoolean(UnitTable.Rows[0][Unit.UnitGlobal]); } } } catch (Exception) { RetVal = null; } return RetVal; }
private void tas_BattleOpened(object sender, TasEventArgs e) { tas.DisableUnits(UnitInfo.ToStringList(config.DisabledUnits)); }
/// <summary> /// To Import a unit into template or database /// </summary> /// <param name="unitInfo"></param> /// <param name="NidInSourceDB"></param> /// <param name="sourceQurey"></param> /// <param name="sourceDBConnection"></param> /// <returns></returns> public int ImportUnit(UnitInfo unitInfo, int NidInSourceDB, DIQueries sourceQurey, DIConnection sourceDBConnection) { int RetVal = -1; UnitInfo TrgUnitInfo; try { //check unit already exists in database or not RetVal = this.GetUnitNid(unitInfo.GID, unitInfo.Name); if (RetVal > 0) { TrgUnitInfo = this.GetUnitInfo(FilterFieldType.NId, RetVal.ToString()); // dont import if target is global but source is local if (TrgUnitInfo.Global & unitInfo.Global == false) { // dont import if target is global but source is local } else { //update the gid,name and global on the basis of nid this.DBConnection.ExecuteNonQuery(DALQueries.Unit.Update.UpdateByNid(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, unitInfo.Name, unitInfo.GID, unitInfo.Global, RetVal)); } } else { if (this.InsertIntoDatabase(unitInfo)) { //get nid RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY")); } } //update/insert icon DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.Unit, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection); } catch (Exception ex) { throw new ApplicationException(ex.Message); } return RetVal; }
public void UpdateBenchmarkDataTest() { // setup var benchmarkCollection = new ProteinBenchmarkService(); var database = MockRepository.GenerateMock <IUnitInfoDatabase>(); var legacyClient = new LegacyClient { BenchmarkService = benchmarkCollection, UnitInfoDatabase = database }; var unitInfo1 = new UnitInfo(); unitInfo1.OwningClientName = "Owner"; unitInfo1.OwningClientPath = "Path"; unitInfo1.ProjectID = 2669; unitInfo1.ProjectRun = 1; unitInfo1.ProjectClone = 2; unitInfo1.ProjectGen = 3; unitInfo1.FinishedTime = new DateTime(2010, 1, 1); var currentUnitInfo = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1 }; var unitInfo1Clone = unitInfo1.DeepClone(); unitInfo1Clone.FramesObserved = 4; unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0 }); unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1 }); unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2 }); unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3 }); var unitInfoLogic1 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone }; var unitInfo2 = new UnitInfo(); unitInfo2.OwningClientName = "Owner"; unitInfo2.OwningClientPath = "Path"; unitInfo2.ProjectID = 2669; unitInfo2.ProjectRun = 2; unitInfo2.ProjectClone = 3; unitInfo2.ProjectGen = 4; unitInfo2.FinishedTime = new DateTime(2010, 1, 1); var unitInfoLogic2 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo2 }; var unitInfo3 = new UnitInfo(); unitInfo3.OwningClientName = "Owner"; unitInfo3.OwningClientPath = "Path"; unitInfo3.ProjectID = 2669; unitInfo3.ProjectRun = 3; unitInfo3.ProjectClone = 4; unitInfo3.ProjectGen = 5; unitInfo3.FinishedTime = new DateTime(2010, 1, 1); var unitInfoLogic3 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo3 }; var parsedUnits = new[] { unitInfoLogic1, unitInfoLogic2, unitInfoLogic3 }; // arrange database.Stub(x => x.Connected).Return(true); database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(3); var benchmarkClient = new ProteinBenchmarkSlotIdentifier("Owner", "Path"); // assert before act Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient)); Assert.AreEqual(false, new List <int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669)); Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData)); // act legacyClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 2); // assert after act Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient)); Assert.AreEqual(true, new List <int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669)); Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime); database.VerifyAllExpectations(); }
/// <summary> /// Insert unit record into Unit table /// </summary> /// <param name="unitRecord">object of UnitInfo </param> /// <returns>Ture/False. Return true after successful insertion otherwise false</returns> public bool InsertIntoDatabase(UnitInfo unitInfo) { bool RetVal = false; string unitName = unitInfo.Name; string unitGID = unitInfo.GID; string UnitGId = Guid.NewGuid().ToString(); string LanguageCode = string.Empty; string DefaultLanguageCode = string.Empty; string UnitForDatabase = string.Empty; try { DefaultLanguageCode = this.DBQueries.LanguageCode; //replace GID only if given gid is not empty or null. if (!string.IsNullOrEmpty(unitGID)) { UnitGId = unitGID; } foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = languageRow[Language.LanguageCode].ToString(); if (LanguageCode == DefaultLanguageCode.Replace("_", String.Empty)) { UnitForDatabase = unitName; } else { UnitForDatabase = Constants.PrefixForNewValue + unitName; } this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Unit.Insert.InsertUnit(this.DBQueries.DataPrefix, "_" + LanguageCode, UnitForDatabase, UnitGId, unitInfo.Global, this.DBConnection.ConnectionStringParameters.ServerType)); } RetVal = true; } catch (Exception) { RetVal = false; } return RetVal; }
public List <UnitInfo> SingleTargetFinder(UnitInfo unit, int radius, GameObject center, string targ) { List <UnitInfo> hits = new List <UnitInfo>(); Vector3 position = center.transform.position; RaycastHit hit; for (int i = 0; i <= radius; i++) { for (int j = 0; (j + i) <= radius; j++) { if (Physics.Raycast(new Vector3(position.x + i, 10, position.z + j), new Vector3(0, -1, 0), out hit)) { if (hit.transform.gameObject.tag == "Unit") { if (CheckTarget(unit, hit.transform.parent.gameObject.GetComponent <UnitInfo>(), targ)) { hits.Add(hit.transform.parent.gameObject.GetComponent <UnitInfo>()); } } } if (i > 0) { if (Physics.Raycast(new Vector3(position.x - i, 10, position.z + j), new Vector3(0, -1, 0), out hit)) { if (hit.transform.gameObject.tag == "Unit") { if (CheckTarget(unit, hit.transform.parent.gameObject.GetComponent <UnitInfo>(), targ)) { hits.Add(hit.transform.parent.gameObject.GetComponent <UnitInfo>()); } } } } if (j > 0) { if (Physics.Raycast(new Vector3(position.x + i, 10, position.z - j), new Vector3(0, -1, 0), out hit)) { if (hit.transform.gameObject.tag == "Unit") { if (CheckTarget(unit, hit.transform.parent.gameObject.GetComponent <UnitInfo>(), targ)) { hits.Add(hit.transform.parent.gameObject.GetComponent <UnitInfo>()); } } } } if (i > 0 && j > 0) { if (Physics.Raycast(new Vector3(position.x - i, 10, position.z - j), new Vector3(0, -1, 0), out hit)) { if (hit.transform.gameObject.tag == "Unit") { if (CheckTarget(unit, hit.transform.parent.gameObject.GetComponent <UnitInfo>(), targ)) { hits.Add(hit.transform.parent.gameObject.GetComponent <UnitInfo>()); } } } } } } return(hits); }
public bool Matches(UnitInfo unitInfo) => unitInfo.Token == SpecialToken.InjectValue && unitInfo.Id is ParameterInfo;
private bool CanReach(UnitInfo unit, int range, int radius, string target) { List <string> status = new List <string>(); status.Add(unit.faction); status.AddRange(unit.status.Keys); moveCalc.MoveFinder(unit.move, unit.gameObject, status); List <GameObject> positions = new List <GameObject>(); positions.AddRange(moveCalc.selectedTiles); positions.Add(unit.currentTile); moveCalc.HighlightClear(); string[] targVals = target.Split(new char[] { ' ' }); List <string> cond = new List <string>(); cond.Add("noTerrain"); cond.Add("noElevation"); cond.Add(unit.faction); value = 0; foreach (GameObject tile in positions) { if (radius == 0) { List <UnitInfo> possible = moveCalc.BlastTargetFinder(range, tile); if (unit.faction == "enemy" && target == "enemy") { foreach (UnitInfo posTar in possible) { if (posTar.faction != "enemy") { moveTile = tile; targetUnit = posTar; return(true); } } } if (unit.faction == "enemy" && target == "ally") { foreach (UnitInfo posTar in possible) { if (posTar.faction == "enemy") { moveTile = tile; targetUnit = posTar; return(true); } } } } else { moveCalc.MoveFinder(range, tile, cond); List <GameObject> centers = new List <GameObject>(); centers.AddRange(moveCalc.selectedTiles); moveCalc.HighlightClear(); foreach (GameObject center in centers) { List <UnitInfo> hits = moveCalc.BlastTargetFinder(radius, center); int i = 0; foreach (UnitInfo hit in hits) { if (unit.faction == "enemy" && targVals[0] == "enemies" && hit.faction != "enemy") { i++; } else if (unit.faction == "enemy" && targVals[0] == "allies" && hit.faction == "enemy") { i++; } } if (targVals.Length > 1) { foreach (UnitInfo hit in hits) { if (unit.faction == "enemy" && targVals[1] == "enemies" && hit.faction != "enemy") { i--; } else if (unit.faction == "enemy" && targVals[1] == "allies" && hit.faction == "enemy") { i--; } } } if (i > value) { value = i; moveTile = tile; targetCenter = center; allTargets.Clear(); allTargets.AddRange(hits); moveCalc.MoveFinder(radius, center, cond); listTiles = new List <GameObject>(); listTiles.AddRange(moveCalc.selectedTiles); moveCalc.HighlightClear(); } } if (value > 0) { return(true); } } } return(false); }
public PlayerTurn(UnitInfo units, PlayerID player) : base("Player turn") { mMyUnits = units; mPlayerID = player; }
public IEnumerator TakeAction(UnitInfo unit) { bool actionTaken = false; //if (unit.faction == "enemy") //{ string actionName = ""; List <string> actionNames = unit.actionNames; for (int i = 0; i < unit.actionNames.Count; i++) { actionName = actionNames[0]; UnitInfo.Action thisAction = actDesc.actions[actionName]; if (thisAction.target == "self") { MoveClosestEnemy(unit); yield return(new WaitForSeconds(2.0f)); List <UnitInfo> self = new List <UnitInfo>(); self.Add(unit); List <GameObject> selfTile = new List <GameObject>(); selfTile.Add(unit.currentTile); yield return(actHand.ActionInterpreter(unit, actionNames[0], self, selfTile)); turnHistory.AddMessage(unit.name + " used " + actionName); actionTaken = true; break; } if (thisAction.target == "enemy") { if (CanReach(unit, thisAction.range, thisAction.rad, "enemy")) { List <UnitInfo> targ = new List <UnitInfo>(); targ.Add(targetUnit); List <GameObject> tile = new List <GameObject>(); tile.Add(targetUnit.currentTile); cubeClick.MoveToTile(moveTile, unit.gameObject); yield return(new WaitForSeconds(2.0f)); turnHistory.AddMessage(unit.name + " used " + actionName + " on " + targetUnit.name); yield return(actHand.ActionInterpreter(unit, actionName, targ, tile)); actionTaken = true; break; } } if (thisAction.target == "ally") { if (CanReach(unit, thisAction.range, thisAction.rad, "ally")) { List <UnitInfo> targ = new List <UnitInfo>(); targ.Add(targetUnit); List <GameObject> tile = new List <GameObject>(); tile.Add(targetUnit.currentTile); cubeClick.MoveToTile(moveTile, unit.gameObject); yield return(new WaitForSeconds(2.0f)); yield return(actHand.ActionInterpreter(unit, actionName, targ, tile)); actionTaken = true; break; } } else { if (CanReach(unit, thisAction.range, thisAction.rad, thisAction.target)) { List <GameObject> tile = listTiles; foreach (UnitInfo targ in allTargets) { turnHistory.AddMessage(unit.name + " uses " + thisAction.name + " on " + targ.name); tile.Add(targ.currentTile); } cubeClick.MoveToTile(moveTile, unit.gameObject); yield return(new WaitForSeconds(2.0f)); yield return(actHand.ActionInterpreter(unit, actionName, allTargets, tile)); actionTaken = true; break; } } actionNames.Remove(actionName); actionNames.Add(actionName); } if (actionTaken == true) { actionNames.Remove(actionName); actionNames.Add(actionName); unit.actionNames = actionNames; } else { turnHistory.AddMessage(unit.name + " moves"); MoveClosestEnemy(unit); yield return(new WaitForSeconds(2.0f)); } // } }
UnitInfo[] GetClosestUnits( Hashtable UnitDefListByDeployedId, Float3 targetpos, int numclosestunits ) { UnitInfo[] closestunits = new UnitInfo[ numclosestunits ]; double worsttopfivesquareddistance = 0; // got to get better than this to enter the list int numclosestunitsfound = 0; foreach( DictionaryEntry de in UnitDefListByDeployedId ) { int deployedid = (int)de.Key; IUnitDef unitdef = de.Value as IUnitDef; Float3 unitpos = aicallback.GetUnitPos( deployedid ); double unitsquareddistance = Float3Helper.GetSquaredDistance( unitpos, targetpos ); if( numclosestunitsfound < numclosestunits ) { UnitInfo unitinfo = new UnitInfo( deployedid, unitpos, unitdef, unitsquareddistance ); InsertIntoArray( closestunits, unitinfo, numclosestunitsfound ); numclosestunitsfound++; worsttopfivesquareddistance = closestunits[ numclosestunitsfound - 1 ].squareddistance; } else if( unitsquareddistance < worsttopfivesquareddistance ) { UnitInfo unitinfo = new UnitInfo( deployedid, unitpos, unitdef, unitsquareddistance ); InsertIntoArray( closestunits, unitinfo, numclosestunits ); worsttopfivesquareddistance = closestunits[ numclosestunits - 1 ].squareddistance; } } return closestunits; }
public static Units CreateMonsterByUnitInfo(UnitInfo info) { Units result; try { if (info == null) { ClientLogger.Error("CreateMonsterByUnitInfo: info is null"); result = null; } else if (MapManager.Instance == null) { ClientLogger.Error("MapManager.Instance is null"); result = null; } else if (GlobalSettings.TestCreep) { Singleton <CreepSpawner> .Instance.CreateCreeps(new List <string> { "101" }, info.unitId); result = null; } else if (GlobalSettings.NoMonster) { ClientLogger.Warn("P2C_CreateUnits create monster ignored"); result = null; } else if (info.unitType == UnitType.EyeItem) { result = PvpProtocolTools.CreateEyeItemByUnitInfo(info); } else { TeamType teamType = PvpProtocolTools.GroupToTeam((int)info.group); int num = -1; Transform transform = null; if (StringUtils.CheckValid(info.burnValue)) { string[] stringValue = StringUtils.GetStringValue(info.burnValue, '|'); UnitType unitType = info.unitType; if (unitType != UnitType.Monster) { if (unitType != UnitType.Soldier) { ClientLogger.Error("cannot be here"); } else { num = int.Parse(stringValue[2]); } } else { num = int.Parse(stringValue[1]); transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, num); } if (num < 0) { ClientLogger.Error("burnValue is invalid, use position #" + info.typeId + " " + info.burnValue); } } else if (info.unitType == UnitType.EyeUnit) { transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else if (info.unitType == UnitType.SummonMonster || info.unitType == UnitType.BoxUnit) { transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else if (info.unitType == UnitType.Pet) { transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else if (info.unitType == UnitType.LabisiUnit) { transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else { ClientLogger.Error(string.Concat(new object[] { "burnValue is invalid, use default position #", info.typeId, " utype:", info.unitType })); } Units unit = MapManager.Instance.GetUnit(info.mainHeroId); int skin = 0; if (unit != null && info.unitType == UnitType.SummonMonster) { skin = HeroSkins.GetRealHeroSkin((TeamType)unit.teamType, unit.model_id); } EntityVo npcinfo = new EntityVo(EntityType.Monster, info.typeId, num, 0, string.Empty, "Default", 0) { uid = info.unitId, skin = skin }; if (null == GameManager.Instance) { Debug.LogError("null == GameManager.Instance"); result = null; } else if (GameManager.Instance.Spawner == null) { Debug.LogError("null == GameManager.Instance.Spawner"); result = null; } else { SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility(); Units units = spawnUtility.SpawnInstance(npcinfo, "Monster", teamType, num, "[]", transform, UnitControlType.None, info.unitType); if (units == null) { ClientLogger.Error(string.Concat(new object[] { "P2C_CreateUnits create monster failed, creepId=", info.creepId, " typeid= ", info.typeId, " burnValue=", info.burnValue ?? "null" })); result = null; } else { if (units.UnitType == UnitType.EyeUnit) { } if (unit != null) { units.ParentUnit = unit; } if (units.UnitType == UnitType.EyeUnit || units.UnitType == UnitType.SummonMonster) { units.m_fLiveTime = info.liveTime; units.m_fLeftTime = info.liveTime; } units.SetOrigin(true, info.creepId.ToString(), info.monsterTeamId); units.TryAddBirthEffect(); units.SetIsMonsterCreep(info.unitType == UnitType.Monster || info.unitType == UnitType.CreepBoss); PvpProtocolTools.SyncUnitLifeStateAndSkill(units, info, 0L); if (units.isMonster && units.skillManager != null) { units.skillManager.EnableSkills(true); } if (units != null && transform != null) { units.SetPosition(transform.position, true); } result = units; } } } } catch (Exception e) { ClientLogger.LogException(e); result = null; } return(result); }
void checkupX(int moveLeft, GameObject current, ICollection <string> status) { Vector3 position = current.transform.position; RaycastHit hit; int newMove = moveLeft - 1; if (Physics.Raycast(new Vector3(position.x + 1, 10, position.z), new Vector3(0, -1, 0), out hit)) { int height = (int)(10.0 - hit.distance); string terrain = hit.transform.gameObject.tag; if (terrain == "Unit") { UnitInfo unIf = hit.transform.parent.GetComponent <UnitInfo>(); if (!status.Contains(unIf.faction)) { return; } else { terrain = unIf.currentTile.tag; newMove -= checkCost(terrain, (int)(unIf.currentTile.transform.position.y - position.y), status); if (newMove > 0) { checkupX(newMove, unIf.currentTile, status); checkupZ(newMove, unIf.currentTile, status); checkdownZ(newMove, unIf.currentTile, status); } } } int eleDiff = (int)(height - position.y); newMove -= checkCost(terrain, eleDiff, status); if (newMove > -1) { GameObject nextTile = hit.transform.gameObject; Material[] mats = nextTile.GetComponent <Renderer>().materials; mats[1] = highlight; nextTile.GetComponent <Renderer>().materials = mats; selectedTiles.Add(nextTile); if (newMove > 0) { checkupX(newMove, nextTile, status); checkupZ(newMove, nextTile, status); checkdownZ(newMove, nextTile, status); } } } return; }
protected virtual void Start() { unitInfo = transform.GetComponentInParent <UnitInfo>(); actionComponent = unitInfo.transform.GetComponent <ActionComponent>(); animator = unitInfo.transform.GetComponent <Animator>(); }