public void OnTurretInfoComponentAuthorityChanged(AuthorityChangeOp op) { if (op.Authority == Authority.Authoritative) { authoritativeTurretRotations.Add(op.EntityId); var update = new Improbable.Demo.TurretInfo.Update(); update.colorId = thisWorkerColorId; connection.SendComponentUpdate(op.EntityId, update); connection.SendCommandRequest(op.EntityId, new CheckOutColor.Commands.SendAndUpdateColorId.Request(thisWorkerColorId), 300); } else if (op.Authority == Authority.AuthorityLossImminent) { var update = new Improbable.Demo.TurretInfo.Update(); update.AddLosingAuth(LosingTurretAuthInfo.Create()); connection.SendComponentUpdate(op.EntityId, update); entitiesToConfirmAuthorityLoss[op.EntityId] = framesBeforeAcknowledgingAuthLoss; } else if (op.Authority == Authority.NotAuthoritative) { authoritativeTurretRotations.Remove(op.EntityId); } }
}//创建明细 public void deleteOrderItem(Goods goods, int quantity, DateTime deadline) { foreach (OrderItem oi in OrderItemlist) { if ((oi.Goods == goods) && (oi.Quantity == quantity) && (oi.Deadline == deadline)) { OrderItemlist.Remove(oi); } } }//删除订单明细
public void BrisiUposlenog(string ime) { for (int i = 0; i < Uposleni.Count(); i++) { if (Uposleni[i].DajIme() == ime) { Uposleni.Remove(Uposleni[i]); } } }
public void OnDestroy() { try { g_StructuresWithBounds.Remove(this); g_Structures.Remove(this); } finally { base.OnDestroy(); } }
public bool CullComponent(StructureComponent component) { if ((component == null) || !this._structureComponents.Remove(component)) { return(false); } this.RemoveCompPositionEntry(component); this.RecalculateStructureLinks(); this.MarkBoundsDirty(); if (this._structureComponents.Count == 0) { g_StructuresWithBounds.Remove(this); } return(true); }
public bool Remove(String RecordID) { Trace.TraceInformation("Enter."); lock (objLock) { if (RecordID != null && RecordID != String.Empty) { CallbackRecord ToBeRemoved = null; foreach (CallbackRecord record in _Records) { if (record.ID == RecordID) { ToBeRemoved = record; break; } } if (ToBeRemoved != null) { Trace.TraceInformation("Record list size (before):" + _Records.Count.ToString()); _Records.Remove(ToBeRemoved); Trace.TraceInformation("Record with ID = " + RecordID + " was removed from the list."); Trace.TraceInformation("Record list size (after):" + _Records.Count.ToString()); iRecordCount = _Records.Count; UpdateNumberOfRecordsCurrentlyInIVR(); WriteToDisk(); return(true); } else { Trace.TraceWarning("No record with id " + RecordID + " was found."); return(false); } } else { Trace.TraceWarning("RecordID is either null or empty."); return(false); } } }
void DoRestart() { System.Collections.Generic.List <string> args = new System.Collections.Generic.List <string>(); var cmds = System.Environment.GetCommandLineArgs(); foreach (string a in cmds) { args.Add(a); } args.RemoveAt(0); args.Remove("-restart"); string sArgs = string.Empty; foreach (string s in args) { sArgs += (s + " "); } sArgs += " -restart"; Process.Start("Elpis.exe", sArgs); }
// Update is called once per frame void Update() { // If fire 2 button is pressed, fire projectile if (Input.GetButtonDown("Fire2")) { GameObject bullet = (GameObject)Instantiate(projectilePrefab, transform.position, Quaternion.identity); Projectiles.Add(bullet); } for (int i = 0; i < Projectiles.Count; i++) { GameObject goBullet = Projectiles[i]; if (goBullet != null) { float direction = 1; //direction = Input.GetAxis("Horizontal"); goBullet.transform.Translate(new Vector3(direction, 0) * Time.deltaTime * projectileVelocity); Vector3 bulletScreenPos = Camera.main.WorldToScreenPoint(goBullet.transform.position); if (bulletScreenPos.x >= Screen.width || bulletScreenPos.x <= 0) { DestroyObject(goBullet); Projectiles.Remove(goBullet); } } } //Projectile script ends }
public List <IVector2> GetWallCoords(bool _excludeDoorways) { var walls = new System.Collections.Generic.List <IVector2>(); switch (m_ShapeType) { case ShapeType.Rectangle: walls.AddRange(Support2D.CreateRect(m_Bounds)); break; case ShapeType.Ellipse: walls.AddRange(Support2D.CreateEllipseRect(m_Bounds)); break; } if (_excludeDoorways) { return(walls); } foreach (var doorway in m_Doorways) { walls.Remove(doorway); } return(walls); }
public bool Remove(V3Data item) { bool res = collect.Remove(item); CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); return(res); }
void Update() { foreach (var e in scheduledEvents) { e.timeToSend -= Time.deltaTime; if (!(e.timeToSend <= 0)) { continue; } switch (e.ValueType) { case EventType.String: EventManager.StringEvent(e.passedValues as string[]); break; case EventType.Sound: EventManager.SoundEvent(e.passedValues as Sound[]); break; case EventType.Object: EventManager.ObjectEvent(e.passedValues); break; default: throw new ArgumentOutOfRangeException(); } scheduledEvents.Remove(e); } }
void OnGUI() { expansionName = EditorGUILayout.TextField("Expansion name", expansionName); bundleName = EditorGUILayout.TextField("Bundle name", bundleName); if (GUILayout.Button("Add")) { scenes.Add(EditorUtility.OpenFilePanel("Select scene", "", "unity")); } for (int i = 0; i < scenes.Count; i++) { EditorGUILayout.BeginHorizontal(); scenes[i] = EditorGUILayout.TextField(scenes[i].Split('/')[scenes[i].Split('/').Length - 1], scenes[i]); if (GUILayout.Button("Change")) { scenes[i] = EditorUtility.OpenFilePanel("Select scene", "", "unity"); } if (GUILayout.Button("Remove")) { scenes.Remove(scenes[i]); } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Build AssetBundle")) { string path = EditorUtility.SaveFilePanel("Save Bundle", Application.dataPath + "/../Expansions", expansionName + "_" + bundleName, "unity3d"); if (path.Length != 0) { BuildPipeline.BuildStreamedSceneAssetBundle(scenes.ToArray(), path, BuildTarget.StandaloneWindows, BuildOptions.BuildAdditionalStreamedScenes | BuildOptions.UncompressedAssetBundle); } } }
private static void RemoveCacheKey(string key) { lock (_lockObject) { cacheKeys.Remove(key); } }
void DoRestart() { System.Collections.Generic.List <string> args = new System.Collections.Generic.List <string>(); var cmds = System.Environment.GetCommandLineArgs(); foreach (string a in cmds) { args.Add(a); } args.RemoveAt(0); args.Remove("-restart"); string sArgs = string.Empty; foreach (string s in args) { sArgs += (s + " "); } sArgs += " -restart"; //Process.Start("Elpis.exe", sArgs); try { //run the program again and close this one Process.Start("Elpis.exe", sArgs); //or you can use Application.ExecutablePath //close this one Process.GetCurrentProcess().Kill(); } catch { } }
public void PlayerDeath(bool byLava) { var targets = Camera.main.GetComponent <CameraController>().targets; System.Collections.Generic.List <Transform> listOfTargets = new System.Collections.Generic.List <Transform>(targets); listOfTargets.Remove(gameObject.transform); Camera.main.GetComponent <CameraController>().targets = listOfTargets.ToArray(); if (!byLava) { // Show Player Death Effect deathEffect.startColor = playerColor; ParticleSystem instantiatedDeathEffect = Instantiate(deathEffect, gameObject.transform.position, gameObject.transform.rotation); Destroy(instantiatedDeathEffect.gameObject, 2f); } var gameControllerScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); var livingPlayers = new GameObject[gameControllerScript.players.Length - 1]; var i = 0; foreach (var player in gameControllerScript.players) { if (player != gameObject) { livingPlayers[i] = player; i++; } } gameControllerScript.players = livingPlayers; // Destroy the Player Destroy(gameObject); }
protected IEnumerable <T> _GetObjectSet() { Operation operation; while (_Operations.TryDequeue(out operation)) { if (operation.Type == TYPE.ADD) { lock (_Items) { _Items.Add(operation.Item); } operation.Item.Launch(); if (AddEvent != null) { AddEvent(operation.Item); } } else { lock (_Items) _Items.Remove(operation.Item); operation.Item.Shutdown(); if (RemoveEvent != null) { RemoveEvent(operation.Item); } } } return(_Objects); }
public void CleanUp() { for (int i = InvalidCount; i < items.Length; i++) { T obj = items[i]; if (validate(obj)) { continue; } if (i != InvalidCount) { items[i] = items[InvalidCount]; items[InvalidCount] = obj; } enumerableItemList.Remove(obj); if (Uninitialize != null) { Uninitialize(obj); } InvalidCount++; } }
public void SaveButtonClicked() { Settings settings = new Settings(); if (settingsField.text.Length < 1) { return; } settings.rewardPort = rewardPortField.text; settings.parallelPort = parallelPortField.text; settings.joyStickPort = joystickPortField.text; settings.interTrialFixed = interTrialFixed.text; settings.interTrialMin = interTrialMin.text; settings.interTrialMax = interTrialMax.text; settings.completionWindow = completionWindowFixed.text; settings.rewardTime = rewardFixed.text; settings.timeOut = timeoutFixed.text; settings.settingName = settingsField.text; settings.interSessionTime = interSessionFixed.text; settings.randomizeInterTrialTime = interTrialRandomize.isOn; settings.useJoystick = useJoystickToggle.isOn; settings.translationSpeed = translationSpeedSlider.value; settings.rotationSpeed = rotationSpeedSlider.value; settings.joystickDeadzone = joystickDeadzoneSlider.value; settings.enableReverse = enableReverseToggle.isOn; settings.enableForward = enableForwardToggle.isOn; settings.enableRight = enableRightToggle.isOn; settings.enableLeft = enableLeftToggle.isOn; settings.enablePoster = enablePoster.isOn; settings.rewardViewCriteria = rewardViewCriteriaSlider.value; settings.sessionList = new List <Dictionary <string, string> > (); foreach (Transform element in verticalSessionsPanel.transform) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("numTrials", element.gameObject.GetComponent <SessionPrefabScript>().numTrials); dict.Add("indexOfLevel", element.gameObject.GetComponent <SessionPrefabScript>().index.ToString()); settings.sessionList.Add(dict); } System.Collections.Generic.List <Settings> settingsList = SaveLoad.settingsList; //check for similar name - delete it for (int i = 0; i < settingsList.Count; i++) { if (settingsList[i].settingName == settingsField.text) { settingsList.Remove(settingsList[i]); } } //add new setting to list settingsList.Add(settings); SaveLoad.settingsList = settingsList; experimentStatus = "Saved settings"; CloseSettings(); }
public static void RemoveZone(NoPlacementZone zone) { if (_zones.Contains(zone)) { _zones.Remove(zone); } }
public static float EntityDecay(object entity, float dmg) { if (entity == null) { return(0f); } try { DecayEvent de = new DecayEvent(new Entity(entity), ref dmg); if (OnEntityDecay != null) { OnEntityDecay(de); } if (decayList.Contains(entity)) { decayList.Remove(entity); } decayList.Add(entity); return(de.DamageAmount); } catch { } return(0f); }
static int _m_Remove(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.Collections.Generic.List <string> gen_to_be_invoked = (System.Collections.Generic.List <string>)translator.FastGetCSObj(L, 1); { string _item = LuaAPI.lua_tostring(L, 2); bool gen_ret = gen_to_be_invoked.Remove( _item); LuaAPI.lua_pushboolean(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public static float EntityDecay(object entity, float dmg) { Contract.Assume(entity != null); try { DecayEvent de = new DecayEvent(new Entity(entity), ref dmg); if (OnEntityDecay != null) { OnEntityDecay(de); } if (decayList.Contains(entity)) { decayList.Remove(entity); } decayList.Add(entity); return(de.DamageAmount); } catch (Exception ex) { Logger.LogException(ex); } return(0f); }
public virtual bool Remove(T item) { bool ret = list.Remove(item); OnCountChanged(); return(ret); }
internal void RemoveSubArea(SubArea subArea) { this.m_subAreas.Remove(subArea); this.m_maps.RemoveAll(delegate(Map entry) { bool result; if (subArea.Maps.Contains(entry)) { if (this.m_mapsByPoint.ContainsKey(entry.Position)) { System.Collections.Generic.List <Map> list = this.m_mapsByPoint[entry.Position]; list.Remove(entry); if (list.Count <= 0) { this.m_mapsByPoint.Remove(entry.Position); } } result = true; } else { result = false; } return(result); }); subArea.Area = null; }
public static bool Remove(string strName) { if (!Contains(strName)) { return(false); } return(faveList.Remove(strName)); }
/// <summary> /// Deselects the node. /// Nothing happens if node is already deselected. /// </summary> /// <param name="node"></param> public void Remove(MapNode node) { bool success = selectedNodes.Remove(node); if (success) { NodeDeselected(node, this); } }
private void C_PRESETLIST_BUTTON_DELETE_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; PresetItem pi = (PresetItem)button.DataContext; C_PRESETLIST.ItemsSource = null; m_Presets.Remove(pi); C_PRESETLIST.ItemsSource = m_Presets; }
public bool CanShowSecondary(int arTransactionId) // each band needs a different function that calls a different Dup { bool show = false; if (arDictSecondary.Contains(arTransactionId) && arDictDupSecondary.Contains(arTransactionId)) { show = true; arDictSecondary.Remove(arTransactionId); arDictDupSecondary.Remove(arTransactionId); } else if (arDictSecondary.Contains(arTransactionId)) { show = true; arDictSecondary.Remove(arTransactionId); } //MessageBox.Show(show.ToString() + " Secondary " + arDictDupGroupSecondary.Contains(arTransactionId).ToString()); return(show); }
protected internal void RemoveConnection(string id) { ClientObject client = clients.FirstOrDefault(c => c.Id == id); // получаем по id закрытое подключение if (client != null) // и удаляем его из списка подключений { clients.Remove(client); } }
public static decimal?CalculatePathCost(this BO.Shipment @this, System.Collections.Generic.List <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder> Orders) { using (new zAppDev.DotNet.Framework.Profiling.Profiler("Shipment", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "CalculatePathCost")) { System.Collections.Generic.List <string> coordinates = new System.Collections.Generic.List <string>(); coordinates.Add((@this?.DeparturePoint?.Coordinates?.CoordinateY ?? 0) + "," + (@this?.DeparturePoint?.Coordinates?.CoordinateX ?? 0)); zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Error, "Shipment", DSS3_LogisticsPoolingForUrbanDistribution.Hubs.EventsHub.RaiseDebugMessage, coordinates.FirstOrDefault()); foreach (var i in Orders ?? Enumerable.Empty <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder>()) { string departure = (i?.DeparturePoint?.Coordinates?.CoordinateY ?? 0) + "," + (i?.DeparturePoint?.Coordinates?.CoordinateX ?? 0); string arrival = (i?.ArrivalPoint?.Coordinates?.CoordinateY ?? 0) + "," + (i?.ArrivalPoint?.Coordinates?.CoordinateX ?? 0); if ((((coordinates.Contains(departure)) == false) && i?.DeparturePoint != @this?.FinalDestination)) { coordinates.Add(departure); } if ((((coordinates.Contains(arrival)) == false) && i?.ArrivalPoint != @this?.FinalDestination)) { coordinates.Add(arrival); } } string FinalCoordinate = (@this?.FinalDestination?.Coordinates?.CoordinateY ?? 0) + "," + (@this?.FinalDestination?.Coordinates?.CoordinateX ?? 0); coordinates.Add(FinalCoordinate); while ((coordinates.Contains("0,0"))) { coordinates.Remove("0,0"); } string coord = ""; foreach (var i in coordinates ?? Enumerable.Empty <string>()) { if (coord == "") { coord = coord + i; } else { coord = coord + "," + i; } } DSS3_LogisticsPoolingForUrbanDistribution.ExternalStructs.Router_Mapotempo.Router_MapotempoRoot response = DSS3_LogisticsPoolingForUrbanDistribution.BLL.ExternalRestServices.Router_MapotempoRestService.route("time", "true", "true", "true", "200", "EUR", "en", coord, "inlecom-1-pe3io4Ui5aimobich1oot0eilothongo"); zAppDev.DotNet.Framework.Utilities.Serializer <DSS3_LogisticsPoolingForUrbanDistribution.ExternalStructs.Router_Mapotempo.Router_MapotempoRoot> serializer = new zAppDev.DotNet.Framework.Utilities.Serializer <DSS3_LogisticsPoolingForUrbanDistribution.ExternalStructs.Router_Mapotempo.Router_MapotempoRoot>(); zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "Shipment", DSS3_LogisticsPoolingForUrbanDistribution.Hubs.EventsHub.RaiseDebugMessage, serializer.ToJson(response)); decimal?time = (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(response.features, 0)).properties.router.total_time / 3600; decimal?distance = (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(response.features, 0)).properties.router.total_distance / 1000; decimal?DistanceCost = distance.GetValueOrDefault(0) * (@this?.VehiculeType?.CalculatedDistanceCost ?? 0); decimal?TimeCost = time.GetValueOrDefault(0) * (@this?.VehiculeType?.CalculatedTimeCost ?? 0); decimal?TotalCost = new decimal?(); if (@this?.VehiculeType?.AmortizationType1?.Label == "technical") { TotalCost = TimeCost.GetValueOrDefault(0) + DistanceCost.GetValueOrDefault(0) + (@this?.VehiculeType?.CalculatedOwnershipCost ?? 0) * distance.GetValueOrDefault(0); } else { TotalCost = TimeCost.GetValueOrDefault(0) + DistanceCost.GetValueOrDefault(0) + (@this?.VehiculeType?.CalculatedOwnershipCost ?? 0) * time.GetValueOrDefault(0); } TotalCost = TotalCost.GetValueOrDefault(0) * (1 + (@this?.VehiculeType?.OverHeadCost ?? 0) / 100); return(TotalCost); } }
//this is code to adjust the maximum value of the attribute up downs. Only one attribute can max out. //there is corresponding code in the AttributeUpDown class and in the Character class that works to achieve this public void AttributeUpDown_ValueChanged(object sender, EventArgs e) { AttributeUpDown attribute = (AttributeUpDown)sender; System.Collections.Generic.List<AttributeUpDown> upDowns = new System.Collections.Generic.List<AttributeUpDown>(); upDowns.Add(agilityUpDown); upDowns.Add(strengthUpDown); upDowns.Add(bodyUpDown); upDowns.Add(reactionUpDown); upDowns.Add(logicUpDown); upDowns.Add(charismaUpDown); upDowns.Add(intuitionUpDown); upDowns.Add(willpowerUpDown); if (character.attributeMax == false) { if (attribute.Value == attribute.Maximum) { upDowns.Remove(attribute); foreach (AttributeUpDown n in upDowns) { n.Maximum = n.Maximum - 1; n.maxReached = true; } character.attributeMax = true; } } else if (character.attributeMax == true && attribute.maxReached == false) { upDowns.Remove(attribute); foreach (AttributeUpDown n in upDowns) { n.Maximum = n.Maximum + 1; n.maxReached = false; } character.attributeMax = false; } }
static void Main(string[] args) { int hSeg = 16; int vSeg = 8; mikity.index myIndex = new mikity.index(); //節点番号と座標変数の対応表 mikity.index mask = new mikity.index(); //節点番号と座標変数の対応表 mikity.shape myShape = new mikity.shape(); //座標変数 mikity.elements Triangles = new mikity.elements(); //三角形要素 mikity.elements myElements = new mikity.elements(); //張力要素リスト mikity.elements Border = new mikity.elements(); //境界要素リスト //形状定義 System.Random rand = new System.Random(0); for (int i = 0; i < hSeg; i++) { for (int j = 0; j < vSeg + 1; j++) { int num = i + j * (hSeg); myIndex.Add(new int[3] { num * 3, num * 3 + 1, num * 3 + 2 }); myShape.AddRange(new double[3] { (rand.NextDouble() - 0.5) * 15d, (rand.NextDouble() - 0.5) * 15d, (rand.NextDouble() - 0.5) * 15d }); } } double Radius = 10.0; for (int i = 0; i < hSeg; i++) { int num = i + 0 * (hSeg); mask.Add(myIndex[num]); double theta = System.Math.PI * 2 / hSeg * i; myShape[mask.Last()] = new double[3] { Radius*System.Math.Cos(theta), Radius*System.Math.Sin(theta), -2.0 }; } for (int i = 0; i < hSeg; i++) { int num = i + vSeg * (hSeg); double theta = System.Math.PI * 2 / hSeg * i; mask.Add(myIndex[num]); myShape[mask.Last()] = new double[3] { Radius * System.Math.Cos(theta), Radius * System.Math.Sin(theta), 0.0 }; } //基準正方形を構成する2つの三角形 int[,] _t = (matrix_INT)(new int[2, 2] { { 0, 1 }, { hSeg, hSeg+1 } }); Triangles.Add(new int[3] { _t[0, 0], _t[0, 1], _t[1, 0] }); Triangles.Add(new int[3] { _t[0, 1], _t[1, 1], _t[1, 0] }); int[] tmp = vector.lin(0, 1); //作成した基準正方形を並べて行を作成 for (int i = 1; i < hSeg; i++) { Triangles.AddRange((elements)Triangles[tmp] + i); } Triangles[Triangles.Count-2][1] = 0; Triangles[Triangles.Count-1][0] = 0; Triangles[Triangles.Count-1][1] = hSeg; //作成した基準行を並べて膜を作成 tmp = vector.lin(0, 2*hSeg-1); for (int i = 1; i < vSeg; i++) { Triangles.AddRange((elements)Triangles[tmp] + i * (hSeg)); } myElements.AddRange(Triangles); //3項法の準備 mikity.term p = new mikity.term(myShape.Count); //加速度 mikity.term q = new mikity.term(myShape.Count); //速度 mikity.term x = new mikity.term(myShape); //位置 //GUIと可変パラメータの準備 mikity.visualize.FigureUI figUI = new mikity.visualize.FigureUI(); //時間の刻み幅 mikity.visualize.slider s1 = figUI.addSlider(min: 1, step: 2, max: 44, val: 38, text: "dt"); s1.Converter = val => Math.Pow(10, ((double)val / 10) - 4.8) * 2.0; System.Collections.Generic.List<double> dt = new System.Collections.Generic.List<double>(); //リング間の距離 mikity.visualize.slider s2 = figUI.addSlider(min: 0, step: 2, max: 4000, val: 800, text: "Ring"); s2.Converter = val => (val)/200; //描画ウインドウの準備 mikity.visualize.figure3D myFigure = new mikity.visualize.figure3D(); myFigure.xtitle = "Tanzbrunnen"; System.Collections.Generic.List<double> fps = new System.Collections.Generic.List<double>(); System.Collections.Generic.List<int> ticks = new System.Collections.Generic.List<int>(); ticks.AddRange(new int[101]); //3項法のメインループ int t = 0; mikity.visualize.drawelements.scale(0.5); while (figUI.Exit == false) { if (figUI.Pause == false) { t++; ticks.Add(System.Environment.TickCount); ticks.Remove(ticks[0]); fps.Add((double)1000 / (ticks[100] - ticks[0]) * 100); dt.Add(s1.value); double w1 = s2.value;//リング for (int i = 0; i < hSeg; i++) { double theta = System.Math.PI * 2 / hSeg * i; myShape[mask[i]] = new double[3] { Radius * System.Math.Cos(theta), Radius * System.Math.Sin(theta), -w1 }; } for (int i = 0; i < hSeg; i++) { double theta = System.Math.PI * 2 / hSeg * i; myShape[mask[i + hSeg]] = new double[3] { Radius * System.Math.Cos(theta), Radius * System.Math.Sin(theta), -0.0 }; } if (figUI.Exit == true) break; System.Threading.Tasks.Parallel.ForEach(myElements, (element e) => { e.Update(myShape, myIndex); e.Stress = e.Metric; e.makeOmega(); }); vector grad = myElements.Gradient(); vector.mask(grad, mask); p.Add(grad); if (vector.norm(p[t]) != 0) { p[t] = (vector)p[t] / vector.norm(p[t]); } q.Add((0.98 * (vector)q[t - 1]) - (vector)p[t] * dt[t - 1]); //x.Add(myShape + (vector)q[t] * dt[t - 1]); x.Add(myShape - (vector)p[t] * dt[t - 1]*10); myShape = x[t]; if (t % 5 == 0) { myFigure.drawlater(); myFigure.clf(); myFigure.WriteLine("dt=" + dt[t - 1].ToString("0.000e00")); myFigure.WriteLine("FPS=" + fps[t - 1].ToString("0.0")); myFigure.set_shape(myShape, myIndex); mikity.visualize.drawelements.draw_fixedpoints(myFigure, mask, myIndex); mikity.visualize.drawelements.draw_triangles(myFigure, Triangles, myIndex); myFigure.drawnow(); } } if (figUI.expPNG == true) { myFigure.exportPNG(); } if (figUI.expEMF == true) { myFigure.exportEMF(); } if (figUI.expSeq == true) { System.Windows.MessageBoxResult res = System.Windows.MessageBox.Show("Click OK to export sequential BMPs", "Message from mikity", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Information); if (res == System.Windows.MessageBoxResult.OK) { mikity.visualize.sequence.init(); using (mikity.visualize.figure3D myFigure2 = new mikity.visualize.figure3D()) { myFigure2.xtitle = "Tanzbrunnen"; for (int i = 1; i <= t; i += 5) { myFigure2.drawlater(); myFigure2.clf(); myFigure2.WriteLine("dt=" + dt[i - 1].ToString("0.000e00")); myFigure2.WriteLine("FPS=" + fps[i - 1].ToString("0.0")); myFigure2.set_shape(x[i], myIndex); mikity.visualize.drawelements.draw_fixedpoints(myFigure2, mask, myIndex); mikity.visualize.drawelements.draw_triangles(myFigure2, Triangles, myIndex); myFigure2.drawnow(); myFigure2.exportBMP((int)i / 5); System.Windows.Forms.Application.DoEvents(); } } } System.Windows.MessageBox.Show("Finish!", "Message from mikity", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } System.Windows.Forms.Application.DoEvents(); } }
// CALL THIS EVERY TIME A UNIT GETS A NEW TURN public static void GenerateMovementTree(UnitActions mover) { System.Collections.Generic.List<Tile> all = new System.Collections.Generic.List<Tile>(); //optimization int mx = (int)mover.gridPosition.x; int my = (int)mover.gridPosition.y; int mxmin = mx - mover.MovementTiles; int mxmax = mx + mover.MovementTiles; int mymin = my - mover.MovementTiles; int mymax = my + mover.MovementTiles; if (mxmin < 0) mxmin = 0; if (mxmax >= GameManager.MapWidth) mxmax = GameManager.MapWidth - 1; if (mymin < 0) mymin = 0; if (mymax >= GameManager.MapHeight) mymax = GameManager.MapHeight - 1; Tile temp = GetTileFromPlayer(mover); for (int i = mxmin; i <= mxmax; ++i) { for (int j = mymin; j <= mymax; ++j) { if (GetDistance(temp, GameManager.map[i][j]) < mover.MovementTiles + 1) if (true) //TODO replace this with a check to see if the mover can walk on map[i][j] all.Add(GameManager.map[i][j]); } } //TODO This will need to be tweaked if we allow movement through allied units //if allied movement is desired, this foreach can be removed to allow it, but you'll need to manually remove player location tiles // from the output of getmovement or they'll be able to walk into each other //uncomment this to make it so that allied units block player movement /*foreach (Player p in GameManager.currentTeam.myRoster) { temp = GetTileFromPlayer(p); if (all.Contains(temp)) all.Remove(temp); }*/ foreach (UnitActions p in GameManager.enemyTeam.myRoster) { temp = GetTileFromPlayer(p); if (all.Contains(temp)) all.Remove(temp); } //Dijkstra's Algorithm Dictionary<Tile, int> weights = new Dictionary<Tile, int>(); List<Tile> unvisited = new List<Tile>(); Dictionary<Tile, Tile> nextParent = new Dictionary<Tile, Tile>(); foreach (Tile t in all) { weights.Add(t, Infinity); unvisited.Add(t); } temp = GetTileFromPlayer(mover); weights[temp] = 0; unvisited.Remove(temp); CurrentMovementTree.Clear(); CurrentMovementTree.Value = temp; while (unvisited.Count > 0) { List<Tile> uvn = GetUnvisitedNeighbors(unvisited, temp); int dist; foreach (Tile t in uvn) { float jdist = t.elevation - temp.elevation; if (jdist < 0) jdist *= -1; if (t.isAccessible && jdist <= mover.MovementJump) dist = t.MoveCost + weights[temp]; else dist = Infinity; if (dist < weights[t]) { weights[t] = dist; if (nextParent.ContainsKey(t)) nextParent[t] = temp; else nextParent.Add(t, temp); } } if (unvisited.Count > 0) { temp = unvisited[0]; foreach (Tile t in weights.Keys) { if (unvisited.Contains(t) && weights[t] < weights[temp]) temp = t; } } unvisited.Remove(temp); } Queue<Tile> distancecheck = new Queue<Tile>(); foreach (Tile t in nextParent.Keys) { distancecheck.Enqueue(t); } Queue<Tile> Remove = new Queue<Tile>(); while (distancecheck.Count > 0) { if (weights[distancecheck.Peek()] > mover.MovementTiles) Remove.Enqueue(distancecheck.Dequeue()); else distancecheck.Dequeue(); } while (Remove.Count > 0) nextParent.Remove(Remove.Dequeue()); RecursiveBuildTileTree(nextParent, CurrentMovementTree); }
//跨距 private string[] kuaJu() { System.Collections.Generic.List<string> result = new System.Collections.Generic.List<string>(); string[] allNum = heZhi(); if (killKuaDu.Checked == false) { List<int> nums = new List<int>(); foreach (Control ctls in this.kuaJuGpb.Controls) { bool isNum = isNumber(ctls.Text); if ((ctls as CheckBox).Checked == true && isNum == true) { nums.Add(Convert.ToInt16(ctls.Text)); } } if (nums.Count > 0) { for (int i = 0; i < allNum.Count(); i++) { for (int j = 0; j < nums.Count(); j++) { int a = Convert.ToInt32(allNum[i].Substring(0, 1)); int b = Convert.ToInt32(allNum[i].Substring(1, 1)); int c = Convert.ToInt32(allNum[i].Substring(2, 1)); int max = 0; int min = 0; if (a > b) { if (a > c) { max = a; } else { max = c; } } else { if (b > c) { max = b; } else { max = c; } } if (a < b) { if (a < c) { min = a; } else { min = c; } } else { if (b < c) { min = b; } else { min = c; } } if ( max - min == nums[j] ) { result.Add(allNum[i]); } } } } else { result.AddRange(allNum); } List<string> result1 = result.Distinct().ToList();//去除重复项 return result1.ToArray(); } else { List<int> nums = new List<int>(); result.AddRange(allNum); foreach (Control ctls in this.kuaJuGpb.Controls) { bool isNum = isNumber(ctls.Text); if ((ctls as CheckBox).Checked == true && isNum == true) { nums.Add(Convert.ToInt16(ctls.Text)); } } if (nums.Count > 0) { for (int i = 0; i < allNum.Count(); i++) { for (int j = 0; j < nums.Count(); j++) { int a = Convert.ToInt32(allNum[i].Substring(0, 1)); int b = Convert.ToInt32(allNum[i].Substring(1, 1)); int c = Convert.ToInt32(allNum[i].Substring(2, 1)); int max = 0; int min = 0; if (a > b) { if (a > c) { max = a; } else { max = c; } } else { if (b > c) { max = b; } else { max = c; } } if (a < b) { if (a < c) { min = a; } else { min = c; } } else { if (b < c) { min = b; } else { min = c; } } if ( max - min == nums[j] ) { result.Remove(allNum[i]); } } } } List<string> result1 = result.Distinct().ToList();//去除重复项 return result1.ToArray(); } }
//和值 public string[] sumZhi() { System.Collections.Generic.List<string> result = new System.Collections.Generic.List<string>(); string[] allNum = locChaExecute(); if (this.killHeZhi.Checked == false) { List<int> nums = new List<int>(); foreach (Control ctls in this.sumZhiGbp.Controls) { if ((ctls as CheckBox).Checked == true) { nums.Add(Convert.ToInt16(ctls.Text)); } } if (nums.Count > 0) { for (int i = 0; i < allNum.Count(); i++) { for (int j = 0; j < nums.Count(); j++) { int allNumSum = Convert.ToInt32(allNum[i].Substring(0, 1)) + Convert.ToInt32(allNum[i].Substring(1, 1)) + Convert.ToInt32(allNum[i].Substring(2, 1)); if ( allNumSum == nums[j] ) { result.Add(allNum[i]); } } } } else { result.AddRange(allNum); } List<string> result1 = result.Distinct().ToList();//去除重复项 return result1.ToArray(); } else { List<int> nums = new List<int>(); result.AddRange(allNum); foreach (Control ctls in this.sumZhiGbp.Controls) { if ((ctls as CheckBox).Checked == true) { nums.Add(Convert.ToInt16(ctls.Text)); } } if (nums.Count > 0) { for (int i = 0; i < allNum.Count(); i++) { for (int j = 0; j < nums.Count(); j++) { int allNumSum = Convert.ToInt32(allNum[i].Substring(0, 1)) + Convert.ToInt32(allNum[i].Substring(1, 1)) + Convert.ToInt32(allNum[i].Substring(2, 1)); if ( allNumSum == nums[j] ) { result.Remove(allNum[i]); } } } } List<string> result1 = result.Distinct().ToList();//去除重复项 return result1.ToArray(); } }
void DoRestart() { System.Collections.Generic.List<string> args = new System.Collections.Generic.List<string>(); var cmds = System.Environment.GetCommandLineArgs(); foreach (string a in cmds) args.Add(a); args.RemoveAt(0); args.Remove("-restart"); string sArgs = string.Empty; foreach(string s in args) sArgs += (s + " "); sArgs += " -restart"; Process.Start("Elpis.exe", sArgs); }
/// <summary> /// Creates Compound commands if necessary /// </summary> /// <param name="commands"></param> private Command[] OptimizeCommands(SyncEngine engine, IList<Entity> commands) { if (commands == null) throw new ArgumentNullException("commands"); if (commands.Count == 0) return new Command[0]; HashedList<Command> optimizedCommands = new HashedList<Command>(); System.Collections.Generic.List<CompoundCreateCommand> createdCommands = new System.Collections.Generic.List<CompoundCreateCommand>(); int j; for (int i = 0; i < commands.Count; i++) { Entity e = commands[i]; string currentId = e.GetString(SyncUtils.PARENTID); int transaction = e.GetInt32(SyncUtils.TRANSACTION); switch (e.Type) { case SyncUtils.CREATE_ENTITY: string createType = e.GetString(SyncUtils.TYPE); j = i + 1; CompoundCreateCommand ccc = new CompoundCreateCommand(currentId, createType, new List<AttributeCommand>()); CompoundCreateCommand actual = createdCommands.Find(delegate(CompoundCreateCommand toFind) { return toFind.ClientId == ccc.ClientId && toFind.ParentId == ccc.ParentId && toFind.Type == ccc.Type; }); if (actual == null) { createdCommands.Add(ccc); optimizedCommands.Add(ccc); while (j < commands.Count) { string subType = commands[j].GetString(SyncUtils.PARENTTYPE); string subId = commands[j].GetString(SyncUtils.PARENTID); int subTransaction = commands[j].GetInt32(SyncUtils.TRANSACTION); string subCommand = commands[j].Type; if (commands[j].Type == SyncUtils.CREATE_ATTRIBUTE && subId == currentId && subType == createType) { if (subTransaction != transaction) break; ccc.InnerCommands.Add((AttributeCommand)engine.CreateCommand(commands[j])); commands.RemoveAt(j); } else { j++; } } } else { optimizedCommands.Remove(actual); optimizedCommands.Add(ccc); createdCommands.Remove(actual); createdCommands.Add(ccc); } break; case SyncUtils.UPDATE_ATTRIBUTE: string updateType = e.GetString(SyncUtils.PARENTTYPE); j = i + 1; CompoundUpdateCommand cuc = new CompoundUpdateCommand(currentId, updateType, new List<AttributeCommand>()); cuc.InnerCommands.Add((AttributeCommand)engine.CreateCommand(commands[i])); optimizedCommands.Add(cuc); while (j < commands.Count) { string subType = commands[j].GetString(SyncUtils.PARENTTYPE); string subId = commands[j].GetString(SyncUtils.PARENTID); int subTransaction = commands[j].GetInt32(SyncUtils.TRANSACTION); string subCommand = commands[j].Type; if (commands[j].Type == SyncUtils.UPDATE_ATTRIBUTE && subId == currentId && subType == updateType) { if (subTransaction != transaction) break; cuc.InnerCommands.Add((AttributeCommand)engine.CreateCommand(commands[j])); commands.RemoveAt(j); } else { j++; } } break; default: optimizedCommands.Add(engine.CreateCommand(e)); break; } } Command[] result = new Command[optimizedCommands.Count]; for (int i = 0; i < result.Length; i++) result[i] = (Command)optimizedCommands[i]; return result; }