void OnDestroy() { view.OnCompleteMove -= Move; view.OnCollisionDetected -= CollisionDetected; model = null; }
public static UnitModel MapUnit(string[] _unitJsonCell) { string[] unitJsonCell = _unitJsonCell; UnitModel unit = new UnitModel(); unit.name = unitJsonCell[0]; if (unitJsonCell.Length > 1 && unitJsonCell[1] != null) { unit.status = unitJsonCell[1]; } return unit; }
public void AddUnit(UnitModel unit) { if (unit.UnitId == UnitDefId.Pacman) { pacman = unit; ((PacmanModel)unit).PacmanInBonusPoint += CollectBonus; } else { enemies.Add(unit); ((EnemyModel)unit).OnEnemyCatched += EnemyCatched; } }
public override void OnModelInitialized() { base.OnModelInitialized(); unitModel = model as UnitModel; transform.localPosition = unitModel.TransformBehaviour.Position; graphic = Object.Instantiate(unitModel.Data.prefab); graphic.transform.SetParent(transform, false); structure = graphic.GetComponent<UnitGameObjectStructure>(); unitModel.SelectableBehaviour.IsSelected.ValueChanged += (_) => { structure.selectionGO.SetActive(unitModel.SelectableBehaviour.IsSelected.Value); }; }
public IUnit CreateUnit(Vector3 position, UnitTypes type, UnitData data, bool isDefender) { IUnit unit; if (type == UnitTypes.HERO) { unit = new HeroModel(); } else { unit = new UnitModel(); } InjectionBinder.injector.Inject(unit); unit.Spawn(position, data, type, isDefender); unit.InitializeStates(); unit.StartAct(); return unit; }
private void OnModelDeath(UnitModel model) { _army.Remove(model); }
public ImpossibleMovePredictionException(UnitModel unit, MyHexPosition targetPosition, List <MyHexPosition> possibleTargets) : base($"Cannot move unit {unit} to position {targetPosition}. Only possible moves are {possibleTargets.Select(c => c.ToString()).Aggregate((acc, c) => acc+","+c)}") { }
/// <summary> /// 主汽流量 /// </summary> /// <returns></returns> public double Flow(string key) { UnitModel um = new UnitModel(key); return(um.Flow); }
/// <summary> /// 机组历史负荷 /// </summary> /// <returns></returns> public double HisPower(string key) { UnitModel um = new UnitModel(key); return(um.HisPower); }
internal void SetModel( UnitModel unitModel ) { model = Instantiate( unitModel, transform.position, transform.rotation ) as UnitModel; if( model == null ) { throw new UnityException( "model is NULL, yo" ); } model.transform.parent = transform; model.Init( this ); }
public void SetUnitModel(UnitModel model) { this.model = model; SetMaterial(); }
public void DeleteUnitModel(UnitModel model) { _unitRepository.Delete(model); _unitRepository.Save(); }
private void InitTable(DataTable _dtPoints) { //drPoits = _dtPoints.Select("T_UNITID<>'0'"); //string[] _strUnit = new string[drPoits.Length]; //string[] _strPoints = new string[drPoits.Length * (_dtPoints.Columns.Count - 3)]; //int j = 0; //for (int i = 0; i < drPoits.Length; i++) //{ // _strUnit[i] = drPoits[i][1].ToString(); // for (int k = 2; k < _dtPoints.Columns.Count - 1; k++) // { // _strPoints[j] = drPoits[i][k].ToString(); // j++; // } //} //double[] _val = new double[_strPoints.Length]; //_val = bllPoint.GetPointVal(_strPoints); //sbl.Append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#cccccc\">"); //sbl.Append("<tr class=\"td1\">"); //sbl.Append("<td>机组</td>"); //sbl.Append("<td>运行状态</td>"); //sbl.Append("<td>机组负荷</td>"); //sbl.Append("<td>主汽流量</td>"); //sbl.Append("<td>主汽压力</td>"); //sbl.Append("<td>主汽温度</td>"); //sbl.Append("<td>再热温度</td>"); //sbl.Append("<td>真空</td>"); //sbl.Append("<td>锅炉效率</td>"); //sbl.Append("<td>热耗</td>"); //sbl.Append("<td>煤耗</td>"); //sbl.Append("</tr>"); //for (int i = 0; i < _strUnit.Length; i++) //{ // if (i % 2 == 0) // sbl.Append("<tr class=\"td2\">"); // else // sbl.Append("<tr class=\"td3\">"); // sbl.Append("<td>" + _strUnit[i] + "</td>"); // for (int k = -1; k < _dtPoints.Columns.Count - 3; k++) // { // if (k == -1) // if (_val[(k + 1) + (k + 1) * i] < 5) // sbl.Append("<td>停机</td>"); // else // sbl.Append("<td>运行</td>"); // else // if (_val[k + (dtPoints.Columns.Count - 3) * i] == -1000000) // sbl.Append("<td style='color: red;'>bad</td>"); // else // sbl.Append("<td>" + _val[k + (dtPoints.Columns.Count - 3) * i] + "</td>"); // } // sbl.Append("</tr>"); //} //sbl.Append("</table>"); drPoits = _dtPoints.Select("T_UNITID<>'0'"); string[] _strUnit = new string[drPoits.Length]; string[] _strPoints = new string[drPoits.Length * (_dtPoints.Columns.Count - 3)]; for (int i = 0; i < drPoits.Length; i++) { _strUnit[i] = drPoits[i][1].ToString(); } sbl.Append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#cccccc\">"); sbl.Append("<tr class=\"td1\">"); sbl.Append("<td>机组</td>"); sbl.Append("<td>运行状态</td>"); sbl.Append("<td>机组负荷</td>"); sbl.Append("<td>主汽流量</td>"); sbl.Append("<td>主汽压力</td>"); sbl.Append("<td>主汽温度</td>"); sbl.Append("<td>再热温度</td>"); sbl.Append("<td>真空</td>"); sbl.Append("<td>锅炉效率</td>"); sbl.Append("<td>热耗</td>"); sbl.Append("<td>煤耗</td>"); sbl.Append("</tr>"); double[] _vals = new double[36]; for (int i = 1; i <= drPoits.Length; i++) { UnitModel unit = new UnitModel(drPoits[i - 1][1].ToString()); double[] v = unit.Val; for (int k = 0; k < 9; k++) { _vals[(i - 1) * 9 + k] = v[k]; } //_vals[(i - 1) * 9 + 0] = unit.Power; //_vals[(i - 1) * 9 + 1] = unit.Flow; //_vals[(i - 1) * 9 + 2] = unit.Pressure; //_vals[(i - 1) * 9 + 3] = unit.Temperature; //_vals[(i - 1) * 9 + 4] = unit.ReheatTemperature; //_vals[(i - 1) * 9 + 5] = unit.Vacuum; //_vals[(i - 1) * 9 + 6] = unit.Efficiency; //_vals[(i - 1) * 9 + 7] = unit.Heatconsumption; //_vals[(i - 1) * 9 + 8] = unit.Coalconsumption; } for (int i = 0; i < _strUnit.Length; i++) { if (i % 2 == 0) { sbl.Append("<tr class=\"td2\">"); } else { sbl.Append("<tr class=\"td3\">"); } sbl.Append("<td>" + _strUnit[i] + "</td>"); for (int k = -1; k < _dtPoints.Columns.Count - 3; k++) { if (k == -1) { if (_vals[(k + 1) + (k + 1) * i] < 5) { sbl.Append("<td>停机</td>"); } else { sbl.Append("<td>运行</td>"); } } else if (_vals[k + 9 * i] == -1000000) { sbl.Append("<td style='color: red;'>bad</td>"); } else { sbl.Append("<td>" + _vals[k + 9 * i] + "</td>"); } } sbl.Append("</tr>"); } sbl.Append("</table>"); object _obj = new { tbl = sbl.ToString() }; string result = JsonConvert.SerializeObject(_obj); Response.Write(result); Response.End(); }
public UnitSellingPageModel(MasterData masters, UnitModel model) { _masters = masters; _model = model; }
/// <summary> /// 編集項目テキストボックスフォーカス移動後の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemTextBoxValidated(object sender, EventArgs e) { // 選択中の国家がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } Country country = Countries.Tags[countryListBox.SelectedIndex]; // 選択中のユニット名種類がなければ戻る UnitClass unit = typeListBox.SelectedItem as UnitClass; if (unit == null) { return; } TextBox textBox = sender as TextBox; if (textBox == null) { return; } int index = (int)textBox.Tag; if (unit.ExistsModelName(index, country)) { // 値に変化がなければ何もしない if (textBox.Text.Equals(unit.GetCountryModelName(index, country))) { return; } if (string.IsNullOrEmpty(textBox.Text)) { // 変更後の文字列が空ならば国別のモデル名を削除する unit.RemoveModelName(index, country); } else { // 値を更新する unit.SetModelName(index, country, textBox.Text); } } else { // 値に変化がなければ何もしない if (string.IsNullOrEmpty(textBox.Text)) { return; } // 値を更新する unit.SetModelName(index, country, textBox.Text); } // 編集済みフラグを設定する UnitModel model = unit.Models[index]; model.SetDirtyName(country); Units.SetDirtyModelName(country, unit.Type); // 文字色を変更する textBox.ForeColor = Color.Red; // 編集済みフラグが更新されるため国家リストボックスの表示を更新する countryListBox.Refresh(); typeListBox.Refresh(); // ユニットモデル名の更新を通知する HoI2EditorController.OnItemChanged(EditorItemId.CountryModelName, this); }
public void Open(SkillAttribute attribute, UnitModel character) { Character = character; Open(attribute); }
private async Task DownloadAttachmentAsync(UnitModel unit, MoocRequest mooc, string unitPath, string unitFileName) { if (!_config.IsDownloadAttachment) { return; } const string attachmentBaseUrl = "https://www.icourse163.org/course/attachment.htm"; if (string.IsNullOrEmpty(unit.JsonContent)) { WriteLog($"附件 {unit.Name} 下载链接为空, 跳过下载."); return; } var content = JObject.Parse(unit.JsonContent); var nosKey = content["nosKey"]?.ToString(); var fileName = content["fileName"]?.ToString(); var attachmentUrl = $@"{attachmentBaseUrl}?fileName={fileName}&nosKey={nosKey}"; var downloadAttSuccess = false; var attachSavePath = Path.Combine(unitPath, $@"{unitFileName}-{FixPath(fileName)}"); if (File.Exists(attachSavePath)) // exist attachment, skip. { WriteLog($@"附件 {fileName} 已下载, 跳过."); return; } WriteLog($@"准备下载附件: {fileName}"); for (var i = 0; i < MAX_TIMES; i++) { try { var attachment = await mooc.DownloadAttachmentAsync(attachmentUrl); if (attachment is null) { WriteLog($"下载附件 {fileName} 失败, 准备重试, 当前重试第 {i + 1} 次."); await Task.Delay(TimeSpan.FromSeconds(Math.Pow(2, i))); } else { File.WriteAllBytes(attachSavePath, attachment); downloadAttSuccess = true; WriteLog($@"附件 {fileName} 已下载完成."); break; } } catch (Exception exception) { await Task.Delay(TimeSpan.FromSeconds(Math.Pow(2, i))); WriteLog($@"下载附件 {fileName} 发生错误, 原因: {exception.Message}, 准备重试, 当前重试第 {i + 1} 次."); } } if (!downloadAttSuccess) { WriteLog($"下载附件 {fileName} 失败, 已跳过."); } }
public static bool AddUpdateUnit(UnitModel unitConfig) { UnitModel unitModel = new UnitModel(); return(unitModel.AddUpdateUnitForAdmin(unitConfig)); }
public UnitMaterialManager( UnitModel unitModel ) { Init( unitModel ); }
public void AddUnitModel(UnitModel model) { _unitRepository.Add(model); _unitRepository.Save(); }
public FriendlyAnimalIdleState(UnitModel model, IAnimatorHelper animatorHelper) : base(model, animatorHelper) { }
public void UpdateUnitModel(UnitModel model) { _unitRepository.Edit(model); _unitRepository.Save(); }
/// <summary> /// 电量 /// </summary> /// <returns></returns> public double GetDL(string key, string st, string et) { UnitModel um = new UnitModel(key, st, et); return(um.Dl); }
/// <summary> /// 风速 /// </summary> /// <returns></returns> public double GetWind(string key) { UnitModel um = new UnitModel(key); return(um.Wind); }
/// <summary> /// 机组平均负荷 /// </summary> /// <returns></returns> public double PowerAvg(string key) { UnitModel um = new UnitModel(key); return(um.PowerAvg); }
public ActionResult BuyLot(int lotId) { using (var db = new BGS_DBContext()) { var id = User.Identity.GetUserId(); var lot = db.LotModels.Single(p => p.Id == lotId); User user = db.Users.Single(u => u.Id == id); if (user.AccountBalance - lot.Price > 0) { switch (lot.Type) { default: throw new Exception("No this lot"); case LotType.Unit: UnitModel unitModel = db.UnitModels.Single(u => u.LotId == lotId); unitModel.LotId = null; unitModel.Owner = user; break; case LotType.Armor: ArmorModel armorModel = db.ArmorModels.Single(u => u.LotId == lotId); armorModel.LotId = null; armorModel.Owner = user; break; case LotType.Accessory: AccessoryModel accessoryModel = db.AccessoryModels.Single(u => u.LotId == lotId); accessoryModel.LotId = null; accessoryModel.Owner = user; break; case LotType.Weapon: WeaponModel weaponModel = db.WeaponModels.Single(u => u.LotId == lotId); weaponModel.LotId = null; weaponModel.Owner = user; break; case LotType.Storage: StorageModel storageModel = db.StorageModels.Single(u => u.LotId == lotId); storageModel.LotId = null; storageModel.Owner = user; break; case LotType.Modification: AimModificationModel aim = db.AimModificationModels.SingleOrDefault(a => a.LotId == lot.Id); MagazineModificationModel magazine = db.MagazineModificationModels.SingleOrDefault(a => a.LotId == lot.Id); BarrelModificationModel barrel = db.BarrelModificationModels.SingleOrDefault(a => a.LotId == lot.Id); ButtModificationModel butt = db.ButtModificationModels.SingleOrDefault(a => a.LotId == lot.Id); if (aim != null) { aim.LotId = null; aim.Owner = user; } if (magazine != null) { magazine.LotId = null; magazine.Owner = user; } if (barrel != null) { barrel.LotId = null; barrel.Owner = user; } if (butt != null) { butt.LotId = null; butt.Owner = user; } break; } lot.Status = LotStatus.Closed; lot.BuyerId = user.GameId; user.AccountBalance -= lot.Price; lot.Seller.AccountBalance += lot.Price; db.SaveChanges(); return(RedirectToAction("Index", "Market", new { buy = $"Лот #{lot.Id} успешно куплен за {lot.Price}$4" })); } else { return(RedirectToAction("Index", "Market", new { error = "У вас не хватает средств для этой покупки" })); } } }
/// <summary> /// 主汽压力 /// </summary> /// <returns></returns> public double Pressure(string key) { UnitModel um = new UnitModel(key); return(um.Pressure); }
public void RemoveAllUnits() { RemoveListeners(); enemies.Clear(); pacman = null; }
public bool IsPositionMovable(UnitModel unit, MyHexPosition position) { var possibleTargets = GameCourseController.GetPossibleMoveTargets(unit, null); return(possibleTargets.Any(c => c.Equals(position))); }
public void DespawnUnit(UnitModel unitModel) { _worldModel.Units.Remove(unitModel); }
private void OnAttacked(UnitModel unitModel, IAttacker attacker) { unitModel.ApplyDamage(attacker.Damage); }
public UnitIdleState(UnitModel model, IAnimatorHelper animatorHelper) : base(model, animatorHelper) { }
/// <summary> /// Updates the unit entity instance with the values of the unit DTO instance. /// </summary> /// <param name="entity">The database entity instance of the unit.</param> /// <param name="dto">The DTO instance of the unit.</param> protected virtual void UpdateEntityValues(UnitModel entity, IUnit dto) { entity.Description = dto.Description; }
public static List <UnitModel> GetAllUnits() { UnitModel unitModel = new UnitModel(); return(unitModel.GetAllUnits()); }
private void RemoveUnit(UnitModel unit) { var team = Teams.Find(entry => entry.Units.Contains(unit)); team?.RemoveUnit(unit); }
public ReviveCommand(UnitModel unit, TickService tick) { //takes in this unit _tick = tick; _unit = unit; }
public int Unit_Update(UnitModel model) { return unitbll.Unit_Update(model); }
/// <summary> /// 再热温度 /// </summary> /// <returns></returns> public double ReheatTemperature(string key) { UnitModel um = new UnitModel(key); return(um.ReheatTemperature); }
public void Init( UnitModel model ) { renderer = model.meshRenderer; SetMode( UnitMaterialMode.Normal ); }
/// <summary> /// 真空 /// </summary> /// <returns></returns> public double Vacuum(string key) { UnitModel um = new UnitModel(key); return(um.Vacuum); }
/// <summary> /// 锅炉效率 /// </summary> /// <returns></returns> public double Efficiency(string key) { UnitModel um = new UnitModel(key); return(um.Efficiency); }
/// <summary> /// 煤耗 /// </summary> /// <returns></returns> public double Coalconsumption(string key) { UnitModel um = new UnitModel(key); return(um.Coalconsumption); }
public override void Start(UnitModel unit) { base.Start(unit); RunState<UnitMoveState>(); }
/// <summary> /// 获取机组负荷、主汽流量、主汽压力、主汽温度、再热温度、真空、锅炉效率、热耗、煤耗的最新值 /// </summary> /// <returns></returns> public double[] Val(string key) { UnitModel um = new UnitModel(key); return(um.Val); }
public override void Start(UnitModel unit) { base.Start(unit); RunState<FriendlyAnimalIdleState>(); }
public UnitViewModel() { UnitModel = new UnitModel(); }