Inheritance: MonoBehaviour
Example #1
0
		public Interaction(Agent source, Agent target, StatAdjustment adjustment, BuffEffect? effect = null)
		{
			Source = source;
			Target = target;
			this.adjustment = adjustment;
			this.effect = effect;
		}
            public int GetWeight(Agent pAgent)
            {
                Debug.Check(this.GetNode() is DecoratorWeight);
                DecoratorWeight pNode = (DecoratorWeight)(this.GetNode());

                return pNode != null ? pNode.GetWeight(pAgent) : 0;
            }
Example #3
0
 public void Initialize(Agent[] agents, GameObject host)
 {
     relations = new List<AgentRelation>();
     for(int i = 0; i < agents.Length; i++)
     {
         for (int j = 0; j < agents.Length; j++)
         {
             if (i == j) continue;
             GameObject go = new GameObject();
             go.transform.parent = host.transform;
             var rend = go.AddComponent<LineRenderer>();
             rend.SetWidth(0.05f, 0.05f);
             rend.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
             rend.receiveShadows = false;
             rend.material = new Material(Shader.Find("Sprites/Default"));
             relations.Add(new AgentRelation
             {
                 a = agents[i],
                 b = agents[j],
                 relation = Random.Range(minRelation, 1f),
                 renderer = rend
             });
         }
     }
 }
Example #4
0
        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);
        }
 public override void DayStart()
 {
     declaredPlanningVoteAgent = null;
     planningVoteAgent = null;
     SetPlanningVoteAgent();
     readTalkListNum = 0;
 }
Example #6
0
        // Returns the AID of the first found service provider
        public static AID FindService(string serviceName, Agent myAgent, int timeOut)
        {
            AID providerAID = null;
            bool found = false;

            double t1 = PerformanceCounter.GetValue();
            while (!found)
            {
                if (PerformanceCounter.GetValue() - t1 > timeOut)
                    break;

                Application.DoEvents();

                // search for a provider
                DFAgentDescription template = new DFAgentDescription();
                ServiceDescription sd = new ServiceDescription();
                sd.setType(serviceName);
                template.addServices(sd);

                DFAgentDescription[] result = DFService.search(myAgent, template);
                if (result != null && result.Length > 0)
                {
                    providerAID = result[0].getName();
                    found = true;
                }
            }

            return providerAID;
        }
Example #7
0
 public AStar(Agent a)
 {
     agent = a;
     findTarget = false;
     currGoal = agent.transform.position;
     hasPath = false;
 }
Example #8
0
 void AgentPanel(Agent agent)
 {
     GUILayout.BeginVertical();
         //GUILayout.Box(agent._name, GUILayout.Height(100f));
         GUILayout.Box(agent._name);
         GUILayout.Label("HP: "+agent.life+"/"+agent.lifeTotal+"  "+"XP: "+agent.skill);
         GUILayout.BeginHorizontal();
          GUILayout.Label("BP:");
          Dictionary<Type, int> typeToCount = new Dictionary<Type, int>();
          Dictionary<Type, Texture> typeToIcon = new Dictionary<Type, Texture>();
          foreach (EObject obj in agent.backpack) {
             if (typeToCount.ContainsKey(obj.GetType()))
                 typeToCount[obj.GetType()] = typeToCount[obj.GetType()] + 1;
             else {
                 typeToCount.Add(obj.GetType(), 1);
                 typeToIcon.Add(obj.GetType(), obj.getIcon());
             }
          }
         foreach (Type type in typeToCount.Keys) {
         GUILayout.BeginHorizontal();
             GUIStyle iconStyle = new GUIStyle();
             iconStyle.margin = new RectOffset(0, 0, 5, 0);
             GUILayout.Label(typeToIcon[type], iconStyle, GUILayout.Width (20), GUILayout.Height (15));
             GUIStyle textStyle = new GUIStyle();
             textStyle.margin = new RectOffset(0, 10, 5, 0);
             textStyle.normal.textColor = Color.white;
             GUILayout.Label(": " + typeToCount[type], textStyle);
         GUILayout.EndHorizontal();
         }
         GUILayout.EndHorizontal();
     GUILayout.EndVertical();
 }
Example #9
0
 // 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.");
 }
Example #10
0
        public void TestDouble()
        {
            var agent = new Agent();

            agent.Init("Test", 1.0);
            Assert.AreEqual(1.0, agent["Test"][0], "Vanilla Agent double initialisation");

            agent["Test"].Add(2.0);
            Assert.AreEqual(2.0, agent["Test"][1], "Vanilla Agent double append");

            var l = new List<double> { 3.0, 4.0 };
            agent["Test"].Add(l);

            Assert.AreEqual(3.0, agent["Test"][2], "Vanilla Agent double add IEnumeration");
            Assert.AreEqual(4.0, agent["Test"][3], "Vanilla Agent double add IEnumeration");

            agent["Test"].First = 0.0;
            Assert.AreEqual(0.0, agent["Test"][0], "Vanilla Agent double set First");
            Assert.AreEqual(0.0, agent["Test"].First, "Vanilla Agent double get First");

            agent["Test"].AssignFrom(l);
            Assert.AreEqual(3.0, agent["Test"][0], "Vanilla Agent double assign IEnumeration");
            Assert.AreEqual(4.0, agent["Test"][1], "Vanilla Agent double assign IEnumeration");

            Assert.AreEqual(2, agent["Test"].Count, "Vanilla Agent double Count");
        }
Example #11
0
        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);
        }
Example #12
0
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                EBTStatus s = childStatus;
                Debug.Check(this.m_activeChildIndex < this.m_children.Count);

                // Keep going until a child behavior says its running.
                for (; ;)
                {
                    if (s == EBTStatus.BT_RUNNING)
                    {
                        int childIndex = this.m_set[this.m_activeChildIndex];
                        BehaviorTask pBehavior = this.m_children[childIndex];
                        s = pBehavior.exec(pAgent);
                    }

                    // If the child succeeds, or keeps running, do the same.
                    if (s != EBTStatus.BT_FAILURE)
                    {
                        return s;
                    }

                    // Hit the end of the array, job done!
                    ++this.m_activeChildIndex;

                    if (this.m_activeChildIndex >= this.m_children.Count)
                    {
                        return EBTStatus.BT_FAILURE;
                    }

                    s = EBTStatus.BT_RUNNING;
                }
            }
