コード例 #1
0
 /// <summary>
 /// Adds/removes an amount of a faction's resource.
 /// </summary>
 /// <param name="factionID">ID of the faction whose resources will be updated.</param>
 /// <param name="resourceInput">Defines the resource type and amount to add/remove.</param>
 public void UpdateResource(int factionID, ResourceInput resourceInput)
 {
     UpdateResource(factionID, resourceInput.Name, resourceInput.Amount);
 }
コード例 #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;
            }

            ResourceInput[] requiredResources = new ResourceInput[0];
            ResourceInput[] completeResources = new ResourceInput[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);
        }