Exemplo n.º 1
0
        public void UpdateResourceGeneratorTasks(FactionEntity sourceEntity, ResourceGenerator generatorComp)
        {
            if (sourceEntity == null || generatorComp == null)
            {
                return;
            }

            for (int generatorID = 0; generatorID < generatorComp.GetGeneratorsLength(); generatorID++)
            {
                ResourceGenerator.Generator generator = generatorComp.GetGenerator(generatorID);
                if (generator.IsMaxAmountReached() == true) //only display the resource collection task if the maximum amount is reached
                {
                    Add(new TaskUIAttributes
                    {
                        ID     = generatorID,
                        icon   = generator.GetTaskIcon(),
                        source = sourceEntity,
                        type   = TaskTypes.generateResource
                    }, generatorComp.GetTaskPanelCategory());
                }
            }
        }
Exemplo n.º 2
0
        //this method is called whenever the mouse hovers over a task button:
        public void ShowTaskInfo()
        {
            if (!enabled) //if this component is not enabled do not show task tooltip
            {
                return;
            }

            ResourceManager.Resources[] requiredResources = new ResourceManager.Resources[0];
            ResourceManager.Resources[] completeResources = new ResourceManager.Resources[0];

            string message = "";

            switch (attributes.type)         //display a different message depending on the type of the task
            {
            case TaskTypes.deselectIndiv:    //deselect a currently selected unit
            case TaskTypes.deselectMul:
                return;                      //do not show anything

            case TaskTypes.generateResource: //generating resource task.

                ResourceGenerator.Generator generator = (attributes.source as Building).GeneratorComp.GetGenerator(attributes.ID);
                message += "Maximum amount reached! Click to collect " + generator.GetCurrAmount().ToString() + " of " + generator.GetResourceName();
                break;

            case TaskTypes.APCEject:     //APC release task.

                message += "Eject unit: " + (attributes.source as FactionEntity).APCComp.GetStoredUnit(attributes.ID).GetName() + " from the " + (attributes.source as FactionEntity).GetName() + ".";
                break;

            case TaskTypes.APCEjectAll:     //APC release task.

                message += "Eject all units inside the " + (attributes.source as FactionEntity).GetName() + ".";
                break;

            case TaskTypes.APCCall:     //apc calling units

                message += "Call units to get into the " + (attributes.source as FactionEntity).GetName() + ".";
                break;

            case TaskTypes.placeBuilding:

                //Get the building associated with this task ID:
                Building currentBuilding = gameMgr.PlacementMgr.GetBuilding(attributes.ID);

                message += currentBuilding.GetName() + ": " + currentBuilding.GetDescription();

                requiredResources = currentBuilding.GetResources();

                if (currentBuilding.GetRequiredBuildings().Count > 0)     //if the building requires other buildings to be placed
                {
                    message += "\n<b>Required Buildings:</b>";
                    foreach (Building.RequiredBuilding b in currentBuilding.GetRequiredBuildings())
                    {
                        message += " " + b.GetName() + " -";
                    }

                    message = message.Substring(0, message.Length - " -".Length);
                }
                break;

            case TaskTypes.attackTypeSelection:

                message += "Switch attack type.";
                break;

            case TaskTypes.toggleWander:

                message += "Toggle wandering.";
                break;

            case TaskTypes.cancelPendingTask:

                message += "Cancel pending task.";
                break;

            case TaskTypes.movement:

                message += "Move unit.";
                break;

            case TaskTypes.build:

                message += "Construct building.";
                break;

            case TaskTypes.collectResource:

                message += "Collect resource.";
                break;

            case TaskTypes.attack:

                message += "Attack enemy unit/building.";
                break;

            case TaskTypes.heal:

                message += "Heal friendly unit.";
                break;

            case TaskTypes.convert:

                message += "Convert enemy unit.";
                break;

            default:
                if (attributes.taskLauncher != null)
                {
                    requiredResources = attributes.taskLauncher.GetTask(attributes.ID).GetRequiredResources();
                    completeResources = attributes.taskLauncher.GetTask(attributes.ID).GetCompleteResources();
                    message          += attributes.taskLauncher.GetTask(attributes.ID).GetDescription();
                }
                break;
            }

            //display the required and complete resources:
            AddResourceInfo(requiredResources, "Required Resources", ref message);
            AddResourceInfo(completeResources, "Complete Resources", ref message);

            //show the task info on the tooltip:
            gameMgr.UIMgr.ShowTooltip(message);
        }