public override void Apply(GameObject target, ActionOptions options) { //SceneManager.GetActiveScene(); var sceneOptions = (SwitchLevelOptions)options; GameStateManager.instance.SwitchScene(sceneOptions.sceneName, sceneOptions.spawnId); }
public ActionOptions GetActionOptionById(int actOptId) { EntityKey key = new EntityKey("SimpleFlowEntities.ActionOptions", "ActionOptionId", actOptId); ActionOptions actOpt = model.GetObjectByKey(key) as ActionOptions; return(actOpt); }
private void CheckInitialize(SerializedProperty property, GUIContent label) { if (_actionProperty == null) { var target = property.serializedObject.targetObject; _actionProperty = fieldInfo.GetValue(target) as ActionProperty; if (_actionProperty == null) { _actionProperty = new ActionProperty(); fieldInfo.SetValue(target, _actionProperty); } _options = _actionProperty.options; _action = _actionProperty.action; CheckOptions(); _foldout = EditorPrefs.GetBool("Options"); } if (_actionProperty.options != null) { foreach (var field in _actionProperty.options.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)) { _optionValues[field.Name] = field.GetValue(_actionProperty.options); //Console.WriteLine("{0} = {1}", field.Name, field.GetValue(structValue)); } } }
protected override void AppendExitOption() { int lastKeyValue = ActionOptions.Keys.Last(); lastKeyValue++; ActionOptions.Add(lastKeyValue, new Option(Actions.DoNothing, "Exit / Back")); }
public override void Apply(GameObject target, ActionOptions options) { var targetInventory = target.GetComponent <Inventory>(); var ownerInventory = owner.GetComponent <Inventory>(); var items = ownerInventory.TakeItems(); targetInventory.AddItems(items); }
/// <summary> /// Performs a HTTP request /// </summary> /// <param name="request"></param> /// <param name="options"></param> /// <returns>Text received</returns> protected string HttpGet(string[,] request, ActionOptions options) { string url = BuildUrl(request, options); lastGetUrl = url; return(HttpGet(url)); }
public static Task <bool> DisplayToastAsync(this Page page, ActionOptions actionOptions) { var snackBar = new SnackBar(); var arguments = actionOptions ?? new ActionOptions(); var options = new SnackBarOptions(arguments.MessageOptions, arguments.Duration, arguments.BackgroundColor, arguments.IsRtl, null); snackBar.Show(page, options); return(options.Result.Task); }
public void Initialise(ActionOptions actionOptions) { labelDescription.Text = ""; m_actionOptions = actionOptions; List<string> descriptions = GetListOfActionOptionDescriptions(); UserActionControlHelper userActionControlHelper = new UserActionControlHelper(this); labelDescription.Text = GetActionOptionDescription(descriptions); FixHeightIfNeeded(); }
public override void Apply(GameObject target, ActionOptions options) { Debug.Log("Test Action!"); var testOptions = (TestOptions)options; if (testOptions != null && testOptions.testObject != null) { Destroy(testOptions.testObject); } }
public override bool Check(GameObject target, ActionOptions options) { var targetInventory = target.GetComponent <Inventory>(); var ownerInventory = owner.GetComponent <Inventory>(); if (targetInventory != null && ownerInventory != null) { return(true); } return(false); }
public ActionOption GetOption(ActorState state) { if (state.AmountToCall == state.SmallBlind && state.Odds > 0.52) { return new ActionOption(GameAction.Call, state.AmountToCall * (state.Odds - 0.5)); } var options = new ActionOptions(); if (state.NoAmountToCall) { options.Add(new ActionOption(GameAction.Check, state.Odds * state.Pot, 1)); } else { options.Add(GameAction.Call); } if (state.AmountToCall != state.SmallBlind) { var step = 1 + ((state.MaximumRaise - state.BigBlind) >> 4); for (var raise = state.BigBlind; raise <= state.MaximumRaise; raise += step) { options.Add(GameAction.Raise(raise)); } } // Only add a fold if we have to call, and there is a change that we // can play a next round. if (!state.NoAmountToCall && state.OtherPot >= state.BigBlind) { options.Add(GameAction.Fold); } Node test = state.ToNode(); options.Sort(test, Nodes); var best = SelectOption(options); if (best.Action != GameAction.Fold) { if (best.Action != GameAction.Check) { test.Profit = (short)state.OwnPot; test.Action = best.Action; test.IsNew = true; Buffer.Add(test); } } else if(options.Count > 1) { best = new ActionOption(GameAction.Fold, options[1].Profit, options[1].Weight); } return best; }
public void Initialise(ActionOptions actionOptions) { m_actionOptions = actionOptions; List<string> descriptions = GetListOfDescriptions(); UserActionControlHelper userActionControlHelper = new UserActionControlHelper(this); string description = GetDescriptionToUse(descriptions); labelDescription.Text = description; CalculateHeight(); }
void HandleQueuedStationActions() { if (CanDoQueuedAction()) { if (ActionQueued == ActionOptions.StopCurrent) { if (RadioStation.CurrentPlaying != null) { // Turn off custom radio RadioStation.CurrentPlaying.Stop(); // Enable last played vanilla radio RadioNativeFunctions.SET_RADIO_TO_STATION_INDEX(lastVanillaStationPlayed); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); RadioStation.CurrentPlaying = null; lastRadioWasCustom = false; } } else if (ActionQueued == ActionOptions.PlayQueued) { if (RadioStation.NextQueuedStation != null && RadioStation.NextQueuedStation != RadioStation.CurrentPlaying) { // Enable custom radio if (RadioStation.CurrentPlaying != null) { RadioStation.CurrentPlaying.Stop(); } RadioStation.CurrentPlaying = RadioStation.NextQueuedStation; RadioStation.CurrentPlaying.Play(); RadioStation.NextQueuedStation = null; // Set vanilla radio to Off but save what station was playing beforehand lastVanillaStationPlayed = RadioNativeFunctions.GET_PLAYER_RADIO_STATION_INDEX(); RadioNativeFunctions.SetVanillaRadioOff(); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); lastRadioWasCustom = true; } } // Set to DoNothing since queued action is completed ActionQueued = ActionOptions.DoNothing; } }
public ActionButtonNode GetOptionTreeRoot(Actor actor) { ActionButtonNode root = new ActionButtonNode(); root.label = ValueLabel(); DecorateOption(root); root.choice = this; PopulatePathChildren(root, ActionOptions.ToList(), actor); if (UseLimitReachedUntilLongRest) { root.disabled = true; root.disabledReason = "You have to wait until a long rest to use this again."; } return(root); }
/// <summary> /// /// </summary> /// <param name="get"></param> /// <param name="post"></param> /// <param name="options"></param> /// <returns></returns> protected string HttpPost(string[,] get, string[,] post, ActionOptions options) { string url = BuildUrl(get, options); string query = BuildQuery(post); byte[] postData = Encoding.UTF8.GetBytes(query); HttpWebRequest req = CreateRequest(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postData.Length; using (Stream rs = req.GetRequestStream()) { rs.Write(postData, 0, postData.Length); } return(GetResponseString(req)); }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="options"></param> /// <returns></returns> protected string AppendOptions(string url, ActionOptions options) { if ((options & ActionOptions.CheckMaxlag) > 0 && Maxlag > 0) { url += "&maxlag=" + Maxlag; } if ((options & ActionOptions.RequireLogin) > 0) { url += "&assert=user"; } if ((options & ActionOptions.CheckNewMessages) > 0) { url += "&meta=userinfo&uiprop=hasmsg"; } return(url); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.DrawRect(position, new Color(0.6f, 0.6f, 0.6f)); EditorGUI.BeginChangeCheck(); var actionPos = position; actionPos.height = 17; var action = (BaseAction)EditorGUI.ObjectField(actionPos, "Action", _actionProperty.action, typeof(BaseAction), true); if (EditorGUI.EndChangeCheck()) { _action = action; if (!_action) { _actionProperty.action = null; _actionProperty.options = null; return; } _actionProperty.action = _action; _options = _actionProperty.options; CheckOptions(); } else if (_action != null && _options != null) { position.y += 17; var foldoutRect = position; foldoutRect.width -= 2 * 18.0f; foldoutRect.height = 17.0f; _foldout = EditorGUI.Foldout(foldoutRect, _foldout, new GUIContent("Options"), true); EditorPrefs.SetBool("Options", _foldout); position.y += 17; if (_foldout) { FillOptions(position); } } }
void HandleRadioWheelToggle() { if (WheelVars.CurrentRadioWheel.Visible) { ActionQueued = ActionOptions.StopCurrent; RadioStation.NextQueuedStation = null; SetActionDelay(Config.WheelActionDelay); // Switch to vanilla radio WheelVars.CurrentRadioWheel.Visible = false; lastRadioWasCustom = false; } else { // Switch to custom radio WheelVars.CurrentRadioWheel.Visible = true; lastRadioWasCustom = true; } }
public bool CanFillOptions(Actor actor) { ActionButtonNode root = new ActionButtonNode(); root.label = ValueLabel(); bool canFill = false; CheckInOptionLeafAction checkin = (leaf) => { Debug.Log("found a leaf!: " + leaf.label); //any leaf will do... canFill = true; }; DeadEndOptionLeafAction deadend = (leaf, reason) => { Debug.Log("Dead end: " + leaf.label); Debug.Log("reason: " + reason); }; CheckForLeaves(root, ActionOptions.ToList(), actor, checkin, deadend); return(canFill); }
private void DeserializeOptions() { if (action == null || _serializedOptions == null) { return; } if (_options == null) { _options = action.GetOptions(); } if (_options == null) { return; } foreach (var field in _options.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)) { if (field.FieldType == typeof(GameObject)) { if (_serializedGameObjectOptions.ContainsKey(field.Name)) { field.SetValue(_options, _serializedGameObjectOptions[field.Name]); } } else if (_serializedOptions.ContainsKey(field.Name)) { var fieldType = field.FieldType; TypeConverter typeConverter = TypeDescriptor.GetConverter(fieldType); object fieldValue = typeConverter.ConvertFromString(_serializedOptions[field.Name]); field.SetValue(_options, fieldValue); } } }
protected override void AppendExitOption() { ActionOptions.Add("Exit", new Option(Actions.DoNothing, "Exit / Back")); }
void ReadSettings() { Action = (ActionOptions)Settings.Default.Action; Guard = (GuardOptions)Settings.Default.Guard; Stand = (StandOptions)Settings.Default.Stand; CounterHit = (CounterHitOptions)Settings.Default.CounterHit; Stun = (StunOptions)Settings.Default.Stun; SAGauge = (SAGaugeOptions)Settings.Default.SAGauge; AttackData = (AttackDataOptions)Settings.Default.AttackData; InputDisplay = (InputDisplayOptions)Settings.Default.InputDisplay; LagSimulation = Settings.Default.LagSimulation; dgvPlayer1.Visible = (InputDisplay != InputDisplayOptions.Off); lblComboDamage.Visible = lblComboDamageT.Visible = lblLastDamage.Visible = lblLastDamageT.Visible = lblMaxCombo.Visible = lblMaxComboT.Visible /*= lblMaxDamage.Visible = lblMaxDamageT.Visible */ = (AttackData == AttackDataOptions.On); lblComboDamage.Text = "0 (0%)"; switch (InputDisplay) { case InputDisplayOptions.Off: dgvPlayer1.Rows.Clear(); dgvPlayer2.Rows.Clear(); formWidth = 180; break; case InputDisplayOptions.On: formWidth = 180; dgvPlayer2.Rows.Clear(); break; case InputDisplayOptions.Dual: formWidth = 360; break; } SetWindowPos(this.Handle, Game.Window, Game.WindowCoords.Left - formWidth, Game.WindowCoords.Top, formWidth, Game.WindowCoords.Height, SWP_SHOWWINDOW); if (AttackData == AttackDataOptions.On) { MaxDamage = 0; MaxComboLength = 0; P2HealthBeforeCurrentCombo = 160; DateTime LastComboEndedTime = DateTime.Now.AddDays(99); } KeyboardManager.LoadStateOnPlayback = Settings.Default.LoadStateOnPlayback; }
/// <summary> /// Performs a HTTP request /// </summary> /// <param name="request"></param> /// <param name="options"></param> /// <returns>Text received</returns> protected string HttpGet(Dictionary<string, string> request, ActionOptions options) { string url = BuildUrl(request, options); lastGetUrl = url; return HttpGet(url); }
public void SetupRadio() { // Get folders in script's main folder "Custom Radio Stations" string[] wheelDirectories = Directory.GetDirectories(mainPath, "*", SearchOption.TopDirectoryOnly); foreach (var wheelDir in wheelDirectories) { Logger.Log("Loading " + wheelDir); Logger.Log("Checking if " + wheelDir + "\\settings.ini exists"); var wheelIni = Config.LoadWheelINI(wheelDir); // Create wheel obj Wheel radioWheel = new Wheel("Radio Wheel", wheelDir, 0, 0, new System.Drawing.Size(wheelIni.iconX, wheelIni.iconY), 200, wheelIni.wheelRadius); // Get folders in script's main folder "Custom Radio Stations" string[] stationDirectories = Directory.GetDirectories(wheelDir, "*", SearchOption.TopDirectoryOnly); Logger.Log("Number of stations: " + stationDirectories.Count()); // Specify file extensions to search for in the next step var extensions = new List <string> { ".mp3", ".wav", ".flac", ".lnk" }; // Keep count of the number of station folders with actual music files int populatedStationCount = 0; // Generate wheel categories for each folder, which will be our individual stations on the wheel foreach (var stationDir in stationDirectories) { Logger.Log("Loading " + stationDir); // Get all files that have the above-mentioned extensions. var musicFilePaths = Directory.GetFiles(stationDir, "*.*", SearchOption.TopDirectoryOnly) .Where(x => extensions.Contains(Path.GetExtension(x))); // Don't make a station out of an empty folder if (musicFilePaths.Count() == 0) { Logger.Log("Skipping " + Path.GetFileName(stationDir) + " as there are no music files."); continue; } // Increase count populatedStationCount++; WheelCategory stationCat = new WheelCategory(Path.GetFileName(stationDir)); radioWheel.AddCategory(stationCat); WheelCategoryItem stationItem = new WheelCategoryItem(stationCat.Name); stationCat.AddItem(stationItem); RadioStation station = new RadioStation(stationCat, musicFilePaths); // Add wheel category-station combo to a station list StationWheelPair pair = new StationWheelPair(radioWheel, stationCat, station); StationWheelPair.List.Add(pair); // Get description pair.LoadStationINI(Path.Combine(stationDir, "station.ini")); radioWheel.OnCategoryChange += (sender, selectedCategory, selectedItem, wheelJustOpened) => { // HandleRadioWheelToggle() handles what happens when the wheel is opened. // So we will only use this anonymous method for when the station is actually changed. //if (wheelJustOpened) return; if (selectedCategory == stationCat) { // If there is no input for a short amount of time, set the selected station as next to play ActionQueued = ActionOptions.PlayQueued; RadioStation.NextQueuedStation = station; // If radio is still being decided, add delay before station changes SetActionDelay(Config.WheelActionDelay); lastRadioWasCustom = true; } }; radioWheel.OnItemChange += (sender, selectedCategory, selectedItem, wheelJustOpened, goTo) => { if (wheelJustOpened) { return; } if (radioWheel.Visible && radioWheel == WheelVars.CurrentRadioWheel && WheelVars.NextQueuedWheel == null) { if (goTo == GoTo.Next) { radioWheel.Visible = false; WheelVars.NextQueuedWheel = WheelVars.RadioWheels.GetNext(radioWheel); } else if (goTo == GoTo.Prev) { radioWheel.Visible = false; WheelVars.NextQueuedWheel = WheelVars.RadioWheels.GetPrevious(radioWheel); } } }; } if (populatedStationCount > 0) { WheelVars.RadioWheels.Add(radioWheel); radioWheel.Origin = new Vector2(0.5f, 0.45f); radioWheel.SetCategoryBackgroundIcons(iconBgPath, Config.IconBG, Config.IconBgSizeMultiple, iconhighlightPath, Config.IconHL, Config.IconHlSizeMultiple); radioWheel.CalculateCategoryPlacement(); } Logger.Log(@"/\/\/\/\/\/\/\/\/\/\/\/\/\/\"); } if (WheelVars.RadioWheels.Count > 0) { WheelVars.CurrentRadioWheel = WheelVars.RadioWheels[0]; } else { UI.ShowSubtitle("No music found in Custom Radio Stations. " + "Please add music and reload script with the INS key."); Logger.Log("ERROR: No music found in any station directory. Aborting script..."); Tick -= OnTick; } }
void SetupEvents() { GeneralEvents.OnPlayerEnteredVehicle += (veh) => { bool vehWasEngineRunning = veh.EngineRunning; // Make vanilla radio silent RadioNativeFunctions.VanillaRadioFadedOut(true); DateTime enteredTime = DateTime.Now; while (!veh.EngineRunning || DateTime.Now > enteredTime.AddSeconds(10)) { //UI.ShowSubtitle((enteredTime.AddSeconds(10) - DateTime.Now).TotalMilliseconds.ToString()); vehWasEngineRunning = false; Yield(); } // In case the timeout above caused the loop to break, // We will not continue because the vehicle is dead. if (!veh.EngineRunning) { return; } if (UsedVehiclesManager.IsUsedVehicle(veh)) { canResumeCustomStation = false; if (UsedVehiclesManager.GetVehicleStationInfo(veh) == null) { // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = false; lastRadioWasCustom = false; return; } ActionQueued = ActionOptions.PlayQueued; UsedVehiclesManager.SetLastStationNow(veh); SetActionDelay(Config.WheelActionDelay + 300); lastRadioWasCustom = true; //UI.ShowSubtitle("Started playback"); } else { // If the engine was running, don't mess with it. // Since I can't figure out how to see if a vehicle // was emitting a station, I'll just not mess with it. if (vehWasEngineRunning) { //UI.ShowSubtitle("RADIO IS ENABLED: " + RadioNativeFunctions.GET_PLAYER_RADIO_STATION_INDEX().ToString()); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = false; lastRadioWasCustom = false; return; } int chooseRandom = RadioStation.random.Next(10); //UI.ShowSubtitle("RANDOM: " + chooseRandom.ToString()); // 70% chance to play a custom station. if (chooseRandom >= 3) { ActionQueued = ActionOptions.PlayQueued; // Set the queued radio station randomly, chosen from stationPairList. chooseRandom = RadioStation.random.Next(StationWheelPair.List.Count); UsedVehiclesManager.UpdateVehicleWithStationInfo(veh, StationWheelPair.List[chooseRandom]); UsedVehiclesManager.SetLastStationNow(veh); SetActionDelay(Config.WheelActionDelay + 300); canResumeCustomStation = false; lastRadioWasCustom = true; } else { UsedVehiclesManager.UpdateVehicleWithStationInfo(veh, null); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = false; lastRadioWasCustom = false; } } }; GeneralEvents.OnPlayerExitedVehicle += (veh) => { if (veh == null) { return; } /*if (!IsMobileRadioEnabled()) * { * lastRadioWasCustom = IsCurrentCustomStationPlaying() ? true : false; * }*/ // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); UsedVehiclesManager.UpdateVehicleWithStationInfo(veh, lastRadioWasCustom ? StationWheelPair.List.Find(x => x.Category == WheelVars.CurrentRadioWheel.SelectedCategory) : null); }; /*GeneralEvents.OnPlayerVehicleEngineTurnedOn += (veh) => * { * if (IsCurrentCustomStationPlaying()) return; * * if (lastRadioWasCustom && canResumeCustomStation) * { * ActionQueued = ActionOptions.PlayQueued; * * // Set the queued radio station based on the current category selected, using stationPairList. * RadioStation.NextQueuedStation = StationWheelPair.List.Find(x => x.Category == WheelVars.CurrentRadioWheel.SelectedCategory).Station; * * SetActionDelay(Config.WheelActionDelay); * * canResumeCustomStation = false; * } * };*/ }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="options"></param> /// <returns></returns> protected string BuildUrl(string[,] request, ActionOptions options) { string url = ApiURL + "?format=xml" + BuildQuery(request); return(AppendOptions(url, options)); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="options"></param> /// <returns></returns> protected string BuildUrl(string[,] request, ActionOptions options) { string url = ApiURL + "?format=xml" + BuildQuery(request); return AppendOptions(url, options); }
/// <summary> /// Performs a HTTP request /// </summary> /// <param name="request"></param> /// <param name="options"></param> /// <returns>Text received</returns> protected string HttpGet(string[,] request, ActionOptions options) { string url = BuildUrl(request, options); return HttpGet(url); }
public bool IsChoiceValid(T choice) { return(ActionOptions.ContainsKey(choice)); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="options"></param> /// <returns></returns> protected string BuildUrl(Dictionary<string, string> request, ActionOptions options) { AppendOptions(request, options); return ApiURL + "?format=xml" + BuildQuery(request); }
public virtual bool Check(GameObject target, ActionOptions options) { return(true); }
/// <summary> /// Reset the action options of the control and set the /// controls associated with the options accordingly /// </summary> /// <param name="actionOptions"></param> public void Initialise(ActionOptions actionOptions, bool allowOverride) { m_actionOptions = actionOptions; m_allowOverride = allowOverride; InitialiseUiComponents(); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="options"></param> protected void AppendOptions(Dictionary<string, string> request, ActionOptions options) { if ((options & ActionOptions.CheckMaxlag) > 0 && Maxlag > 0) { request.Add("maxlag", Maxlag.ToString()); } if ((options & ActionOptions.RequireLogin) > 0) { request.Add("assert", "user"); } if (request.ContainsKey("action") && request["action"] == "query" && ((options & ActionOptions.CheckNewMessages) > 0)) { if (request.ContainsKey("meta")) { request["meta"] += "|userinfo"; } else { request.Add("meta", "userinfo"); } if (Variables.NotificationsEnabled) { request["meta"] += "|notifications"; } request.Add("uiprop", "hasmsg"); request.Add("notprop", "count"); } }
protected string AppendOptions(string url, ActionOptions options) { if ((options & ActionOptions.CheckMaxlag) > 0 && Maxlag > 0) url += "&maxlag=" + Maxlag; if ((options & ActionOptions.RequireLogin) > 0) url += "&assert=user"; if ((options & ActionOptions.CheckNewMessages) > 0) url += "&meta=userinfo&uiprop=hasmsg"; return url; }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="request"></param> /// <param name="options"></param> /// <returns></returns> protected string AppendOptions(string url, string[,] request, ActionOptions options) { if ((options & ActionOptions.CheckMaxlag) > 0 && Maxlag > 0) { url += "&maxlag=" + Maxlag; } if ((options & ActionOptions.RequireLogin) > 0) { url += "&assert=user"; } if (GetAction(request) == "query" && ((options & ActionOptions.CheckNewMessages) > 0)) { url += "&meta=userinfo|notifications&uiprop=hasmsg¬prop=count"; } return url; }
/// <summary> /// /// </summary> /// <param name="get"></param> /// <param name="post"></param> /// <param name="options"></param> /// <returns></returns> protected string HttpPost(string[,] get, string[,] post, ActionOptions options) { string url = BuildUrl(get, options); string query = BuildQuery(post); byte[] postData = Encoding.UTF8.GetBytes(query); HttpWebRequest req = CreateRequest(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postData.Length; using (Stream rs = req.GetRequestStream()) { rs.Write(postData, 0, postData.Length); } return GetResponseString(req); }
public virtual void Apply(GameObject target, ActionOptions options) { }
public override bool Check(GameObject target, ActionOptions options) { return(true); }
public void WhenIChooseTheSaveOption(ActionOptions option) { // test code }
/// <summary>Select the option to play.</summary> /// <remarks> /// Returns a random profitable if any, otherwise the best case. /// </remarks> private ActionOption SelectOption(ActionOptions options) { var best = options[0]; var profitable = options .Where(option => option.IsProfitable) .ToArray(); if (profitable.Length > 1) { var weights = new double[profitable.Length]; var sum = 0.0; for (var index = 0; index < weights.Length; index++) { weights[index] = sum; sum += profitable[index].WeightedProfit; } var pick = Rnd.NextDouble(sum); for (var index = 0; index < weights.Length; index++) { if (pick < weights[index]) { break; } best = profitable[index]; } } return best; }
/// <summary> /// /// </summary> /// <param name="get"></param> /// <param name="post"></param> /// <param name="options"></param> /// <returns></returns> protected string HttpPost(Dictionary<string, string> get, Dictionary<string, string> post, ActionOptions options) { string url = BuildUrl(get, options); Tools.WriteDebug("ApiEdit::HttpPost", url); lastGetUrl = url; lastPostParameters = post; string query = BuildQuery(post); byte[] postData = Encoding.UTF8.GetBytes(query); HttpWebRequest req = CreateRequest(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postData.Length; using (Stream rs = req.GetRequestStream()) { rs.Write(postData, 0, postData.Length); } return GetResponseString(req); }