Exemple #1
0
        public void ShowTaskInfo()
        {
            //This method is called whenever the mouse hovers over a task button:
            //First activate both the task info menu and text objects to show them for the player:
            string Msg = "";

            //If the player is currently selecting building:
            if (SelectionMgr.SelectedBuilding != null)
            {
                //We'll show the task info for this building.

                if (TaskType != TaskManager.TaskTypes.ResourceGen)
                { //if it's not a resource collection task:
                    ResourceManager.Resources[] RequiredResources = new ResourceManager.Resources[0];
                    //First we will show the task's desription:

                    if (TaskType == TaskManager.TaskTypes.TaskUpgrade)
                    {
                        //if this is an upgrade task, then show the upgrade's description and set its required resources:
                        Msg = SelectionMgr.SelectedBuilding.BuildingTasksList[ID].Upgrades[SelectionMgr.SelectedBuilding.BuildingTasksList[ID].CurrentUpgradeLevel].UpgradeDescription;
                        RequiredResources = SelectionMgr.SelectedBuilding.BuildingTasksList[ID].Upgrades[SelectionMgr.SelectedBuilding.BuildingTasksList[ID].CurrentUpgradeLevel].UpgradeResources;
                    }
                    else if (TaskType == TaskManager.TaskTypes.UpgradeBuilding)
                    {
                        Msg = "Upgrade Building. ";
                        RequiredResources = SelectionMgr.SelectedBuilding.BuildingUpgradeResources;

                        //Then we will go through all the required buildings..
                        if (SelectionMgr.SelectedBuilding.UpgradeRequiredBuildings.Length > 0)
                        {
                            //And show them:
                            Msg += " <b>Required Buildings :</b>";

                            for (int i = 0; i < SelectionMgr.SelectedBuilding.UpgradeRequiredBuildings.Length; i++)
                            {
                                if (i > 0)
                                {
                                    Msg += " -";
                                }
                                Msg += " " + SelectionMgr.SelectedBuilding.UpgradeRequiredBuildings[i].Name;
                            }
                        }
                    }
                    else if (TaskType == TaskManager.TaskTypes.APCRelease)
                    {
                        if (ID == 0)
                        {
                            Msg = "Eject all units inside the APC.";
                        }
                        else
                        {
                            Msg = "Eject unit: " + SelectionMgr.SelectedBuilding.gameObject.GetComponent <APC>().CurrentUnits[ID - 1].Name + " from the APC.";
                        }
                    }
                    else if (TaskType == TaskManager.TaskTypes.APCCall)
                    {
                        Msg = "Call units to get in the APC";
                    }
                    else
                    {
                        RequiredResources = SelectionMgr.SelectedBuilding.BuildingTasksList[ID].RequiredResources;
                        Msg = SelectionMgr.SelectedBuilding.BuildingTasksList[ID].Description;
                    }


                    //Then we will go through all the required resources..
                    if (RequiredResources.Length > 0)
                    {
                        //And show them:
                        Msg += " <b>Required Resources :</b>";

                        for (int i = 0; i < RequiredResources.Length; i++)
                        {
                            if (i > 0)
                            {
                                Msg += " -";
                            }
                            Msg += " " + RequiredResources[i].Name + ": " + RequiredResources[i].Amount.ToString();
                        }
                    }
                }
                else
                {
                    int ResourceID = SelectionMgr.SelectedBuilding.GetComponent <ResourceGenerator>().ReadyToCollect[ID];
                    Msg = "Maximum amount reach! Click to collect " + SelectionMgr.SelectedBuilding.GetComponent <ResourceGenerator>().Resources[ResourceID].Amount.ToString() + " " + SelectionMgr.SelectedBuilding.GetComponent <ResourceGenerator>().Resources[ResourceID].Name;
                }
            }
            else
            {
                //If the player is currently selecting units, we'll display a description of the tasks they can do:

                //If it's a task that allows the player to place a building to construct it:
                if (TaskType == TaskManager.TaskTypes.PlaceBuilding)
                {
                    //Get the building associated with this task ID:
                    Building CurrentBuilding = UIMgr.PlacementMgr.AllBuildings[ID].GetComponent <Building>();
                    Msg += CurrentBuilding.Name + ": " + CurrentBuilding.Description;
                    if (CurrentBuilding.BuildingResources.Length > 0)
                    {
                        //Go through all the required resources to place this building:

                        for (int i = 0; i < CurrentBuilding.BuildingResources.Length; i++)
                        {
                            Msg += "\n" + CurrentBuilding.BuildingResources[i].Name + ": " + CurrentBuilding.BuildingResources[i].Amount.ToString();
                        }
                    }
                }
                else if (TaskType == TaskManager.TaskTypes.APCRelease)
                {
                    if (ID == 0)
                    {
                        Msg = "Eject all units inside the APC.";
                    }
                    else
                    {
                        Msg = "Eject unit: " + GameManager.Instance.SelectionMgr.SelectedUnits[0].gameObject.GetComponent <APC>().CurrentUnits[ID - 1].Name + " from the APC.";
                    }
                }
                else if (TaskType == TaskManager.TaskTypes.APCCall)
                {
                    Msg = "Call units to get in the APC.";
                }
                else if (TaskType == TaskManager.TaskTypes.ToggleInvisibility)
                {
                    Msg = "Toggle Invisibility.";
                }
                else if (TaskType == TaskManager.TaskTypes.Mvt)
                {
                    Msg = "Move unit(s).";
                }
                else if (TaskType == TaskManager.TaskTypes.Build)
                {
                    Msg = "Construct a building.";
                }
                else if (TaskType == TaskManager.TaskTypes.Collect)
                {
                    Msg = "Collect resources.";
                }
                else if (TaskType == TaskManager.TaskTypes.Attack)
                {
                    Msg = "Attack enemy units/buildings.";
                }
                else if (TaskType == TaskManager.TaskTypes.Heal)
                {
                    Msg = "Heal unit(s).";
                }
                else if (TaskType == TaskManager.TaskTypes.Convert)
                {
                    Msg = "Convert enemy unit(s).";
                }
                else if (TaskType == TaskManager.TaskTypes.AttackTypeSelection)
                {
                    Msg = "Switch attack type.";
                }
                else if (TaskType == TaskManager.TaskTypes.ToggleWander)
                {
                    Msg = "Toggle wandering.";
                }
            }

            //show the task info on the tooltip:
            UIMgr.ShowTooltip(Msg);
        }
Exemple #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);
        }