Example #13
0
        //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()
        }
Example #14
0
        public static bool EvaluteAssignment(Agent pAgent, Property opl, Property opr, behaviac.CMethodBase opr_m)
        {
            bool bValid = false;

            if (opl != null)
            {
                if (opr_m != null)
                {
                    object returnValue = opr_m.Invoke(pAgent);

                    Agent pParentOpl = opl.GetParentAgent(pAgent);
                    opl.SetValue(pParentOpl, returnValue);

                    bValid = true;
                }
                else if (opr != null)
                {
                    Agent pParentL = opl.GetParentAgent(pAgent);
                    Agent pParentR = opr.GetParentAgent(pAgent);

                    opl.SetFrom(pParentR, opr, pParentL);

                    bValid = true;
                }
            }

            return bValid;
        }
Example #15
0
        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;
        }
Example #16
0
        public void TestString()
        {
            dynamic agent = new Agent();

            agent.TestString = new Bin<string>("First");
            Assert.AreEqual("First", agent.TestString[0], "Dynamic Agent string initialisation");

            agent.TestString.Add("Second");
            Assert.AreEqual("Second", agent.TestString[1], "Dynamic Agent string append");

            var l = new List<string> { "Third", "Fourth" };
            agent.TestString.Add(l);

            Assert.AreEqual("Third", agent.TestString[2], "Dynamic Agent string add IEnumeration");
            Assert.AreEqual("Fourth", agent.TestString[3], "Dynamic Agent string add IEnumeration");

            agent.TestString.First = "Zero";
            Assert.AreEqual("Zero", agent.TestString[0], "Dynamic Agent string set First");
            Assert.AreEqual("Zero", agent.TestString.First, "Dynamic Agent string get First");

            agent.TestString.AssignFrom(l);
            Assert.AreEqual("Third", agent.TestString[0], "Dynamic Agent string assign IEnumeration");
            Assert.AreEqual("Fourth", agent.TestString[1], "Dynamic Agent string assign IEnumeration");

            Assert.AreEqual(2, agent.TestString.Count, "Dynamic Agent int Count");
        }
 public Configuration()
 {
     EnvironmentSettings = new Environment();
     AgentSettings = new Agent();
     TagSettings = new Tag();
     ResourceSettings = new Resource();
 }
Example #18
0
        public void TestDouble()
        {
            dynamic agent = new Agent();

            agent.TestDouble = new Bin<double>(1.0);

            Assert.AreEqual(1.0, agent.TestDouble[0], "Dynamic Agent double initialisation");

            agent.TestDouble.Add(2.0);
            Assert.AreEqual(2.0, agent.TestDouble[1], "Dynamic Agent double append");

            var l = new List<double> { 3.0, 4.0 };
            agent.TestDouble.Add(l);

            Assert.AreEqual(3.0, agent.TestDouble[2], "Dynamic Agent double add IEnumeration");
            Assert.AreEqual(4.0, agent.TestDouble[3], "Dynamic Agent double add IEnumeration");

            agent.TestDouble.First = 0.0;
            Assert.AreEqual(0.0, agent.TestDouble[0], "Dynamic Agent double set First");
            Assert.AreEqual(0.0, agent.TestDouble.First, "Dynamic Agent double get First");

            agent.TestDouble.AssignFrom(l);
            Assert.AreEqual(3.0, agent.TestDouble[0], "Dynamic Agent double assign IEnumeration");
            Assert.AreEqual(4.0, agent.TestDouble[1], "Dynamic Agent double assign IEnumeration");

            Assert.AreEqual(2, agent.TestDouble.Count, "Dynamic Agent double Count");
        }
Example #19
0
        public void TestInt()
        {
            dynamic agent = new Agent();

            agent.TestInt = new Bin<int>(1);
            Assert.AreEqual(1, agent.TestInt[0], "Dynamic Agent int initialisation");

            agent.TestInt.Add(2);
            Assert.AreEqual(2, agent.TestInt[1], "Dynamic Agent int append");

            var l = new List<int> { 3, 4 };
            agent.TestInt.Add(l);

            Assert.AreEqual(3, agent.TestInt[2], "Dynamic Agent int add IEnumeration");
            Assert.AreEqual(4, agent.TestInt[3], "Dynamic Agent int add IEnumeration");

            agent.TestInt.First = 0;
            Assert.AreEqual(0, agent.TestInt[0], "Dynamic Agent int set First");
            Assert.AreEqual(0, agent.TestInt.First, "Dynamic Agent int get First");

            agent.TestInt.AssignFrom(l);
            Assert.AreEqual(3, agent.TestInt[0], "Dynamic Agent int assign IEnumeration");
            Assert.AreEqual(4, agent.TestInt[1], "Dynamic Agent int assign IEnumeration");

            Assert.AreEqual(2, agent.TestInt.Count, "Dynamic Agent int Count");

            agent.Init<int>("SecondTestInt");
            agent.SecondTestInt.Add(1);
            Assert.AreEqual(1, agent.SecondTestInt.First);
        }
Example #20
0
        public void Start(Action<TcpClient, byte[]> onData, Action<TcpClient> onDisconnect)
        {
            TcpListener listener = new TcpListener(port);
            listener.Start();
            running = true;
            AutoResetEvent are = new AutoResetEvent(false);
            agent = new Agent<Action>(
                () => { },
                () => { },
                nextaction =>
                {

                    nextaction();

                    if (running)
                    {
                        return NextAction.WaitForNextMessage;
                    }
                    are.Set();
                    return NextAction.Finish;
                });

            agent.Start();

            agent.SendMessage(() => { StartAccepting(listener, onData, onDisconnect); });
            are.WaitOne();

            listener.Stop();
        }
