public ActorAction(ActionType type, int duration, ActorAction following = null) { Type = type; CurrentTick = duration; Following = following; }
public void InterpretAction(ActorAction action) { if (action is Move && timeDelay <= 0 && !InAir) { DeclareMovement((action as Move).MovementVector.normalized); action.Interpret(); } if (action is DodgeRoll && timeDelay <= 0 && !InAir) { DeclareMovement((action as DodgeRoll).MovementVector.normalized); action.Interpret(); } if (action is Jump && JumpsAvailable > 0) { VerticalVelocity = Mechanics.Movement.JumpSpeed; InAir = true; JumpsAvailable--; action.Interpret(); } if (action.Interpreted) { timeDelay += action.BaseTimeDelay; } }
// Update is called once per frame void FixedUpdate() { /* * if (ShouldBeKilled && Alive) * { * ActorDiedEventArgs arg = new ActorDiedEventArgs (ExpReward, LastAttacker, this); * OnActorDied (arg); * } */ if (!Alive) { return; } while (ActionCreator.CanPopAction) { ActorAction action = ActionCreator.PopAction; foreach (ActorActionReceiver receiver in actionReceivers) { if (receiver != null) { receiver.InterpretAction(action); } } } /* * if(Input.GetKeyDown(KeyCode.P)) * { * BeingAttackedEventArgs arg = new BeingAttackedEventArgs (new Attack (AttackType.Melee, 2, 0.5f, 0.05f, 2), this); * OnBeingHit(arg); * } */ }
protected override ActorAction SelectAction(RogueGame game, List <Percept> percepts) { List <Percept> mapPercepts = FilterSameMap(game, percepts); //////////////////////////////////////////// // 1 move in straight line to nearest enemy // 2 idle? % chance. // 3 wander //////////////////////////////////////////// // 1 move in straight line to nearest enemy Percept nearestEnemy = FilterNearest(game, FilterEnemies(game, mapPercepts)); if (nearestEnemy != null) { ActorAction bumpAction = BehaviorStupidBumpToward(game, nearestEnemy.Location.Position); if (bumpAction != null) { m_Actor.Activity = Activity.CHASING; m_Actor.TargetActor = nearestEnemy.Percepted as Actor; return(bumpAction); } } // 2 idle? % chance. if (game.Rules.RollChance(IDLE_CHANCE)) { m_Actor.Activity = Activity.IDLE; return(new ActionWait(m_Actor, game)); } // 3 wander m_Actor.Activity = Activity.IDLE; return(BehaviorWander(game)); }
void attack() { attackOrdered = false; if (Type.PreparationDelay != 0 && !self.DoesAction(ActionType.PREPARE_ATTACK)) { return; // Preparation has been canceled } var weapon = WeaponCache.Create(self.World, info.Type, target, self); Target = weapon.TargetPosition; beam = weapon as BeamWeapon; if (self.AttackWith(target, weapon)) { var reloadModifier = 1f; foreach (var effect in self.GetEffects(EffectType.COOLDOWN)) { reloadModifier *= effect.Effect.Value; } Reload = (int)(Type.Reload * reloadModifier); var cooldownAction = new ActorAction(ActionType.END_ATTACK, Type.CooldownDelay); self.AddAction(ActionType.ATTACK, Type.ShootDuration, cooldownAction); } }
private async Task <bool> AccountHasChangeRights(ActorAction actorAction, Process process, Person actingUser, CancellationToken cancellationToken = default(CancellationToken), IDictionary <object, object> context = null) { bool isValid = false; //note this should be false, but we need to hock up to directory services first. if (actingUser.Id == actorAction.ActorHanfordId) { Activity activity = process.Activities[actorAction.ActivityId]; foreach (var item in activity.Actors) { if (item.Value.ActorHanfordId == actorAction.ActorHanfordId) { isValid = true; return(isValid); } } } else { isValid = await _securityStore.IsAuthorizedChangeAccountAsync(process.ProcessDefinitionId, actingUser.Network.Username, cancellationToken, context); return(isValid); } if (!isValid) { _logger.LogInformation($"Approvals User: {actingUser.Network.Username} does not have rights to act on Activity {actorAction.ActivityId} for {actorAction.ActorHanfordId}!"); } return(isValid); }
ActorAction ExecuteDropAllItems(RogueGame game) { // if no more items, done. if (m_Actor.Inventory.IsEmpty) { return(null); } // alpha10.1 bugfix followers drop all was looping // use drop item behaviour on the first item it can. for (int i = 0; i < m_Actor.Inventory.CountItems; i++) { ActorAction dropAction = BehaviorDropItem(game, m_Actor.Inventory[i]); if (dropAction != null) { return(dropAction); } } // we still have at least one item but cannot drop it for some reason, // consider the order done. return(null); /* bugged code, did mark item to be dropped as taboo (causing loop bug) and could illegaly drop an item * // drop next item. * Item dropIt = m_Actor.Inventory[0]; * if (dropIt.IsEquipped) * return new ActionUnequipItem(m_Actor, game, dropIt); * else * return new ActionDropItem(m_Actor, game, dropIt); */ }
void RefreshWithActions(ActorProp obj) { if (obj == null) { return; } ActorActionControl accontrol = obj.ActorLogicObj.ActionControl; if (accontrol != null) { for (int i = 0; i < accontrol.ActionList.Count; i++) { ActorAction ac = accontrol.ActionList[i]; string str = ac.GetActionType().ToString(); m_strs.Add(str); } return; } else { Trap tmpTrap = obj.ActorLogicObj as Trap; TrapActionControl trapActionControl = tmpTrap.mActionControl; for (int i = 0; i < trapActionControl.ActionList.Count; i++) { TrapAction ac = trapActionControl.ActionList[i]; string str = ac.GetActionType().ToString(); m_strs.Add(str); } } }
public void FixedUpdate() { for (int index = m_actionList.Count - 1; index >= 0; --index) { ActorAction action = m_actionList[index]; if (!action.IsInited) { action.AnimStartTime = Time.time; action.OnEnter(); action.IsInited = true; } if (!action.IsEnable) { RemoveDisableCount(action.GetActionType()); m_actionList.RemoveAt(index); ReleaseObj(action); continue; } if (action.OnUpdate()) { action.OnExit(); RemoveDisableCount(action.GetActionType()); action.IsEnable = false; m_actionList.RemoveAt(index); ReleaseObj(action); } } if (m_actionList.Count == 0) { AddAction(ActorAction.ENType.enStandAction); } }
public MoveCommand(ActorAction actor, int x, int y) { x_ = x; y_ = y; xBefore_ = actor.getX(); yBefore_ = actor.getY(); }
public ActorAction Parse(Actor actor, string value) { var action = new ActorAction(); // TODO: currenty only switch actions are supported. if (value.Equals("true", StringComparison.InvariantCultureIgnoreCase) || value.Equals("on", StringComparison.InvariantCultureIgnoreCase)) { action.Type = "Switch"; action.Value = true; } else if (value.Equals("false", StringComparison.InvariantCultureIgnoreCase) || value.Equals("off", StringComparison.InvariantCultureIgnoreCase)) { action.Type = "Switch"; action.Value = false; } else { Console.WriteLine($"Can't parse action: '{action}'"); return(null); } return(action); }
public void PrintActions(string selectedTarget) //#Alterar vai ser alterado para metodo que busca dados de itens ataques e aplica na ficha em memoria chars e inimigos { List <ActorAction> actions = null; int j = 0; RemoveFalseCombination(selectedTarget); //#Temporario pensando, ler no metodo if (_actions.TryGetValue(selectedTarget, out actions)) { ActorAction actorAction = actions.Last(); j = actions.Count; if (actorAction.IsCombination) { for (int i = 0; i < j; i++) { actorAction = actions.Last(); if (actorAction.IsCombination) { Debug.Log(actorAction.Actor + " deu alvo em : " + actorAction.Target + " com a ação: " + actorAction.Action + ". É uma combinação!"); RemoveActor(actorAction.Actor); j--; i--; } } } else { Debug.Log(actorAction.Actor + " deu alvo em : " + actorAction.Target + " com a ação: " + actorAction.Action + ". Não é uma combinação!"); RemoveActor(actorAction.Actor); } } }
public override void OnGetBuffEffect() { base.OnGetBuffEffect(); Actor actor = ActorManager.Singleton.Lookup(TargetID); if (null == actor) { Debug.LogWarning("OnGetBuffEffect failed! actor is not exist! actor id=" + TargetID.ToString()); return; } BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); if (info == null) { Debug.LogWarning("buff is not exist, id is " + BuffID); return; } foreach (var item in info.BuffResultList) { if (item.ID == (int)ClassID) { m_action = actor.ActionControl.AddAction(ControlMoveAction.SGetActionType()) as ControlMoveAction; if (null != m_action) { ControlMoveAction cmAction = m_action as ControlMoveAction; cmAction.Init((ControlMoveAction.ENAnimType)item.ParamList[0]); } else { Debug.LogWarning("add ControlMoveAction failed"); } } } }
public override void ResultServerExec(IResultControl control) { base.ResultServerExec(control); Actor actor = ActorManager.Singleton.Lookup(TargetID); if (null == actor) { return; } if (actor.Type == ActorType.enMain) { MainPlayer player = actor as MainPlayer; //通知头像 player.NotifyChanged((int)Actor.ENPropertyChanged.enMainHead, EnMainHeadType.enActorRelive); } if (actor.Type == ActorType.enMain || actor.Type == ActorType.enPlayer) { //主控角色或其他玩家 if (!actor.IsActorExit) { //战斗中 actor.ForceMoveToPosition(SM.RandomRoomLevel.Singleton.m_sceneCampReliveNode[actor.Camp]); } } if (actor.Type == ActorType.enMain && !actor.IsActorExit) { MainGame.Singleton.MainCamera.MoveAtOnce(actor); } //设置头顶血条 ActorAction action = actor.ActionControl.AddAction(ActorAction.ENType.enReliveAction); if (action == null) {//添加复活action失败,则删除所有的action,再添加复活action actor.ActionControl.RemoveAll(); actor.ActionControl.AddAction(ActorAction.ENType.enReliveAction); } }
internal static ActorAction CreateActorAction(ActorItemTrack track, Type type, string name, float firetime) { GameObject item = new GameObject(name); item.transform.parent = track.transform; ActorAction action = item.AddComponent(type) as ActorAction; SortedDictionary <float, ActorAction> sortedActions = new SortedDictionary <float, ActorAction>(); foreach (ActorAction a in track.ActorActions) { sortedActions.Add(a.Firetime, a); } float latestTime = 0; float length = DEFAULT_ACTOR_ACTION_LENGTH; foreach (ActorAction a in sortedActions.Values) { if (latestTime >= a.Firetime) { latestTime = Mathf.Max(latestTime, a.Firetime + a.Duration); } else { length = a.Firetime - latestTime; break; } } action.Firetime = latestTime; action.Duration = length; track.Manager.recache(); return(action); }
private KeyValuePair <int, int> FindFirst(ActorAction src) { var ret = new KeyValuePair <int, int>(int.MaxValue, int.MaxValue); foreach (var x in m_Candidates) { int ub = x.Value.Count; while (0 <= --ub) { var test_act = x.Value[ub]; if (test_act is Actions.ActionChain chain) { if (src.AreEquivalent(chain.ConcreteAction)) { return(new KeyValuePair <int, int>(x.Key, ub)); } continue; } if (src.AreEquivalent(test_act)) { return(new KeyValuePair <int, int>(x.Key, ub)); } } } return(ret); }
public ActorAction AddAction(ActorAction.ENType newType) { if (!IsDisable(newType)) { bool isValidateActionState = false; for (int index = m_actionList.Count - 1; index >= 0; --index) { ActorAction item = m_actionList[index]; if (!item.IsEnable) { continue; } if (ActorAction.ENRelation.enReplace == CheckRelation(newType, item.GetActionType())) { m_actionList.RemoveAt(index); isValidateActionState = true; item.OnInterupt(); RemoveDisableCount(item.GetActionType()); item.IsEnable = false; ReleaseObj(item); } } ActorAction obj = CreateObj(newType); obj.CurrentActor = CurrentActor; if (null != CurrentActor.mActorBlendAnim) { CurrentActor.mActorBlendAnim.CurActionType = newType; } ActioningObjArray[(int)newType] = obj; m_actionList.Add(obj); AddDisableCount(obj.GetActionType()); if (isValidateActionState) { for (int i = 0; i < ActioningArray.Length; i++) { ActioningArray[i] = 0; ActioningObjArray[i] = null; } for (int i = 0; i < m_actionList.Count; i++) { ActorAction ac = m_actionList[i]; ActioningObjArray[(int)ac.GetActionType()] = ac; ActioningArray[(int)ac.GetActionType()]++; } } return(obj); } else { string currentActions = CurrentActor.GetType() + ":" + newType.ToString() + " Current Actions:"; foreach (ActorAction action in m_actionList) { currentActions += action.GetActionType().ToString() + ", "; } //Debug.LogWarning("Add action failed:" + newType.ToString()+" actor type:"+CurrentActor.Type.ToString()); return(null); } }
public async Task ApplyActorActionAsync_ThrowsInvalidOperationException_ActivityNull() { int testId = -4; IList <int> activityComplete = new List <int>() { testId }; List <Process> returnList = new List <Process>(); returnList.Add(new Process() { ProcessId = testId, ProcessState = "PENDING", Activities = new Dictionary <int, Activity>() { { 1, new Activity() { ActivityId = 1, ActivityState = "NULL" } } } }); PagedResult <Process> result = new PagedResult <Process>(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), returnList); ActorAction actorAction = new ActorAction() { ProcessId = testId, ActivityId = 1 }; _mockProcessStore // arrange .Setup(store => store.GetAsync(It.Is <IList <int> >(s => s[0] == testId), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>(), It.IsAny <IDictionary <object, object> >())) .ReturnsAsync(result); _mockSecurityStore // arrange .Setup(store => store.GetAuthorizedAccountsAsync(It.IsAny <Process>(), It.IsAny <CancellationToken>(), It.IsAny <IDictionary <object, object> >())) .ReturnsAsync(new List <string>() { "Valid Id" }); try { var facade = InstanceActivityFacade(_mockActivityStore, _mockProcessStore, _mockPersonIdentificationStore, _mockApprovalsLegacyStore, _mockSecurityStore); var actual = await facade.ApplyActorActionAsync(actorAction, It.IsAny <Person>(), It.IsAny <CancellationToken>(), It.IsAny <IDictionary <object, object> >()); // act Assert.Fail(); } catch (InvalidOperationException) { // correct behavior } catch (Exception) { Assert.Fail(); } }
public ActionBump(Actor actor, RogueGame game, Direction direction) : base(actor, game) { m_Direction = direction; m_NewLocation = actor.Location + direction; m_ConcreteAction = game.Rules.IsBumpableFor(m_Actor, game, m_NewLocation, out m_FailReason); }
new void Start() { base.Start(); priorityAction = GetAction("Move Forward Action"); otherActions.Add(GetAction("Turn Left Action")); otherActions.Add(GetAction("Turn Right Action")); }
ActorAction ExecuteBarricading(RogueGame game, Location location, bool toTheMax) { ///////////////////// // 1. Check validity. // 2. Perform. ///////////////////// // 1. Check validity. if (m_Actor.Location.Map != location.Map) { return(null); } DoorWindow door = location.Map.GetMapObjectAt(location.Position) as DoorWindow; if (door == null) { return(null); } if (!game.Rules.CanActorBarricadeDoor(m_Actor, door)) { return(null); } // 2. Perform. // 2.1 If adjacent, barricade. // 2.2 Move closer. // 2.1 If adjacent, barricade. if (game.Rules.IsAdjacent(m_Actor.Location.Position, location.Position)) { ActorAction barricadeAction = new ActionBarricadeDoor(m_Actor, game, door); if (barricadeAction.IsLegal()) { if (!toTheMax) { SetOrder(null); } return(barricadeAction); } else { return(null); } } // 2.2 Move closer. ActorAction moveAction = BehaviorIntelligentBumpToward(game, location.Position, false, false); if (moveAction != null) { RunIfPossible(game.Rules); return(moveAction); } else { return(null); } }
private bool Temp_Remove_Action(ActorAction act) { if (act.GetActionType() == m_curRemoveType_Temp) { ReleaseObj(act); return(true); } return(false); }
public void ConnectButton(string buttonName, ActorAction action) { PlayerActionButton button = GetButton(buttonName); if (button != null) { button.actionToPerform = action; } }
public void ReleaseAll() { for (int i = 0; i < m_actionList.Count; i++) { ActorAction action = m_actionList[i]; ReleaseObj(action); } m_actionList.Clear(); }
public StageAction(int t0, Actor who, ActorAction free_act) : base(t0, who) { #if DEBUG if (!(who.Controller is ObjectiveAI)) { throw new ArgumentOutOfRangeException(nameof(who), who, "not intelligent enough to plan ahead"); } #endif Intent = free_act; }
public ActorAction CreateAction(int actorID, ActorAction.ActionType actionType) { ActorAction action = new ActorAction { actorID = actorID, actionType = actionType }; return(action); }
public void RemoveAction(ActorAction action) { if (action == null) { return; } action.OnInterupt(); RemoveDisableCount(action.GetActionType()); m_actionList.Remove(action); ReleaseObj(action); }
public override bool IsLegal() { if (_AP <= m_Actor.ActionPoints && _turn >= m_Actor.Location.Map.LocalTime.TurnCounter) { return(true); } if (0 < _handler_codes.Count && !m_Actor.Controller.IsMyTurn()) { return(true); // XXX i.e., this ActionSequence class will not work for PlayerController } return((_result ?? (_result = _resolve()))?.IsPerformable() ?? false); }
public ActionBump(Actor actor, Direction direction) : base(actor) { m_Direction = direction; m_NewLocation = actor.Location + direction; // tentatively excluding this ActionBump class from IsPerformable upgrade due to this m_ConcreteAction = Rules.IsBumpableFor(m_Actor, in m_NewLocation, out m_FailReason); #if DEBUG if (null != m_ConcreteAction && !m_ConcreteAction.IsPerformable()) { throw new ArgumentOutOfRangeException(nameof(m_ConcreteAction), m_ConcreteAction, "not performable"); } #endif }
public void MakeAction() { ActorAction currentAction = GetCurrentActorsAction(); switch (currentAction.actionType) { case ActorAction.ActionType.MOVEUP: activeActor.MoveDirection(ControllableActor.Direction.UP); break; case ActorAction.ActionType.MOVELEFT: activeActor.MoveDirection(ControllableActor.Direction.LEFT); break; case ActorAction.ActionType.MOVERIGHT: activeActor.MoveDirection(ControllableActor.Direction.RIGHT); break; case ActorAction.ActionType.MOVEDOWN: activeActor.MoveDirection(ControllableActor.Direction.DOWN); break; case ActorAction.ActionType.FACEUP: activeActor.FaceDirection(ControllableActor.Direction.UP); break; case ActorAction.ActionType.FACELEFT: activeActor.FaceDirection(ControllableActor.Direction.LEFT); break; case ActorAction.ActionType.FACERIGHT: activeActor.FaceDirection(ControllableActor.Direction.RIGHT); break; case ActorAction.ActionType.FACEDOWN: activeActor.FaceDirection(ControllableActor.Direction.DOWN); break; case ActorAction.ActionType.MELEEATTACK: activeActor.MeleeAttack(); break; case ActorAction.ActionType.RANGEDATTACK: activeActor.RangedAttack(); break; case ActorAction.ActionType.USEITEM: break; case ActorAction.ActionType.USESPELL: break; } }
public void ForEachActor(ActorAction myDelegate) { int[] layerOrder = new int[_layers.Keys.Count]; _layers.Keys.CopyTo(layerOrder, 0); Array.Sort(layerOrder); for (int i = 0; i < layerOrder.Length; ++i) { LinkedList<Renderable> currentLayer = _layers[layerOrder[i]]; foreach (Renderable renderable in currentLayer) { Actor theActor = renderable as Actor; if (theActor != null) myDelegate(theActor); } } }