public override void ControllerUpdate() { foreach (var Unit in units) { Unit.Update(); } }
private bool FollowCheck() { if (Me.PartyleaderGuid != 0) { Unit activeUnit = null; foreach (WowObject p in AmeisenDataHolder.ActiveWoWObjects) { if (p.Guid == Me.PartyleaderGuid) { activeUnit = (Unit)p; } } Me.Update(); activeUnit?.Update(); if (activeUnit != null) { double distance = Utils.GetDistance(Me.pos, activeUnit.pos); if (AmeisenDataHolder.IsAllowedToFollowParty && distance > AmeisenDataHolder.Settings.followDistance) { StateMachine.PushAction(BotState.Follow); return(true); } else if (StateMachine.GetCurrentState() == BotState.Follow) { StateMachine.PopAction(BotState.Follow); return(false); } } } return(false); }
public void UnitUpdate() { Vector3 oldPosition = new Vector3(2, 0, 5); Unit unit = new Unit(100, ArmorType.Unarmored, 10, 15.0, oldPosition); unit.Movement.SetTarget(new Vector3(15, 0, 8)); unit.Update(1.2); Assert.AreNotEqual<Vector3>(oldPosition, unit.Position); }
public ActionResult Edit(Unit unit) { if (ModelState.IsValid) { unit.Update(); return(RedirectToAction("Index")); } return(View(unit)); }
public RememberUnitWindow(Unit unit) { InitializeComponent(); unit.Update(); UnitName = unit.Name; ZoneID = unit.ZoneID; MapID = unit.MapID; Position = unit.pos; }
private void btnPauseAutomatic_Click(object sender, EventArgs e) { Unit ls = Unit.GetUnit(MySelectedStation); if (ls != null) { ls.BlockForManualOrderUntil = DateTime.UtcNow.AddMinutes(Registry.ManuallyBlockMaxMinutes); // 20 min. ls.Update(); } }
private void UpdateUnit(ref bool _mWin, ref bool _oWin, ref Dictionary <int, LinkedList <int> > _clientAttackData) { LinkedList <Unit> .Enumerator enumerator = unitList.GetEnumerator(); while (enumerator.MoveNext()) { Unit unit = enumerator.Current; unit.Update(isClient, ref _clientAttackData); } LinkedListNode <Unit> node = unitList.First; while (node != null) { LinkedListNode <Unit> next = node.Next; Unit unit = node.Value; if (!unit.IsAlive()) { bool isBase = unit.Die(); if (isBase) { if (unit.isMine) { _oWin = true; } else { _mWin = true; } } unitList.Remove(node); unitDic.Remove(unit.uid); if (unit.sds.GetIsHero()) { Dictionary <int, Unit> tmpDic = unit.isMine ? mHeroPool : oHeroPool; tmpDic.Remove(unit.id); } } else { unit.CheckHpOverflow(); } node = next; } }
public ActionResult UnitDetail(FormCollection collection) { Unit u = new Unit(); u.UnitID = Convert.ToInt32(collection["UnitID"]); if (u.UnitID > 0) { u.SelectByID(); u.UnitID = Convert.ToInt32(collection["UnitID"]); u.UnitName = collection["UnitName"]; u.WingID = Convert.ToInt32(collection["WingID"]); u.UnitTypeID = Convert.ToInt32(collection["UnitTypeID"]); u.Status = (collection["Status"].ToString() == "True"? "Active" : "Inactive"); u.OwnerName = collection["OwnerName"]; if (Request.Files["DocumentPath"] != null) { string path = "/uploads/" + DateTime.Now.Ticks.ToString() + "_" + Request.Files["DocumentPath"].FileName; Request.Files["DocumentPath"].SaveAs(Server.MapPath(path)); u.DocumentPath = path; } else { u.DocumentPath = ""; } u.Mobile = collection["Mobile"]; u.Phone = collection["Phone"]; u.Update(); return(RedirectToAction("UnitSearch")); } else { string status = collection["Status"].ToString(); u.UnitName = collection["UnitName"]; u.WingID = Convert.ToInt32(collection["WingID"]); u.UnitTypeID = Convert.ToInt32(collection["UnitTypeID"]); u.Status = (status.Equals("True") ? "Active":"Inactive"); u.OwnerName = collection["OwnerName"]; if (Request.Files["DocumentPath"] != null) { string path = "/uploads/" + DateTime.Now.Ticks.ToString() + "_" + Request.Files["DocumentPath"].FileName; Request.Files["DocumentPath"].SaveAs(Server.MapPath(path)); u.DocumentPath = path; } else { u.DocumentPath = ""; } u.Mobile = collection["Mobile"]; u.Phone = collection["Phone"]; u.Insert(); return(RedirectToAction("UnitSearch")); } }
// Update is called once per frame void Update() { var commoand = InputHandler.Instance.HandleInput(); if (commoand != null) { commoand.Execute(); } unit.Update(); }
public static Unit TargetTargetToHeal(Me me, List <WowObject> activeWowObjects) { // Get the one with the lowest hp and target him/her List <Unit> units = PartymembersInCombat(me, activeWowObjects); if (units.Count > 0) { Unit u = units.OrderBy(o => o.HealthPercentage).ToList()[0]; u.Update(); AmeisenCore.TargetGUID(u.Guid); return(u); } return(null); }
public static void FaceTarget(Me me, Unit target) { if (target != null) { target.Update(); if (!Utils.IsFacing(me.pos, me.Rotation, target.pos)) { AmeisenCore.InteractWithGUID( target.pos, target.Guid, InteractionType.FACETARGET); } } }
private void HandleTimer(object sender, ElapsedEventArgs e) { try { global.Update(); if (Global.SelectedUnitCount > 0) { unit = global.SelectedUnitList[0] as Unit; unit.Update(); } } catch (Exception exception) { Message = exception.Message; } }
public static Unit AssistParty(Me me, List <WowObject> activeWowObjects) { // Get the one with the lowest hp and assist him/her List <Unit> units = PartymembersInCombat(me, activeWowObjects); if (units.Count > 0) { Unit u = units.OrderBy(o => o.HealthPercentage).ToList()[0]; u.Update(); Unit targetToAttack = (Unit)GetWoWObjectFromGUID(u.TargetGuid, activeWowObjects); targetToAttack.Update(); AmeisenCore.TargetGUID(targetToAttack.Guid); me.Update(); return(targetToAttack); } return(null); }
private void btnSave_Click(object sender, EventArgs e) { int er = 0; ep.Clear(); if (txtName.Text == "") { er++; ep.SetError(txtName, "Name Required"); } if (txtDescription.Text == "") { er++; ep.SetError(txtDescription, "Description Required"); } if (txtPrimaryQty.Text == "") { er++; ep.SetError(txtPrimaryQty, "Description Required"); } if (er > 0) { return; } unit.Name = txtName.Text; unit.Description = txtDescription.Text; unit.PrimaryQty = Convert.ToInt32(txtPrimaryQty.Text); if (unit.Update()) { MessageBox.Show(@"Unit Updated"); } else { MessageBox.Show(unit.Error); } }
private void UpdateTargetViews() { labelNameTarget.Content = $"{BotManager.Target.Name} lvl.{BotManager.Target.Level}"; labelTargetHP.Content = $"Health {BotManager.Target.Health} / {BotManager.Target.MaxHealth}"; progressBarHPTarget.Maximum = BotManager.Target.MaxHealth; progressBarHPTarget.Value = BotManager.Target.Health; labelTargetEnergy.Content = $"Energy {BotManager.Target.Energy} / {BotManager.Target.MaxEnergy}"; progressBarEnergyTarget.Maximum = BotManager.Target.MaxEnergy; progressBarEnergyTarget.Value = BotManager.Target.Energy; labelTargetDistance.Content = $"Distance: {Math.Round(BotManager.Target.Distance, 2)}m"; Unit target = BotManager.Target; if (target != null && target.Guid != 0) { if (target.Guid != LastGuid) { target.Update(); RememberedUnit rememberedUnit = BotManager.CheckForRememberedUnit(target.Name, target.ZoneID, target.MapID); if (rememberedUnit != null) { labelRemember.Content = "I know this Unit"; StringBuilder sb = new StringBuilder(); foreach (UnitTrait u in rememberedUnit.UnitTraits) { sb.Append($"{UnitTraitSymbols[u]} "); } labelUnitTraits.Content = sb.ToString(); } else { labelRemember.Content = "I don't know this Unit"; labelUnitTraits.Content = "-"; } LastGuid = target.Guid; } } }
private void btnStop_Click(object sender, EventArgs e) { log.Info("btnStop"); return_tab = tabs.SelectedTab; // stop button Program.RequestUserLevel(UserLevels.SERVICE, () => { if (MessageBox.Show("Do you really want to reset the RFZ ?", "Attention", MessageBoxButtons.OKCancel) == DialogResult.OK) { Unit unit = Unit.Trolley1; unit.Mode = 1; unit.Update(); } ; }, () => { tabs.SelectedTab = return_tab; } ); }
/// <summary> /// Move into a spell range /// </summary> /// <param name="me">me object</param> /// <param name="unitToAttack">unit to attack</param> /// <param name="distance">distance how close you want to get to the target</param> public static void MoveInRange(Me me, Unit unitToAttack, double distance) { int count = 0; while (Utils.GetDistance(me.pos, unitToAttack.pos) > distance && count < 5) { AmeisenCore.MovePlayerToXYZ( unitToAttack.pos, InteractionType.MOVE, distance); me.Update(); unitToAttack.Update(); Thread.Sleep(50); count++; } AmeisenCore.InteractWithGUID( unitToAttack.pos, unitToAttack.Guid, InteractionType.STOP); }
public void Update(GameTime gameTime) { foreach (Tile tile in Tiles) { tile.Update(gameTime); } for (int i = 0; i < units.Count; i++) { Unit unit = units[i]; unit.Update(gameTime); if (unit.CurrentHealth <= 0) { TryDespawnUnit(unit); } } foreach (Generator generator in generators) { generator.Update(gameTime); } }
/// <summary> /// Get a target to attack by scanniung hat your partymembers attack /// </summary> /// <param name="me">me object</param> /// <param name="activeWowObjects">all active wow objects</param> /// <returns>a possible target unit</returns> public static Unit AssistParty(Me me, List <WowObject> activeWowObjects, List <Unit> partymembers) { // Get the one with the lowest hp and assist him/her List <Unit> units = GetPartymembersInCombat(me, partymembers); if (units.Count > 0) { foreach (Unit u in units.OrderBy(o => o.HealthPercentage).ToList()) { u.Update(); Unit targetToAttack = (Unit)GetWoWObjectFromGUID(u.TargetGuid, activeWowObjects); if (IsUnitValid(targetToAttack)) { continue; } targetToAttack.Update(); // check if the target is an invalid object if (activeWowObjects.FindAll(o => o.Guid == targetToAttack.Guid).Count == 0) { continue; } AmeisenCore.TargetGUID(targetToAttack.Guid); me.Update(); // if we can attack the target, do it if (CanAttack(LuaUnit.target)) { return(targetToAttack); } } } return(null); }
private void timer1_Tick(object sender, EventArgs e) { if (!Program.MainIsRunning) { return; } try { string[] units = { "+ST01.BU", "+ST01.LS01", "+ST01.LS02", "+ST01.LS03", "+ST01.SC01", "+ST01.SC02", "+ST01.SC03", "+ST01.CAR01", "+ST01.CAR02" }; ListBox list_err = new ListBox(); ListBox list_warn = new ListBox(); ListBox list_msg = new ListBox(); foreach (string SelectedUnit in units) { un = Unit.GetUnit(SelectedUnit); if (un == null) { continue; } if (un.SystemError != null && un.SystemError.Length > 0) { OnNewSystemMessage?.Invoke(un.Unit_ID, un.SystemError); log.Error(un.FriendlyName + " : System failure: " + un.SystemError); un.SystemError = ""; un.Update(); } int[] errValues = null; int no = (int)un.Number; errValues = un.ErrorValues; if (errValues != null) { for (int i = 0; i < errValues.Length; i++) { int x = errValues[i]; for (int j = 0; j < 16; j++) { if ((x & (int)(Math.Pow(2, j))) != 0) { DB_Error.ErrorMessage msg = DB_Error.GetErrorMessage(SelectedUnit, Registry.Culture, (i * 16) + j + 1); ListBox l = null; switch (msg.Sensitivity) { case 500: l = list_err; break; case 300: l = list_warn; break; case 100: l = list_msg; break; default: l = list_err; break; } if (l != null) { l.Items.Add(msg.Number + " " + un.Name + " : " //+ msg.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " + msg.Message); } } } } } if (list_err.Items.Count > 0) { isError = true; } else { isError = false; } if (list_msg.Items.Count > 0) { isMessage = true; } else { isMessage = false; } if (list_warn.Items.Count > 0) { isWarning = true; } else { isWarning = false; } } #region arrange listbox for (int i = 0; i < listError.Items.Count; i++) { if (!list_err.Items.Contains(listError.Items[i])) { listError.Items.Remove(listError.Items[i]); } } for (int j = 0; j < list_err.Items.Count; j++) { if (!listError.Items.Contains(list_err.Items[j])) { listError.Items.Add(list_err.Items[j]); } } #endregion #region arrange listbox for (int i = 0; i < listWarn.Items.Count; i++) { if (!list_warn.Items.Contains(listWarn.Items[i])) { listWarn.Items.Remove(listWarn.Items[i]); } } for (int j = 0; j < list_warn.Items.Count; j++) { if (!listWarn.Items.Contains(list_warn.Items[j])) { listWarn.Items.Add(list_warn.Items[j]); } } #endregion #region arrange listbox for (int i = 0; i < listMessages.Items.Count; i++) { if (!list_msg.Items.Contains(listMessages.Items[i])) { listMessages.Items.Remove(listMessages.Items[i]); } } for (int j = 0; j < list_msg.Items.Count; j++) { if (!listMessages.Items.Contains(list_msg.Items[j])) { listMessages.Items.Add(list_msg.Items[j]); } } #endregion } catch (Exception ex) { log.Error("error reading errors", ex); } }
public override void Update(GameTime gameTime) { if (FIRSTLOAD) { //must put some first loading code here, since when states are added to the stack they have their content load/initialize functions called immediately. // This would result in some strange behaviour with units being removed from the grid when they shouldn't be if this was put in load/initialize. if (useAiOpponent) { //the following variable is used for displaying the outcome of the ai round at the end of the round. moneyAtRoundStart = playerToCheckWinCondition.Money; //remove the other player's units this turn only otherPlayer = players.Where(player => player.Id != nonAiPlayerId).First(); grid.MoveUnitsOffGridTemporarily(otherPlayer.Id); //add the ai opponents units to the grid. Random random = new Random(); foreach (Unit unit in aiRoundUnits) { //find an unoccupied tile in the opponents half (Note their units have been removed temporarily this round) Vector3 location = Vector3.Zero; bool occupied = true; while (occupied) { location = otherPlayer.GetRandomPositionInHalf(); if (!grid.IsTileOccupied(location)) { occupied = false; } } //add the ai unit at the random location. unit.AddToGrid(grid, location); } } FIRSTLOAD = false; } helpButton.Update(gameTime); //check that the round has not finished. i.e. only one side's units are left. int oneSidesUnitCount = grid.Units.Where(unit => unit.OwnerId == playerToCheckWinCondition.Id).ToList().Count; if (oneSidesUnitCount == 0 || oneSidesUnitCount == grid.Units.Count) { EndBattle(); } else { //each time the timer resets... if (timer == stepTimeInterval) { //get the next unit to update //unitsToUpdate list stores the units that haven't been updated in order by their speed for each step if (unitsToUpdate == null) { //get a new list if its hasn't been defined //(Note: order by descending, higher speed => move first) unitsToUpdate = grid.Units.OrderByDescending(unit => unit.Stats.Speed.Value).ToList(); } else if (unitsToUpdate.Count == 0) { //... or has been emptied. unitsToUpdate = grid.Units.OrderByDescending(unit => unit.Stats.Speed.Value).ToList(); } if (unitsToUpdate.Count != 0) { //first get information about the next move a unit will make so it can be displayed //to the player before being committed. //check that list is not empty before trying to update the unit. pendingUpdateUnit = unitsToUpdate.First(); //get the fastest unit and store it to commit changes later. if (pendingUpdateUnit.IsAlive()) { pendingAction = pendingUpdateUnit.Update(players, grid, false); //... and update it - not commiting changes (get pending action info) } } } //decrement the timer by time elapsed. timer -= (float)gameTime.ElapsedGameTime.TotalSeconds; //commit changes if the interval has elapsed (gives time for update to be shown to player) if (timer <= 0) { if (pendingUpdateUnit != null && pendingAction != null) { ActionArgs action = pendingUpdateUnit.Update(players, grid, true); //update the unit, comitting changes actionLog.AddEntry(action); //add result of update to the action log (the action performed) //then remove it from units needing to be updated for this step. unitsToUpdate.RemoveAll(match => match.id == pendingUpdateUnit.id); //remove any units thay may have fainted as a result of an action to stop them from trying to update this step. unitsToUpdate.RemoveAll(match => match.IsAlive() == false); //and finally reset the interval timer. timer = stepTimeInterval; } } } }
public override void Update(GameTime gameTime) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; #region 更新单位 removingUnits.Clear(); for (int i = 0; i < units.Count; i++) { Unit u = units[i]; if (u != null) { u.Update(gameTime); if (u.UnitState == UnitState.dead) { removingUnits.Add(u);//收集要被移除的单位 } } } #endregion #region 回收多余的单位 foreach (Unit u in removingUnits) { if (u != null) { units.Remove(u); } } #endregion #region 环境物 removingDecorations.Clear();//晕,终于发现这里居然错误地写成了removingMissiles.Clear(); foreach (Decoration d in decorations) { if (AODGameLibrary.Helpers.RandomHelper.WithinRange(d.Position, GameWorld.CurrentStage.Player.Position, GameConsts.GameViewDistance) || d.Far) { d.Update(gameTime); if (d.UnitState == UnitState.dead) { removingDecorations.Add(d);//收集要被移除的单位 } } } #endregion #region 回收多余的单位 foreach (Decoration d in removingDecorations) { if (d != null) { decorations.Remove(d); } } #endregion #region 更新导弹 removingMissiles.Clear(); foreach (Missile m in missiles) { if (m != null) { m.Update(gameTime); if (m.UnitState == UnitState.dead) { removingMissiles.Add(m); } } } foreach (Missile m in removingMissiles) { if (m != null) { missiles.Remove(m); } } #endregion #region 更新LOOT { removingLoots.Clear(); foreach (LootItem loot in lootItems) { if (AODGameLibrary.Helpers.RandomHelper.WithinRange(loot.Position, GameWorld.CurrentStage.Player.Position, GameConsts.GameViewDistance)) { loot.Update(gameTime); if (loot.UnitState == UnitState.dead) { removingLoots.Add(loot); } } } foreach (LootItem loot in removingLoots) { if (loot != null) { lootItems.Remove(loot); } } if (lootItems.Count > GameConsts.MaxLootNum) { lootItems.Remove(lootItems[0]); } } #endregion #region 更新弹药 removingBullets.Clear(); //终于。。不再慢了。。。 foreach (Bullet bullet in bullets) { if (bullet != null) { bullet.Update(gameTime); if (bullet.IsDead) { removingBullets.Add(bullet); } } } foreach (Bullet bullet in removingBullets) { if (bullet != null) { bullets.Remove(bullet); } } #endregion #region 单位间碰撞检测 VioableUnit a; VioableUnit b; for (int m = 0; m < boundingCollection.Count; m++) { a = boundingCollection[m]; if (a.Dead) { continue; } for (int n = m + 1; n < boundingCollection.Count; n++) { b = boundingCollection[n]; if (b.Dead) { continue; } if (b != null && a != b) { bool ts = b.Heavy || a.Heavy; if (a.Bounding && b.Bounding && (AODGameLibrary.Helpers.RandomHelper.WithinRange(a.Position, b.Position, GameConsts.BoundingDistance) || ts)) { if (Collision.IsCollided(a, b)) { if ((!a.Heavy && !b.Heavy) || (a.Heavy && b.Heavy && a is Unit && b is Unit)) { //float t = Vector3.Dot(a.Thrust, Vector3.Normalize(b.position - a.position));//推力在两单位中心线的投影 //if (t > 0) // //a.GetThrust(-1 * t * Vector3.Normalize(b.position - a.position)); // a.Thrust = Vector3.Zero; //float x = Vector3.Dot(a.velocity, Vector3.Normalize(b.position - a.position));//速度在两单位中心线的投影 //if (x > 0) // a.GetThrust(-2f * x * Vector3.Normalize(b.position - a.position) * a.mass); if (a.collided == false && b.collided == false) { if (a.Position != b.Position) { { float s1 = Vector3.Dot(a.Velocity, Vector3.Normalize(b.Position - a.Position)); float s2 = Vector3.Dot(b.Velocity, Vector3.Normalize(a.Position - b.Position)); if (s1 > 0) { a.GetImpulse(-1 * Vector3.Normalize(b.Position - a.Position) * s1 * a.Mass); a.GetImpulse(Vector3.Normalize(a.Position - b.Position) * s2 * b.Mass); } } { float s1 = Vector3.Dot(b.Velocity, Vector3.Normalize(a.Position - b.Position)); float s2 = Vector3.Dot(a.Velocity, Vector3.Normalize(b.Position - a.Position)); if (s1 > 0) { b.GetImpulse(-1 * Vector3.Normalize(a.Position - b.Position) * s1 * b.Mass); b.GetImpulse(Vector3.Normalize(b.Position - a.Position) * s2 * a.Mass); } } } } if (a.Position != b.Position) { a.GetImpulse(-1 * Vector3.Normalize(b.Position - a.Position) * a.FrictionForce * elapsedTime); b.GetImpulse(-1 * Vector3.Normalize(a.Position - b.Position) * b.FrictionForce * elapsedTime); } else { a.GetImpulse(Vector3.Left * a.FrictionForce * elapsedTime); b.GetImpulse(Vector3.Right * b.FrictionForce * elapsedTime); } a.collided = true; b.collided = true; } else { VioableUnit l = null; VioableUnit h = null; if (a.Heavy != b.Heavy) { if (b.Heavy) { h = b; l = a; } else { h = a; l = b; } } else { if (b is Decoration && !(a is Decoration)) { h = b; l = a; } if (a is Decoration && !(b is Decoration)) { h = a; l = b; } } if (l != null && h != null) { if (l.Position != h.Position) { float t = Vector3.Dot(l.Thrust, Vector3.Normalize(h.Position - l.Position));//推力在两单位中心线的投影 if (t > 0) { // a.GetThrust(-1 * t * Vector3.Normalize(b.position - a.position)); l.Thrust = Vector3.Zero; } float x = Vector3.Dot(l.Velocity, Vector3.Normalize(h.Position - l.Position));//速度在两单位中心线的投影 if (x > 0) { l.GetImpulse(-1 * x * Vector3.Normalize(h.Position - l.Position) * l.Mass); } l.GetImpulse(-1 * Vector3.Normalize(h.Position - l.Position) * l.FrictionForce * elapsedTime); //if (a.Thrust != Vector3.Zero) // if (Collision.IsCollided(b, new Ray(a.position, Vector3.Normalize(a.Thrust)))) // a.Thrust = Vector3.Zero; //if (a.velocity != Vector3.Zero) // if (Collision.IsCollided(b, new Ray(a.position, Vector3.Normalize(a.velocity)))) // a.velocity *= -1.1f; } } else { l.GetThrust(-1 * l.Velocity * Vector3.Forward * l.Mass / elapsedTime); } } } } } } } #endregion #region 更新位置 foreach (Unit u in units) { if (u != null) { u.UpdateLocation(gameTime); } } foreach (Decoration d in decorations) { if (AODGameLibrary.Helpers.RandomHelper.WithinRange(d.Position, GameWorld.CurrentStage.Player.Position, GameConsts.GameViewDistance) || d.Far) { d.UpdateLocation(gameTime); } } foreach (Missile m in missiles) { if (m != null) { m.UpdateLocation(gameTime); } } foreach (LootItem loot in lootItems) { if (AODGameLibrary.Helpers.RandomHelper.WithinRange(loot.Position, GameWorld.CurrentStage.Player.Position, GameConsts.GameViewDistance)) { loot.UpdateLocation(gameTime); } } for (int i = 0; i < units.Count; i++) { Unit u = units[i]; if (u != null) { u.UpdateWeapons(gameTime); } } #endregion base.Update(gameTime); }
public void Update(GameTime gameTime) { player.Update(gameTime); }
public override void Update(GameTime time) { building?.Update(time); unit?.Update(time); }
public void DoAction() { if (inside_action) { return; } try { inside_action = true; log.Debug("Fetch started"); //if (btnLoginFirst.CenteredText == "Order sent") // btnLoginFirst.CenteredText = "Login first"; if (btnFetchCylinder.CenteredText == "Order sent") { btnFetchCylinder.CenteredText = "Select cylinder"; // only reset button text ButtonVisibilityFromUserLevel(); return; } btnFetchCylinder.Visible = false; btnFetchCylinder.Refresh(); StopDisplayUpdate(); var data = GetSelectedCylinderData(); if (data == null) { return; } Cylinder cyl = null; int cyl_count = 0; foreach (var test in Main.Database.Fetch <Cylinder>("WHERE Number=@0", GetSelectedCylinderNumber())) { cyl_count++; if (test.InRackAnyWhere) { cyl = test; } } if (cyl != null && cyl_count > 1) { foreach (var test in Main.Database.Fetch <Cylinder>("WHERE Number=@0", GetSelectedCylinderNumber())) { if (test.ID != cyl.ID) { log.Fatal($"Same roll found 2 times deleting {test.Number}/{test.ID}, keeping {cyl.ID}"); test.Delete(); } } } if (cyl == null) { lblCylinderInfo.Text = "Number not found"; btnFetchCylinder.Visible = true; return; } Unit ls = GetSaveUnit(MySelectedStation); if (cyl != null && !cyl.InRackAnyWhere) { lblCylinderInfo.Text = $"{cyl.Number} not found in storage"; btnFetchCylinder.Visible = true; cyl = null; } if (cyl != null && cyl.GetHook() != null && cyl.GetHook().TransportOrderID != 0) { lblCylinderInfo.Text = $"{cyl.Number} already ordered"; btnFetchCylinder.Visible = true; cyl = null; } if (cyl != null) { if (!ls.Ready) { lblCylinderInfo.Text = $"Station {ls.Unit_ID - 10} not ready"; btnFetchCylinder.Visible = true; return; } if (ls.Reserved != 0) { lblCylinderInfo.Text = $"order pending"; btnFetchCylinder.Visible = true; return; } } if (cyl != null) { var ready_transports = Main.Database.ExecuteScalar <int>( "SELECT COUNT(*) FROM StorageOrders " + " WHERE Cylinder_ID=@0 " + " AND NOT Status IN ('done', 'error', 'timeout')", cyl.ID); if (ready_transports > 0) { lblCylinderInfo.Text = $"{cyl.Number} already ordered"; log.Error($"{cyl.Number} already ordered"); btnFetchCylinder.Visible = true; return; } } if (cyl != null) { try { if (remembered_rolls.Contains(cyl.Number)) { remembered_rolls.Remove(cyl.Number); } } catch { } TransportOrder ta = new TransportOrder(); ta.ID = TransportOrder.GetNextNegativeID(); ta.Cylinder_ID = (int)cyl.ID; ta.LoadingStation = ls.Unit_ID; ta.TransportSource = TransportOrder.Destinations.Storage; ta.TransportTarget = TransportOrder.Destinations.Forklifter; ta.State = TransportOrder.OrderStates.New; ta.Label = cyl.Number; ta.Priority = -1; log.Info($"placed order id {ta.ID} fetch {cyl.Number} outside to {ls.FriendlyName}"); ls.ClearCylinderID(); var h = Hook.LoadingStation(ls.Unit_ID, true); h.ClearID(); ls.Reserved = ta.ID; ls.BlockForManualOrderUntil = DateTime.UtcNow; ls.Update(); ta.Insert(); CancelAction(); Program.ResetUserLevel(); // reload AllowDisplayUpdate(); refresh_timer_Tick(this, null); btnFetchCylinder.CenteredText = "Order sent"; btnFetchCylinder.Visible = true; btnFetchCylinder.Refresh(); System.Threading.Thread.Sleep(5000); btnFetchCylinder.CenteredText = "Select cylinder"; SearchCylinderPrefixAndText(); ButtonVisibilityFromUserLevel(); refresh_timer_Tick(this, null); log.Debug("Fetch sent"); return; } } catch (Exception fex) { log.Error("common exception in Fetch/DoAction", fex); } finally { inside_action = false; } }
// ユニット u に搭乗 public void Ride(Unit u, bool is_support = false) { double hp_ratio, en_ratio; double plana_ratio; // 既に乗っていればなにもしない if (ReferenceEquals(Unit, u)) { return; } // TODO Impl Ride { //var u = u; //hp_ratio = 100 * u.HP / (double)u.MaxHP; //en_ratio = 100 * u.EN / (double)u.MaxEN; //// 現在の霊力値を記録 //if (MaxPlana() > 0) //{ // plana_ratio = 100 * Plana / (double)MaxPlana(); //} //else //{ // plana_ratio = -1; //} // XXX 仮 Unit = u; u.AddPilot(this); //short localInStrNotNest1() { string argstring1 = Class; string argstring2 = "サポート)"; var ret = GeneralLib.InStrNotNest(argstring1, argstring2); this.Class = argstring1; return ret; } //short localLLength() { string arglist = Class; var ret = GeneralLib.LLength(arglist); this.Class = arglist; return ret; } //if (localInStrNotNest1() > 0 && localLLength() == 1 && !u.IsFeatureAvailable("ダミーユニット")) //{ // // サポートにしかなれないパイロットの場合 // u.AddSupport(this); //} //else if (IsSupport(u)) //{ // // 同じユニットクラスに対して通常パイロットとサポートの両方のパターン // // がいける場合は通常パイロットを優先 // short localInStrNotNest() { string argstring1 = Class; string argstring2 = u.Class0 + " "; var ret = GeneralLib.InStrNotNest(argstring1, argstring2); this.Class = argstring1; return ret; } // if (u.CountPilot() < Math.Abs(u.Data.PilotNum) && localInStrNotNest() > 0 && !is_support) // { // u.AddPilot(this); // } // else // { // u.AddSupport(this); // } //} //else //{ // // パイロットが既に規定数の場合は全パイロットを降ろす // if (u.CountPilot() == Math.Abs(u.Data.PilotNum)) // { // u.Pilot(1).GetOff(); // } // u.AddPilot(this); //} // Pilotコマンドで作成されたパイロットは全て味方なので搭乗時に変更が必要 Party = u.Party0; // ユニットのステータスをアップデート u.Update(); //// 霊力値のアップデート //if (plana_ratio >= 0d) //{ // Plana = (int)((long)(MaxPlana() * plana_ratio) / 100L); //} //else //{ // Plana = MaxPlana(); //} //// パイロットが乗り込むことによるHP&ENの増減に対応 //u.HP = (int)((long)(u.MaxHP * hp_ratio) / 100L); //u.EN = (int)((long)(u.MaxEN * en_ratio) / 100L); } }