Example #21
0
 /// <summary>
 /// Performs the main action of the Enemy when it reaches its target
 /// </summary>
 /// <param name="target">Target is the Turret that will be Attacked</param>
 public void Attack(Agent target)
 {
     if (state != AgentState.Dead)
     {
         target.Die();
     }
 }
            public int GetCount(Agent pAgent)
            {
                Debug.Check(this.GetNode() is DecoratorCount);
                DecoratorCount pDecoratorCountNode = (DecoratorCount)(this.GetNode());

                return pDecoratorCountNode != null ? pDecoratorCountNode.GetCount(pAgent) : 0;
            }
    //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
    }
Example #24
0
 public Judge(int day, Agent agent, Agent target, Species result)
 {
     Day = day;
     Agent = agent;
     Target = target;
     Result = result;
 }
Example #25
0
 // 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);
     }
 }
Example #26
0
        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);
                }
            }
        }
Example #27
0
 void Awake()
 {
     agentObject = gameObject.transform.parent.gameObject;
     agentComponent = (Agent)agentObject.GetComponent("Agent");
     clan = agentComponent.GetClan();
     facts = agentComponent.GetSubsystemFacts();
 }
Example #28
0
        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;
        }
Example #29
0
        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");
        }
Example #30
0
        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown) {
                Random rand = new Random();
                Vector3 dir = Vector3.Normalize(p.getDirectionVector());
                Vector3 right = Vector3.Cross(dir, Vector3.Up);
                Vector3 up = Vector3.Cross(dir, right);
                up *= inaccuracy;
                right *= inaccuracy;
                dir = dir + (float)(rand.NextDouble() * 2 - 1) * up + (float)(rand.NextDouble() * 2 - 1) * right;
                inaccuracy = Math.Min(maxInaccuracy, inaccruacyJump + inaccuracy);
                inaccuracyCurCooldown = 0;

                List<Agent> l = new List<Agent>();
                l.Add(p);
                PhysicsEngine.HitScan hs = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
                PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 60, 0) + p.getDirectionVector() * 10, dir, l);
                if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                    makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Rifle");
                else if (ahs != null) {
                    ahs.agent.dealDamage(damage, p);
                    makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Rifle");
                }
            }
        }
Example #31
0
        static void DoReasoning(Agent reasoner)
        {
            //Gets an input to use for reasoning. Note that the World.GetSensoryInformation method can also be used here
            ActivationCollection si = ImplicitComponentInitializer.NewDataSet();

            //activation values
            double act1 = 0;
            double act2 = 0;

            //Sets up the input
            foreach (DimensionValuePair dv in dvs)
            {
                if (chunks[0].Contains(dv))
                {
                    si.Add(dv, 1);
                }
            }

            Console.WriteLine("Using features for \"bird\" as input to reasoner:\r\n" + si);
            Console.WriteLine();
            Console.WriteLine("Output from reasoner:");

            //Performs reasoning based on the input.
            var o = reasoner.NACS.PerformReasoning(si);

            //Iterates through the conclusions from reasoning
            foreach (var i in o)
            {
                // if the bird chunk, skip
                if (i.CHUNK == chunks[0])
                {
                    continue;
                }
                else
                {
                    Console.WriteLine(i.CHUNK);
                    //if the robin chunk, set the first activation value
                    if (i.CHUNK == chunks[1])
                    {
                        act1 = i.ACTIVATION;
                    }
                    //otherwise, set the second activation value for penguins
                    else
                    {
                        act2 = i.ACTIVATION;
                    }
                    Console.WriteLine("Activation of \"" + i.CHUNK.LabelAsIComparable + "\" chunk based on \"bird\" features: " + Math.Round(i.ACTIVATION, 2));
                }
                Console.WriteLine();
            }

            Console.WriteLine("Which is more typical of a bird?");

            if (act1 > act2)
            {
                Console.WriteLine("A robin because its chunk activation is higher (" + Math.Round(act1, 2) + " vs. " + Math.Round(act2, 2) + ")");
            }
            else
            {
                Console.WriteLine("A penguin because its chunk activation is higher (" + Math.Round(act2, 2) + " vs. " + Math.Round(act1, 2) + ")");
            }
        }
 public override void OnAgentRemoved(Agent affectedAgent, Agent affectorAgent, AgentState agentState, KillingBlow blow)
 {
     _querySystemSubLogic.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);
 }
        public override void OnAgentFleeing(Agent affectedAgent)
        {
            base.OnAgentFleeing(affectedAgent);

            FormationColorSubLogic.OnAgentFleeing(affectedAgent);
        }
 public override void OnAgentBuild(Agent agent, Banner banner)
 {
     _querySystemSubLogic.OnAgentBuild(agent, banner);
     FormationColorSubLogic.OnAgentBuild(agent, banner);
 }
 public override void Enter(Agent owner)
 {
     Debug.Log(GetType().Name + " Enter");
 }
 public override void Exit(Agent owner)
 {
     Debug.Log(GetType().Name + " Exit");
 }
Example #37
0
 public AgentBuffData(Agent agent, Dictionary <Skill, IBuffStackCollection> stackCollectionsBySkills)
 {
     Agent = agent;
     StackCollectionsBySkills = stackCollectionsBySkills;
 }
Example #38
0
 public Jump(ModifierTypes modifier, Agent agent) : base(modifier, agent)
 {
     Type = VerbTypes.Jump;
 }
Example #39
0
 public Tile()
 {
     occupier = null;
 }
Example #40
0
 /// <summary>
 /// The xmpp on on agent item.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="agent">
 /// The agent.
 /// </param>
 private void XmppOnOnAgentItem(object sender, Agent agent)
 {
 }
