本文整理汇总了C#中Agent类的典型用法代码示例。如果您正苦于以下问题:C# Agent类的具体用法?C# Agent怎么用?C# Agent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Agent类属于命名空间,在下文中一共展示了Agent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAccess
public void TestAccess()
{
var agent = new Agent().Face<ITestAgent>();
agent["Access"] = new Bin<bool>();
agent.Init("stream", typeof(Stream), false);
try
{
var f = agent["stream"].First;
}
catch (Exception e)
{
Assert.Inconclusive(e.ToString());
}
Assert.AreEqual(false, agent["Access"].First);
Assert.AreEqual(1, agent["Access"].Count);
agent.Init("Secure", true);
agent["Secure"].Add(true);
Assert.AreEqual(true, agent["Secure"][1]);
Assert.AreEqual(2, agent["Secure"].Count);
}
示例2: AStar
public AStar(Agent a)
{
agent = a;
findTarget = false;
currGoal = agent.transform.position;
hasPath = false;
}
示例3: DayStart
public override void DayStart()
{
declaredPlanningVoteAgent = null;
planningVoteAgent = null;
SetPlanningVoteAgent();
readTalkListNum = 0;
}
示例4: TestInt
public void TestInt()
{
var agent = new Agent();
agent.Init("Test", 1);
Assert.AreEqual(1, agent["Test"][0], "Vanilla Agent int initialisation");
agent["Test"].Add(2);
Assert.AreEqual(2, agent["Test"][1], "Vanilla Agent int append");
var l = new List<int> { 3, 4 };
agent["Test"].Add(l);
Assert.AreEqual(3, agent["Test"][2], "Vanilla Agent int add IEnumeration");
Assert.AreEqual(4, agent["Test"][3], "Vanilla Agent int add IEnumeration");
agent["Test"].First =0;
Assert.AreEqual(0, agent["Test"][0], "Vanilla Agent int set First");
Assert.AreEqual(0, agent["Test"].First, "Vanilla Agent int get First");
agent["Test"].AssignFrom(l);
Assert.AreEqual(3, agent["Test"][0], "Vanilla Agent int assign IEnumeration");
Assert.AreEqual(4, agent["Test"][1], "Vanilla Agent int assign IEnumeration");
Assert.AreEqual(2, agent["Test"].Count, "Vanilla Agent int Count");
agent.Init<int>("SecondTestInt");
agent["SecondTestInt"].Add(1);
Assert.AreEqual(1, agent["SecondTestInt"].First);
}
示例5: DeregisterServiceOnTakeDown
// Handles the messages associated with the take down of an agent, and deregisters the service on its behalf
public static void DeregisterServiceOnTakeDown(Agent myAgent)
{
DFService.deregister(myAgent);
MessageBox.Show(
"Agent " + myAgent.getLocalName() +
" was taken down.\r\nAn unhandled exception probably occured.");
}
示例6: Insert
public bool Insert(AirtimeBilling.Core.Entities.Agent entity)
{
if (entity == null)
{
throw new ArgumentNullException("No Agent supplied");
}
if (entity.Id != null)
{
throw new ArgumentOutOfRangeException("Agent Id is not null");
}
try
{
using (var db = DbFactory.GetDataContext())
{
var agent = new Agent();
PopulateAgentFromAgentEntity(entity, ref agent);
db.Agents.InsertOnSubmit(agent);
db.SubmitChanges();
entity.Inserted(agent.AgentId);
return true;
}
}
catch (Exception ex)
{
LoggingUtility.LogException(ex);
}
return false;
}
示例7: printSKB
//Print the Social Knowledgebase
private static void printSKB()
{
KB_S SKB = new KB_S();
SocialGame girlGame = new SocialGame(new Subject(SubjectType.Girl));
SocialGame playerGame = new SocialGame(new Subject(SubjectType.Player));
Agent agent1 = new Agent("agent1");
Agent agent2 = new Agent("agent2");
Agent agent3 = new Agent("agent3");
Agent agent4 = new Agent("agent4");
SocialFact sf1 = new SocialFact(girlGame, agent1, agent2);
SocialFact sf2 = new SocialFact(playerGame, agent1, agent2);
SocialFact sf3 = new SocialFact(girlGame, agent3, agent1);
SKB.addNewFact(sf1);
SKB.addNewFact(sf2);
SKB.addNewFact(sf3);
List<SocialFact> factsByAgent = SKB.getSocialFactsByAgent(agent2);
Console.WriteLine("FOUND: " + factsByAgent.Count + " FACTS.");
List<SocialFact> factsByGame = SKB.getSocialFactsBySubject(new Subject(SubjectType.Girl));
Console.WriteLine("FOUND: " + factsByGame.Count + " FACTS.");
//SocialFact sf1 = new SocialFact()
}
示例8: InitBehavior
//public WorldScript WorldScript;
/*
* CharacterScript (Me)
* -ActiveTask (stored as string)
* -TaskParameters (list / dictionary of strings)
* WorldScript (MyWorld)
*/
public override void InitBehavior(Agent actor)
{
//Find the relevant variables from the parent object.
WorldScript ws = GameObject.Find("Root").GetComponent<WorldScript>();
WorldGUI wGUI = GameObject.Find("Root").GetComponent<WorldGUI>();
CharacterScript cs = this.transform.parent.GetComponent<CharacterScript>();
if (ws == null || wGUI == null || cs == null) Debug.LogError("Error finding attached scripts during activation.");
actor.actionContext.AddContextItem<WorldScript>("world", ws);
actor.actionContext.AddContextItem<WorldGUI>("gui", wGUI);
actor.actionContext.AddContextItem<CharacterScript>("character", cs);
actor.actionContext.AddContextItem<GameObject>("moveTarget", cs.gameObject);
#region Temp testing.
//CharacterScript player = ws.PartyCharacter;
//Item sword = ws.GetItemByName("Sword");
//LocaleScript locale = ws.GetLocaleByName("Happyville");
//Debug.Log(locale);
//Task task = new Task("deliver", cs, player, sword, locale);
//ws.DramaManager.EmergencyRepair(task);
//cs.ActiveTask = task;
#endregion
}
示例9: executeAction
public override EnvironmentState executeAction(Agent a, Action agentAction)
{
if (ACTION_MOVE_RIGHT == agentAction)
{
envState.setAgentLocation(a, LOCATION_B);
updatePerformanceMeasure(a, -1);
}
else if (ACTION_MOVE_LEFT == agentAction)
{
envState.setAgentLocation(a, LOCATION_A);
updatePerformanceMeasure(a, -1);
}
else if (ACTION_SUCK == agentAction)
{
if (LocationState.Dirty == envState.getLocationState(envState
.getAgentLocation(a)))
{
envState.setLocationState(envState.getAgentLocation(a),
LocationState.Clean);
updatePerformanceMeasure(a, 10);
}
}
else if (agentAction.isNoOp())
{
// In the Vacuum Environment we consider things done if
// the agent generates a NoOp.
isDone = true;
}
return envState;
}
示例10: Judge
public Judge(int day, Agent agent, Agent target, Species result)
{
Day = day;
Agent = agent;
Target = target;
Result = result;
}
示例11: Instantiate
// called before loading files, otherwise, locals have been added and will be instantiated
public void Instantiate(Agent pAgent)
{
foreach(Property property_ in this.m_properties.Values)
{
property_.Instantiate(pAgent);
}
}
示例12: Awake
void Awake()
{
agentObject = gameObject.transform.parent.gameObject;
agentComponent = (Agent)agentObject.GetComponent("Agent");
clan = agentComponent.GetClan();
facts = agentComponent.GetSubsystemFacts();
}
示例13: CopyTo
public void CopyTo(Agent pAgent, Variables target)
{
target.m_variables.Clear();
var e = this.m_variables.Keys.GetEnumerator();
while (e.MoveNext())
{
uint id = e.Current;
IInstantiatedVariable pVar = this.m_variables[id];
IInstantiatedVariable pNew = pVar.clone();
target.m_variables[id] = pNew;
}
if (!Object.ReferenceEquals(pAgent, null))
{
e = target.m_variables.Keys.GetEnumerator();
while (e.MoveNext())
{
uint id = e.Current;
IInstantiatedVariable pVar = this.m_variables[id];
pVar.CopyTo(pAgent);
}
}
}
示例14: TestInt
public void TestInt()
{
var agent = new Agent().Face<ITestAgent>(true);
// agent.Init("SingleInt", typeof(int));
agent.SingleInt++;
Assert.AreEqual(1, agent["SingleInt"].First, "Face Agent int initialisation");
agent.TestInt = new Bin<int>(1);
Assert.AreEqual(1, agent.TestInt[0], "Face Agent int initialisation");
agent.TestInt.Add(2);
Assert.AreEqual(2, agent.TestInt[1], "Face Agent int append");
var l = new List<int> {3, 4};
agent.TestInt.Add(l);
Assert.AreEqual(3, agent.TestInt[2], "Face Agent int add IEnumeration");
Assert.AreEqual(4, agent.TestInt[3], "Face Agent int add IEnumeration");
agent.TestInt.First = 0;
Assert.AreEqual(0, agent.TestInt[0], "Face Agent int set First");
Assert.AreEqual(0, agent.TestInt.First, "Face Agent int get First");
agent.TestInt.AssignFrom(l);
Assert.AreEqual(3, agent.TestInt[0], "Face Agent int assign IEnumeration");
Assert.AreEqual(4, agent.TestInt[1], "Face Agent int assign IEnumeration");
Assert.AreEqual(2, agent.TestInt.Count, "Face Agent int Count");
}
示例15: Configuration
public Configuration()
{
EnvironmentSettings = new Environment();
AgentSettings = new Agent();
TagSettings = new Tag();
ResourceSettings = new Resource();
}