public override bool ReflexCompatible(ReflexData clip, ProgrammingElement replacedElement) { bool compatible = false; Actuator actuator = clip.Actuator; Sensor sensor = clip.Sensor; if (actuator != null && sensor != null) { Actuator.Category category = Actuator.Category.Direction | Actuator.Category.TargetlessDirection; if ((actuator.category & category) != 0 && (sensor.category & Sensor.Category.GamePad) != 0) { compatible = true; // check the filters for compatibility against our type for (int indexFilter = 0; indexFilter < clip.Filters.Count; indexFilter++) { Filter filter = clip.Filters[indexFilter] as Filter; if (filter != null) { if (!filter.ElementCompatible(clip, this)) { compatible = false; break; } } } } } return(compatible); }
/// <summary> /// Rank and sort the set of examples relevant to the provided actor, reflex, /// and selection. /// </summary> /// <param name="actor">Optional</param> /// <param name="reflex">Required</param> /// <param name="selected">Optional</param> public static void RankAndSortProgrammingExamples( GameActor actor, ReflexData reflex, ProgrammingElement selected) { Debug.Assert(reflex != null, "The reflex argument must not be null."); instance.InternalRankAndSortProgrammingExamples(actor, reflex, selected); }
} // end of UIGrid2DExampleElement Render() #endregion #region Internal public override void LoadContent(bool immediate) { // Load the normal map texture. if (selectedBackground == null) { selectedBackground = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpCard\GreenSquare"); } if (unselectedBackground == null) { unselectedBackground = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpCard\GreySquare"); } if (tiles == null) { tiles = new List <Texture2D>(); // For now, we're assuming there's only one reflex. ReflexData reflex = example.reflexes[0]; // Sensor if (reflex.Sensor != null) { tiles.Add(CardSpace.Cards.CardFaceTexture(reflex.sensorUpid)); } // Filters if (reflex.Filters != null) { for (int i = 0; i < reflex.Filters.Count; i++) { tiles.Add(CardSpace.Cards.CardFaceTexture(reflex.filterUpids[i])); } } // Actuator if (reflex.Actuator != null) { tiles.Add(CardSpace.Cards.CardFaceTexture(reflex.actuatorUpid)); } // Selector if (reflex.Selector != null) { tiles.Add(CardSpace.Cards.CardFaceTexture(reflex.selectorUpid)); } // Modifiers if (reflex.Modifiers != null) { for (int i = 0; i < reflex.Modifiers.Count; i++) { tiles.Add(CardSpace.Cards.CardFaceTexture(reflex.modifierUpids[i])); } } } } // end of UIGrid2DExampleElement LoadContent()
public override bool MatchAction(Reflex reflex, out object param) { // See if there's a filter defining which player we should be. If not, use bit0. if (playerId == GamePadSensor.PlayerId.Dynamic) { playerId = GamePadSensor.PlayerId.All; ReflexData data = reflex.Data; for (int i = 0; i < data.Filters.Count; i++) { if (data.Filters[i] is PlayerFilter) { playerId = ((PlayerFilter)data.Filters[i]).playerIndex; } } } bool shaken = false; #if !NETFX_CORE Microbit bit = MicrobitExtras.GetMicrobitOrNull(playerId); if (bit != null) { int currGeneration = bit.State.Generation; if (currGeneration != 0 && currGeneration != prevGeneration) { Vector3 currAccel = bit.State.Acc; Vector3 accelDiff = currAccel - prevAccel; prevAccel = currAccel; prevGeneration = currGeneration; float strength = accelDiff.Length(); // Default range [1, 2] float minStrength = 1; float maxStrength = 2; // 2G - This is the maximum length of micro:bit's accelerometer vector (configured in kodu-microbit.hex). int stronglyCount = reflex.Data.GetFilterCount("filter.strongly"); // Range adjustment upward to [1.5, 2] minStrength += stronglyCount * 0.166f; int weaklyCount = reflex.Data.GetFilterCount("filter.weakly"); // Range adjustment downward to [0.075, 0.2] minStrength -= weaklyCount * 0.308f; maxStrength -= weaklyCount * 0.6f; shaken = (strength >= minStrength && strength <= maxStrength); //System.Diagnostics.Debug.WriteLine(String.Format("range [{0},{1}], value {2}, {3}", minStrength, maxStrength, strength, shaken ? "SHAKE!" : "")); } } #endif param = shaken; return(shaken); }
public override bool ReflexCompatible(GameActor actor, ReflexData reflex, ProgrammingElement replacedElement, bool allowArchivedCategories) { // An actuator must exist before any modifiers may appear. if (reflex.Actuator == null || reflex.Actuator is NullActuator) { return(false); } // Check compatibility with actor. { if (!this.ActorCompatible(actor)) { return(false); } } // Check modifier instance count { string selectionUpid = (replacedElement != null) ? replacedElement.upid : null; int instanceCount = reflex.GetModifierCount(this.upid); // Don't consider the selected one if it's of our type, since we'd be replacing it. if (selectionUpid == this.upid) { instanceCount -= 1; } if (instanceCount >= this.MaxInstanceCount) { return(false); } } // Check modifier class count { Type selectionType = (replacedElement != null) ? replacedElement.GetType() : null; int count = reflex.GetModifierCountByType(this.GetType()); // Don't consider the selected one if it's of our type, since we'd be replacing it. if (selectionType == this.GetType()) { count -= 1; } if (count >= this.MaxClassCount) { return(false); } } return(base.ReflexCompatible(actor, reflex, replacedElement, allowArchivedCategories)); }
protected void CleanseDependantCards(ReflexCard reflexCard, ProgrammingElement pendingCard) { ReflexData clip = reflex.Copy(); if (reflexCard.cardType == CardSpace.CardType.Sensor) { if (pendingCard != null) { clip.Sensor = pendingCard as Sensor; } else { clip.Sensor = null; } } if (reflexCard.cardType == CardSpace.CardType.Actuator) { // Kind of a hack here to deal with mixing Switch and Inline. If either // of these actuators are removed and replaced with the other then we need // to clear the Modifier list to prevent loops and self-referential inlines. if (pendingCard != null && reflexCard != null) { if ((pendingCard.upid == "actuator.inlinetask" && reflexCard.Card.upid == "actuator.switchtask") || (pendingCard.upid == "actuator.switchtask" && reflexCard.Card.upid == "actuator.inlinetask")) { clip.Modifiers.Clear(); } } if (pendingCard != null) { clip.Actuator = pendingCard as Actuator; } else { clip.Actuator = null; } } if (reflexCard.cardType == CardSpace.CardType.Selector) { if (pendingCard != null) { clip.Selector = pendingCard as Selector; } else { clip.Selector = null; } } reflex.Paste(clip); }
public override bool MatchAction(Reflex reflex, out object param) { float result = 0; // See if there's a filter defining which player we should be. If not, use pad0. if (playerId == GamePadSensor.PlayerId.Dynamic) { playerId = GamePadSensor.PlayerId.All; ReflexData data = reflex.Data; for (int i = 0; i < data.Filters.Count; i++) { if (data.Filters[i] is PlayerFilter) { playerId = ((PlayerFilter)data.Filters[i]).playerIndex; } } } #if !NETFX_CORE Microbit bit = MicrobitExtras.GetMicrobitOrNull(playerId); if (bit != null) { // Get the correct button. switch (pin) { case MicrobitPin.Pin1: result = bit.ReadPinValue(0, Microbit.EPinOperatingMode.Digital); break; case MicrobitPin.Pin2: result = bit.ReadPinValue(1, Microbit.EPinOperatingMode.Digital); break; case MicrobitPin.Pin3: result = bit.ReadPinValue(2, Microbit.EPinOperatingMode.Digital); break; } } #endif // Return as a parameter a vector that can be used for input to the movement system, so // that players can drive and turn bots using gamepad buttons. param = new Vector2(0, result / 255.0f); return(result != 0); }
private void RankAndSortProgrammingExamples( RankSettings settings, GameActor actor, ProgrammingElement selected, ReflexData reflex) { for (int i = 0; i < programmingExamples.Count; ++i) { ExamplePage example = programmingExamples[i]; RankProgrammingExample( example, settings, actor, selected, reflex); } programmingExamples.Sort(CompareByRank); }
private void InternalRankAndSortProgrammingExamples( GameActor actor, ReflexData reflex, ProgrammingElement selected) { RankSettings settings = new RankSettings(); settings.sensorRank = 2; settings.selectorRank = 2; settings.filterRank = 2; settings.actuatorRank = 2; settings.modifierRank = 2; settings.otherFilterRank = 1; settings.otherModifierRank = 1; if (selected is Filter) { settings.filterRank = 10; } else if (selected is Actuator) { settings.actuatorRank = 10; } else if (selected is Modifier) { settings.modifierRank = 10; } else if (selected is Selector) { settings.selectorRank = 10; } else if (selected is Sensor) { settings.sensorRank = 10; } RankAndSortProgrammingExamples( settings, actor, selected, reflex ); }
public override bool MatchAction(Reflex reflex, out object param) { bool result = false; // See if there's a filter defining which player we should be. If not, use bit0. if (playerId == GamePadSensor.PlayerId.Dynamic) { playerId = GamePadSensor.PlayerId.All; ReflexData data = reflex.Data; for (int i = 0; i < data.Filters.Count; i++) { if (data.Filters[i] is PlayerFilter) { playerId = ((PlayerFilter)data.Filters[i]).playerIndex; } } } #if !NETFX_CORE Microbit bit = MicrobitExtras.GetMicrobitOrNull(playerId); if (bit != null) { // Get the correct button. switch (button) { case MicrobitButton.Left: result = bit.State.ButtonA.IsPressed(); break; case MicrobitButton.Right: result = bit.State.ButtonB.IsPressed(); break; } } #endif // Return as a parameter a vector that can be used for input to the movement system, so // that players can drive and turn bots using gamepad buttons. param = new Vector2(0, 1); return(result); }
} // end of OnBeforeSave() /// <summary> /// In OnBeforeSave() we shifted the localized strings back into the configuration they /// need to have on disc. Once saved we need to restore the in-memory (localized) state. /// </summary> public override void OnAfterSave() { // For saving, we used the original versions of the strings but if this class instance // is still being used in memory we need to restore the localized versions. foreach (XmlData.Actor a in actor) { var brain = a.brain; foreach (Task task in brain.tasks) { foreach (Reflex reflex in task.reflexes) { ReflexData rd = reflex.Data; rd.sayString = rd.LocalizedSayString; rd.saidString = rd.LocalizedSaidString; } } } base.OnAfterSave(); } // end of OnAfterSave()
/// <summary> /// Check if this selector is compatible within the given reflex and replacing the given element /// </summary> /// <param name="reflex">reflex to check if it works within</param> /// <param name="replacedElement">optional, if provided this will replace it</param> /// <returns>true if compatible</returns> public override bool ReflexCompatible(GameActor actor, ReflexData reflex, ProgrammingElement replacedElement, bool allowArchivedCategories) { // Actuator must exist { if (reflex.Actuator == null || reflex.Actuator is NullActuator) { return(false); } } // Check actuator compatibility { if (!this.ElementCompatible(reflex.Actuator)) { return(false); } } return(base.ReflexCompatible(actor, reflex, replacedElement, allowArchivedCategories)); }
public override bool MatchAction(Reflex reflex, out object param) { UpdateCommands(); // See if there's a filter defining which player we should be. If not, use pad0. if (playerId == GamePadSensor.PlayerId.Dynamic) { playerId = GamePadSensor.PlayerId.All; ReflexData data = reflex.Data; for (int i = 0; i < data.Filters.Count; i++) { if (data.Filters[i] is PlayerFilter) { playerId = ((PlayerFilter)data.Filters[i]).playerIndex; } } } bool match = false; param = null; this.tiltPosition = Vector2.Zero; #if !NETFX_CORE // TODO @*******: use the player# to get the right Microbit, or blended from all if no player#. Microbit bit = MicrobitExtras.GetMicrobitOrNull(playerId); if (bit != null) { tiltPosition = new Vector2(bit.State.Acc.Y, -bit.State.Acc.X); tiltPosition = DeadZone(tiltPosition * tiltPosition * new Vector2(Math.Sign(tiltPosition.X), Math.Sign(tiltPosition.Y)), 0.01f); } #endif param = this.tiltPosition; match = (this.tiltPosition != Vector2.Zero); // only if not centered return(match); } // end of MatchAction()
} // end of Update() /// <summary> /// What happens if the user chooses one of the pre-programmed options. /// </summary> private void Select() { if (parent.parent != null) { // Call the OnSelect() method on the pie menu. This will cause it to go through // its normal process of creating and adding the new actor to the scene. parent.parent.OnSelect(null, null); // Now, need to get the brain of the bot we just added and // stuff it full of code. Yumm, stuffed bot brains... if (shared.actor != null) { // Got brain? Brain brain = shared.actor.Brain; ActorHelp help = shared.actorHelp; if (help.programs != null && help.programs.Count > 0) { ExampleProgram program = help.programs[shared.examplesGrid.SelectionIndex.Y]; for (int page = 0; page < program.pages.Count; page++) { Task task = (Task)brain.tasks[page]; for (int r = 0; r < program.pages[page].reflexes.Length; r++) { ReflexData clip = program.pages[page].reflexes[r]; Reflex reflex = new Reflex(task); task.AddReflex(reflex); reflex.Paste(clip); } } } } Instrumentation.IncrementCounter(Instrumentation.CounterId.AddItemHelpCardInsertExample); } parent.Deactivate(); } // end of Select()
} // end of OnAfterSave() protected override bool OnLoad() { // Need to check for localization of any SayStrings in each reflex of each actor's brains. foreach (XmlData.Actor a in actor) { var brain = a.brain; foreach (Task task in brain.tasks) { foreach (Reflex reflex in task.reflexes) { ReflexData rd = reflex.Data; rd.sayString = TextHelper.CleanUpString(rd.sayString); rd.sayString = XmlWorldData.OnLoadLocalizedString(rd.sayString, ref rd.OriginalSayString, ref rd.LocalizedSayString, ref rd.LocalizedSayStringDict); rd.saidString = TextHelper.CleanUpString(rd.saidString); rd.saidString = XmlWorldData.OnLoadLocalizedString(rd.saidString, ref rd.OriginalSaidString, ref rd.LocalizedSaidString, ref rd.LocalizedSaidStringDict); } } } return(base.OnLoad()); } // end of OnLoad()
} // end of XmlLevelData ReadFromXml() /// <summary> /// Stuff we have to fix up before saving. Currently this is where we /// resotre the orginal strings for any strings that have been localized. /// </summary> public override void OnBeforeSave() { foreach (XmlData.Actor a in actor) { var brain = a.brain; foreach (Task task in brain.tasks) { foreach (Reflex reflex in task.reflexes) { // If the user has changed the strings, then keep the new strings and remove the localized versions. ReflexData rd = reflex.Data; if (rd.actuatorUpid != "actuator.say") { // This reflex doesn't have a 'say' actuator so it shouldn't have a sayString. This // generally only happens when a 'say' tile once existed in the reflex and was then // removed. rd.sayString = null; rd.LocalizedSayString = null; rd.OriginalSayString = null; rd.LocalizedSayStringDict = null; } else { if (rd.sayString != rd.LocalizedSayString) { // Reset everything to reflect the fact that we have a new string. rd.LocalizedSayStringDict = null; rd.OriginalSayString = rd.sayString; rd.LocalizedSayString = rd.sayString; } else { // No change so restore original so it's the one that gets saved out. rd.sayString = rd.OriginalSayString; } } if (rd.sensorUpid != "sensor.ears" && rd.HasFilter("filter.said")) { // This reflex doesn't have 'hear said' so it shouldn't have a saidString. This // generally only happens when a 'said' tile once existed in the reflex and was then // removed. rd.saidString = null; rd.LocalizedSaidString = null; rd.OriginalSaidString = null; rd.LocalizedSaidStringDict = null; } else { if (rd.saidString != rd.LocalizedSaidString) { // Reset everything to reflect the fact that we have a new string. rd.LocalizedSaidStringDict = null; rd.OriginalSaidString = rd.saidString; rd.LocalizedSaidString = rd.saidString; } else { // No change so restore original so it's the one that gets saved out. rd.saidString = rd.OriginalSaidString; } } } // end of loop over reflexes } // end of loop over tasks } // end of loop over actors base.OnBeforeSave(); } // end of OnBeforeSave()
public virtual bool ReflexCompatible(GameActor actor, ReflexData reflex, ProgrammingElement replacedElement, bool allowArchivedCategories) { // Check actor compatibility { if (!this.ActorCompatible(actor)) { return(false); } } // Build datatype bitmask { string selectionUpid = (replacedElement != null) ? replacedElement.upid : null; scratchOutputs.SetAll(false); scratchNegOutputs.SetAll(false); // Set sensor bits if (reflex.Sensor != null) { scratchOutputs.Or(reflex.Sensor.Outputs); } else { // if no sensor, simulate a boolean output type (for "always" behavior). scratchOutputs.Set((int)SensorOutputType.Boolean, true); } // Set filter bits foreach (Filter filter in reflex.Filters) { // Don't consider the selected one, since we'd be replacing it. if (filter.upid == selectionUpid) { selectionUpid = null; continue; } scratchOutputs.Or(filter.Outputs); scratchNegOutputs.Or(filter.NegOutputs); } // Set actuator bits if (reflex.Actuator != null) { scratchNegOutputs.Or(reflex.Actuator.NegOutputs); } // Set selector bits if (reflex.Selector != null) { scratchNegOutputs.Or(reflex.Selector.NegOutputs); } // Set modifier bits foreach (Modifier modifier in reflex.Modifiers) { // Don't consider the selected one, since we'd be replacing it. if (modifier.upid == selectionUpid) { selectionUpid = null; continue; } scratchNegOutputs.Or(modifier.NegOutputs); } } // If this element is on the do side, remove negated outputs. // TODO (****) I just noticed that "this is Filter" is here even though filters // shouldn't be on the DO side. Is this a bug or do we need this? if (this is Actuator || this is Selector || this is Modifier || this is Filter) { scratchOutputs.And(scratchNegOutputs.Not()); } // Check datatype compatibility { if (this.InputCount > 0 && !MatchesAnyBit(scratchOutputs, this.Inputs)) { return(false); } } // Build category bitmask int scratchExclusionCount = 0; { string selectionUpid = (replacedElement != null) ? replacedElement.upid : null; scratchCategories.SetAll(false); scratchNegations.SetAll(false); // Set sensor bits if (reflex.Sensor != null && reflex.Sensor.upid != selectionUpid) { scratchCategories.Or(reflex.Sensor.Categories); scratchNegations.Or(reflex.Sensor.Negations); } // Set actuator bits if (reflex.Actuator != null && reflex.Actuator.upid != selectionUpid) { scratchCategories.Or(reflex.Actuator.Categories); scratchNegations.Or(reflex.Actuator.Negations); } // Set selector bits if (reflex.Selector != null && reflex.Selector.upid != selectionUpid) { scratchCategories.Or(reflex.Selector.Categories); scratchNegations.Or(reflex.Selector.Negations); } // Set filter bits foreach (Filter filter in reflex.Filters) { // Don't consider the selected modifier, since we'd be replacing it. // Don't consider any filters after the selection either, since we need to consider only everything to its left when replacing. if (filter.upid == selectionUpid) { selectionUpid = null; break; } scratchCategories.Or(filter.Categories); scratchNegations.Or(filter.Negations); scratchExclusionCount += Math.Max(scratchExclusionCount, filter.ExclusionCount); } // Set modifier bits foreach (Modifier modifier in reflex.Modifiers) { // Don't consider the selected modifier, since we'd be replacing it. // Don't consider any modifiers after the selection either, since we need to consider only everything to its left when replacing. if (modifier.upid == selectionUpid) { selectionUpid = null; break; } scratchCategories.Or(modifier.Categories); scratchNegations.Or(modifier.Negations); scratchExclusionCount = Math.Max(scratchExclusionCount, modifier.ExclusionCount); } } // If this element is on the "do" side, remove negated categories. // Let Negations work on WHEN side also... //if (this is Actuator || this is Selector || this is Modifier) { scratchNegations.Not(); // Invert the negations. scratchCategories.And(scratchNegations); } // Build my inclusion bitmask { scratchMyCategories.SetAll(false); scratchMyCategories.Or(this.Inclusions); if (allowArchivedCategories) { scratchMyCategories.Or(this.ArchivedInclusions); } } #if DEBUG_COMPATIBILITY if (this.upid == "modifier.it") { scratchNegations.Not(); // Restore negations so they dump correctly. num++; Debug.Print(num.ToString()); Debug.Print(this.upid); DumpCategories(this.Inclusions, " inclusions"); DumpCategories(this.Exclusions, " exclusions"); DumpCategories(scratchCategories, " scratch"); DumpCategories(scratchMyCategories, " scratchMy"); DumpCategories(scratchNegations, " scratchNegations"); } #endif // Check category compatibility { if (this.InclusionCount > 0 && !MatchesAnyBit(scratchCategories, scratchMyCategories)) { return(false); } if (this.ExclusionCount > 0 && MatchesAnyBit(scratchCategories, this.Exclusions)) { return(false); } } return(true); }
} // end of c'tor /// <summary> /// Activate the pattern editor. /// </summary> /// <param name="reflex">The current reflex containing the Pattern tile.</param> /// <param name="modifier">Modifier we're changing the pattern on. If null this indicates we want the last one.</param> public void Activate(ReflexData reflex, Modifier modifier) { Debug.Assert(active == false, "Already active, why?"); if (!active) { this.reflex = reflex; // If we passed in null, that indicates we want the last one. if (modifier == null) { for (int i = reflex.Modifiers.Count - 1; i >= 0; i--) { if (reflex.Modifiers[i].upid == "modifier.microbit.pattern") { modifier = reflex.Modifiers[i]; break; } } Debug.Assert(modifier != null); } this.modifier = modifier; modifierIndex = -1; for (int i = 0; i < reflex.Modifiers.Count; i++) { if (reflex.Modifiers[i].upid == "modifier.microbit.pattern") { ++modifierIndex; } if (reflex.Modifiers[i] == modifier) { // Ensure blank settings exist. if (reflex.microbitPatterns == null) { reflex.microbitPatterns = new List <MicroBitPattern>(); reflex.microbitPatterns.Add(new MicroBitPattern()); } if (reflex.microbitPatterns.Count <= i) { reflex.microbitPatterns.Add(new MicroBitPattern()); } break; } } // Valid index? Debug.Assert(modifierIndex > -1); Debug.Assert(modifierIndex < reflex.microbitPatterns.Count); // Get the current pattern. pattern = (MicroBitPattern)reflex.microbitPatterns[modifierIndex].Clone(); // Copy values to UI. ledGrid.LEDs = pattern.LEDs; ledGrid.FocusLEDIndex = 0; brightnessSlider.CurrentValue = pattern.Brightness; durationSlider.CurrentValue = pattern.Duration; brightnessSlider.Selected = true; durationSlider.Selected = false; ledGrid.Selected = true; bar.Selected = true; thumbnail = InGame.inGame.SmallThumbNail; HelpOverlay.Push(@"MicrobitPatternEditor"); active = true; } } // end of Activate()
public override bool MatchAction(Reflex reflex, out object param) { bool result = false; // Only jump through hoops the first time to get the pad. if (ButtonState == null) { GamePadInput pad = null; // See if there's a filter defining which player we should be. If not, use pad0. if (playerId == GamePadSensor.PlayerId.Dynamic) { playerId = GamePadSensor.PlayerId.All; ReflexData data = reflex.Data; for (int i = 0; i < data.Filters.Count; i++) { if (data.Filters[i] is PlayerFilter) { playerId = ((PlayerFilter)data.Filters[i]).playerIndex; } } } // Get the correct game pad. switch (playerId) { case GamePadSensor.PlayerId.All: pad = GamePadInput.GetGamePad0(); break; case GamePadSensor.PlayerId.One: pad = GamePadInput.GetGamePad1(); break; case GamePadSensor.PlayerId.Two: pad = GamePadInput.GetGamePad2(); break; case GamePadSensor.PlayerId.Three: pad = GamePadInput.GetGamePad3(); break; case GamePadSensor.PlayerId.Four: pad = GamePadInput.GetGamePad4(); break; } // Get the correct game pad button. switch (button) { case GamePadButton.A: ButtonState = pad.ButtonA; break; case GamePadButton.B: ButtonState = pad.ButtonB; break; case GamePadButton.X: ButtonState = pad.ButtonX; break; case GamePadButton.Y: ButtonState = pad.ButtonY; break; case GamePadButton.LeftTrigger: ButtonState = pad.LeftTriggerButton; break; case GamePadButton.RightTrigger: ButtonState = pad.RightTriggerButton; break; } } result = ButtonState.IsPressed; // Return as a parameter a vector that can be used for input to the movement system, so // that players can drive and turn bots using gamepad buttons. param = new Vector2(0, 1); return(result); }
private void RankProgrammingExample( ExamplePage example, RankSettings settings, GameActor actor, ProgrammingElement selected, ReflexData reflex) { if (!example.ActorCompatible(actor)) { example.rank = -1; return; } string selectedUpid; if (selected != null) { selectedUpid = selected.upid; } else { selectedUpid = String.Empty; } example.rank = 0; for (int iReflex = 0; iReflex < example.reflexes.Length; ++iReflex) { ReflexData exampleReflex = example.reflexes[iReflex]; // Rank sensor if (selected == exampleReflex.Sensor) { example.rank += RankElements(exampleReflex.Sensor, selected, settings.sensorRank); } if (exampleReflex.Sensor != null && reflex.Sensor != null) { example.rank += RankElements(exampleReflex.Sensor, reflex.Sensor, settings.sensorRank); } // Rank selector if (selected == exampleReflex.Selector) { example.rank += RankElements(exampleReflex.Selector, selected, settings.selectorRank); } if (exampleReflex.Selector != null && reflex.Selector != null) { example.rank += RankElements(exampleReflex.Selector, reflex.Selector, settings.selectorRank); } // Rank actuator if (selected == exampleReflex.Actuator) { example.rank += RankElements(exampleReflex.Actuator, selected, settings.actuatorRank); } if (exampleReflex.Actuator != null && reflex.Actuator != null) { example.rank += RankElements(exampleReflex.Actuator, reflex.Actuator, settings.actuatorRank); } // Rank filters for (int i = 0; i < exampleReflex.Filters.Count; ++i) { if (selected == exampleReflex.Filters[i]) { example.rank += RankElements(exampleReflex.Filters[i], selected, settings.filterRank); } for (int j = 0; j < reflex.Filters.Count; ++j) { example.rank += RankElements(exampleReflex.Filters[i], reflex.Filters[j], settings.filterRank); } } // Rank modifiers for (int i = 0; i < exampleReflex.Modifiers.Count; ++i) { if (selected == exampleReflex.Modifiers[i]) { example.rank += RankElements(exampleReflex.Modifiers[i], selected, settings.modifierRank); } for (int j = 0; j < reflex.Modifiers.Count; ++j) { example.rank += RankElements(exampleReflex.Modifiers[i], reflex.Modifiers[j], settings.modifierRank); } } } }