Example #41
0
    public override void Update(Agent a, float dt)
    {
        Seeker agentScript = a.GetComponent <Seeker>();


        if (GameLogic.instance.currentPlayer != null)
        {
            agentScript.target = GameLogic.instance.currentPlayer.transform;
        }

        int currentTarget = agentScript.currentTarget;

        //Debug.Log(currentTarget);
        //Debug.Log(Vector2.Distance(seek.Path_Points[currentTarget].position, a.transform.position));

        a.GetComponent <Rigidbody2D>().gravityScale = 0;
        if (Vector2.Distance(agentScript.Path_Positions[currentTarget], a.transform.position) > threshold)
        {
            //ATENUACIÓN SE SPEED CUANDO ESTA LLEGANDO
            if (Vector2.Distance(agentScript.Path_Positions[currentTarget], a.transform.position) > slowThreshold)
            {
                followSpeed = Mathf.Clamp(followSpeed + Time.deltaTime, minSpeed, maxSpeed);
            }
            //RECUPERA LA SPEED NORMAL SI NO ESTA LLEGANDO
            else
            {
                followSpeed = maxSpeed - (2 - Vector2.Distance(agentScript.Path_Positions[currentTarget], a.transform.position));
            }

            //SET VELOCITY A CADA FRAME
            a.gameObject.GetComponent <Rigidbody2D>().velocity = ((agentScript.Path_Positions[currentTarget] - a.transform.position).normalized * followSpeed);
            //Debug.Log((seek.Path_Points[currentTarget].position - a.transform.position).normalized * followSpeed);
            //Debug.Log(a.gameObject.GetComponent<Rigidbody2D>().velocity);
        }
        else
        {
            if (a.GetComponent <Seeker>().increasing)
            {
                if (currentTarget < agentScript.Path_Positions.Length - 1)
                {
                    currentTarget++;
                    agentScript.currentTarget++;
                }
                else
                {
                    agentScript.increasing = false;
                }
            }
            else
            {
                if (currentTarget > 0)
                {
                    currentTarget--;
                    agentScript.currentTarget--;
                }
                else
                {
                    agentScript.increasing = true;
                }
            }
        }
        Transform target    = a.GetComponent <Seeker>().target;
        Vector2   targetDir = target.position - a.transform.position;
        Vector2   whereTo   = a.transform.right;

        if (a.GetComponent <Rigidbody2D>().velocity.x < 0)
        {
            whereTo *= -1;
        }

        float angle = Vector2.Angle(targetDir, whereTo);

        if (angle < agentScript.coneAngle && Vector2.Distance(target.position, a.transform.position) < agentScript.visionRange)
        {
            //Debug.Log(angle);
            //if (target.gameObject.GetComponent<PlayerController>().)
            if (!target.GetComponent <PlayerController>().behindBush || !target.GetComponent <PlayerController>().crawling)
            {
                a.SwitchState(0, new SeekerChaseState());
            }
        }

        //Debug.DrawLine(a.transform.position, a.transform.position);
        //Debug.Log(angle);
    }
Example #42
0
 public override bool DoWant(Agent agent)
 {
     return(agent.IsWorker && Units.Count < 2);
 }
Example #43
0
 public override void OnExit(Agent a)
 {
     a.gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
 }
Example #44
0
        protected virtual Agent UpdateAgent(Agent agent, List <Agent> localAgents)
        {
            var separationF          = Vector3.zero;
            var alignmentF           = Vector3.zero;
            var cohesionF            = Vector3.zero;
            var boundsF              = Vector3.zero;
            var avoidF               = Vector3.zero;
            var agentPosition        = agent.position;
            var focusDelta           = focusPosition - agentPosition;
            var swarmRadius2         = swarmRadius * swarmRadius;
            var avoidDistance2       = avoidDistance * avoidDistance;
            var minAttractionRadius2 = minAttractionRadius * minAttractionRadius;
            var maxAttractionRadius2 = maxAttractionRadius * maxAttractionRadius;

            if (focusDelta.sqrMagnitude > swarmRadius2)
            {
                boundsF = focusDelta / swarmRadius;
            }

            if (useVerticalAvoidance)
            {
                var floorHeight = agentPosition.y - (floorPosition.y + relativeFloorHeight);
                floorHeight = floorHeight > 0 ? 0 : floorHeight;
                avoidF     += Vector3.up * floorWeight * (-floorHeight);
                var ceilingHeight = agentPosition.y - (floorPosition.y + relativeCeilingHeight);
                ceilingHeight = ceilingHeight < 0 ? 0 : ceilingHeight;
                avoidF       += Vector3.up * ceilingWeight * (-ceilingHeight);
            }

            for (var k = 0; k < avoidPositions.Length; k++)
            {
                var d = (avoidPositions[k] - agentPosition);
                if (d.sqrMagnitude < avoidDistance2)
                {
                    var distanceToAvoid = d.magnitude;
                    var direction       = -d / distanceToAvoid;
                    var power           = avoidDistance / distanceToAvoid;
                    avoidF += direction * power;
                }
            }

            for (var k = 0; k < attractPositions.Length; k++)
            {
                var d            = (attractPositions[k] - agentPosition);
                var sqrMagnitude = d.sqrMagnitude;
                if (sqrMagnitude > minAttractionRadius2 && sqrMagnitude < maxAttractionRadius2)
                {
                    var distanceToAttract = d.magnitude;
                    var direction         = d / distanceToAttract;
                    var power             = maxAttractionRadius / distanceToAttract;
                    avoidF += direction * power;
                }
            }

            if (localAgents.Count > 0)
            {
                var alignmentCoeff = 1f / localAgents.Count;
                var stride         = localAgents.Count / maxNeighbors;
                stride = stride < 1 ? 1 : stride;
                for (var k = 0; k < localAgents.Count; k += stride)
                {
                    var other         = localAgents[k];
                    var otherPosition = other.position;
                    if (agentPosition == otherPosition)
                    {
                        continue;
                    }
                    var otherVelocity = other.velocity;
                    alignmentF += otherVelocity;
                    var   delta           = agentPosition - otherPosition;
                    var   distanceToOther = delta.magnitude;
                    var   direction       = delta / distanceToOther;
                    float power           = separation / distanceToOther;
                    if (distanceToOther < separation)
                    {
                        separationF += (separationWeight * direction * power);
                    }
                    else
                    {
                        separationF -= (cohesionWeight * direction * power);
                    }
                }
                separationF *= alignmentCoeff;
                alignmentF  *= alignmentCoeff;
            }

            var newVelocity = Vector3.zero;

            newVelocity += separationF;
            newVelocity += alignmentF * alignmentWeight;
            newVelocity += boundsF * boundsWeight;
            newVelocity += avoidF * avoidWeight;

            newVelocity    = newVelocity * deltaTime * maxSteer;
            agent.velocity = Vector3.ClampMagnitude(agent.velocity + newVelocity, speed) + (windDirection * windPower * deltaTime);
            return(agent);
        }
