private void showPilotDataPreview() { SquadBuilderUtil.resetImagesInGameObject(pilotDataPreview, "PilotDataUpgradeSlots"); Pilot pilotToShow = LocalDataWrapper.getPlayer().getSelectedPilot(); if (pilotToShow != null) { string pilotName = pilotToShow.Unique ? "*" + pilotToShow.Name.ToLower() : pilotToShow.Name.ToLower(); pilotDataPreview.transform.Find("PilotLevel/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotToShow.Level.ToString(); pilotDataPreview.transform.Find("PilotCost/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotToShow.Cost.ToString(); pilotDataPreview.transform.Find("PilotDataPilotName/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotName; pilotDataPreview.transform.Find("PilotDataPilotDescription/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotToShow.Text; int upgradeIndex = 0; foreach (UpgradeSlot upgrade in pilotToShow.UpgradeSlots.UpgradeSlot) { Sprite sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + upgrade.Type); Transform upgradeImageHolderPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.UPGRADE_IMAGE_HOLDER); RectTransform rt = (RectTransform)upgradeImageHolderPrefab; float upgradeImageHolderWidth = rt.rect.width; Transform upgradeImageHolder = (Transform)GameObject.Instantiate( upgradeImageHolderPrefab, new Vector3((upgradeIndex * upgradeImageHolderWidth) + SquadBuilderConstants.UPGRADE_IMAGE_X_OFFSET, SquadBuilderConstants.UPGRADE_IMAGE_Y_OFFSET, SquadBuilderConstants.UPGRADE_IMAGE_Z_OFFSET), Quaternion.identity ); Transform upgradesBar = pilotDataPreview.transform.Find("PilotDataUpgradeSlots"); Image upgradeImage = upgradeImageHolder.gameObject.GetComponent <Image>(); upgradeImageHolder.transform.SetParent(upgradesBar, false); upgradeImage.sprite = sprite; upgradeImage.color = new Color(upgradeImage.color.r, upgradeImage.color.g, upgradeImage.color.b, 1.0f); upgradeIndex++; } } }
private void showShipDataPreview() { SquadBuilderUtil.resetImagesInGameObject(shipDataPreview, "ShipDataManeuvers/ShipManeuvers"); Ship shipToShow = LocalDataWrapper.getPlayer().getSelectedEmptyShip(); if (shipToShow != null) { shipDataPreview.transform.Find("ShipDataShipName/ShipName").gameObject.GetComponent <UnityEngine.UI.Text>().text = shipToShow.ShipName.ToLower(); shipDataPreview.transform.Find("ShipDataShipDescription/ShipDescription").gameObject.GetComponent <UnityEngine.UI.Text>().text = shipToShow.ShipDescription; shipDataPreview.transform.Find("ShipDataShipAttributes/ShipDataAttackPower/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text = shipToShow.Weapon.ToString(); shipDataPreview.transform.Find("ShipDataShipAttributes/ShipDataAgility/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text = shipToShow.Agility.ToString(); shipDataPreview.transform.Find("ShipDataShipAttributes/ShipDataShield/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text = shipToShow.Shield.ToString(); shipDataPreview.transform.Find("ShipDataShipAttributes/ShipDataHull/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text = shipToShow.Hull.ToString(); string actions = "Actions: \n"; foreach (string action in shipToShow.Actions.Action) { actions += "* " + action + "\n"; } shipDataPreview.transform.Find("ShipDataActions/ShipActions").gameObject.GetComponent <UnityEngine.UI.Text>().text = actions; foreach (Maneuver maneuver in shipToShow.Maneuvers.Maneuver) { Image image = null; Sprite sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + maneuver.Bearing + "_" + maneuver.Difficulty); string maneuverHolderName = maneuver.Speed + "_" + maneuver.Bearing; if (maneuverHolderName.Contains("koiogran") || maneuverHolderName.Contains("segnor") || maneuverHolderName.Contains("tallon")) { if (maneuverHolderName.Contains("left")) { shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuver.Speed + "_special_left/Image").gameObject.GetComponent <Image>().sprite = sprite; image = shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuver.Speed + "_special_left/Image").gameObject.GetComponent <Image>(); } else if (maneuverHolderName.Contains("right")) { shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuver.Speed + "_special_right/Image").gameObject.GetComponent <Image>().sprite = sprite; image = shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuver.Speed + "_special_right/Image").gameObject.GetComponent <Image>(); } else { shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuver.Speed + "_special_left/Image").gameObject.GetComponent <Image>().sprite = sprite; image = shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuver.Speed + "_special_left/Image").gameObject.GetComponent <Image>(); } } else { shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuverHolderName + "/Image").gameObject.GetComponent <Image>().sprite = sprite; image = shipDataPreview.transform.Find("ShipDataManeuvers/ShipManeuvers/Speed" + maneuverHolderName + "/Image").gameObject.GetComponent <Image>(); } if (image != null) { image.color = new Color(image.color.r, image.color.g, image.color.b, 1.0f); } } } }