Ejemplo n.º 1
0
    public void QueueTrainUnitCommand()
    {
        Debug.Log("clicky");
        GameBehaviourCommand command = ArmyCommandFactory.CreateBuyUnitCommand(type, PlayerType.PLAYER);

        QueueUpCommand(command);
    }
Ejemplo n.º 2
0
    public void QueueBuildCommand()
    {
        BuildPlotLocation    location = selectedBuildPlotManager.GetSelectedLocation();
        GameBehaviourCommand command  = BuildingCommandFactory.CreateConstructBuildingCommand(location, buildingType, PlayerType.PLAYER);

        QueueUpCommand(command);
    }
Ejemplo n.º 3
0
 public void ExecuteNextCommand()
 {
     if (commandQueue.Count > 0)
     {
         GameBehaviourCommand nextCommand = commandQueue.Dequeue();
         nextCommand.Execute();
     }
 }
Ejemplo n.º 4
0
    public void QueueDemolishCommand()
    {
        // Get plot that contains building
        Dictionary <BuildPlotLocation, BuildPlot> buildPlots = GetBuildPlotController().buildPlotMap.buildPlots;

        foreach (BuildPlotLocation plotLocation in buildPlots.Keys)
        {
            if (GetBuildPlotController().buildPlotMap.GetBuilding(plotLocation) == buildingType)
            {
                GameBehaviourCommand command = BuildingCommandFactory.CreateDemolishCommand(plotLocation, PlayerType.PLAYER);
                QueueUpCommand(command);
            }
        }
    }
Ejemplo n.º 5
0
    public AI_GameBehaviourCommand GetBuildingCommand(BuildingModel model)
    {
        BuildPlotController buildPlotController = GetBuildPlotController();

        BuildingType buildingType = model.type;

        foreach (BuildPlotLocation location in Enum.GetValues(typeof(BuildPlotLocation)).Cast <BuildPlotLocation>())
        {
            BuildingType buildingOnPlot = buildPlotController.buildPlotMap.GetBuilding(location);

            if (buildingOnPlot == BuildingType.NONE)
            {
                GameBehaviourCommand    command   = BuildingCommandFactory.CreateConstructBuildingCommand(location, buildingType, PlayerType.AI);
                AI_GameBehaviourCommand aiCommand = new AI_GameBehaviourCommand(command, model.buildCost, model.constructionTime);
                return(aiCommand);
            }
        }

        // No building commmand
        return(null);
    }
Ejemplo n.º 6
0
    // queue up target army creation
    public Queue <AI_GameBehaviourCommand> GetArmyConstructionCommands(UnitMap targetMap, BuildingType plannedBuilding)
    {
        // calculate units that need to be trained
        Queue <AI_GameBehaviourCommand> armyCommands = new Queue <AI_GameBehaviourCommand>();
        UnitMap unitsToBeConstructed = startingUnits.UnitsRequiredToBecome(targetMap);

        Debug.Log(unitsToBeConstructed.StatusString());

        // iterate over required units and add the command to the queue
        foreach (KeyValuePair <UnitType, int> unitMapEntry in unitsToBeConstructed.units)
        {
            UnitType          type  = unitMapEntry.Key;
            UnitPurchaseModel model = UnitPurchaseModelFactory.Create(type);
            int numUnits            = unitMapEntry.Value;

            while (numUnits > 0)
            {
                if (IsUnitTrainable(type, remainingSupply, plannedBuilding))
                {
                    GameBehaviourCommand    command   = GetUnitToAddToQueue(type);
                    AI_GameBehaviourCommand aiCommand = new AI_GameBehaviourCommand(command, model.buildCost);

                    armyCommands.Enqueue(aiCommand);
                    numUnits--;
                    remainingSupply -= model.armySize;
                }
                else
                {
                    Debug.LogError("Bad error -- cant create unit that was planned to be created");
                    break;
                }
            }
        }

        return(armyCommands);
    }