Example #45
0
    //abstact class that is used to create states down the line. Just includes the shared execute function that all states will possess. 


    public abstract void Execute(Agent agent);
Example #46
0
 public override void OnEnter(Agent a)
 {
 }
Example #47
0
    public void AddOrder(AgentOrder order)
    {
        if (IsOrderAddPossible(order.Type))
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type);
            switch (order.Type)
            {
            case AgentOrder.E_OrderType.E_STOPMOVE:
                Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
                DesiredPosition = Owner.Position;
                break;

            case AgentOrder.E_OrderType.E_GOTO:
                Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
                DesiredPosition   = order.Position;
                DesiredDirection  = order.Direction;
                MoveSpeedModifier = order.MoveSpeedModifier;
                break;

            case AgentOrder.E_OrderType.E_DODGE:
                DesiredDirection = order.Direction;
                break;

            case AgentOrder.E_OrderType.E_USE:
                Owner.WorldState.SetWSProperty(E_PropKey.E_USE_WORLD_OBJECT, true);

                if ((order.Position - Owner.Position).sqrMagnitude <= 1)
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
                }
                else
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
                }
                DesiredPosition   = order.Position;
                InteractionObject = order.InteractionObject;
                Interaction       = order.Interaction;
                break;

            case AgentOrder.E_OrderType.E_ATTACK:
                if (order.Target == null || (order.Target.Position - Owner.Position).magnitude <= (WeaponRange + 0.2f))
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, true);
                }
                else
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, false);
                }

                DesiredAttackType  = order.AttackType;
                DesiredTarget      = order.Target;
                DesiredDirection   = order.Direction;
                DesiredAttackPhase = order.AnimAttackData;
                break;
            }
        }
        else if (order.Type == AgentOrder.E_OrderType.E_ATTACK)
        {
        }

        AgentOrderFactory.Return(order);
    }
Example #48
0
 public BehaviourTree(Agent ownerBrain)
 {
     nodeOwnerBrain = ownerBrain;
 }
Example #49
0
        public override void OnFrame(Bot bot)
        {
            BuildingType pylonType    = BuildingType.LookUp[UnitTypes.PYLON];
            BuildingType gatewayType  = BuildingType.LookUp[UnitTypes.GATEWAY];
            BuildingType roboType     = BuildingType.LookUp[UnitTypes.ROBOTICS_FACILITY];
            Point2D      hideLocation = GetHideLocation();

            if (hideLocation == null)
            {
                return;
            }
            Agent pylon   = null;
            Agent gateway = null;
            Agent robo    = null;

            foreach (Agent agent in bot.UnitManager.Agents.Values)
            {
                if (agent.Unit.UnitType != UnitTypes.PYLON &&
                    agent.Unit.UnitType != UnitTypes.GATEWAY &&
                    agent.Unit.UnitType != UnitTypes.WARP_GATE &&
                    agent.Unit.UnitType != UnitTypes.ROBOTICS_FACILITY)
                {
                    continue;
                }
                if (agent.DistanceSq(HideLocation) > 20 * 20)
                {
                    continue;
                }
                if (agent.Unit.UnitType == UnitTypes.PYLON)
                {
                    pylon = agent;
                }
                else if (agent.Unit.UnitType == UnitTypes.ROBOTICS_FACILITY)
                {
                    robo = agent;
                }
                else
                {
                    gateway = agent;
                }
            }
            if (pylon == null && bot.Minerals() >= 100 && BuildRequests.Count == 0)
            {
                Point2D placement = ProxyBuildingPlacer.FindPlacement(GetHideLocation(), pylonType.Size, UnitTypes.PYLON);
                if (placement != null)
                {
                    BuildRequests.Add(new BuildRequest()
                    {
                        Type = UnitTypes.PYLON, Pos = placement
                    });
                }
            }
            else if (gateway == null && pylon != null && pylon.Unit.BuildProgress > 0.99 && bot.Minerals() >= 150)
            {
                Point2D placement = ProxyBuildingPlacer.FindPlacement(GetHideLocation(), gatewayType.Size, UnitTypes.GATEWAY);
                if (placement != null)
                {
                    BuildRequests.Add(new BuildRequest()
                    {
                        Type = UnitTypes.GATEWAY, Pos = placement
                    });
                }
            }
            else if (BuildRobo && robo == null && pylon != null && gateway != null && pylon.Unit.BuildProgress > 0.99 && bot.Minerals() >= 200 && bot.Gas() >= 100)
            {
                Point2D placement = ProxyBuildingPlacer.FindPlacement(GetHideLocation(), roboType.Size, UnitTypes.ROBOTICS_FACILITY);
                if (placement != null)
                {
                    BuildRequests.Add(new BuildRequest()
                    {
                        Type = UnitTypes.ROBOTICS_FACILITY, Pos = placement
                    });
                }
            }

            List <BuildRequest> doneRequests = new List <BuildRequest>();

            foreach (BuildRequest request in BuildRequests)
            {
                if (request.worker != null && !Bot.Main.UnitManager.Agents.ContainsKey(request.worker.Unit.Tag))
                {
                    request.worker = null;
                }
                if (request.worker == null)
                {
                    foreach (Agent agent in Units)
                    {
                        if (BuildingType.BuildingAbilities.Contains((int)agent.CurrentAbility()))
                        {
                            continue;
                        }
                        request.worker = agent;
                        break;
                    }
                }

                if (!ProxyBuildingPlacer.CheckPlacement(request.Pos, BuildingType.LookUp[request.Type].Size, request.Type, null, true))
                {
                    doneRequests.Add(request);
                    continue;
                }
                foreach (Agent agent in bot.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == request.Type &&
                        agent.DistanceSq(request.Pos) < 4)
                    {
                        doneRequests.Add(request);
                        break;
                    }
                }
            }

            foreach (BuildRequest request in doneRequests)
            {
                BuildRequests.Remove(request);
            }

            foreach (Agent agent in Units)
            {
                bool building = false;
                foreach (BuildRequest request in BuildRequests)
                {
                    if (request.worker == null || request.worker.Unit.Tag != agent.Unit.Tag)
                    {
                        continue;
                    }

                    building = true;
                    if (agent.DistanceSq(request.Pos) <= 10 * 10)
                    {
                        agent.Order(BuildingType.LookUp[request.Type].Ability, request.Pos);
                    }
                    else
                    {
                        agent.Order(Abilities.MOVE, request.Pos);
                    }
                    break;
                }
                if (building)
                {
                    continue;
                }

                if (agent.DistanceSq(GetHideLocation()) >= 4 * 4)
                {
                    agent.Order(Abilities.MOVE, GetHideLocation());
                    continue;
                }
            }
        }
