public Movable Evolve(AgentActionType actionType) { int actionX = 0; int actionY = 0; switch (actionType) { case AgentActionType.North: actionY = 1; break; case AgentActionType.East: actionX = 1; break; case AgentActionType.South: actionY = -1; break; case AgentActionType.West: actionX = -1; break; } return(new Movable(x, y, agentType, who, actionX, actionY)); }
private void HandleAgentAction(ushort agentId, AgentType agentType, AgentActionType actionType) { if (movables.Keys.Contains(agentId)) { SetMovable(agentId, movables[agentId].Evolve(actionType)); } else { Debug.LogWarning(string.Format("Could not find player id {0}", agentId)); } }
public static AgentAction Get(AgentActionType actionType, Agent owner) { if (_buffers[(int)actionType].Count > 0) { _buffers[(int)actionType].Peek().Reset(owner); return(_buffers[(int)actionType].Dequeue()); } switch (actionType) { case AgentActionType.ROLL: return(new AgentActionRoll(owner)); case AgentActionType.MOVE: return(new AgentActionMove(owner)); case AgentActionType.ATTACK_MELEE: return(new AgentActionAttackMelee(owner)); case AgentActionType.COMBAT_MOVE: return(new AgentActionCombatMove(owner)); case AgentActionType.GOTO_POS: return(new AgentActionGoTo(owner)); case AgentActionType.INJURY: return(new AgentActionInjury(owner)); case AgentActionType.DEATH: return(new AgentActionDeath(owner)); case AgentActionType.KNOCKDOWN: return(new AgentActionKnockdown(owner)); case AgentActionType.ATTACK_WHIRL: return(new AgentActionAttackWhirl(owner)); case AgentActionType.BLOCK: return(new AgentActionBlock(owner)); default: return(null); } }
private void PlayerController_OnInput(InputType inputType) { switch (inputType) { case InputType.North: nextAction = AgentActionType.North; break; case InputType.East: nextAction = AgentActionType.East; break; case InputType.South: nextAction = AgentActionType.South; break; case InputType.West: nextAction = AgentActionType.West; break; } }
void HandleWalkStatus(Movable m) { if (m.x == prevX && m.y == prevY && myAction != TurnEnemyAction.ATTACK) { annoyance += 1; myAction = TurnEnemyAction.TURN; if (annoyance > PanicTurnAtAnnoyance) { heading = RandomHeading; } else { heading = GetTurnedHeading(); } } else { myAction = TurnEnemyAction.WALK; annoyance = 0; } prevX = m.x; prevY = m.y; }
void SetupBehaviour() { heading = RandomHeading; SetupTurnPattern(); }
public AgentAction(AgentActionType actionType, Agent owner) { _type = actionType; Owner = owner; }
private void PlayerController_OnTick(int n, int partialTick, float tickDuration, bool everyone) { Emit(nextAction); nextAction = AgentActionType.Rest; }
protected void Emit(AgentActionType action) { OnAction?.Invoke(AgentID, TypeOfAgent, action); }
public static AgentActionType Turn(AgentActionType action, TurnType turn) { if (action == AgentActionType.Rest) { return(AgentActionType.Rest); } switch (turn) { case TurnType.BOUNCE: switch (action) { case AgentActionType.East: return(AgentActionType.West); case AgentActionType.West: return(AgentActionType.East); case AgentActionType.North: return(AgentActionType.South); case AgentActionType.South: return(AgentActionType.North); } break; case TurnType.LEFT: switch (action) { case AgentActionType.North: return(AgentActionType.West); case AgentActionType.West: return(AgentActionType.South); case AgentActionType.South: return(AgentActionType.East); case AgentActionType.East: return(AgentActionType.North); } break; case TurnType.RIGHT: switch (action) { case AgentActionType.North: return(AgentActionType.East); case AgentActionType.East: return(AgentActionType.South); case AgentActionType.South: return(AgentActionType.West); case AgentActionType.West: return(AgentActionType.North); } break; } throw new System.Exception($"Invalid turn {turn} on aciton {action}"); }