Ejemplo n.º 7
0
    private void QueueUpCommand(GameBehaviourCommand command)
    {
        GameBehaviourCommandController controller = GameObject.Find("GameController").GetComponent <GameController>().GetPlayerModel(PlayerType.PLAYER).gameBehaviourCommandController;

        controller.QueueUpCommand(command);
    }
Ejemplo n.º 8
0
 public void QueueUpCommand(GameBehaviourCommand command)
 {
     commandQueue.Enqueue(command);
 }
Ejemplo n.º 9
0
 private void QueueUpCommand(GameBehaviourCommand command)
 {
     GetGameBehaviourCommandController().QueueUpCommand(command);
 }
Ejemplo n.º 10
0
    // Generate Queue of WorkerCommands
    public Queue <AI_GameBehaviourCommand> GetWorkerReassignmentCommands(Dictionary <ResourceType, int> distribution)
    {
        // Queue to output
        Queue <AI_GameBehaviourCommand> commands = new Queue <AI_GameBehaviourCommand>();

        ResourceGatheringModel resourceGatheringModel = GetResourceController().gatheringController.gatheringModel;

        // current values
        int currWoodWorkers       = resourceGatheringModel.GetNumWorkers(ResourceType.WOOD);
        int currMagicStoneWorkers = resourceGatheringModel.GetNumWorkers(ResourceType.MAGIC_STONE);
        int currIdleWorkers       = resourceGatheringModel.GetNumIdleWorkers();


        // target values
        int targetWoodWorkers       = distribution[ResourceType.WOOD];
        int targetMagicStoneWorkers = distribution[ResourceType.MAGIC_STONE];

        // differences
        int numWoodWorkersToAdd       = targetWoodWorkers - currWoodWorkers;
        int numMagicStoneWorkersToAdd = targetMagicStoneWorkers - currMagicStoneWorkers;


        // Remove Wood Workers
        if (numWoodWorkersToAdd < 0)
        {
            for (int i = numWoodWorkersToAdd; i < 0; i++)
            {
                GameBehaviourCommand    command   = WorkerCommandFactory.CreateRemoveWorkerCommand(ResourceType.WOOD, PlayerType.AI);
                AI_GameBehaviourCommand aiCommand = new AI_GameBehaviourCommand(command);
                commands.Enqueue(aiCommand);
            }
        }

        // Remove Magic Stone Workers
        if (numMagicStoneWorkersToAdd < 0)
        {
            for (int i = numMagicStoneWorkersToAdd; i < 0; i++)
            {
                GameBehaviourCommand    command   = WorkerCommandFactory.CreateRemoveWorkerCommand(ResourceType.MAGIC_STONE, PlayerType.AI);
                AI_GameBehaviourCommand aiCommand = new AI_GameBehaviourCommand(command);
                commands.Enqueue(aiCommand);
            }
        }

        // Add Wood Workers
        if (numWoodWorkersToAdd > 0)
        {
            for (int i = 0; i < numWoodWorkersToAdd; i++)
            {
                GameBehaviourCommand    command   = WorkerCommandFactory.CreateAddWorkerCommand(ResourceType.WOOD, PlayerType.AI);
                AI_GameBehaviourCommand aiCommand = new AI_GameBehaviourCommand(command);
                commands.Enqueue(aiCommand);
            }
        }

        // Add Magic Stone Workers
        if (numMagicStoneWorkersToAdd > 0)
        {
            for (int i = 0; i < numMagicStoneWorkersToAdd; i++)
            {
                GameBehaviourCommand    command   = WorkerCommandFactory.CreateAddWorkerCommand(ResourceType.MAGIC_STONE, PlayerType.AI);
                AI_GameBehaviourCommand aiCommand = new AI_GameBehaviourCommand(command);
                commands.Enqueue(aiCommand);
            }
        }

        return(commands);
    }
Ejemplo n.º 11
0
    public void RemoveWorker()
    {
        GameBehaviourCommand command = WorkerCommandFactory.CreateRemoveWorkerCommand(resourceType, PlayerType.PLAYER);

        QueueUpCommand(command);
    }