Example #50
0
        public static void Equipment(Agent __instance, MissionEquipment value)
        {
            if (!__instance.IsHero)
            {
                return;
            }

            var charObj = __instance.Character as CharacterObject;

            if (charObj == null)
            {
                return;
            }

            for (var i = 0; i < 5; i++)
            {
                MissionWeapon missionWeapon = value[i];

                if (missionWeapon.Weapons.IsEmpty())
                {
                    continue;
                }

                var weaponComponentData = missionWeapon.Weapons[0];
                if (weaponComponentData == null)
                {
                    continue;
                }


                short add = 0;
                if (weaponComponentData.WeaponClass == WeaponClass.Arrow)
                {
                    if (charObj.GetPerkValue(DefaultPerks.Bow.LargeQuiver))
                    {
                        add += 3;
                    }

                    if (__instance.HasMount && charObj.GetPerkValue(DefaultPerks.Riding.SpareArrows))
                    {
                        add += 3;
                    }

                    if (__instance.HasMount && charObj.GetPerkValue(DefaultPerks.Bow.BattleEquipped))
                    {
                        add += 6;
                    }

                    if (!__instance.HasMount && charObj.GetPerkValue(DefaultPerks.Athletics.ExtraArrows))
                    {
                        add += 2;
                    }
                    missionWeapon.Amount += add;
                    short newMaxValue = (short)(missionWeapon.MaxAmount + add);
                    MaxAmmoField.SetValue(missionWeapon, newMaxValue);
                    value[i] = missionWeapon;
                }
                else if (weaponComponentData.WeaponClass == WeaponClass.Crossbow)
                {
                    if (__instance.HasMount && charObj.GetPerkValue(DefaultPerks.Riding.SpareArrows))
                    {
                        add += 3;
                    }
                    if (!__instance.HasMount && charObj.GetPerkValue(DefaultPerks.Athletics.ExtraArrows))
                    {
                        add += 2;
                    }
                    missionWeapon.Amount += add;
                    short newMaxValue = (short)(missionWeapon.MaxAmount + add);
                    MaxAmmoField.SetValue(missionWeapon, newMaxValue);
                    value[i] = missionWeapon;
                }
            }
        }
