public void SetAbility(int garrAbilityID, bool hideCounterInfo = false, bool hideName = false, FollowerDetailView followerDetailView = null) { this.m_followerDetailView = followerDetailView; if (this.m_iconErrorText != null) { this.m_iconErrorText.gameObject.SetActive(false); } this.m_garrAbilityID = garrAbilityID; GarrAbilityRec record = StaticDB.garrAbilityDB.GetRecord(this.m_garrAbilityID); if (record == null) { Debug.LogWarning(string.Concat("Invalid garrAbilityID ", this.m_garrAbilityID)); return; } this.m_abilityNameText.text = record.Name; if (record.IconFileDataID <= 0) { this.m_abilityIcon.enabled = false; } else { Sprite sprite = GeneralHelpers.LoadIconAsset(AssetBundleType.Icons, record.IconFileDataID); if (sprite != null) { this.m_abilityIcon.sprite = sprite; if (this.m_grayscaleShader != null) { Material material = new Material(this.m_grayscaleShader); this.m_abilityIcon.material = material; } } else if (this.m_iconErrorText != null) { this.m_iconErrorText.gameObject.SetActive(true); this.m_iconErrorText.text = string.Concat(string.Empty, record.IconFileDataID); } this.m_abilityIcon.enabled = true; } this.m_garrAbilityID = record.ID; GarrAbilityCategoryRec garrAbilityCategoryRec = StaticDB.garrAbilityCategoryDB.GetRecord((int)record.GarrAbilityCategoryID); if (garrAbilityCategoryRec != null) { this.m_counteredMechanicName.text = garrAbilityCategoryRec.Name; } if (this.m_counteredMechanicGroup != null) { if (!hideCounterInfo) { this.m_counteredGarrMechanicTypeID = 0; GarrAbilityEffectRec garrAbilityEffectRec1 = StaticDB.garrAbilityEffectDB.GetRecordsByParentID(record.ID).FirstOrDefault <GarrAbilityEffectRec>((GarrAbilityEffectRec garrAbilityEffectRec) => { if (garrAbilityEffectRec.GarrMechanicTypeID == 0) { return(false); } if (garrAbilityEffectRec.AbilityAction != 0) { return(false); } return(StaticDB.garrMechanicTypeDB.GetRecord((int)garrAbilityEffectRec.GarrMechanicTypeID) != null); }); if (garrAbilityEffectRec1 != null) { GarrMechanicTypeRec garrMechanicTypeRec = StaticDB.garrMechanicTypeDB.GetRecord((int)garrAbilityEffectRec1.GarrMechanicTypeID); Sprite sprite1 = GeneralHelpers.LoadIconAsset(AssetBundleType.Icons, garrMechanicTypeRec.IconFileDataID); if (sprite1 == null) { this.m_counteredMechanicName.text = string.Concat("ERR ", garrMechanicTypeRec.IconFileDataID); } else { this.m_counteredMechanicIcon.sprite = sprite1; } this.m_counteredGarrMechanicTypeID = garrMechanicTypeRec.ID; } } else { this.m_counteredMechanicGroup.SetActive(false); } } this.SetCountered(false, true); if (this.m_counteredMechanicGroup != null) { this.m_counteredMechanicGroup.SetActive(this.m_counteredGarrMechanicTypeID > 0); } this.m_abilityNameText.gameObject.SetActive(!hideName); }
public void SetFollower(int garrFollowerID) { this.m_garrFollowerRec = null; if (this.m_abilityAreaRootObject != null) { RectTransform[] componentsInChildren = this.m_abilityAreaRootObject.GetComponentsInChildren <RectTransform>(true); if (componentsInChildren != null) { for (int i = 0; i < (int)componentsInChildren.Length; i++) { if (componentsInChildren[i] != null && componentsInChildren[i] != this.m_abilityAreaRootObject.transform) { componentsInChildren[i].gameObject.transform.SetParent(null); UnityEngine.Object.Destroy(componentsInChildren[i].gameObject); } } } } if (garrFollowerID == 0) { if (this.m_portraitRingImage != null) { this.m_portraitRingImage.gameObject.SetActive(false); } if (this.m_heartPanel != null) { this.m_heartPanel.SetActive(false); } this.m_levelBorderImage.gameObject.SetActive(false); this.m_levelBorderImage_TitleQuality.gameObject.SetActive(false); this.m_portraitImage.gameObject.SetActive(false); this.m_qualityColorImage.gameObject.SetActive(false); this.m_levelText.gameObject.SetActive(false); this.isOccupied = false; this.m_portraitFrameImage.enabled = true; if (this.currentGarrFollowerID != garrFollowerID) { AdventureMapPanel.instance.MissionFollowerSlotChanged(this.currentGarrFollowerID, false); } bool flag = this.currentGarrFollowerID != 0; this.currentGarrFollowerID = 0; if (flag && this.m_missionDetailView != null) { this.m_missionDetailView.UpdateMissionStatus(); } if (this.m_disableButtonWhenFollowerAssigned) { this.m_portraitFrameImage.GetComponent <Image>().enabled = true; } if (this.m_missionDetailView != null) { this.m_missionDetailView.NotifyFollowerSlotsChanged(); } return; } this.m_portraitRingImage.gameObject.SetActive(true); this.m_levelBorderImage.gameObject.SetActive(true); GarrFollowerRec garrFollowerRec = StaticDB.garrFollowerDB.GetRecord(garrFollowerID); if (garrFollowerRec == null) { return; } if (garrFollowerRec.GarrFollowerTypeID != (uint)GarrisonStatus.GarrisonFollowerType) { return; } MissionMechanic[] missionMechanicArray = base.gameObject.transform.parent.parent.parent.gameObject.GetComponentsInChildren <MissionMechanic>(true); if (missionMechanicArray == null) { return; } WrapperGarrisonFollower item = PersistentFollowerData.followerDictionary[garrFollowerID]; float single = 0f; if (this.m_missionDetailView != null) { single = MissionDetailView.ComputeFollowerBias(item, item.FollowerLevel, (item.ItemLevelWeapon + item.ItemLevelArmor) / 2, this.m_missionDetailView.GetCurrentMissionID()); } if (single == -1f) { this.m_levelText.color = Color.red; } else if (single >= 0f) { this.m_levelText.color = Color.white; } else { this.m_levelText.color = new Color(0.9333f, 0.4392f, 0.2117f); } if (this.m_abilityAreaRootObject != null && single > -1f) { for (int j = 0; j < item.AbilityIDs.Count; j++) { GarrAbilityRec garrAbilityRec = StaticDB.garrAbilityDB.GetRecord(item.AbilityIDs[j]); if ((garrAbilityRec.Flags & 1) == 0) { GarrAbilityEffectRec garrAbilityEffectRec1 = StaticDB.garrAbilityEffectDB.GetRecordsByParentID(garrAbilityRec.ID).FirstOrDefault <GarrAbilityEffectRec>((GarrAbilityEffectRec garrAbilityEffectRec) => { if (garrAbilityEffectRec.GarrMechanicTypeID == 0 || garrAbilityEffectRec.AbilityAction != 0) { return(false); } GarrMechanicTypeRec record = StaticDB.garrMechanicTypeDB.GetRecord((int)garrAbilityEffectRec.GarrMechanicTypeID); if (record == null) { return(false); } return(missionMechanicArray.Any <MissionMechanic>((MissionMechanic mechanic) => mechanic.m_missionMechanicTypeID == record.ID)); }); if (garrAbilityEffectRec1 != null) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_missionMechanicCounterPrefab, this.m_abilityAreaRootObject.transform, false); MissionMechanicTypeCounter component = gameObject.GetComponent <MissionMechanicTypeCounter>(); component.usedIcon.gameObject.SetActive(false); Sprite sprite = GeneralHelpers.LoadIconAsset(AssetBundleType.Icons, garrAbilityRec.IconFileDataID); if (sprite != null) { component.missionMechanicIcon.sprite = sprite; } component.countersMissionMechanicTypeID = (int)garrAbilityEffectRec1.GarrMechanicTypeID; } } } } this.m_levelText.gameObject.SetActive(true); this.m_levelText.text = item.FollowerLevel.ToString(); this.m_portraitImage.gameObject.SetActive(true); Sprite sprite1 = GeneralHelpers.LoadIconAsset(AssetBundleType.PortraitIcons, (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? garrFollowerRec.AllianceIconFileDataID : garrFollowerRec.HordeIconFileDataID)); if (sprite1 != null) { this.m_portraitImage.sprite = sprite1; } if (item.Quality != 6) { this.m_levelBorderImage_TitleQuality.gameObject.SetActive(false); this.m_qualityColorImage.gameObject.SetActive(true); this.m_levelBorderImage.gameObject.SetActive(true); Color qualityColor = GeneralHelpers.GetQualityColor(item.Quality); this.m_qualityColorImage.color = qualityColor; } else { this.m_levelBorderImage_TitleQuality.gameObject.SetActive(true); this.m_qualityColorImage.gameObject.SetActive(false); this.m_levelBorderImage.gameObject.SetActive(false); } this.isOccupied = true; bool flags = (item.Flags & 8) != 0; this.m_qualityColorImage.gameObject.SetActive(!flags); this.m_levelBorderImage.gameObject.SetActive(!flags); if (this.m_heartPanel != null) { this.m_heartPanel.SetActive(flags); if (flags) { this.m_garrFollowerRec = garrFollowerRec; this.m_follower = item; } } this.m_portraitFrameImage.enabled = !flags; this.currentGarrFollowerID = garrFollowerID; if (this.m_disableButtonWhenFollowerAssigned) { this.m_portraitFrameImage.GetComponent <Image>().enabled = false; } if (this.m_missionDetailView != null) { this.m_missionDetailView.UpdateMissionStatus(); this.m_missionDetailView.NotifyFollowerSlotsChanged(); } }