コード例 #1
0
    public BuildingAction[] GetBuildingActionOptions(Vector3Int position)
    {
        if (!HasActiveBuilding(position))
        {
            Debug.LogError($"Position {position} does not have a working building to act on");
            return(null);
        }

        List <BuildingAction> options       = new List <BuildingAction>();
        GameObject            buildingLogic = _positionToBuildingLogic[position];

        if (buildingLogic.GetComponent <BuildingLogicBase>().CanUpgradeProduction())
        {
            options.Add(BuildingAction.UPGRADE_PRODUCTION);
        }
        BuildingHealth buildingHealth = buildingLogic.GetComponent <BuildingHealth>();

        if (buildingHealth.CanUpgradeHealth())
        {
            options.Add(BuildingAction.UPGRADE_HEALTH);
        }
        if (buildingHealth.CurrentHealth < buildingHealth.MaxHealth)
        {
            options.Add(BuildingAction.REPAIR);
        }
        return(options.ToArray());
    }