Example #51
0
        //public ObservableList<IDatabase> GetDatabaseList()
        //{
        //    return new ObservableList<IDatabase>();
        //}

        //public ObservableList<DataSourceBase> GetDatasourceList()
        //{
        //    return WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<DataSourceBase>();
        //}


        //public ObservableList<IAgent> GetAllIAgents()
        //{
        //    return new ObservableList<IAgent>( WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<Agent>().ListItems.ConvertAll(x => (IAgent)x));
        //}

        public void StartAgentDriver(IAgent agent)
        {
            Agent           zAgent          = (Agent)agent;
            BusinessFlow    BusinessFlow    = zAgent.BusinessFlow;
            ProjEnvironment ProjEnvironment = zAgent.ProjEnvironment;
            bool            Remote          = zAgent.Remote;

            DriverBase Driver = null;

            zAgent.mIsStarting = true;
            zAgent.OnPropertyChanged(Fields.Status);
            try
            {
                try
                {
                    if (Remote)
                    {
                        throw new Exception("Remote is Obsolete, use GingerGrid");
                        //We pass the agent info
                    }
                    else
                    {
                        switch (zAgent.DriverType)
                        {
                        case eDriverType.InternalBrowser:
                            Driver = new InternalBrowser(BusinessFlow);
                            break;

                        case eDriverType.SeleniumFireFox:
                            Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.FireFox);
                            break;

                        case eDriverType.SeleniumChrome:
                            Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome);
                            break;

                        case eDriverType.SeleniumIE:
                            Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.IE);
                            break;

                        case eDriverType.SeleniumRemoteWebDriver:
                            Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.RemoteWebDriver);
                            // set capabilities
                            if (zAgent.DriverConfiguration == null)
                            {
                                zAgent.DriverConfiguration = new ObservableList <DriverConfigParam>();
                            }
                            ((SeleniumDriver)Driver).RemoteGridHub     = zAgent.GetParamValue(SeleniumDriver.RemoteGridHubParam);
                            ((SeleniumDriver)Driver).RemoteBrowserName = zAgent.GetParamValue(SeleniumDriver.RemoteBrowserNameParam);
                            ((SeleniumDriver)Driver).RemotePlatform    = zAgent.GetParamValue(SeleniumDriver.RemotePlatformParam);
                            ((SeleniumDriver)Driver).RemoteVersion     = zAgent.GetParamValue(SeleniumDriver.RemoteVersionParam);
                            break;

                        case eDriverType.SeleniumEdge:
                            Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Edge);
                            break;

                        case eDriverType.ASCF:
                            Driver = new ASCFDriver(BusinessFlow, zAgent.Name);
                            break;

                        case eDriverType.DOSConsole:
                            Driver = new DOSConsoleDriver(BusinessFlow);
                            break;

                        case eDriverType.UnixShell:
                            Driver = new UnixShellDriver(BusinessFlow, ProjEnvironment);
                            ((UnixShellDriver)Driver).SetScriptsFolder(System.IO.Path.Combine(zAgent.SolutionFolder, @"Documents\sh\"));
                            break;

                        case eDriverType.MobileAppiumAndroid:
                            Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.Android, BusinessFlow);
                            break;

                        case eDriverType.MobileAppiumIOS:
                            Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.iOS, BusinessFlow);
                            break;

                        case eDriverType.MobileAppiumAndroidBrowser:
                            Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.AndroidBrowser, BusinessFlow);
                            break;

                        case eDriverType.MobileAppiumIOSBrowser:
                            Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.iOSBrowser, BusinessFlow);
                            break;

                        case eDriverType.PerfectoMobileAndroid:
                            Driver = new PerfectoDriver(PerfectoDriver.eContextType.NativeAndroid, BusinessFlow);
                            break;

                        case eDriverType.PerfectoMobileAndroidWeb:
                            Driver = new PerfectoDriver(PerfectoDriver.eContextType.WebAndroid, BusinessFlow);
                            break;

                        case eDriverType.PerfectoMobileIOS:
                            Driver = new PerfectoDriver(PerfectoDriver.eContextType.NativeIOS, BusinessFlow);
                            break;

                        case eDriverType.PerfectoMobileIOSWeb:
                            Driver = new PerfectoDriver(PerfectoDriver.eContextType.WebIOS, BusinessFlow);
                            break;

                        case eDriverType.WebServices:
                            WebServicesDriver WebServicesDriver = new WebServicesDriver(BusinessFlow);
                            Driver = WebServicesDriver;
                            break;

                        case eDriverType.WindowsAutomation:
                            Driver = new WindowsDriver(BusinessFlow);
                            break;

                        case eDriverType.FlaUIWindow:
                            Driver = new WindowsDriver(BusinessFlow, UIAutomationDriverBase.eUIALibraryType.FlaUI);
                            break;

                        case eDriverType.PowerBuilder:
                            Driver = new PBDriver(BusinessFlow);
                            break;

                        case eDriverType.FlaUIPB:
                            Driver = new PBDriver(BusinessFlow, UIAutomationDriverBase.eUIALibraryType.FlaUI);
                            break;

                        case eDriverType.JavaDriver:
                            Driver = new JavaDriver(BusinessFlow);
                            break;

                        case eDriverType.MainFrame3270:
                            Driver = new MainFrameDriver(BusinessFlow);
                            break;

                        case eDriverType.AndroidADB:
                            string DeviceConfigFolder = zAgent.GetOrCreateParam("DeviceConfigFolder").Value;
                            if (!string.IsNullOrEmpty(DeviceConfigFolder))
                            {
                                Driver = new AndroidADBDriver(BusinessFlow, System.IO.Path.Combine(zAgent.SolutionFolder, @"Documents\Devices", DeviceConfigFolder, @"\"));
                            }
                            else
                            {
                                //TODO: Load create sample folder/device, or start the wizard
                                throw new Exception("Please set device config folder");
                            }
                            break;

                        default:
                        {
                            throw new Exception("Matching Driver was not found.");
                        }
                        }
                    }
                }
                catch (Exception e)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Failed to set Agent Driver", e);
                    return;
                }

                if (zAgent.AgentType == eAgentType.Service)
                {
                    zAgent.StartPluginService();
                    zAgent.OnPropertyChanged(Fields.Status);
                }
                else
                {
                    zAgent.Driver       = Driver;
                    Driver.BusinessFlow = zAgent.BusinessFlow;
                    zAgent.SetDriverConfiguration();

                    //if STA we need to start it on seperate thread, so UI/Window can be refreshed: Like IB, Mobile, Unix
                    if (Driver.IsSTAThread())
                    {
                        zAgent.CTS = new CancellationTokenSource();

                        zAgent.MSTATask = new Task(() => { Driver.StartDriver(); }, zAgent.CTS.Token, TaskCreationOptions.LongRunning);
                        zAgent.MSTATask.Start();
                    }
                    else
                    {
                        Driver.StartDriver();
                    }
                }
            }
            finally
            {
                if (zAgent.AgentType == eAgentType.Service)
                {
                    zAgent.mIsStarting = false;
                }
                else
                {
                    if (Driver != null)
                    {
                        // Give the driver time to start
                        Thread.Sleep(500);
                        Driver.IsDriverRunning            = true;
                        Driver.driverMessageEventHandler += zAgent.driverMessageEventHandler;
                    }

                    zAgent.mIsStarting = false;
                    zAgent.OnPropertyChanged(Fields.Status);
                    zAgent.OnPropertyChanged(Fields.IsWindowExplorerSupportReady);
                }
            }
        }
Example #52
0
 public override bool DoWant(Agent agent)
 {
     return(true);
 }
Example #53
0
        public void TestGetAgent()
        {
            Agent agent = ariesApiHelper.GetAgent("AGENT0");

            Assert.IsNotNull(agent);
        }
