/**
	 * The constructor function for this panel
	 * @param factionName The name of the faction to load the units from
	 * @param unitName The name of the unit to load
	 */
	public void construct (string factionName, string unitName) {
		unitsSelectPanel = UnitsSelectPanel.S;

		// Get the text script for the count game object
		countTxt = countObj.GetComponent<Text> ();

		// Get the population cost for this unit type
		UnitsController unitsController = UnitsController.S;
		populationCost = unitsController.getUnitPopulationCost (unitName);

		// Set the name and unit cost text values
		costObj.GetComponent<Text> ().text = string.Format ("Cost: {0}", populationCost);
		nameObj.GetComponent<Text> ().text = unitName;
		name = unitName;

		// Load the RawImage
		string fileName = string.Format ("{0}_{1}", factionName.ToLower (), unitName.ToLower ().Replace (" ", "_"));

		// Set the image on the panel
		RawImage img = imageObj.GetComponent<RawImage>();
		img.texture = unitsSelectPanel.getTexture (fileName);

		// Disable the down button at start
		downButton.GetComponent<Button> ().interactable = false;
	}
Пример #2
0
	/**
	 * Function that shows the requested canvas on the mobile phone
	 * @param canvas String name of the canvas
	 */
	public void showCanvas (string canvas) {
		// Initialize the canvas to show
		GameObject hiddenCanvas = null;

		try {
			// Hide all of the canvases, this eleminates double showing
			hideAllCanvases ();

			// Get the wanted canvas
			canvases.TryGetValue (canvas, out hiddenCanvas);

			// Show the canvas
			hiddenCanvas.SetActive (true);

			// Choose what to do
			switch (canvas) {
			case "Units Select":
				unitsSelectPanel = UnitsSelectPanel.S;
				unitsSelectPanel.construct ();
				break;
			}
		} catch (Exception e) {
			Debug.Log (string.Format ("canvas: {0} & error: {1}", hiddenCanvas, e));
		}
	}
Пример #3
0
	private PlayerController playerController = null; //!< The local reference to the player's controller
	#endregion

	#region /// @name Unity methods
	/**
	 * Called when the script is loaded, before the game starts
	 */
	void Awake () {
		S = this;

		panels = new List<GameObject> ();

		// Make the associative array of textures
		unitTextures = new Dictionary<string, Texture>();
		foreach (Texture unit in unitsTextures) {
			unitTextures.Add (unit.name, unit);
		}

		gameController = GameController.S;
		playerController = PlayerController.S;
	}