public LSAgent CreateAgent(AgentCode agentCode)
        {
            FastStack <LSAgent> cache = CachedAgents[(int)agentCode];

            if (cache != null && cache.Count > 0)
            {
                curAgent = cache.Pop();
            }
            else
            {
                curAgent = GameObject.Instantiate(AgentObjects[(int)agentCode]).GetComponent <LSAgent> ();
            }

            localID              = GenerateLocalID();
            curAgent.LocalID     = localID;
            Agents[localID]      = curAgent;
            AgentActive[localID] = true;

            globalID          = GenerateGlobalID();
            curAgent.GlobalID = globalID;

            curAgent.Initialize();

            RingController ringController = GameObject.Instantiate(LockstepManager.Instance.SelectionRing).GetComponent <RingController> ();

            ringController.Initialize(curAgent);
            curAgent.ringController = ringController;

            return(curAgent);
        }
예제 #2
0
 private void InitializeAgent(LSAgent agent,
                              Vector2d position,
                              Vector2d rotation)
 {
     AddAgent(agent);
     agent.Initialize(position, rotation);
 }
        /*
         * //Create agent from pre-existing template
         * public LSAgent CreateAgent(GameObject agentObject,
         *                         Vector2d position = default(Vector2d)) {
         *  curAgent = GameObject.Instantiate(agentObject).GetComponent<LSAgent>();
         *  curAgent.Setup(this, default(AgentCode));
         *  InitializeAgent (curAgent, position);
         *
         *  return curAgent;
         * }*/

        private void InitializeAgent(LSAgent agent,
                                     Vector2d position)
        {
            ushort localID = GenerateLocalID();

            LocalAgents[localID]      = agent;
            LocalAgentActive[localID] = true;

            ushort globalID = GenerateGlobalID();

            GlobalAgentActive[globalID] = true;
            GlobalAgents[globalID]      = agent;
            agent.Initialize(this, localID, globalID, position);
        }
        /*
        //Create agent from pre-existing template
        public LSAgent CreateAgent(GameObject agentObject,
                                   Vector2d position = default(Vector2d)) {
            curAgent = GameObject.Instantiate(agentObject).GetComponent<LSAgent>();
            curAgent.Setup(this, default(AgentCode));
            InitializeAgent (curAgent, position);

            return curAgent;
        }*/
        private void InitializeAgent(LSAgent agent,
                                      Vector2d position)
        {
            ushort localID = GenerateLocalID();
            LocalAgents[localID] = agent;
            LocalAgentActive[localID] = true;

            ushort globalID = GenerateGlobalID();
            GlobalAgentActive[globalID] = true;
            GlobalAgents[globalID] = agent;
            agent.Initialize(this, localID, globalID, position);
        }