Example #54
0
        public Type GetDriverType(IAgent agent)
        {
            Agent zAgent = (Agent)agent;

            switch (zAgent.DriverType)
            {
            case Agent.eDriverType.InternalBrowser:
                return(typeof(InternalBrowser));

            case Agent.eDriverType.SeleniumFireFox:
                return(typeof(SeleniumDriver));

            case Agent.eDriverType.SeleniumChrome:
                return(typeof(SeleniumDriver));

            case Agent.eDriverType.SeleniumIE:
                return(typeof(SeleniumDriver));

            case Agent.eDriverType.SeleniumRemoteWebDriver:
                return(typeof(SeleniumDriver));

            case Agent.eDriverType.SeleniumEdge:
                return(typeof(SeleniumDriver));

            case Agent.eDriverType.ASCF:
                return(typeof(ASCFDriver));

            case Agent.eDriverType.DOSConsole:
                return(typeof(DOSConsoleDriver));

            case Agent.eDriverType.UnixShell:
                return(typeof(UnixShellDriver));

            case Agent.eDriverType.MobileAppiumAndroid:
                return(typeof(SeleniumAppiumDriver));

            case Agent.eDriverType.MobileAppiumIOS:
                return(typeof(SeleniumAppiumDriver));

            case Agent.eDriverType.MobileAppiumAndroidBrowser:
            case Agent.eDriverType.MobileAppiumIOSBrowser:
                return(typeof(SeleniumAppiumDriver));

            case Agent.eDriverType.PowerBuilder:
                return(typeof(PBDriver));

            case Agent.eDriverType.WindowsAutomation:
                return(typeof(WindowsDriver));

            case Agent.eDriverType.WebServices:
                return(typeof(WebServicesDriver));

            case Agent.eDriverType.JavaDriver:
                return(typeof(JavaDriver));

            case Agent.eDriverType.MainFrame3270:
                return(typeof(MainFrameDriver));

            case Agent.eDriverType.AndroidADB:
                return(typeof(AndroidADBDriver));

            case Agent.eDriverType.PerfectoMobileAndroid:
            case Agent.eDriverType.PerfectoMobileAndroidWeb:
            case Agent.eDriverType.PerfectoMobileIOS:
            case Agent.eDriverType.PerfectoMobileIOSWeb:
                return(typeof(PerfectoDriver));

            default:
                throw new Exception("GetDriverType: Unknow Driver type " + zAgent.DriverType);
            }
        }
Example #55
0
 public Task AddAsync(Agent agent)
 {
     agentsDataSet.Add(agent);
     return(dbContext.SaveChangesAsync());
 }
Example #56
0
 public void Init(Agent _agent)
 {
     agent = _agent;
     Init(agent.net);
 }
 public FormationOrderComponent(Agent agent)
     : base(agent)
 {
 }
Example #58
0
        public async Task <Agent> GetAsync(long key)
        {
            Agent m = await _agentRep.GetAsync(key);

            return(m);
        }
Example #59
0
        public async Task History_01()
        {
            /********************************************************************************************************************************/

            var m2 = new Agent
            {
                Id                = Guid.NewGuid(),
                CreatedOn         = DateTime.Now,
                UserId            = Guid.NewGuid(),
                PathId            = "x-xx-xxx-xxxx",
                Name              = "张三",
                Phone             = "18088889999",
                IdCardNo          = "No.12345",
                CrmUserId         = "yyyyy",
                AgentLevel        = AgentLevel.DistiAgent,
                ActivedOn         = null, // DateTime?
                ActiveOrderId     = null, // Guid?
                DirectorStarCount = 5
            };

            xx = string.Empty;

            var res2 = await MyDAL_TestDB.InsertAsync(m2);

            Assert.True(res2 == 1);



            /********************************************************************************************************************************/

            xx = string.Empty;

            var res5 = await MyDAL_TestDB.InsertAsync(new Agent
            {
                Id                = Guid.NewGuid(),
                CreatedOn         = Convert.ToDateTime("2018-10-07 17:02:05"),
                UserId            = Guid.NewGuid(),
                PathId            = "xx-yy-zz-mm-nn",
                Name              = "meng-net",
                Phone             = "17600000000",
                IdCardNo          = "876987698798",
                CrmUserId         = Guid.NewGuid().ToString(),
                AgentLevel        = null,
                ActivedOn         = null,
                ActiveOrderId     = null,
                DirectorStarCount = 1
            });



            /********************************************************************************************************************************/

            xx = string.Empty;

            await ClearData6();

            var m6 = new Agent
            {
                Id                = Guid.Parse("ea1ad309-56f7-4e3e-af12-0165c9121e9b"),
                CreatedOn         = Convert.ToDateTime("2018-10-07 17:02:05"),
                UserId            = Guid.NewGuid(),
                PathId            = "xx-yy-zz-mm-nn",
                Name              = "meng-net",
                Phone             = "17600000000",
                IdCardNo          = "876987698798",
                CrmUserId         = Guid.NewGuid().ToString(),
                AgentLevel        = AgentLevel.DistiAgent,
                ActivedOn         = null,
                ActiveOrderId     = null,
                DirectorStarCount = 1
            };

            var res6 = await MyDAL_TestDB.InsertAsync(m6);



            var res61 = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == Guid.Parse("ea1ad309-56f7-4e3e-af12-0165c9121e9b"));

            Assert.True(res61.AgentLevel == AgentLevel.DistiAgent);

            /********************************************************************************************************************************/

            xx = string.Empty;

            await ClearData7();

            var m7 = new Agent
            {
                Id                = Guid.Parse("08d60369-4fc1-e8e0-44dc-435f31635e6d"),
                CreatedOn         = Convert.ToDateTime("2018-08-16 19:34:25.116759"),
                UserId            = Guid.NewGuid(),
                PathId            = "xx-yy-zz-mm-nn",
                Name              = "meng-net",
                Phone             = "17600000000",
                IdCardNo          = "876987698798",
                CrmUserId         = Guid.NewGuid().ToString(),
                AgentLevel        = AgentLevel.DistiAgent,
                ActivedOn         = null,
                ActiveOrderId     = null,
                DirectorStarCount = 1
            };

            var res7 = await MyDAL_TestDB.InsertAsync(m7);



            var res71 = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == Guid.Parse("08d60369-4fc1-e8e0-44dc-435f31635e6d"));

            Assert.True(res71.CreatedOn == Convert.ToDateTime("2018-08-16 19:34:25.116759"));

            /********************************************************************************************************************************/

            xx = string.Empty;
        }
Example #60
0
 /*public AnimFsmStateMove(BlackBoard blackBoard, AnimSetPlayer animSetPlayer, Animation animEngine, Transform trans, CharacterController characterController)
  *  : base(blackBoard, animSetPlayer, animEngine, trans, characterController)
  * {
  *
  * }*/
 public AnimFsmStateMove(Agent owner) : base(owner)
 {
 }