public async Task <ActionResult> CreateUnit(IFormCollection collection) { BUnit bUnit = new BUnit(); bUnit.gameid = collection["gameid"]; bUnit.dateadded = DateTime.Now.ToString(); bUnit.loaned = "false"; bUnit.description = collection["description"]; bUnit.barcode = collection["barcode"]; var jdata = JsonConvert.SerializeObject(bUnit); var httpContent = new StringContent(jdata, Encoding.UTF8, "application/json"); Console.WriteLine("---- PostAsync ------"); var httpResponse = await _service.Client.PostAsync($"/api/BUnit/", httpContent); Console.WriteLine("---- PostAsync END------"); Console.WriteLine(httpResponse); try { return(RedirectToAction(nameof(Details), new { id = bUnit.gameid })); } catch { return(View()); } }
public async Task <ActionResult> DeleteUnit(string id, IFormCollection collection) { BUnit unit = new BUnit(); unit.oid = collection["oid"]; unit.gameid = collection["gameid"]; unit.dateadded = collection["dateadded"]; unit.loaned = collection["loaned"]; unit.dateofrent = collection["dateofrent"]; unit.barcode = collection["barcode"]; unit.description = collection["description"]; var jdata = JsonConvert.SerializeObject(unit); var httpContent = new StringContent(jdata, Encoding.UTF8, "application/json"); Console.WriteLine("---- PutAsync ------"); var httpResponse = await _service.Client.DeleteAsync($"/api/BUnit/{id}"); Console.WriteLine("---- PutAsync END------"); Console.WriteLine(httpResponse); try { return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ContentResult Update() { ResultData <string> rt = new ResultData <string>(); BUnit u = GetUpdate <BUnit>(); //非空验证和属性格式验证 string msg = uService.CheckEmpty(u); if (!string.IsNullOrEmpty(msg)) { rt.message = msg; rt.status = -1; return(ReturnResult(rt)); } //验证用户是否存在 if (uService.IsNotExits(u, false)) { u.UpdateDate = DateTime.Now; u.UpdateBy = this.CurrentUser.ID; uService.UpdateUnit(u); } else { rt.status = -1; rt.message = "单位编码已经存在."; } return(ReturnResult(rt)); }
public void Init(BUnit parent) { this.parent = parent; // change color of life bar depending on team if (parent.unit.team == Unit.Team.PLAYER) { UISprite sprite = (UISprite)lifebar.foregroundWidget; sprite.color = playerColor; //lifebar.foreground.GetComponent<UISprite>().color = playerColor; } else { lifebar.foregroundWidget.color = aiColor; //lifebar.foreground.GetComponent<UISprite>().color = aiColor; } // set name label nameLabel.text = parent.unit.UnitName; typeSprite.spriteName = parent.unit.Element.elementName; // init lifebar currentHealth = parent.unit.MaxHealthPoints; lifebar.value = currentHealth / (float)parent.unit.MaxHealthPoints; healthLabel.text = currentHealth + "/" + parent.unit.MaxHealthPoints; initalized = true; }
private void txtUnitCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtUnitCode.Text.Trim())) { BaseUnitTable Unit = new BaseUnitTable(); BUnit bUnit = new BUnit(); Unit = bUnit.GetModel(this.txtUnitCode.Text); if (Unit == null || "".Equals(Unit)) { txtUnitCode.Focus(); txtUnitCode.Text = ""; txtUnitName.Text = ""; MessageBox.Show("单位编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtUnitCode.Text = Unit.CODE; txtUnitName.Text = Unit.NAME; } } else { txtUnitName.Text = ""; } }
/// <summary> /// 插入记录 /// </summary> /// <param name="unit"></param> /// <returns></returns> public int AddUnit(BUnit unit) { //添加单位 添加扩展 object parentId = uRepository.Insert(unit); return(Convert.ToInt32(parentId)); }
void HandleTurnStarted(object sender, EventArgs args) { TurnStartedEvent e = args as TurnStartedEvent; BUnit bUnit = GetBUnit(e.unit); EventProxyManager.FireEvent(this, new EventDoneEvent()); }
void HandleUnitDied(object sender, EventArgs args) { UnitDiedEvent e = args as UnitDiedEvent; BUnit bUnit = GetBUnit(e.unit); bCameraMover.Focus(bUnit.transform.position); bUnit.Died(); }
void HandleUnitLoseHealth(object sender, EventProxyArgs eventArgs) { UnitLoseHealthEvent e = eventArgs as UnitLoseHealthEvent; BUnit bUnit = GetBUnit(e.unit); bUnit.unitUI.UpdateLifebar(e.damage); EventProxyManager.FireEvent(this, new EventDoneEvent()); }
// GET: BGamesController/Create public ActionResult CreateUnit() { BUnit bUnit = new BUnit(); bUnit.gameid = gameid; return(View(bUnit)); }
public void OpenForBUnit(BUnit bUnit) { HideAttackinfo(); this.bUnit = bUnit; if (bUnit.unit.AIControled) { // if a AI-unit is active, don't show the menu circleAnchor.SetActive(false); backButton.gameObject.SetActive(false); followUnit = false; } else { // the player controls this unit followUnit = true; if (bUnit.unit.CanAttack) { circleAnchor.SetActive(true); cancelButton.gameObject.SetActive(true); } //lockedAttack.gameObject.SetActive(true); locked.gameObject.SetActiveRecursively(true); endTurnButton.gameObject.SetActive(true); backButton.gameObject.SetActive(false); // clear attack ring ui List <GameObject> circleButtons = new List <GameObject>(); foreach (Transform child in circleAnchor.transform) { circleButtons.Add(child.gameObject); } foreach (GameObject child in circleButtons) { Destroy(child); } circleButtons.Clear(); // init attack buttons foreach (Attack atk in bUnit.unit.AttacksArray) { GameObject handle = (GameObject)Instantiate(attackButtonPrefab); handle.transform.parent = circleAnchor.transform; handle.GetComponent <BAttackButton>().Init(atk, this); circleButtons.Add(handle); } //circleButtons.Add(lockedAttack.gameObject); locked.gameObject.SetActiveRecursively(true); circleButtons.Add(endTurnButton.gameObject); // arrange buttons RepositionButtons(circleButtons); } }
public ContentResult Delete() { ResultData <string> rt = new ResultData <string>(); //获取前台传会的删除ID BUnit unit = GetDelete <BUnit>(); uService.RemoveUnit(unit); rt.message = "删除成功."; return(ReturnResult(rt)); }
void OnTap() { // we clicked with mouse or tapped on the touchscreen // cast an ray from the screen point Ray cursorRay = Camera.main.ScreenPointToRay(Input.mousePosition); // create layer mask to ignore layer "Ignore Raycast" and hit all others int mask = 1 << LayerMask.NameToLayer("Ignore Raycast"); mask = ~mask; BMapTile bMapTile = null; RaycastHit[] hits = Physics.RaycastAll(cursorRay, Mathf.Infinity, mask); // this does not work since buttons will be Deactivate just as we cast the ray // so we don't hit them anymore :( if (CheckUIHit()) { return; } // check all objects hit on raycast foreach (RaycastHit hit in hits) { // let's see what we hit with the raycast switch (hit.collider.gameObject.layer) { case UI_LAYER: // we hit an ui element first // stop looking for map and stuff and just return Debug.LogWarning("Hit UI! Stop here"); return; case UNIT_LAYER: // find the quad the unit is standing on BUnit bUnit = hit.collider.GetComponent <BUnit>(); // fire event for the tapped bUnit tapFieldSound.Play(); EventProxyManager.FireEvent(this, new BUnitTappedEvent(bUnit)); break; case GRID_LAYER: // we hit an quad of the map bMapTile = hit.collider.GetComponent <BMapTile>(); // fire event for the tapped mapTile tapFieldSound.Play(); EventProxyManager.FireEvent(this, new BMapTileTappedEvent(bMapTile)); break; } } }
// GET: BGamesController/DeleteUnit/5 public async Task <ActionResult> DeleteUnit(string id) { BUnit bunit = new BUnit(); var response = await _service.Client.GetAsync($"/api/bunit/{id}"); if (response.IsSuccessStatusCode) { var dane = response.Content.ReadAsStringAsync().Result; bunit = JsonConvert.DeserializeObject <BUnit>(dane); } return(View(bunit)); }
IEnumerator NotifyRoutine(BUnit bUnit) { if (bUnit.unit.team == Unit.Team.PLAYER) { bNotification.Display("Dein " + bUnit.unit.UnitName + " ist am Zug"); } else { bNotification.Display("Gegnerische " + bUnit.unit.UnitName + " ist am Zug"); } yield return(new WaitForSeconds(2f)); EventProxyManager.FireEvent(this, new EventDoneEvent()); }
void HandleUnitActivated(object sender, EventArgs args) { UnitActivatedEvent e = args as UnitActivatedEvent; activeBUnit = GetBUnit(e.unit); // place marker for active unit unitMarker.transform.parent = activeBUnit.transform; unitMarker.transform.localPosition = new Vector3(0, 0.01f, 0); bInitativeList.ActivateIcon(e.unit); bCameraMover.Focus(activeBUnit.gameObject.transform.position); activeBUnit.Activate(); bCombatMenu.ShowTurnStart(activeBUnit); }
void HandleUnitAttacked(object sender, EventArgs args) { UnitAttackedEvent e = args as UnitAttackedEvent; BUnit[] bUnits = new BUnit[e.victims.Count]; for (int i = 0; i < e.victims.Count; i++) { bUnits[i] = GetBUnit(e.victims[i]); } BMapTile bMapTile = GetBMapTile(e.target); GetBUnit(e.source).PlayAttack(e, bMapTile, bUnits); CleanMap(); }
/// <summary> /// Instatiate and initialize BUnit which is the view representation of an Unit /// </summary> /// <param name="unit">The Unit we create an representation for</param> void SpawnBUnit(Unit unit) { Debug.Log("Spawning: Character/" + unit.UnitName); GameObject prefab = Resources.Load <GameObject>("Character/" + unit.UnitName); GameObject go = (GameObject)Instantiate(prefab); // positioning go.transform.position = GetBMapTile(unit.mapTile).transform.position; // set references BUnit bUnit = go.GetComponent <BUnit>(); bUnit.Init(this, unit, bCombatMenu); // add to list bUnits.Add(bUnit); }
public void Init(Unit unit, BUnit bUnit) { this.parent = bUnit; if (unit.team == Unit.Team.PLAYER) { meshContainer.transform.rotation = Quaternion.AngleAxis(90f, Vector3.up); } else { meshContainer.transform.rotation = Quaternion.AngleAxis(-90f, Vector3.up); } flashColor = Color.red; }
/// <summary> /// 检查非空验证 /// </summary> /// <param name="user"></param> public string CheckEmpty(BUnit unit) { string msg = string.Empty; if (string.IsNullOrWhiteSpace(unit.UnitCode)) { msg = "单位编码不能为空."; return(msg); } if (string.IsNullOrWhiteSpace(unit.UnitName)) { msg = "单位名称不能为空."; return(msg); } return(msg); }
public IActionResult Update(string id, BUnit bunitIn) { var gdata = Newtonsoft.Json.JsonConvert.SerializeObject(bunitIn); Console.WriteLine(gdata); var bunit = _bunitService.Get(id); if (bunit == null) { return(NotFound()); } _bunitService.Update(id, bunitIn); return(NoContent()); }
/// <summary> /// 单位编号存在CHECK /// </summary> protected string CheckUnit(string unitCode, string title) { if (unitCode == null || "".Equals(unitCode.ToString())) { return(title + ERROR_NULL); } if (_unitTable[unitCode.ToString()] != null) { return(""); } BUnit bUnit = new BUnit(); if (bUnit.Exists(unitCode)) { _unitTable.Add(unitCode, unitCode); return(""); } return(title + ERROR_EXIST); }
private void txtUnitCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtUnitCode.Text.Trim())) { BaseProductUnitTable ProductUnitCode = new BaseProductUnitTable(); ProductUnitCode = bProductUnit.GetModel(txtProductCode.Text, txtUnitCode.Text); if (ProductUnitCode != null) { txtProductCode.Text = ""; txtProductName.Text = ""; txtUnitCode.Text = ""; txtUnitName.Text = ""; txtProductCode.Focus(); MessageBox.Show("商品编号与单位编号组合已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } if (!string.IsNullOrEmpty(this.txtUnitCode.Text.Trim())) { BaseUnitTable Unit = new BaseUnitTable(); BUnit bUnit = new BUnit(); Unit = bUnit.GetModel(this.txtUnitCode.Text); if (Unit == null || "".Equals(Unit)) { txtUnitCode.Focus(); txtUnitCode.Text = ""; txtUnitName.Text = ""; MessageBox.Show("单位编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtUnitName.Text = Unit.NAME; } } }
public void Remove(BUnit bunitIn) => _bunit.DeleteOne(unit => unit.oid == bunitIn.oid);
public void Update(string id, BUnit unitIn) => _bunit.ReplaceOne(unit => unit.oid == id, unitIn);
public override string[] doUpdateDB() { BaseUnitTable UnitTable = null; BUnit bUnit = new BUnit(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE")))) { str.Append(CheckString(GetValue(dr, "CODE"), 20, "编号")); } else { str.Append("编号不能为空!"); } //名称 str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称")); //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { UnitTable = new BaseUnitTable(); UnitTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); UnitTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); UnitTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS)); UnitTable.CREATE_USER = _userInfo.CODE; UnitTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bUnit.Exists(UnitTable.CODE)) { bUnit.Add(UnitTable); } else { bUnit.Update(UnitTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }
/// <summary> /// 基准单位是否存在 /// </summary> /// <param name="unit"></param> /// <param name="isAdd"></param> public bool IsNotExits(BUnit unit, bool isAdd) { return(uRepository.IsNotExits(unit, isAdd)); }
/// <summary> /// 更新记录 /// </summary> /// <param name="unit"></param> /// <returns></returns> public bool UpdateUnit(BUnit unit) { return(uRepository.Update(unit)); }
public void ShowTurnStart(BUnit bUnit) { StartCoroutine(NotifyRoutine(bUnit)); }
/// <summary> /// 删除记录 /// </summary> /// <param name="unit"></param> /// <returns></returns> public bool RemoveUnit(BUnit unit) { return(uRepository.Delete(unit)); }