Ejemplo n.º 1
0
    /**
     * Start generic activity and subtract any cost.
     * Returns true if cost can be paid, otherwise returns false and doesn't start the activity.h
     */
    virtual public bool StartActivity(string type, System.DateTime startTime, string supportingId)
    {
        switch (type)
        {
        case ActivityType.CLEAR:
            if (ResourceManager.Instance.Resources < this.type.cost)
            {
                return(false);
            }
            ResourceManager.Instance.RemoveResources(this.type.cost);
            break;

        case ActivityType.RECRUIT:
            OccupantTypeData odata = OccupantManager.GetInstance().GetOccupantTypeData(supportingId);
            if (ResourceManager.Instance.Resources < odata.cost)
            {
                return(false);
            }
            ResourceManager.Instance.RemoveResources(odata.cost);
            break;

        default:
            ActivityData data = ActivityManager.GetInstance().GetActivityData(type);
            if (data != null && ResourceManager.Instance.Resources < data.activityCost)
            {
                return(false);
            }
            ResourceManager.Instance.RemoveResources(data.activityCost);
            break;
        }
        StartCoroutine(GenericActivity(type, startTime, supportingId));
        return(true);
    }
	/**
	 * Set up the occupant with the given type data.
     */
	public void InitialiseWithOccupantType(OccupantTypeData type) {
		this.type = type;
		titleLabel.text = type.name;
		descriptionLabel.text = type.description;
		costLabel.text = type.cost.ToString();
		sprite.spriteName = type.spriteName;
		UpdateOccupantStatus ();
	}
    private void AddOccupantPanel(OccupantTypeData type)
    {
        GameObject            panelGo = (GameObject)NGUITools.AddChild(occupantScrollPanel, occupantPanelPrefab);
        UIOccupantSelectPanel panel   = panelGo.GetComponent <UIOccupantSelectPanel>();

        panel.InitialiseWithOccupantType(type);
        occupantSelectPanels.Add(panel);
    }
 /**
  * Set up the occupant with the given type data.
  */
 public void InitialiseWithOccupantType(OccupantTypeData type)
 {
     this.type             = type;
     titleLabel.text       = type.name;
     descriptionLabel.text = type.description;
     costLabel.text        = type.cost.ToString();
     sprite.spriteName     = type.spriteName;
     UpdateOccupantStatus();
 }
Ejemplo n.º 5
0
    /**
     * Formats the allows/required identifiers to be nice strings, coloured correctly.
     * Returns the identifiers.
     */
    virtual protected string FormatIds(List <string> allowIds, bool redIfNotPresent)
    {
        BuildingManager manager = BuildingManager.GetInstance();
        string          result  = "";

        foreach (string id in allowIds)
        {
            if (redIfNotPresent && !manager.PlayerHasBuilding(id) && !OccupantManager.GetInstance().PlayerHasOccupant(id))
            {
                result += "[ff0000]";
            }
            else
            {
                result += "[000000]";
            }
            BuildingTypeData type  = manager.GetBuildingTypeData(id);
            OccupantTypeData otype = OccupantManager.GetInstance().GetOccupantTypeData(id);
            if (type != null)
            {
                result += type.name + ", ";
            }
            else if (otype != null)
            {
                result += otype.name + ", ";
            }
            else
            {
                Debug.LogWarning("No building or occupant type data found for id:" + id);
                result += id + ", ";
            }
        }
        if (result.Length > 2)
        {
            result = result.Substring(0, result.Length - 2);
        }
        else
        {
            return("Nothing");
        }
        return(result);
    }
	private void AddOccupantPanel(OccupantTypeData type) {
		GameObject panelGo = (GameObject) NGUITools.AddChild(occupantScrollPanel, occupantPanelPrefab);
		UIOccupantSelectPanel panel = panelGo.GetComponent<UIOccupantSelectPanel>();
		panel.InitialiseWithOccupantType(type);
		occupantSelectPanels.Add (panel);
	}