public void Open(AgentCode agentCode)
 {
     AgentInterfacer agentInfo = AgentController.GetAgentInterfacer (agentCode);
     Imager.sprite = agentInfo.Icon;
     Texter.text = agentCode.ToString ();
     gameObject.SetActiveIfNot (true);
 }
        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);
        }
        public LSAgent CreateAgent(AgentCode agentCode,
                                   Vector2d position = default(Vector2d))
        {
            Vector2d vec = new Vector2d(0, 1);

            if (Enum.IsDefined(typeof(AgentCode), agentCode) == false)
            {
                throw new System.MissingMemberException("Specified AgentCode does not exist.");
            }
            FastStack <LSAgent> cache    = CachedAgents[agentCode];
            LSAgent             curAgent = null;

            if (cache.IsNotNull() && cache.Count > 0)
            {
                curAgent = cache.Pop();
            }
            else
            {
                AgentInterfacer interfacer = AgentController.CodeInterfacerMap[agentCode];
                curAgent = GameObject.Instantiate(AgentController.CodeInterfacerMap[agentCode].Prefab).GetComponent <LSAgent>();
                curAgent.Setup(interfacer);
            }
            InitializeAgent(curAgent, position);
            return(curAgent);
        }
        public void Open(AgentCode agentCode)
        {
            AgentInterfacer agentInfo = AgentController.GetAgentInterfacer(agentCode);

            Imager.sprite = agentInfo.Icon;
            Texter.text   = agentCode.ToString();
            gameObject.SetActiveIfNot(true);
        }
        public static void OrderSpawn(AgentController cont, AgentCode agentCode, int count, Vector2d position)
        {
            Command com = new Command(InputCode.Spawn);

            com.ControllerID = cont.ControllerID;
            com.Position     = position;
            com.Target       = (ushort)agentCode;
            com.Count        = count;
            CommandManager.SendCommand(com);
        }
        public static void Setup()
        {
            AgentInterfacer[] agentInters = LSDatabaseManager.CurrentDatabase.AgentData;

            AgentCodes   = (AgentCode[])Enum.GetValues(typeof(AgentCode));
            CachedAgents = new Dictionary <AgentCode, FastStack <LSAgent> >(agentInters.Length);

            for (int i = 0; i < agentInters.Length; i++)
            {
                AgentInterfacer interfacer = agentInters[i];
                AgentCode       agentCode  = interfacer.GetAgentCode();
                CodeInterfacerMap.Add(agentCode, interfacer);
                CachedAgents.Add(agentCode, new FastStack <LSAgent>(2));
            }
        }
예제 #7
0
        public LSAgent BuildChild(AgentCode agentCode, Vector2d localPos, float localHeight)
        {
            LSAgent agent = this.Controller.CreateAgent(agentCode);

            agent.Body.Parent           = this.Body;
            agent.Body.LocalPosition    = localPos;
            agent.Body.LocalRotation    = Vector2d.up.rotatedRight;
            agent.Body.visualPosition.y = localHeight + this.Body.LocalPosition.y;
            agent.Body.UpdatePosition();
            agent.Body.UpdateRotation();
            agent.Body.BuildChangedValues();
            if (onBuildChild.IsNotNull())
            {
                onBuildChild(agent);
            }
            return(agent);
        }
        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;
        }
 public static AgentInterfacer GetAgentInterfacer(AgentCode agentCode)
 {
     return(AgentController.CodeInterfacerMap [agentCode]);
 }
 public LSAgent CreateAgent(AgentCode agentCode,
                            Vector2d position = default(Vector2d))
 {
     Vector2d vec = new Vector2d(0,1);
     if (Enum.IsDefined(typeof (AgentCode), agentCode) == false) {
         throw new System.MissingMemberException ("Specified AgentCode does not exist.");
     }
     FastStack<LSAgent> cache = CachedAgents[agentCode];
     LSAgent curAgent = null;
     if (cache .IsNotNull () && cache.Count > 0) {
         curAgent = cache.Pop();
     } else {
         AgentInterfacer interfacer = AgentController.CodeInterfacerMap[agentCode];
         curAgent = GameObject.Instantiate(AgentController.CodeInterfacerMap[agentCode].Prefab).GetComponent<LSAgent>();
         curAgent.Setup(interfacer);
     }
     InitializeAgent (curAgent, position);
     return curAgent;
 }
 public static void OrderSpawn(AgentController cont, AgentCode agentCode, int count, Vector2d position)
 {
     Command com = new Command (InputCode.Spawn);
     com.ControllerID = cont.ControllerID;
     com.Position = position;
     com.Target = (ushort)agentCode;
     com.Count = count;
     CommandManager.SendCommand(com);
 }
 public static AgentInterfacer GetAgentInterfacer(AgentCode agentCode)
 {
     return AgentController.CodeInterfacerMap [agentCode];
 }