Ejemplo n.º 1
0
        /// <summary>
        /// Sends the command for all AgentControllers under the control of this PlayerManager...
        /// Mainly for shared control capabilities
        /// </summary>
        /// <param name="com">COM.</param>
        public static void SendCommand(Command com)
        {
            com.Add <Selection>(new Selection());
            for (int i = 0; i < AgentControllers.PeakCount; i++)
            {
                if (AgentControllers.arrayAllocation [i])
                {
                    AgentController cont = AgentControllers [i];

                    if (cont.SelectedAgents.Count > 0)
                    {
                        com.ControllerID = cont.ControllerID;

                                                #if false
                        if (cont.SelectionChanged)
                        {
                            com.SetData <Selection>(new Selection(cont.SelectedAgents));
                            cont.SelectionChanged = false;
                        }
                        else
                        {
                            com.ClearData <Selection>();
                        }
                                                #else
                        //we always sending selection data
                        com.SetData <Selection>(new Selection(cont.SelectedAgents));
                        cont.SelectionChanged = false;
                                                #endif
                        CommandManager.SendCommand(com);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void ProcessSpawnQueue()
        {
            currentSpawnProgress += spawnIncrement;
            if (currentSpawnProgress > _maxSpawnProgress)
            {
                if (Agent.GetCommander())
                {
                    //if (audioElement != null)
                    //{
                    //    audioElement.Play(finishedJobSound);
                    //}
                    Vector2d spawnOutside = new Vector2d(this.transform.position);
                    RTSAgent agent        = Agent.Controller.CreateAgent(spawnQueue.Dequeue(), spawnOutside);
                    agent.SetProvision(true);

                    if (cachedRally)
                    {
                        if (cachedRally.spawnPoint != cachedRally.rallyPoint)
                        {
                            Command moveCom = new Command(AbilityDataItem.FindInterfacer("Move").ListenInputID);
                            moveCom.Add <Vector2d>(new Vector2d(cachedRally.rallyPoint));
                            moveCom.ControllerID = agent.Controller.ControllerID;
                            moveCom.Add <Influence>(new Influence(agent));

                            CommandManager.SendCommand(moveCom);
                        }
                    }
                }
                currentSpawnProgress = 0;
            }
        }
        public virtual void InfluenceAttack()
        {
            // send attack command
            Command attackCom = new Command(AbilityDataItem.FindInterfacer("Attack").ListenInputID);

            attackCom.Add <DefaultData>(new DefaultData(DataType.UShort, nearbyAgent.GlobalID));
            attackCom.ControllerID = cachedAgent.Controller.ControllerID;

            attackCom.Add <Influence>(new Influence(cachedAgent));

            CommandManager.SendCommand(attackCom);
        }
Ejemplo n.º 4
0
        private void InfluenceConstruction()
        {
            if (nearbyAgent)
            {
                Structure closestBuilding = nearbyAgent.GetComponent <Structure>();
                if (closestBuilding)
                {
                    // send construct command
                    Command constructCom = new Command(AbilityDataItem.FindInterfacer("Construct").ListenInputID);
                    constructCom.Add <DefaultData>(new DefaultData(DataType.UShort, nearbyAgent.GlobalID));
                    constructCom.ControllerID = cachedAgent.Controller.ControllerID;

                    constructCom.Add <Influence>(new Influence(cachedAgent));

                    CommandManager.SendCommand(constructCom);
                }
            }
        }
        private void InfluenceHarvest()
        {
            if (nearbyAgent)
            {
                ResourceDeposit closestResource      = nearbyAgent.GetAbility <ResourceDeposit>();
                Structure       closestResourceStore = nearbyAgent.GetAbility <Structure>();

                if (closestResource && closestResource.ResourceType == cachedHarvest.HarvestType ||
                    closestResourceStore && nearbyAgent.GetAbility <Structure>().CanStoreResources(cachedAgent.GetAbility <Harvest>().HarvestType))
                {
                    // send harvest command
                    Command harvestCom = new Command(AbilityDataItem.FindInterfacer("Harvest").ListenInputID);
                    harvestCom.Add(new DefaultData(DataType.UShort, nearbyAgent.GlobalID));

                    harvestCom.ControllerID = cachedAgent.Controller.ControllerID;
                    harvestCom.Add(new Influence(cachedAgent));

                    CommandManager.SendCommand(harvestCom);
                }
            }
        }