public void Init(Talent talent, List <DynamicTalentLinkUI> talentLinks , UnlockState unlockStateOnDefault = UnlockState.NotUnlockable) { countText.gameObject.SetActive(false); talentContainer = new TalentContainer(talent); AssignLevelupActions(); unlockState = unlockStateOnDefault; links = talentLinks; UpdateImageIcon(); UpdateTalentUI(); }
public bool TryLevelUp(int points) { if (unlockState != UnlockState.Unlockable && unlockState != UnlockState.Unlocked) { Debug.LogWarning("Can't unlock at the moment, unlock state: " + unlockState); return(false); } var levelUpResult = talentContainer.TryLevelupTalent(points); if (!levelUpResult) { return(false); } if (talentContainer.CurrentTalentLevel >= 1) { if (talentContainer.CurrentTalentLevel == 1) { onTalentUnlocked?.Invoke(); unlockState = UnlockState.Unlocked; } if (links != null && links.Count > 0) { foreach (var link in links) { if (!link.CanTraverse(talentContainer.CurrentTalentLevel)) { continue; } link.Destination.TrySetUnlockState(UnlockState.Unlockable); } UpdateLinksUI(); } } UpdateTalentUI(); onTalentLeveledUp?.Invoke(); return(true); }
private void TrySetUnlockState(UnlockState newState) { switch (newState) { case UnlockState.NotUnlockable: { unlockState = newState; break; } case UnlockState.Unlockable: { if (unlockState == UnlockState.Unlocked) { return; } unlockState = newState; break; } case UnlockState.Unlocked: { if (unlockState == UnlockState.NotUnlockable) { return; } unlockState = newState; break; } } UpdateTalentUI(); }
public static bool Prefix(ref UnlockState __result) { __result = UnlockState.Unlocked; return(false); }