private void timer_Tick(object sender, EventArgs e) { switch (_action) { case AlertAction.Start: timer.Interval = 1; Opacity += 0.1; if (positionX < Location.X) { Left--; } else if (Opacity == 1.0) { _action = AlertAction.Wait; } break; case AlertAction.Wait: timer.Interval = _interval; _action = AlertAction.Close; break; case AlertAction.Close: timer.Interval = 1; Opacity -= 0.1; Left -= 3; if (Opacity == 0.0) { Close(); } break; } }
/// <summary> /// Handles alert. /// </summary> /// <param name="alertAction">Action which should be done with appeared alert.</param> /// <param name="text">Text which can be send to alert.</param> /// <exception cref="NoAlertPresentException">Thrown when no alert found.</exception> public void HandleAlert(AlertAction alertAction, string text = null) { Logger.Info($"loc.browser.alert.{alertAction.ToString().ToLower()}"); try { var alert = Driver.SwitchTo().Alert(); if (!string.IsNullOrEmpty(text)) { Logger.Info("loc.send.text", text); alert.SendKeys(text); } if (alertAction.Equals(AlertAction.Accept)) { alert.Accept(); } else { alert.Dismiss(); } } catch (NoAlertPresentException ex) { Logger.Fatal("loc.browser.alert.fail", ex); throw; } }
public async Task Alert(AlertAction action, SocketRole role) { using (var context = new TuckContext()) { Subscription subscription; try { subscription = context.Subscriptions .AsQueryable() .Single(t => t.GuildId == Context.Guild.Id); } catch (InvalidOperationException) { await ReplyAsync("You need to have an active subscription to enable alerts."); return; } switch (action) { case AlertAction.add: await AddAlert(context, subscription, role.Id); break; case AlertAction.remove: await RemoveAlert(context, subscription); break; } } }
//是否取消警戒 private bool IsCancelAlert() { AlertAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enAlertAction) as AlertAction; if (action != null) { for (int i = 0; i < m_alertTargetList.Count; ++i) { TargetInfo info = m_alertTargetList[i]; Actor target = ActorManager.Singleton.Lookup(info.m_targetID); if (target == null || target.IsDead) { info.m_isRemove = true; continue; } Vector3 d = target.RealPos - Self.RealPos; d.y = 0; if (Mathf.Abs(d.magnitude) > Self.CurrentTableInfo.CancelAlertRange) {//超过“取消警戒的范围” info.m_isRemove = true; continue; } } m_alertTargetList.RemoveAll(item => item.m_isRemove); if (m_alertTargetList.Count == 0) { return(true); } } return(false); }
internal void ShowAlert(string message, AlertType alertType, int interval, Image image = null, Color color = default) { Opacity = 0.0; StartPosition = FormStartPosition.Manual; for (int i = 1; i < 10; i++) { var formName = "alert" + i; var frm = (frmAlert)Application.OpenForms[formName]; if (frm == null) { Name = formName; positionX = Screen.PrimaryScreen.WorkingArea.Width - Width + 15; positionY = Screen.PrimaryScreen.WorkingArea.Height - Height * i - 5 * i; Location = new Point(positionX, positionY); break; } } positionX = Screen.PrimaryScreen.WorkingArea.Width - Width - 5; switch (alertType) { case AlertType.Sucess: ptbLogo.Image = Resources.sucess48px; BackColor = Color.SeaGreen; break; case AlertType.Information: ptbLogo.Image = Resources.information48px; BackColor = Color.RoyalBlue; break; case AlertType.Warning: ptbLogo.Image = Resources.warning48px; BackColor = Color.FromArgb(230, 126, 34); break; case AlertType.Error: ptbLogo.Image = Resources.error48px; BackColor = Color.FromArgb(231, 76, 60); break; case AlertType.Custom: ptbLogo.Image = image ?? Resources.information48px; BackColor = color; break; } lblMessage.Text = message; _interval = interval; _action = AlertAction.Start; timer.Interval = 1; timer.Start(); Show(); }
public static void PerformAlertAction(this IWebDriver driver, AlertAction action) { //Switch to the Alert window var alert = driver.SwitchTo().Alert(); if(action == AlertAction.Ok) alert.Accept(); if(action == AlertAction.Cancel) alert.Dismiss(); }
/// <summary> /// Alert 事件驱动框架 /// 构造函数 /// 实体使用方法 /// </summary> /// <param name="alertTestStep">alert步骤所有信息</param> public AlertEDA(TestStep alertTestStep) { _alertAction = alertTestStep.WebAction.Action as AlertAction; ComArgs.SigTestStep = alertTestStep; if (_alertAction != null) { TimeSpan timeSpan = TimeSpan.FromSeconds(_alertAction.Timeout); //提取超时 _webDriverWait = new WebDriverWait(ComArgs.WebTestDriver, timeSpan); } }
public DigitalInputChannel(string name, int regNum, int regLength, bool connected, string pname, LogicType ltype) { this.Logic = ltype; this.Name = name; this.RegisterIndex = regNum; this.RegisterLength = regLength; this.Connected = connected; this.PropertyMap = pname; this.Bypass = false; this.AlarmAction = AlertAction.NOTHING; }
// Start is called before the first frame update void Awake() { damage = enemyPreset.damage; moveTime = enemyPreset.moveTime; idleTimeMin = enemyPreset.idleTimeMin; idleTimeMax = enemyPreset.idleTimeMax; wanderRadius = enemyPreset.wanderRadius; home = transform.position; trigger = GetComponentInChildren <DetectPlayer>(); trigger.GetComponent <SphereCollider>().radius = enemyPreset.detectionRadius; navMeshAgent = GetComponent <NavMeshAgent>(); navMeshAgent.speed = enemyPreset.speed; fsm = new FSM("MeleeAI FSM"); WanderState = fsm.AddState("WanderState"); IdleState = fsm.AddState("IdleState"); AlertState = fsm.AddState("AlertState"); MeleeState = fsm.AddState("MeleeState"); WanderAction = new WanderAction(WanderState); IdleAction = new TextAction(IdleState); alertAction = new AlertAction(AlertState); meleeAction = new MeleeAction(MeleeState); WanderState.AddAction(WanderAction); IdleState.AddAction(IdleAction); AlertState.AddAction(alertAction); MeleeState.AddAction(meleeAction); WanderState.AddTransition("ToIdle", IdleState); WanderState.AddTransition("PlayerDetect", AlertState); IdleState.AddTransition("ToWander", WanderState); IdleState.AddTransition("PlayerDetect", AlertState); AlertState.AddTransition("ToIdle", IdleState); AlertState.AddTransition("ToMelee", MeleeState); MeleeState.AddTransition("ToAlert", AlertState); WanderAction.Init(this.transform, home, navMeshAgent, wanderRadius, moveTime, "ToIdle"); IdleAction.Init("Idling", Random.Range(idleTimeMin, idleTimeMax), "ToWander"); alertAction.Init(trigger, navMeshAgent, "ToIdle"); meleeAction.Init(this.transform, damage, trigger, FindObjectOfType <PlayerManager>(), "ToAlert"); fsm.Start("IdleState"); }
public Task <DateTime> ShowAsync() { var dialogResult = new TaskCompletionSource <DateTime>(); AddAction( AlertAction.Default( _config.First.ToString(CultureInfo.CurrentCulture), () => dialogResult.TrySetResult(_config.First))); AddAction( AlertAction.Default( _config.Second.ToString(CultureInfo.CurrentCulture), () => dialogResult.TrySetResult(_config.Second))); Present(); return(dialogResult.Task); }
/// <summary> /// Also waits for parent page to fully load (_title to change, updater overlay to dissapear, pending ajax calls to finish) /// </summary> /// <param name="alertAction"></param> /// <param name="waitForPageToLoadAfter"></param> /// <returns></returns> public string ActOnAlert(AlertAction alertAction, bool waitForPageToLoadAfter = true) { Log.Info(string.Format("{0}ing alert in {1}", alertAction, Title)); string alertText = WaitForAlertAsLongAs(() => IsAlertPresent, () => { var alert = Driver.SwitchTo().Alert(); alertText = alert.Text; Log.Info(string.Format("{0}ing Alert with TEXT = {1}", alertAction, alertText)); switch (alertAction) { case AlertAction.Accept: alert.Accept(); break; case AlertAction.Dismiss: alert.Dismiss(); break; default: alert.Dismiss(); break; } if (waitForPageToLoadAfter) { WaitForPageToLoad(); } return(alertText); }); Log.Info(string.Format("Alert {0}ed in {1}", alertAction, Title)); if (waitForPageToLoadAfter) { WaitForPageToLoad(); } return(alertText); }
private void timer_Tick(object sender, EventArgs e) { switch (_action) { case AlertAction.START: timer.Interval = 1; Opacity += 1; if (_positionX < Location.X) { Left--; } else if (Opacity == 1.0) { _action = AlertAction.WAIT; } break; case AlertAction.WAIT: timer.Interval = _interval; _action = AlertAction.CLOSE; break; case AlertAction.CLOSE: timer.Interval = 1; Opacity -= 1; Left -= 3; if (Opacity == 0.0) { Close(); } break; } }
public void SwitchToAlert(AlertAction alertAction) { LogMessage(LogLevel.Verbose, "Switching to alert"); var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5)); wait.IgnoreExceptionTypes(typeof(NoAlertPresentException)); wait.Until(ExpectedConditions.AlertIsPresent()); var alert = _driver.SwitchTo().Alert(); switch (alertAction) { case AlertAction.Accept: LogMessage(LogLevel.Verbose, "Accepting the alert"); alert.Accept(); break; case AlertAction.Dismiss: LogMessage(LogLevel.Verbose, "Dismissing the alert"); alert.Dismiss(); break; } }
public override void Update() { base.Update(); m_nextAITime -= Time.deltaTime; if (m_nextAITime > 0.0f) { return; } m_nextAITime = UnityEngine.Random.Range(0.1f, 0.5f); if (Self.IsDead) {//死亡 return; } FindSneak(); if (IsClearTargetWithRange()) {//清除目标列表 Self.TargetManager.ClearTarget(); } else if (!Owner.m_isDeposited && IsGoHome()) {//无敌返回 } else if (IsHealth()) {//治疗 } else if (IsCancelAlert()) {//取消警戒 Self.ActionControl.RemoveAction(ActorAction.ENType.enAlertAction); } else if (GetDamagedTarget()) {//获得伤害我的目标 ; } else if (IsAttack()) {//战斗 IsCalled = false; LoadPreCD(); Self.ShowBossBloodBar(); Self.AttackRangeChangeType = NPC.ENARChangeType.enLarge; m_patrolIndex = 0; //警戒 AlertAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enAlertAction) as AlertAction; if (action != null) {//播放开始战斗前动画 action.Refresh(); return; } //开始战斗 GetRangeTargetList(ENTargetType.enEnemy); //添加警戒目标 for (int i = 0; i < m_alertTargetList.Count; ++i) { int targetID = m_alertTargetList[i].m_targetID; if (!m_targetIDList.Contains(targetID)) { m_targetIDList.Add(targetID); } } //添加当前目标 if (Self.TargetManager.CurrentTarget != null && !Self.TargetManager.CurrentTarget.IsDead) { m_curTargetID = Self.TargetManager.CurrentTarget.ID; if (!m_targetIDList.Contains(m_curTargetID)) { m_targetIDList.Add(m_curTargetID); } } int skillID = 0; if (Self.CurrentCmd != null) {//攻击命令,直接释放 skillID = Self.CurrentCmd.m_skillID; if (Self.CurrentCmd.m_targetID != 0) { m_curTargetID = Self.CurrentCmd.m_targetID; } } if (ActionTryFireSkill(skillID)) { Self.CurrentCmd = null; if (skillID == Self.CurrentTableInfo.StaminaSkillID) {//触怒技 IResult r = BattleFactory.Singleton.CreateResult(ENResult.StaminaChanged, Self.ID, Self.ID); if (r != null) { r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } Actor target = ActorManager.Singleton.Lookup(m_curTargetID); if (target != null && !target.IsDead) { Self.TargetManager.CurrentTarget = target; } Self.CurrentCmd = null; } else { ActionForwardTo(m_curTargetID); } //呼叫同伴 GetRangeTargetList(ENTargetType.enFriendly, Self.CurrentTableInfo.CallNpcRange); Actor curTarget = ActorManager.Singleton.Lookup(m_curTargetID); for (int i = 0; i < m_targetIDList.Count; ++i) { Actor friend = ActorManager.Singleton.Lookup(m_targetIDList[i]); if (friend.Type == Owner.Type) {//只呼叫类型相同的友方 friend.SelfAI.IsCalled = true; if (friend.TargetManager.CurrentTarget == null || friend.TargetManager.CurrentTarget.IsDead) { friend.TargetManager.CurrentTarget = curTarget; } } } } else if (IsAlert()) {//警戒 Self.ShowBossBloodBar(); AlertAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enAlertAction) as AlertAction; if (action == null) { action = Self.ActionControl.AddAction(ActorAction.ENType.enAlertAction) as AlertAction; //action.Init(Self.CurrentTableInfo.AlertPeriod); } } else { //空闲 if (Self.PatrolList.Count != 0) { //巡逻 Vector3 targetPos = Self.PatrolList[m_patrolIndex]; Vector3 d = targetPos - Self.RealPos; d.y = 0; if (d.magnitude <= 0.4f) { ++m_patrolIndex; if (m_patrolIndex >= Self.PatrolList.Count) { m_patrolIndex = 0; } } else { ActionMoveTo(targetPos); } } else { if (!Owner.m_isDeposited) { Vector3 d = Self.RealPos - Self.m_startAttackPos; d.y = 0; if (d.magnitude <= 0.4f) { } else {//返回出生点 ActionMoveTo(Self.m_startAttackPos); } } else { if (!IsFinishPathList) { IsFinishPathList = true; int pathIndex = Self.Props.GetProperty_Int32(ENProperty.camp); if (SM.RandomRoomLevel.Singleton.m_scenePathNodeDic.Count != 0) { if (SM.RandomRoomLevel.Singleton.m_scenePathNodeDic[pathIndex].Count != 0) { Self.m_pathNodeList = new List <Vector3>(SM.RandomRoomLevel.Singleton.m_scenePathNodeDic[pathIndex].ToArray()); } } if (Self.m_pathNodeList.Count > 0) { Vector3 tmpPos = Self.m_pathNodeList[0]; m_curPathNode = tmpPos; Self.m_pathNodeList.Remove(tmpPos); } } if ((Self.MainPos - m_curPathNode).magnitude < 0.5) { if (Self.m_pathNodeList.Count > 0) { Vector3 tmpPos = Self.m_pathNodeList[0]; m_curPathNode = tmpPos; Self.m_pathNodeList.Remove(tmpPos); } } ActionMoveTo(m_curPathNode); } } } }
/// <summary>The handle alert.</summary> /// <param name="actionThatCausesAlert">The action that causes alert.</param> /// <param name="action">The action.</param> /// <param name="waitForCondition">The wait for condition.</param> public abstract void HandleAlert(Action actionThatCausesAlert, AlertAction action, Func <Browser, bool> waitForCondition = null);
private void CloseAlert_Click(object sender, EventArgs e) { timer.Interval = 1; _action = AlertAction.Close; }
public AlertUseCaseInput(int userId, AlertDto alertDto, AlertAction alertAction) { this.UserId = userId; this.AlertDto = alertDto; this.AlertAction = alertAction; }
/// <summary> /// Also waits for parent page to fully load (_title to change, updater overlay to dissapear, pending ajax calls to finish) /// </summary> /// <param name="alertAction"></param> /// <param name="waitForPageToLoadAfter"></param> /// <returns></returns> private void ActOnAlert(AlertAction alertAction, bool waitForPageToLoadAfter = true) { Log.Info(string.Format("{0}ing alert in {1}", alertAction, Title)); string alertText = WaitForAlertAsLongAs(() => IsAlertPresent, () => { var alert = Driver.SwitchTo().Alert(); alertText = alert.Text; Log.Info(string.Format("{0}ing Alert with TEXT = {1}", alertAction, alertText)); switch (alertAction) { case AlertAction.Accept: alert.Accept(); break; case AlertAction.Dismiss: alert.Dismiss(); break; default: alert.Dismiss(); break; } if (waitForPageToLoadAfter) WaitForPageToLoad(); return alertText; }); Log.Info(string.Format("Alert {0}ed in {1}", alertAction, Title)); if (waitForPageToLoadAfter) WaitForPageToLoad(); }
/// <summary>Displays the alert.</summary> /// <param name="message">The message.</param> /// <param name="alertType">Type of the alert.</param> /// <param name="interval">The interval.</param> /// <param name="image">The image.</param> /// <param name="backColour">The back colour.</param> /// <param name="textColour">The text colour.</param> internal void DisplayAlert(string message, AlertType alertType, int interval, Image image = null, Color backColour = default, Color textColour = default) { Opacity = 0.0; StartPosition = FormStartPosition.Manual; for (int i = 1; i < 10; i++) { var windowName = $"Alert { i }"; var window = (KryptonAlertWindow)Application.OpenForms[windowName]; if (window == null) { Name = windowName; _positionX = Screen.PrimaryScreen.WorkingArea.Width - Width - 5; _positionY = Screen.PrimaryScreen.WorkingArea.Height - Height * i - 5 * i; Location = new Point(_positionX, _positionY); break; } } _positionX = Screen.PrimaryScreen.WorkingArea.Width - Width - 5; switch (alertType) { case AlertType.SUCESS: ptbLogo.Image = Resources.sucess48px; ChangeColour(Color.SeaGreen, Color.White); break; case AlertType.INFORMATION: ptbLogo.Image = Resources.information48px; ChangeColour(Color.RoyalBlue, Color.White); break; case AlertType.WARNING: ptbLogo.Image = Resources.warning48px; ChangeColour(Color.FromArgb(230, 126, 34), Color.White); break; case AlertType.ERROR: ptbLogo.Image = Resources.error48px; ChangeColour(Color.FromArgb(231, 76, 60), Color.White); break; case AlertType.CUSTOM: ptbLogo.Image = image ?? Resources.information48px; ChangeColour(backColour, textColour); break; } klblMessage.Text = message; _interval = interval; _action = AlertAction.START; timer.Interval = 1; timer.Start(); Show(); }
private void ptbClose_Click(object sender, EventArgs e) { timer.Interval = 1; _action = AlertAction.CLOSE; }
/// <summary> /// Refreshes web page and handles alert. /// </summary> /// <param name="alertAction">Action which should be done with appeared alert.</param> public void RefreshPageWithAlert(AlertAction alertAction) { Refresh(); HandleAlert(alertAction); }
private ActorAction CreateObj(ActorAction.ENType newType) { ActorAction action = m_pool.GetObjectFromPool(newType) as ActorAction; if (action != null) { return(action); } switch (newType) { case ActorAction.ENType.enStandAction: action = new StandAction(); break; //站立 case ActorAction.ENType.enMoveAction: action = new MoveAction(); break; //移动 case ActorAction.ENType.enAttackAction: action = new AttackAction(); break; //攻击 case ActorAction.ENType.enSpasticityAction: action = new SpasticityAction(); break; //被动僵直 case ActorAction.ENType.enBeAttackAction: action = new BeAttackAction(); break; //受击 case ActorAction.ENType.enUndownAction: action = new UndownAction(); break; //霸体 case ActorAction.ENType.enDeadAction: action = new DeadAction(); break; //死亡 case ActorAction.ENType.enReliveAction: action = new ReliveAction(); break; //复活 case ActorAction.ENType.enPlayEffectAction: action = new PlayEffectAction(); break; //播放特效 case ActorAction.ENType.enSearchEnemyAction: //action = new SearchEnemyAction(); break; //搜索敌人 case ActorAction.ENType.enTeleportAction: action = new TeleportAction(); break; //瞬移 case ActorAction.ENType.enControlMoveAction: action = new ControlMoveAction(); break; //控制技能定身 case ActorAction.ENType.enHoldDownAction: action = new HoldDownAction(); break; //按下状态 case ActorAction.ENType.enSelfSpasticityAction: action = new SelfSpasticityAction(); break; //主动僵直 case ActorAction.ENType.enAlertAction: action = new AlertAction(); break; //警戒 case ActorAction.ENType.enJumpinAction: action = new JumpinAction(); break; //入场 case ActorAction.ENType.enJumpoutAction: action = new JumpoutAction(); break; //退场 case ActorAction.ENType.enRollAction: action = new RollAction(); break; //翻滚 case ActorAction.ENType.enFakeBeAttackAction: action = new FakeBeAttackAction(); break; //假受击 case ActorAction.ENType.enActorExitAction: action = new ActorExitAction(); break; //主控角色退场 case ActorAction.ENType.enActorEnterAction: action = new ActorEnterAction(); break; //主控角色入场 case ActorAction.ENType.enControlAttackAction: action = new ControlAttackAction(); break; //不能攻击 case ActorAction.ENType.enControlBeAttackAction: action = new ControlBeAttackAction(); break; //不能受击 case ActorAction.ENType.enAttackingMoveAction: action = new AttackingMoveAction(); break;//攻击时移动 case ActorAction.ENType.enDragMoveAction: action = new DragMoveAction(); break;//拖拽 default: throw new Exception("Miss Action Create for" + newType.ToString()); } return(action); }