private async Task LoadSuggestions() { await Dispatcher.BeginInvoke((Action)(() => { try { MagicBox.Clear(); allItems1.Clear(); if (System.IO.File.Exists(StaticDeclarations.Historypath)) { string readFile = System.IO.File.ReadAllText(StaticDeclarations.Historypath); dynamic json = JsonConvert.DeserializeObject(readFile); foreach (dynamic item in json) { MagicBox.AddSuggestion(Convert.ToString(item.Title), Convert.ToString(item.Url), mainWindow); allItems1.Add(Convert.ToString(item.Url) + "*" + Convert.ToString(item.Title)); } } } catch (Exception ex) { Console.WriteLine("Load suggestions error: " + ex.Message + " " + ex.Data); } })); }
/// <summary> /// Creates command executions for undefined command type. /// </summary> /// <param name="scvsToHandle">The SCVs to order.</param> /// <param name="fullEntitySet">The set of selected entities.</param> /// <param name="targetPosition">The target position.</param> /// <param name="targetEntityID">The ID of the target entity or -1 if undefined.</param> private IEnumerable <CmdExecutionBase> CreateUndefinedExecutions(RCSet <SCV> scvsToHandle, RCSet <Entity> fullEntitySet, RCNumVector targetPosition, int targetEntityID) { Entity targetEntity = scvsToHandle.First().Scenario.GetElementOnMap <Entity>(targetEntityID, MapObjectLayerEnum.GroundObjects); TerranBuilding targetBuilding = targetEntity as TerranBuilding; MagicBox magicBox = new MagicBox(fullEntitySet, targetPosition); foreach (SCV scv in scvsToHandle.Where(scv => !scv.IsConstructing)) { if (targetBuilding != null && targetBuilding.Owner == scv.Owner && targetBuilding.ConstructionJob != null && !targetBuilding.ConstructionJob.IsFinished && targetBuilding.ConstructionJob.AttachedSCV == null) { /// The target entity is a friendly Terran building that is under construction but its construction is /// not currently in progress -> start a continue build command. yield return(new SCVContinueBuildExecution(scv, targetPosition, targetBuilding.ID.Read())); } else if (targetEntity != null && targetEntity.Owner == scv.Owner && this.IsValidTargetForRepair(targetEntity)) { /// The target entity is a friendly entity and is valid for a repair command -> start a repair command. yield return(new SCVRepairExecution(scv, targetPosition, targetEntityID)); } else if (targetEntity != null && targetEntity.Owner != null && targetEntity.Owner != scv.Owner) { /// The target entity is an enemy entity -> start an attack execution. yield return(new AttackExecution(scv, magicBox.GetTargetPosition(scv), targetEntityID)); } else { /// In any other cases -> start a move execution. yield return(new MoveExecution(scv, magicBox.GetTargetPosition(scv), targetEntityID)); } /// TODO: Handle the cases for Repair, Gather and Return commands! } }
public override void GenerateLoot() { int phrase = Utility.Random(2); switch (phrase) { case 0: this.Say(true, "Bobs for Bob!"); break; case 1: this.Say(true, "Bob will rise!"); break; } // make the magic key Key key = new Key(KeyType.Magic); key.KeyValue = Key.RandomValue(); // make the magic box MagicBox MagicBox = new MagicBox(); MagicBox.Movable = true; MagicBox.KeyValue = key.KeyValue; MagicBox.DropItem(key); PackItem(MagicBox); // add bob's pillow Item pillow = new Item(Utility.RandomList(5029, 5030, 5031, 5032, 5033, 5034, 5035, 5036, 5037, 5038)); pillow.Hue = 23; pillow.Name = "Pillow of The One Bob"; pillow.Weight = 1.0; PackItem(pillow); }
public void WhenMyMethodParamIs3_ThenEventIsRaisedAndNullReturned() { var empty = new MagicBox(); empty.MonitorEvents(); empty.MyMethod(3).Should().BeNull(); empty.ShouldRaise("ErgebnisseReady"); }
protected override void Start() { base.Start(); Movement = new BaseMovement(MaxSpeed); animator = this.gameObject.GetComponent <Animator>(); magics = new MagicBox(this); }
/// <summary> /// Creates patrol executions for the given SCVs. /// </summary> /// <param name="scvsToHandle">The SCVs to patrol.</param> /// <param name="fullEntitySet">The set of selected entities.</param> /// <param name="targetPosition">The target position.</param> private IEnumerable <CmdExecutionBase> CreatePatrolExecutions(RCSet <SCV> scvsToHandle, RCSet <Entity> fullEntitySet, RCNumVector targetPosition) { MagicBox magicBox = new MagicBox(fullEntitySet, targetPosition); foreach (SCV scv in scvsToHandle.Where(scv => !scv.IsConstructing)) { yield return(new PatrolExecution(scv, magicBox.GetTargetPosition(scv))); } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Money") { MagicBox mb = magicBoxTarget.GetComponent <MagicBox>(); mb.deleteMoney(col.gameObject); DispenserCounter dispCounter = dispCounterTarget.GetComponent <DispenserCounter> (); dispCounter.increment(); //dispCounter.counter++; } }
public override void OnInspectorGUI() { DrawDefaultInspector(); MagicBox myScript = (MagicBox)target; if (GUILayout.Button("Set Money to 1000")) { myScript.setMoney(1000); } if (GUILayout.Button("Set Money to 0")) { myScript.setMoney(0); } }
/// <summary> /// Creates repair executions for the given SCVs. /// </summary> /// <param name="scvsToHandle">The reapiring SCVs.</param> /// <param name="targetPosition">The target position.</param> /// <param name="targetEntityID">The ID of the target entity or -1 if undefined.</param> private IEnumerable <CmdExecutionBase> CreateRepairExecutions(RCSet <SCV> scvsToHandle, RCNumVector targetPosition, int targetEntityID) { MagicBox magicBox = new MagicBox(new RCSet <Entity>(scvsToHandle), targetPosition); Entity targetEntity = scvsToHandle.First().Scenario.GetElementOnMap <Entity>(targetEntityID, MapObjectLayerEnum.GroundObjects, MapObjectLayerEnum.AirObjects); if (targetEntity == null) { /// If there is no target entity -> create simple move executions. foreach (SCV scv in scvsToHandle.Where(scv => !scv.IsConstructing)) { yield return(new MoveExecution(scv, magicBox.GetTargetPosition(scv), targetEntityID)); } } /// Create the repair command executions if the target is valid for a repair command. if (this.IsValidTargetForRepair(targetEntity)) { foreach (SCV scv in scvsToHandle.Where(scv => !scv.IsConstructing)) { yield return(new SCVRepairExecution(scv, targetPosition, targetEntityID)); } } }
private async void textBox_KeyDown(object sender, KeyEventArgs e) { try { if (System.IO.File.Exists(StaticDeclarations.Historypath) && textBox.Text != null) { ShowSuggestions(); if (string.IsNullOrEmpty(textBox.Text.Trim()) == false) { MagicBox.Clear(); foreach (string str in allItems1) { if (str.Contains(textBox.Text.Trim())) { string[] split = str.Split(splitChar); await MagicBox.AddSuggestion(split[1], split[0], mainWindow); } } } else if (textBox.Text.Trim() == "") { MagicBox.Clear(); foreach (string str in allItems1) { string[] split = str.Split(splitChar); await MagicBox.AddSuggestion(split[1], split[0], mainWindow); } } StaticFunctions.AnimateHeight(ListContainer.Height, MagicBox.ItemsCount * MagicBox.ItemHeight, ListContainer, 0.2); } else { ListContainer.Height = 0; HideSuggestions(); } } catch (Exception ex) { Console.WriteLine("Listbox find suggestions error: " + ex.Message + " " + ex.Data); } if (e.Key == Key.Down) { MagicBox.Focus(); } if (e.Key == Key.Enter) { dynamic textArray = textBox.Text.Split(); if ((textBox.Text.Contains(".") && !textBox.Text.Contains(" ") && !textBox.Text.Contains(" .") && !textBox.Text.Contains(". ")) || textArray[0].Contains(":/") || textArray[0].Contains(":\\")) { WebView.Load(textBox.Text); } else { try { dynamic dyn = JsonConvert.DeserializeObject(System.IO.File.ReadAllText("settings.json")); if (Convert.ToString(dyn.SE) == "Google") { textBox.Text = textBox.Text.Replace(textBox.Text, "http://google.com/#q=" + textBox.Text); WebView.Load(textBox.Text); } if (Convert.ToString(dyn.SE) == "DuckDuckGo") { textBox.Text = textBox.Text.Replace(textBox.Text, "https://duckduckgo.com/?q=" + textBox.Text); WebView.Load(textBox.Text); } if (Convert.ToString(dyn.SE) == "Bing") { textBox.Text = textBox.Text.Replace(textBox.Text, "http://www.bing.com/search?q=" + textBox.Text); WebView.Load(textBox.Text); } } catch (Exception ex) { Console.WriteLine("textBox KeyDown Key.Enter error: " + ex.Message + " " + ex.Data); } } HideSuggestions(); } }
public new void Draw(SpriteBatch spriteBatch) { Update(Game1.gameTime);// on met a jour spriteBatch.Draw(texture, FooterPosition, Color.White); //on dessine toutes les infos if (GamePage.player.weapon != null) { if (ammo != null) { spriteBatch.DrawString(font, ammo, ammoPosition, Color.White, 0, Vector2.Zero, 0.26f, SpriteEffects.None, 1f); } } spriteBatch.DrawString(font, health.ToString(), healthPosition, Color.White, 0, Vector2.Zero, 0.26f, SpriteEffects.None, 1f); if (GamePage.player.weapon != null) { if (GamePage.player.weapon.NeedReloading) { spriteBatch.DrawString(font, reloading, ReloadingPosition, Color.FloralWhite, 0, new Vector2(font.MeasureString(reloading).X / 2, font.MeasureString(reloading).Y), 0.5f, SpriteEffects.None, 1f); } } spriteBatch.Draw(Body, BodyPosition, null, Color.White, 0f, Vector2.Zero, BodyScale, SpriteEffects.None, 1f); //on dessine le message si le personnage est sur une "weaponPic" #region weaponPics for (var i = 0; i < GamePage.PicList.Count; i++) { if (GamePage.PicList[i] is WeaponPic) { pic = (WeaponPic)GamePage.PicList[i]; } else if (GamePage.PicList[i] is ClothPic) { pic = (ClothPic)GamePage.PicList[i]; } if (pic.takeMsg) { spriteBatch.DrawString(font, takeWeapon, weaponPicPosition, Color.Wheat, 0, new Vector2(font.MeasureString(takeWeapon).X / 2, font.MeasureString(takeWeapon).Y), 0.5f, SpriteEffects.None, 0.2f); } } #endregion //on dessine le message si le personnage est sur une "magicBox" #region magicBox for (var i = 0; i < GamePage.BonusList.Count; i++) { Bonus bonus = GamePage.BonusList[i]; if (bonus is MagicBox) { MagicBox magicBox = (MagicBox)bonus; if (magicBox.pressButtonMsg) { spriteBatch.DrawString(font, pressButton, weaponPicPosition, Color.Wheat, 0, new Vector2(font.MeasureString(takeWeapon).X / 2, font.MeasureString(takeWeapon).Y), 0.5f, SpriteEffects.None, 0.2f); } } else if (bonus is ClothBox) { ClothBox clothBox = (ClothBox)bonus; if (clothBox.pressButtonMsg) { spriteBatch.DrawString(font, pressButton, weaponPicPosition, Color.Wheat, 0, new Vector2(font.MeasureString(takeWeapon).X / 2, font.MeasureString(takeWeapon).Y), 0.5f, SpriteEffects.None, 0.2f); } } } #endregion }