/// <summary> /// Instantiates all the behaviors that this fish knows about /// </summary> public void BuildBehaviors() { fleeReaction = new FleeBehavior(this); Behaviors fishReactions = new Behaviors(); fishReactions.Add(new AlignBehavior(this)); fishReactions.Add(new CohesionBehavior(this)); fishReactions.Add(new SeparationBehavior(this)); behaviors.Add(AnimalType.Fish, fishReactions); }
/// <summary> /// Instantiates all the behaviors that this Bird knows about /// </summary> public void BuildBehaviors() { Behaviors catReactions = new Behaviors(); catReactions.Add(new FleeBehavior(this)); behaviors.Add(AnimalType.Cat, catReactions); Behaviors birdReactions = new Behaviors(); birdReactions.Add(new AlignBehavior(this)); birdReactions.Add(new CohesionBehavior(this)); birdReactions.Add(new SeparationBehavior(this)); behaviors.Add(AnimalType.Bird, birdReactions); }
public void BuildBehaviors() { //Behaviors catReactions = new Behaviors(); //catReactions.Add(new FleeBehavior(this)); //behaviors.Add(EnemyType.Cat, catReactions); Behaviors birdReactions = new Behaviors(); //birdReactions.Add(new FleeBehavior(this)); birdReactions.Add(new AlignBehavior(this)); birdReactions.Add(new CohesionBehavior(this)); birdReactions.Add(new SeparationBehavior(this)); behaviors.Add(EnemyType.Zombie, birdReactions); }
public override void InitializeBehaviors() { base.InitializeBehaviors(); Behaviors.Add(new CollectBehavior <Berry>("Berry", 2, 4)); Behaviors.Add(new CollectBehavior <Branch>("Branch", 1, 4)); Behaviors.Add(new CollectBehavior <Twig>("Twig", 2, 16)); }
public EnumPicker( Type enumType, string currentEnumBindingPropertyName, string currentEnumStrBindingPropertyName, Behavior validator = null) { // ErrorUtils.IssueArgumentErrorIfTrue(enumType.IsEnum, nameof(EnumPicker) + ": Must supply an enum type."); _enumType = enumType; if (currentEnumStrBindingPropertyName.IsNotEmpty()) { this.SetUpBinding(SelectedItemProperty, currentEnumStrBindingPropertyName, BindingMode.TwoWay); } else if (currentEnumBindingPropertyName.IsNotEmpty()) { this.SetUpBinding(CurrentEnumProperty, currentEnumBindingPropertyName, BindingMode.TwoWay); } if (validator.IsNotNullOrDefault()) { Behaviors.Add(validator); } ItemsSource = new List <string>(Enum.GetNames(_enumType)); SelectedIndexChanged += HandleSelectedIndexChanged; // If no valid selection, assert one if (SelectedIndex < 0) { SelectedIndex = 0; } }
public BettingSystemFixture() { Behaviors.OfType <ThrowingRecursionBehavior>().ToList() .ForEach(b => Behaviors.Remove(b)); Behaviors.Add(new OmitOnRecursionBehavior()); Customizations.Add(new PropertyNameOmitter("Id")); }
public LazyContentPage() { Behaviors.Add(new LazyLoadContentPageBehavior { ContentTemplate = new DataTemplate(typeof(TContentView)) }); }
/// <summary> /// Initializes a new instance of the <see cref="NavigationView"/> class. /// </summary> /// <param name="mainScheduler">The main scheduler to scheduler UI tasks on.</param> /// <param name="backgroundScheduler">The background scheduler.</param> /// <param name="viewLocator">The view locator which will find views associated with view models.</param> public NavigationView(IScheduler mainScheduler, IScheduler backgroundScheduler, IViewLocator viewLocator) { MainThreadScheduler = mainScheduler; _backgroundScheduler = backgroundScheduler; _viewLocator = viewLocator; _logger = this.Log(); PagePopped = Observable .FromEvent <EventHandler <NavigationEventArgs>, IViewModel>( handler => { void Handler(object?sender, NavigationEventArgs args) { if (args.Page.BindingContext is IViewModel viewModel) { handler(viewModel); } } return(Handler); }, x => Popped += x, x => Popped -= x); Behaviors.Add(new NavigationPageSystemPopBehavior(_navigationSource.AsObservable())); }
/// <summary> /// Constructor /// </summary> /// <param name="p_Value"></param> public Link(object p_Value) : base(p_Value) { VisualModel = VisualModels.Common.LinkStyle; Behaviors.Add(BehaviorModels.Cursor.Default); Cursor = System.Windows.Forms.Cursors.Hand; }
public Wolf(Level level) : base(EntityType.Wolf, level) { Width = Length = 0.6; Height = 0.8; IsAngry = false; CollarColor = 14; HealthManager.MaxHealth = 80; HealthManager.ResetHealth(); Speed = 0.3; AttackDamage = 2; TargetBehaviors.Add(new HurtByTargetBehavior(this)); TargetBehaviors.Add(new FindAttackableEntityTargetBehavior <Sheep>(this, 16)); TargetBehaviors.Add(new FindAttackableEntityTargetBehavior <Rabbit>(this, 16)); //TargetBehaviors.Add(new FindAttackableEntityTargetBehavior<Fox>(this, 16)); Behaviors.Add(new SittingBehavior(this)); //Behaviors.Add(new JumpAttackBehavior(this, 1.0)); Behaviors.Add(new MeleeAttackBehavior(this, 1.0, 16)); Behaviors.Add(new OwnerHurtByTargetBehavior(this)); Behaviors.Add(new OwnerHurtTargetBehavior(this)); Behaviors.Add(new FollowOwnerBehavior(this, 20, 1.0)); Behaviors.Add(new WanderBehavior(this, 1.0)); Behaviors.Add(new LookAtPlayerBehavior(this, 8.0)); Behaviors.Add(new RandomLookaroundBehavior(this)); }
public Shade(int level) { int headHealth = Dice.Roll("1D5"); int torsoHealth = Dice.Roll("2D5"); int legHealth = Dice.Roll("3D3-2"); Bodyparts.Add(new Torso(torsoHealth, true, 5)); Bodyparts.Add(new Head(headHealth, true, 2) { Strength = 5 }); Bodyparts.Add(new Leg(legHealth, false, 1)); Awareness = 10; int health = CalculateSimpleHealth(); SimpleHealth = health; SimpleMaxHealth = health; Name = "Shade"; Initiative = Dice.Roll("10D7+20"); Speed = Game.Random.Next(1, Initiative); Symbol = 's'; Color = Colors.ShadeColor; Regen = 0; Actions.Add(new Walk(this)); Actions.Add(new Wait(this)); Actions.Add(Prototypes.Attacks.Bite(this)); LastAction = new Wait(this); Behaviors.Add(new HuntPlayer()); }
/// <summary> /// Add a behavior to the event stack. /// </summary> public void Do <T>() where T : Behavior, new() { Behaviors.Add(new T() { Game = this }); }
/* ----------------------------------------------------------------- */ /// /// OnBind /// /// <summary> /// Binds the windows to the specified object. /// </summary> /// /// <param name="src">Binding object.</param> /// /* ----------------------------------------------------------------- */ protected override void OnBind(IBindable src) { if (src is not SettingViewModel vm) { return; } BindCore(vm); Behaviors.Add(new CloseBehavior(this, vm)); Behaviors.Add(new DialogBehavior(vm)); Behaviors.Add(new OpenDirectoryBehavior(vm)); Behaviors.Add(new ClickEventBehavior(ExecuteButton, () => vm.Save(true))); Behaviors.Add(new ClickEventBehavior(ApplyButton, () => vm.Save(false))); Behaviors.Add(new ClickEventBehavior(ExitButton, Close)); Behaviors.Add(new ClickEventBehavior(ContextResetButton, vm.Menu.Reset)); Behaviors.Add(new ClickEventBehavior(ContextCustomizeButton, vm.Menu.Customize)); Behaviors.Add(new ClickEventBehavior(AssociateIconButton, vm.Associate.SelectIcon)); Behaviors.Add(new ClickEventBehavior(AssociateAllButton, vm.Associate.SelectAll)); Behaviors.Add(new ClickEventBehavior(AssociateClearButton, vm.Associate.Clear)); Behaviors.Add(new ClickEventBehavior(CompressSaveButton, vm.Compress.Browse)); Behaviors.Add(new ClickEventBehavior(ExtractSaveButton, vm.Extract.Browse)); Behaviors.Add(new ClickEventBehavior(TempButton, vm.Browse)); Behaviors.Add(new PathLintBehavior(CompressSaveTextBox, _tooltip)); Behaviors.Add(new PathLintBehavior(ExtractSaveTextBox, _tooltip)); Behaviors.Add(new AssociateIconBehavior(vm)); Behaviors.Add(new ShowDialogBehavior <CustomizeWindow, CustomizeViewModel>(vm)); _version.Product = vm.Product; _version.Version = vm.Version; _tooltip.ToolTipTitle = Properties.Resources.MessageInvalidChars; }
public BaseChart() { Background = new SolidColorBrush(Colors.White); VerticalAxis = new LinearAxis(); HorizontalAxis = new CategoricalAxis { SmartLabelsMode = AxisSmartLabelsMode.SmartStep, LabelFitMode = AxisLabelFitMode.Rotate, LabelRotationAngle = 270 }; ChartTrackBallBehavior chartTrackBallBehavior = new ChartTrackBallBehavior { ShowIntersectionPoints = true, ShowTrackInfo = true, }; //System.Windows.Point position = chartTrackBallBehavior.Position; //position.X = (23); //position.Y = (45); //chartTrackBallBehavior.Position = position; ChartPanAndZoomBehavior panAndZoomBehavior = new ChartPanAndZoomBehavior { ZoomMode = ChartPanZoomMode.Both, PanMode = ChartPanZoomMode.Both }; Behaviors.Add(panAndZoomBehavior); Behaviors.Add(chartTrackBallBehavior); }
public ToggleBase() { ToggleBehavior toggleBehavior = new ToggleBehavior(); toggleBehavior.PropertyChanged += OnToggleBehaviorPropertyChanged; Behaviors.Add(toggleBehavior); }
/* ----------------------------------------------------------------- */ /// /// OnBind /// /// <summary> /// Initializes for the About page. /// </summary> /// /* ----------------------------------------------------------------- */ protected override void OnBind(IPresentable src) { base.OnBind(src); if (!(src is MainViewModel vm)) { return; } FileListView.DataSource = vm.Files; MergeButton.Click += (s, e) => vm.Merge(); SplitButton.Click += (s, e) => vm.Split(); FileButton.Click += (s, e) => vm.Add(); UpButton.Click += (s, e) => vm.Move(SelectedIndices, -1); DownButton.Click += (s, e) => vm.Move(SelectedIndices, 1); RemoveButton.Click += (s, e) => vm.Remove(SelectedIndices); ClearButton.Click += (s, e) => vm.Clear(); Behaviors.Add(new CloseBehavior(src, this)); Behaviors.Add(new DialogBehavior(src)); Behaviors.Add(new OpenFileBehavior(src)); Behaviors.Add(new OpenDirectoryBehavior(src)); Behaviors.Add(new SaveFileBehavior(src)); Behaviors.Add(vm.Subscribe <CollectionMessage>(e => vm.Files.ResetBindings(false))); }
public ScrollableListView(ScrollableListViewModel <D, S, I> scrollableListViewModel) : base(ListViewCachingStrategy.RecycleElement) { this.scrollableListViewModel = scrollableListViewModel; ItemsSource = scrollableListViewModel.Items; HasUnevenRows = true; ItemTemplate = Container.ServiceProvider.GetService(typeof(EntityTemplate <D>)) as EntityTemplate <D>; if (ItemTemplate is null) { Debug.WriteLine("Template Not Found : Using default for object"); ItemTemplate = Container.ServiceProvider.GetService(typeof(EntityTemplate <object>)) as EntityTemplate <object>; } InfiniteScrollBehavior infiniteScrollBehavior = new InfiniteScrollBehavior(); Behaviors.Add(infiniteScrollBehavior); Frame frame = new Frame() { BackgroundColor = Color.Transparent, BorderColor = Color.Transparent, HasShadow = false, Content = new ActivityIndicator() { IsRunning = true } }; frame.SetBinding(IsVisibleProperty, new Binding(InfiniteScrollBehavior.IsLoadingMoreProperty.PropertyName, BindingMode.OneWay, source: infiniteScrollBehavior)); Footer = frame; }
public Horse(Level level, bool isDonkey = false, Random rnd = null) : base(isDonkey ? EntityType.Donkey : EntityType.Horse, level) { Width = Length = 1.4; Height = 1.6; var random = rnd ?? new Random(); Variant = random.Next(7); Markings = random.Next(5); Speed = (0.45 + random.NextDouble() * 0.3D + random.NextDouble() * 0.3D + random.NextDouble() * 0.3) * 0.25D; JumpStrength = 0.4 + random.NextDouble() * 0.2 + random.NextDouble() * 0.2 + random.NextDouble() * 0.2; IsAffectedByGravity = true; //IsBreathing = true; // ?? HasCollision = true; Behaviors.Add(new HorseRiddenBehavior(this)); Behaviors.Add(new PanicBehavior(this, 60, Speed, 1.2)); Behaviors.Add(new HorseEatBlockBehavior(this, 100)); Behaviors.Add(new WanderBehavior(this, 0.7)); Behaviors.Add(new LookAtPlayerBehavior(this)); Behaviors.Add(new RandomLookaroundBehavior(this)); Inventory = new HorseInventory(this); }
public Chicken(Level level, Random rnd = null) : base(EntityType.Chicken, level) { EntityTypeId = 0x130a; Width = Length = 0.4; Height = 0.7; HealthManager.MaxHealth = 40; HealthManager.ResetHealth(); Speed = 0.25f; IsWalker = true; CanClimb = true; //IsInWater = true; HasCollision = true; IsAffectedByGravity = true; var random = rnd ?? new Random((int)DateTime.UtcNow.Ticks); _timeUntilLayEgg = 6000 + random.Next(6000); Behaviors.Add(new PanicBehavior(this, 60, Speed, 1.4)); Behaviors.Add(new TemptedBehavior(this, typeof(ItemWheatSeeds), 10, 1.0)); //TODO: Add other seeds Behaviors.Add(new WanderBehavior(this, 1.0)); Behaviors.Add(new LookAtPlayerBehavior(this)); Behaviors.Add(new RandomLookaroundBehavior(this)); }
/* ----------------------------------------------------------------- */ /// /// MainWindow /// /// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> /// /* ----------------------------------------------------------------- */ public MainWindow() { InitializeComponent(); Behaviors.Add(SetupForAbout()); Behaviors.Add(new SelectionBehavior(FileListView)); ExitButton.Click += (s, e) => Close(); }
/// <summary> /// Instantiates all the behaviors that this Bird knows about /// </summary> public void BuildBehaviors() { Behaviors enemyReactions = new Behaviors(); enemyReactions.Add(new FleeingBehavior(this)); behaviors.Add(AnimalType.Enemy, enemyReactions); Behaviors birdReactions = new Behaviors(); birdReactions.Add(new AlignBehavior(this)); birdReactions.Add(new CohesionBehavior(this)); birdReactions.Add(new SeparationBehavior(this)); behaviors.Add(AnimalType.Follower, birdReactions); Behaviors leaderReactions = new Behaviors(); leaderReactions.Add(new FollowingBehavior(this)); behaviors.Add(AnimalType.Leader, leaderReactions); }
public Bullet() { //some sensible defaults R = 7; dieOffScreen = new DieOffScreenBehavior(); Behaviors.Add(dieOffScreen); }
protected BehaviorViewBindingBase(IApplicationContext context, IApplicationContextAccessible contextAccessible) { var behaviorNames = new List <String>(); var assembly = contextAccessible.GetType().Assembly; var types = assembly.GetTypes(); foreach (var type in types) { var attributes = type.GetCustomAttributes(false); foreach (var behaviorAttribute in attributes.OfType <BehaviorAttribute>()) { behaviorNames.Add(behaviorAttribute.Name); var behaviorType = behaviorAttribute.ViewModelName == null ? type : type.MakeGenericType(typeof(object)); var ctor = behaviorType.GetConstructor(new[] { typeof(IApplicationContext) }); if (ctor == null) { continue; } var obj = ctor.Invoke(new object[] { context }); Behaviors.Add(behaviorAttribute.Name, obj as IApplicationContextAccessible); } } }
/// <summary> /// Constructor /// </summary> public Header(object p_Value, VisualModels.IVisualModel p_VisualModel, BehaviorModels.IBehaviorModel p_HeaderBehavior) : base(p_Value) { VisualModel = p_VisualModel; if (p_HeaderBehavior != null) { Behaviors.Add(p_HeaderBehavior); } }
/// <summary> /// Constructor /// </summary> public Header(VisualModels.IVisualModel p_VisualModel, BehaviorModels.IBehaviorModel p_HeaderBehavior) { VisualModel = p_VisualModel; if (p_HeaderBehavior != null) { Behaviors.Add(p_HeaderBehavior); } }
/// <summary> /// Cell constructor /// </summary> /// <param name="p_Value">The value of the cell</param> public Cell(object p_Value) { Value = p_Value; VisualModel = VisualModels.Common.Default; //Default Visual properties Behaviors.Add(BehaviorModels.ToolTipText.Default); Behaviors.Add(BehaviorModels.Cursor.Default); Behaviors.Add(BehaviorModels.ContextMenu.Default); }
/// <summary> Adds behavior. </summary> public Component AddBehavior(IBehavior behavior) { if (Behaviors.All(b => b.Name != behavior.Name)) { Behaviors.Add(behavior); } return(this); }
/// <summary> /// Adds behavior /// </summary> /// <param name="behavior"></param> /// <returns></returns> public Component AddBehavior(IBehavior behavior) { if (!Behaviors.Any(b => b.Name == behavior.Name)) { Behaviors.Add(behavior); } return(this); }
/// <summary> /// Constructor /// </summary> /// <param name="name">The name of the model</param> public CurrentSwitchModel(string name) : base(name) { // Add parameters ParameterSets.Add(new ModelBaseParameters()); // Add factories Behaviors.Add(typeof(ModelLoadBehavior), () => new ModelLoadBehavior(Name)); }
public PlayerBullet(double vx) { IsFriendly = true; Behaviors.Add(new XYMovementBehavior() { Vx = vx }); BaseTexture = "playerbullet"; }
public new void BuildBehaviors() { Behaviors enemyReaction = new Behaviors(); //enemyReaction.Add(new FleeBehavior(this)); enemyReaction.Add(new AlignBehavior(this)); //enemyReaction.Add(new CohesionBehavior(this)); enemyReaction.Add(new SeparationBehavior(this)); behaviors.Add(EnemyType.Zombie, enemyReaction); Behaviors tileReaction = new Behaviors(); //enemyReaction.Add(new FleeBehavior(this)); //enemyReaction.Add(new AlignBehavior(this)); //enemyReaction.Add(new CohesionBehavior(this)); tileReaction.Add(new SeparationBehavior(this)); behaviors.Add(EnemyType.Generic, tileReaction); }
/// <summary> /// Constructor /// </summary> /// <param name="name">The name of the device</param> public Mosfet1Model(Identifier name) : base(name) { // Add parameters ParameterSets.Add(new ModelBaseParameters()); ParameterSets.Add(new ModelNoiseParameters()); // Add factories Behaviors.Add(typeof(ModelTemperatureBehavior), () => new ModelTemperatureBehavior(Name)); }