public static List <BasePart> GetCustomParts(BasePart.PartType type, bool onlyLocked = false) { List <BasePart> list = new List <BasePart>(); List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts; for (int i = 0; i < customParts.Count; i++) { if (customParts[i].PartType == type) { for (int j = 0; j < customParts[i].PartList.Count; j++) { if (onlyLocked && !CustomizationManager.IsPartUnlocked(customParts[i].PartList[j])) { list.Add(customParts[i].PartList[j]); } else if (!onlyLocked) { list.Add(customParts[i].PartList[j]); } } break; } } return(list); }
public static BasePart GetRandomCraftablePartFromTier(BasePart.PartTier tier, bool onlyLocked = false) { BasePart result; if (!Singleton <PredefinedRewards> .Instance.AllRewardsGiven && Singleton <PredefinedRewards> .Instance.GetReward(tier, out result)) { return(result); } List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(tier, (!onlyLocked) ? CustomizationManager.PartFlags.None : CustomizationManager.PartFlags.Locked); if (allTierParts.Count == 0) { return(null); } int num = UnityEngine.Random.Range(0, allTierParts.Count); int num2 = num; while (!allTierParts[num].craftable) { num++; if (num >= allTierParts.Count) { num = 0; } if (num2 == num) { return(null); } } return(allTierParts[num]); }
public static List <BasePart> GetAllTierParts(BasePart.PartTier tier, PartFlags flags = CustomizationManager.PartFlags.None) { List <BasePart> list = new List <BasePart>(); if (tier == BasePart.PartTier.Regular) { for (int i = 0; i < WPFMonoBehaviour.gameData.m_parts.Count; i++) { if (flags == CustomizationManager.PartFlags.None) { list.Add(WPFMonoBehaviour.gameData.m_parts[i].GetComponent <BasePart>()); } } } else { List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts; for (int j = 0; j < customParts.Count; j++) { if (customParts[j] != null && customParts[j].PartList != null && customParts[j].PartList.Count != 0) { for (int k = 0; k < customParts[j].PartList.Count; k++) { if (customParts[j].PartList[k].m_partTier == tier && CustomizationManager.HasPartFlags(customParts[j].PartList[k], flags)) { list.Add(customParts[j].PartList[k]); } } } } } return(list); }
private void Awake() { if (Instance == null) { Instance = this; } }
public static int GetUnlockedPartCount(bool useTier = false, BasePart.PartTier tier = BasePart.PartTier.Common) { int num = 0; if (!useTier) { num = CustomizationManager.cachedUnlockedPartCount; } if (num < 0 || useTier) { num = 0; List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts; for (int i = 0; i < customParts.Count; i++) { if (customParts[i] != null && customParts[i].PartList != null && customParts[i].PartList.Count != 0) { for (int j = 0; j < customParts[i].PartList.Count; j++) { if (CustomizationManager.IsPartUnlocked(customParts[i].PartList[j]) && (!useTier || (useTier && customParts[i].PartList[j].m_partTier == tier))) { num++; } } } } } if (!useTier) { CustomizationManager.cachedUnlockedPartCount = num; } return(num); }
// Use this for initialization void Awake() { // Check if a customization manager instance exists if (instance == null) { // If no, this object is our instance instance = this; DontDestroyOnLoad(gameObject); } else { // If yes, destroy this object Destroy(gameObject); return; } // Set current costume to the first in the list if the list is not empty currentCostume = costumeList.Count > 0 ? costumeList[0] : null; currentCostumeIndex = costumeList.Count > 0 ? 0 : -1; // Set current hairstyle to the first in the list if the list is not empty currentHair = hairList.Count > 0 ? hairList[0] : null; currentHairIndex = hairList.Count > 0 ? 0 : -1; // Set current face to the first in the list if the list is not empty currentFace = faceList.Count > 0 ? faceList[0] : null; currentFaceIndex = faceList.Count > 0 ? 0 : -1; }
private static void Initialize() { if (AlienCustomizationManager.s_initialized) { return; } AlienCustomizationManager.s_unlockOrder = new List <BasePart>(); ConfigData config = Singleton <GameConfigurationManager> .Instance.GetConfig("alien_part_craft_order"); List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(BasePart.PartTier.Legendary, CustomizationManager.PartFlags.Craftable); if (config == null) { return; } for (int i = 0; i < config.Count; i++) { string key = i.ToString(); if (config.HasKey(key)) { string b = config[key]; for (int j = 0; j < allTierParts.Count; j++) { if (allTierParts[j].name == b) { AlienCustomizationManager.s_unlockOrder.Add(allTierParts[j]); break; } } } } AlienCustomizationManager.s_initialized = true; }
public void CustomButtonPressed(int partTypeIndex, int partIndex) { if (this.cachedPartListing.LastMovement > 1.5f) { return; } BasePart customPart = WPFMonoBehaviour.gameData.GetCustomPart((BasePart.PartType)partTypeIndex, partIndex); this.cachedPartListing.UpdateSelectionIcon((BasePart.PartType)partTypeIndex, customPart.name); this.cachedPartListing.PlaySelectionAudio((BasePart.PartType)partTypeIndex, customPart.name); if (!CustomizationManager.IsPartUsed(customPart)) { this.cachedPartListing.ShowExperienceParticles((BasePart.PartType)partTypeIndex, customPart.name); CustomizationManager.SetPartUsed(customPart, true); } if (CustomizationManager.IsPartNew(customPart)) { CustomizationManager.SetPartNew(customPart, false); } CustomizationManager.SetLastUsedPartIndex((BasePart.PartType)partTypeIndex, partIndex); EventManager.Send(new PartCustomizationEvent((BasePart.PartType)partTypeIndex, partIndex)); if (this.onButtonPressed != null) { this.onButtonPressed((BasePart.PartType)partTypeIndex); if (this.customPartWidget != null) { this.customPartWidget.ClosePastList(); } } }
public void AddSelectedIcon(Transform icon) { this.selectedIcon = icon; int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(this.type); this.UpdateSelectionIcon(WPFMonoBehaviour.gameData.GetCustomPart(this.type, lastUsedPartIndex).name); }
public static CustomizationManager getInstance() { if (customizationManager == null){ customizationManager= new CustomizationManager(); } extensionManager= SFSExtensionManager.getInstance(); return customizationManager; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); // If the CostumizationManager is null, grab a reference to the CustomizationManager prefab. if (cm == null) { cm = (AssetDatabase.LoadAssetAtPath ("Assets/PreFabs/Managers/CustomizationManager.prefab", typeof(GameObject)) as GameObject).GetComponent <CustomizationManager>(); } // If the value of this object has not been assigned, assign it. if (value == null) { value = serializedObject.targetObject as CostumeData; } // If the add button is clicked, show the popup if (GUILayout.Button("Add New Piece")) { PopupWindow.Show(buttonRect, new NewCostumePopup(this)); } // If this costume is already in the manager, do not allow this button to be accessed EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(value.IsSelectable(cm)); // When clicked, add the costume to the manager if (GUILayout.Button("Add To Customization Manager")) { value.MakeSelectable(cm); // Refresh the manager EditorUtility.SetDirty(cm.gameObject); } EditorGUI.EndDisabledGroup(); // If this costume is not already in the manager, do not allow this button to be accessed EditorGUI.BeginDisabledGroup(!value.IsSelectable(cm)); // When clicked, remove the costume from the manager if (GUILayout.Button("Remove From Customization Manager")) { value.MakeUnselectable(cm); // Refresh the manager EditorUtility.SetDirty(cm.gameObject); } EditorGUI.EndDisabledGroup(); if (Event.current.type == EventType.Repaint) { buttonRect = GUILayoutUtility.GetLastRect(); } }
private BasePart GetRandomPart(BasePart.PartTier tier) { BasePart randomCraftablePartFromTier = CustomizationManager.GetRandomCraftablePartFromTier(tier, true); if (randomCraftablePartFromTier == null) { randomCraftablePartFromTier = CustomizationManager.GetRandomCraftablePartFromTier(tier, false); } return(randomCraftablePartFromTier); }
public static int GetTotalPartCountForTier(BasePart.PartTier tier) { int num = CustomizationManager.cachedPartTierCount[(int)tier]; if (num < 0) { num = CustomizationManager.GetAllTierParts(tier, CustomizationManager.PartFlags.None).Count; } return(num); }
public async Task CreatesDefaultCustomizationIfNoneExists() { // Arrange var documentStoreProvider = DocumentStoreProvider; // Act var sut = new CustomizationManager(documentStoreProvider); var result = await sut.GetOrCreateCustomizationSettingsAsync(); // Assert result.InstanceName.ShouldBe("Augurk"); }
public static BasePart GetRandomPartFromTier(BasePart.PartTier tier, bool onlyLocked = false) { List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(tier, (!onlyLocked) ? CustomizationManager.PartFlags.None : CustomizationManager.PartFlags.Locked); if (allTierParts.Count == 0) { return(null); } int index = UnityEngine.Random.Range(0, allTierParts.Count); return(allTierParts[index]); }
private void CreateUsers() { for (int i = 0; i < NUMBER_OF_USERS; i++) { Kid k = new Kid(); k.FirstName = "kid" + i; k.LastName = "Kid" + i; k.Gender = i % 2 == 0 ? "Kvinne" : "Mann"; k.Age = rand.Next(CustomizationManager.GetLowestYear(), CustomizationManager.GetHighestYear()); users.Add(k); KidProvider.Save(k); } }
private void Awake() { if (instance == null) { instance = this; //make sure that this object is not destroyed when switching between scenes DontDestroyOnLoad(this.gameObject); } else if (instance != this) { Destroy(this.gameObject); } }
private void InitializeNumberPickers() { if (SettingsProvider.HaveAgeSettings()) { numericUpDown1.Value = SettingsProvider.GetLowestYear(); numericUpDown2.Value = SettingsProvider.GetHighestYear(); } else { numericUpDown1.Value = CustomizationManager.GetLowestYear(); numericUpDown2.Value = CustomizationManager.GetHighestYear(); } }
private void UnlockParts(BasePart.PartTier tier, CustomizationManager.PartFlags flags) { List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(tier, flags); if (allTierParts == null || allTierParts.Count == 0) { return; } for (int i = 0; i < allTierParts.Count; i++) { CustomizationManager.UnlockPart(allTierParts[i], "Cheat"); } }
private void CheckDuplicateParts() { ConfigData config = Singleton <GameConfigurationManager> .Instance.GetConfig("part_salvage_rewards"); for (int i = 0; i < this.m_rewards.Length; i++) { if (CustomizationManager.IsPartUnlocked(this.m_rewards[i].PartReward)) { int amount = int.Parse(config[this.m_rewards[i].PartReward.m_partTier.ToString()]); this.m_rewards[i] = new LootWheelRewards.LootWheelReward(amount, this.m_rewards[i].SingleValue, LootWheelRewards.RewardType.Scrap); } } }
public void InitButtons(PartListing partListing, Action <BasePart.PartType> onButtonPressed) { this.cachedPartListing = partListing; this.onButtonPressed = onButtonPressed; if (this.initButtonsDone) { return; } if (this.customPartWidget != null) { Transform transform = this.cachedPartListing.transform.Find("Close"); if (transform) { this.customPartWidget.closeButton = transform.GetComponent <Button>(); } } for (int i = 0; i < Enum.GetNames(typeof(BasePart.PartType)).Length; i++) { for (int j = 0; j < Enum.GetNames(typeof(BasePart.PartTier)).Length; j++) { BasePart.PartType partType = (BasePart.PartType)i; List <GameObject> partTierInstances = this.cachedPartListing.GetPartTierInstances(partType, (BasePart.PartTier)j); if (partTierInstances != null) { for (int k = 0; k < partTierInstances.Count; k++) { bool enabled = j == 0; int customPartIndex = WPFMonoBehaviour.gameData.GetCustomPartIndex(partType, partTierInstances[k].name); if (j > 0) { enabled = CustomizationManager.IsPartUnlocked(WPFMonoBehaviour.gameData.GetCustomPart(partType, customPartIndex)); } BoxCollider component = partTierInstances[k].GetComponent <BoxCollider>(); if (component != null) { component.enabled = enabled; Button component2 = partTierInstances[k].GetComponent <Button>(); component2.MethodToCall.SetMethod(this, "CustomButtonPressed", new object[] { i, customPartIndex }); } } } } } this.cachedPartListing.CreateSelectionIcons(); this.initButtonsDone = true; }
public bool ContainsNewParts() { foreach (KeyValuePair <BasePart.PartTier, List <BasePart> > keyValuePair in this.parts) { for (int i = 0; i < keyValuePair.Value.Count; i++) { if (CustomizationManager.IsPartNew(keyValuePair.Value[i])) { return(true); } } } return(false); }
void Awake() { //Check if instance already exists if (CM == null) { DontDestroyOnLoad(gameObject); CM = this; } //If instance already exists and it's not this: else if (CM != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } }
public bool IsSelectable(CustomizationManager cm) { switch (costumeType) { case CostumeType.outfit: return(cm.IsCostumeIncluded(this)); case CostumeType.hair: return(cm.IsHairStyleIncluded(this)); case CostumeType.face: return(cm.IsFaceIncluded(this)); } return(false); }
public static void UnlockPart(BasePart part, string unlockType) { if (CustomizationManager.IsPartUnlocked(part)) { return; } CustomizationManager.cachedUnlockedPartCount = -1; GameProgress.SetBool(part.name, true, GameProgress.Location.Local); CustomizationManager.SetPartNew(part, true); CustomizationManager.SetPartUsed(part, false); CustomizationManager.CheckUnlockPartAchievements(); if (CustomizationManager.OnPartUnlocked != null) { CustomizationManager.OnPartUnlocked(part); } }
public bool GetReward(BasePart.PartTier tier, out BasePart part) { part = null; if (this.rewards != null && this.rewards.Count > 0) { int num = UnityEngine.Random.Range(0, this.rewards.Count); int num2 = num; do { num++; if (num >= this.rewards.Count) { num = 0; } BasePart.PartType type = (!this.FirstRewardGiven) ? this.firstReward : this.rewards[num]; List <BasePart> customParts = CustomizationManager.GetCustomParts(type, tier, true); if (customParts.Count > 0) { int num3 = UnityEngine.Random.Range(0, customParts.Count); int num4 = num3; do { num3++; if (num3 >= customParts.Count) { num3 = 0; } if (customParts[num3].craftable) { part = customParts[num3]; if (this.FirstRewardGiven) { this.SetRewardGiven(type, true); } else { this.FirstRewardGiven = true; } num = num2; num3 = num4; } }while (num3 != num4); } }while (num != num2); } return(part != null); }
private void RepositionIcons(PartData data, float xPos) { for (int i = 0; i < this.PartTierCount - 1; i++) { for (int j = 0; j < data.RowWidth(); j++) { int index = j; BasePart.PartTier tier = (BasePart.PartTier)i; Vector3 localPosition = new Vector3(xPos + (float)index * this.horizontalPadding, (float)(this.PartTierCount / 2) - (float)i * this.verticalPadding + this.verticalPadding); localPosition.y += ((i != 0) ? 0f : this.firstRowPadding); if (!this.columns.Contains(localPosition.x)) { this.columns.Add(localPosition.x); } if (tier == BasePart.PartTier.Epic && index >= data.PartCount(tier)) { index -= data.PartCount(tier); tier = BasePart.PartTier.Legendary; } if (data.partInstances.ContainsKey(tier) && index < data.partInstances[tier].Count) { data.partInstances[tier][index].transform.localPosition = localPosition; if (CustomizationManager.IsPartNew(data.parts[tier][index])) { PartData data_ = data; GameObject gameObject; if (this.AddNewContentTag(data.partInstances[tier][index], out gameObject)) { GameObjectEvents gameObjectEvents = gameObject.AddComponent <GameObjectEvents>(); GameObjectEvents gameObjectEvents2 = gameObjectEvents; gameObjectEvents2.OnVisible = (Action <bool>) Delegate.Combine(gameObjectEvents2.OnVisible, new Action <bool>(delegate(bool visible) { if (visible) { CustomizationManager.SetPartNew(data_.parts[tier][index], false); } })); this.newButtons.Add(gameObject); } } } } } int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(data.PartType); data.UpdateSelectionIcon(this.gameData.GetCustomPart(data.PartType, lastUsedPartIndex).name); }
public static bool GetNextUnlockable(out BasePart part) { part = null; if (!AlienCustomizationManager.s_initialized) { return(false); } for (int i = 0; i < AlienCustomizationManager.s_unlockOrder.Count; i++) { if (!CustomizationManager.IsPartUnlocked(AlienCustomizationManager.s_unlockOrder[i])) { part = AlienCustomizationManager.s_unlockOrder[i]; break; } } return(part != null); }
public void MakeUnselectable(CustomizationManager cm) { switch (costumeType) { case CostumeType.outfit: cm.RemoveCostume(this); break; case CostumeType.hair: cm.RemoveHairStyle(this); break; case CostumeType.face: cm.RemoveFace(this); break; } }
public static int UnlockablesLeft() { int num = 0; if (!AlienCustomizationManager.s_initialized) { return(0); } for (int i = 0; i < AlienCustomizationManager.s_unlockOrder.Count; i++) { if (!CustomizationManager.IsPartUnlocked(AlienCustomizationManager.s_unlockOrder[i])) { num++; } } return(num); }
private void Collect() { if (this.partToUnlock != null) { CustomizationManager.UnlockPart(this.partToUnlock, "secret"); } if (this.collectEffect != null) { this.collectEffect.Emit(5); } MeshRenderer[] componentsInChildren = base.GetComponentsInChildren <MeshRenderer>(); if (componentsInChildren != null && componentsInChildren.Length > 0) { for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } }