public void SetEnemiesBehavior(BehaviorTypeEnum behaviorType) { foreach (var enemy in AllEnemies) { enemy.SetBehaviorType(behaviorType); } }
public Player( ICastle castle, IHealthInvoker healthInvoker, IImageManager imageManager, IMovementDirectionManager movementDirectionManager, IMovementStrategyInvoker movementStrategyInvoker, IAllWeaponsFactory weaponsFactory ) { _castle = castle; _healthInvoker = healthInvoker; _imageManager = imageManager; _movementDirectionManager = movementDirectionManager; _movementStrategyInvoker = movementStrategyInvoker; _weaponsFactory = weaponsFactory; behaviorType = BehaviorTypeEnum.Targeted; AllSwordSwingImages = new List <System.Windows.Controls.Image>(); AllMaceSwingImages = new List <System.Windows.Controls.Image>(); AllArrowShootingLeftImages = new List <System.Windows.Controls.Image>(); AllArrowShootingRightImages = new List <System.Windows.Controls.Image>(); weaponsCarried_Observers = new List <IWeapon>(); allEnemies_Observers = new List <IEnemy>(); allTargets = new List <ITarget>(); ShootingDirection_Player = Key.None; _speedMovement = 5; }
/// <summary> /// 异步记录行为记录 /// </summary> /// <param name="userId">用户Id,匿名用户使用Guid.Empty</param> /// <param name="behaviorType">行为类型 1:浏览商品,2:收藏商品,3:删除收藏,4:添加购物车,5:删除购物车商品,6:确认支付</param> /// <param name="behaviorKey">行为关键字,与行为类型对应 1:浏览商品:商品Id,2:收藏商品:商品Id,3:删除收藏:商品Id,4:添加购物车:商品Id,5:删除购物车商品:商品Id,6:确认支付:订单Id</param> public static void SaveBehaviorAsync(Guid userId, BehaviorTypeEnum behaviorType, string behaviorKey) { var statik = new StackTrace(); StackFrame[] stackFrames = statik.GetFrames(); string method = string.Empty; if (stackFrames != null && stackFrames.Count() > 1) { var methodInfo = stackFrames[1].GetMethod(); if (methodInfo.DeclaringType != null) { method = methodInfo.DeclaringType.FullName + "." + methodInfo.Name; } } //行为记录 try { System.Threading.ThreadPool.QueueUserWorkItem( a => { ContextSession contextSession = ContextFactory.CurrentThreadContext; BehaviorRecord commodityBehavior = CreateBehaviorRecord(); commodityBehavior.UserId = userId; commodityBehavior.Method = method; commodityBehavior.Params = string.Empty; commodityBehavior.BehaviorType = (int)behaviorType; commodityBehavior.BehaviorKey = behaviorKey; contextSession.SaveObject(commodityBehavior); contextSession.SaveChanges(); }); } catch (Exception ex) { LogHelper.Error(string.Format(method + " 行为记录记录异常,\r\nMessage:{0},StackTrace:{1}", ex.Message, ex.StackTrace)); } }
public RandomBehavior(IMovementDirectionManager movementDirectionManager) { _movementDirectionManager = movementDirectionManager; BehaviorTypeName = BehaviorTypeEnum.Random; }
public IBehavior GetSelectedBehavior(BehaviorTypeEnum behaviorType) { var selectedBehavior = AllBehaviors.Where(a => a.BehaviorTypeName == behaviorType).FirstOrDefault(); return(selectedBehavior); }
public TargetedBehavior() { BehaviorTypeName = BehaviorTypeEnum.Targeted; }
public void SetBehaviorType(BehaviorTypeEnum behaviorType) { _selectedBehavior = _behaviorInvoker.GetSelectedBehavior(behaviorType); }