public void SetPart(BasePart.PartType type) { this.m_animationNode = base.transform.Find("Open").transform.Find("PartOffset").Find("AnimationNode").gameObject; this.m_plusNode = base.transform.Find("Open").transform.Find("PartOffset").transform.Find("Plus").gameObject; this.m_particleNode = base.transform.Find("Open").transform.Find("PartOffset").transform.Find("StarBurstEffect").gameObject; for (int i = 0; i < 3; i++) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_partIconBackground); gameObject.transform.parent = this.m_animationNode.transform; int index = (!gameObject.GetComponent <Renderer>().sharedMaterial.name.StartsWith("IngameAtlas2")) ? 0 : 1; Material material = AtlasMaterials.Instance.PartQueueZMaterials[index]; gameObject.GetComponent <Renderer>().material = material; gameObject.transform.localPosition = new Vector3(0f, 0f, 0.1f); gameObject.transform.localScale = 3f * Vector3.one; } GameObject part = this.m_gameData.GetPart(type); Sprite constructionIconSprite = part.GetComponent <BasePart>().m_constructionIconSprite; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(constructionIconSprite.gameObject); int index2 = (!gameObject2.GetComponent <Renderer>().sharedMaterial.name.StartsWith("IngameAtlas2")) ? 0 : 1; Material material2 = AtlasMaterials.Instance.PartQueueZMaterials[index2]; gameObject2.GetComponent <Renderer>().material = material2; gameObject2.transform.parent = this.m_animationNode.transform; gameObject2.transform.localPosition = Vector3.zero; gameObject2.transform.localScale = 2.75f * Vector3.one; this.m_animationTimerStarted = true; this.m_animationTimer = 2.8f; this.m_particleTimerStarted = true; this.m_particleTimer = 3.8f; }
private void SpawnSound() { BasePart.PartType partType = this.m_partType; if (partType != BasePart.PartType.CartWheel) { if (partType != BasePart.PartType.SmallWheel) { if (partType != BasePart.PartType.NormalWheel) { if (partType == BasePart.PartType.ObsoleteWheel) { //this.loopingWheelSound = Singleton<AudioManager>.Instance.SpawnCombinedLoopingEffect(WPFMonoBehaviour.gameData.commonAudioCollection.woodenWheelLoop, base.transform).GetComponent<AudioSource>(); } } else { //this.loopingWheelSound = Singleton<AudioManager>.Instance.SpawnCombinedLoopingEffect(WPFMonoBehaviour.gameData.commonAudioCollection.normalWheelLoop, base.transform).GetComponent<AudioSource>(); } } else { //this.loopingWheelSound = Singleton<AudioManager>.Instance.SpawnCombinedLoopingEffect(WPFMonoBehaviour.gameData.commonAudioCollection.smallWheelLoop, base.transform).GetComponent<AudioSource>(); } } else { //this.loopingWheelSound = Singleton<AudioManager>.Instance.SpawnCombinedLoopingEffect(WPFMonoBehaviour.gameData.commonAudioCollection.woodenWheelLoop, base.transform).GetComponent<AudioSource>(); } //this.loopingWheelSound.volume = 0f; }
public void UpdateSelectionIcon(BasePart.PartType partType, string partName) { if (this.parts.ContainsKey(partType)) { this.parts[partType].UpdateSelectionIcon(partName); } }
public PartReaction GetPartReaction(BasePart.PartType partType) { PartReaction result = null; this.m_partReactions.TryGetValue(partType, out result); return(result); }
public void ShowExperienceParticles(BasePart.PartType partType, string partName) { if (this.parts.ContainsKey(partType)) { this.parts[partType].ShowXPParticles(partName); } }
public void CenterOnPart(BasePart.PartType centerPart) { if (centerPart == BasePart.PartType.Unknown || (this.customPartScope != null && this.customPartScope.Contains(centerPart))) { this.centerPart = centerPart; } }
public void PlaySelectionAudio(BasePart.PartType partType, string partName) { if (this.parts.ContainsKey(partType)) { this.parts[partType].PlaySelectionAudio(partName); } }
private void CreateGUI() { this.ClearNewbuttons(); int num = 0; int num2 = 0; GameObject gameObject = new GameObject("Pivot"); gameObject.transform.parent = base.transform; gameObject.transform.localPosition = Vector3.zero; this.scrollPivot = gameObject.transform; for (int i = 0; i < this.partOrder.Count; i++) { BasePart.PartType partType = this.partOrder[i]; if (this.ValidPart(partType)) { float num3 = (float)num * this.horizontalPadding + (float)num2 * this.partPadding; PartData partData = this.parts[partType]; this.totalWidth = num3 + (float)(partData.RowWidth() - 1) * this.horizontalPadding; this.CreatePartIcons(partData, num3, gameObject.transform, this.newButtons); num2++; num += partData.RowWidth(); } } this.scrollPivot.localPosition = new Vector3(this.GetTargetPosition(), this.scrollPivot.localPosition.y, this.scrollPivot.localPosition.z); this.targetPosition = this.GetTargetPosition(); this.InitNewButtons(); }
private void ReadPartOrder() { this.m_partOrder.Clear(); string text = this.m_gameData.m_partOrderList.text; char[] separator = new char[] { '\n' }; string[] array = text.Split(separator); int num = 0; foreach (string text2 in array) { string text3 = text2.Trim(); if (text3 != string.Empty) { BasePart.PartType key = BasePart.PartType.Unknown; foreach (GameObject gameObject in this.m_gameData.m_parts) { BasePart.PartType partType = gameObject.GetComponent <BasePart>().m_partType; if (partType.ToString() == text3) { key = partType; break; } } this.m_partOrder[key] = num; num++; } } }
protected new bool CheckIfPartReachedGoal(BasePart part, Collider collider, BasePart.PartType targetType) { BasePart basePart = WPFMonoBehaviour.levelManager.ContraptionRunning.FindPart(targetType); if (!basePart) { return(false); } bool flag = WPFMonoBehaviour.levelManager.ContraptionRunning.IsConnectedTo(part, collider, basePart); if (flag) { this.OnGoalEnter(basePart); return(true); } List <BasePart> parts = WPFMonoBehaviour.levelManager.ContraptionRunning.Parts; for (int i = 0; i < parts.Count; i++) { BasePart basePart2 = parts[i]; if (basePart2 && basePart2.ConnectedComponent == part.ConnectedComponent) { this.OnGoalEnter(basePart); return(true); } } return(false); }
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 List <GameObject> GetPartTierInstances(BasePart.PartType partType, BasePart.PartTier partTier) { if (this.parts != null && this.parts.ContainsKey(partType) && this.parts[partType].partInstances != null && this.parts[partType].partInstances.ContainsKey(partTier)) { return(this.parts[partType].partInstances[partTier]); } return(null); }
private bool ValidPart(BasePart.PartType type) { if (type == BasePart.PartType.Pumpkin) { return(GameProgress.HasKey("SecretPumpkin", GameProgress.Location.Local, null)); } return(type != BasePart.PartType.Unknown && type != BasePart.PartType.MAX && type != BasePart.PartType.ObsoleteWheel && type != BasePart.PartType.JetEngine && type != BasePart.PartType.TimeBomb); }
public static int AddSandboxParts(string levelName, BasePart.PartType part, int count, bool showUnlockAnimations = true) { if (showUnlockAnimations) { GameProgress.m_data.AddToInt(levelName + "_part_unlocked_" + part.ToString(), count, int.MinValue, int.MaxValue); } return(GameProgress.m_data.AddToInt(levelName + "_part_" + part.ToString(), count, int.MinValue, int.MaxValue)); }
public void PlayPropellerSound() { AudioManager instance = Singleton <AudioManager> .Instance; BasePart.PartType partType = this.m_partType; if (partType != BasePart.PartType.Fan) { if (partType != BasePart.PartType.Rotor) { if (this.m_partTier != BasePart.PartTier.Legendary) { this.loopingSoundPrefab = new GameObject().AddComponent <AudioSource>(); this.loopingSoundPrefab.GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "propeller"); this.loopingSoundPrefab.GetComponent <AudioSource>().Play(); this.loopingSoundPrefab.GetComponent <AudioSource>().loop = true; this.loopingSoundPrefab.GetComponent <AudioSource>().volume = 0.3f; this.loopingSoundPrefab.transform.parent = this.transform; } if (this.m_partTier == BasePart.PartTier.Legendary) { this.loopingSoundPrefab = new GameObject().AddComponent <AudioSource>(); this.loopingSoundPrefab.GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "alien_fan_01"); this.loopingSoundPrefab.GetComponent <AudioSource>().Play(); this.loopingSoundPrefab.GetComponent <AudioSource>().loop = true; this.loopingSoundPrefab.GetComponent <AudioSource>().volume = 0.3f; this.loopingSoundPrefab.transform.parent = this.transform; } //this.loopingSoundPrefab = ((this.m_partTier != BasePart.PartTier.Legendary) ? WPFMonoBehaviour.gameData.commonAudioCollection.propeller : WPFMonoBehaviour.gameData.commonAudioCollection.alienFan); } else { if (this.m_partTier != BasePart.PartTier.Legendary) { this.loopingSoundPrefab = new GameObject().AddComponent <AudioSource>(); this.loopingSoundPrefab.GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "helicopter_rotor"); this.loopingSoundPrefab.GetComponent <AudioSource>().Play(); this.loopingSoundPrefab.GetComponent <AudioSource>().loop = true; this.loopingSoundPrefab.GetComponent <AudioSource>().volume = 0.3f; this.loopingSoundPrefab.transform.parent = this.transform; } if (this.m_partTier == BasePart.PartTier.Legendary) { this.loopingSoundPrefab = new GameObject().AddComponent <AudioSource>(); this.loopingSoundPrefab.GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "alien_rotor_01"); this.loopingSoundPrefab.GetComponent <AudioSource>().Play(); this.loopingSoundPrefab.GetComponent <AudioSource>().loop = true; this.loopingSoundPrefab.GetComponent <AudioSource>().volume = 0.3f; this.loopingSoundPrefab.transform.parent = this.transform; } //this.loopingSoundPrefab = ((this.m_partTier != BasePart.PartTier.Legendary) ? WPFMonoBehaviour.gameData.commonAudioCollection.rotorLoop : WPFMonoBehaviour.gameData.commonAudioCollection.alienRotor); } } else { this.loopingSoundPrefab = ((this.m_partTier != BasePart.PartTier.Legendary) ? WPFMonoBehaviour.gameData.commonAudioCollection.fan : WPFMonoBehaviour.gameData.commonAudioCollection.alienFan); } this.loopingSound = instance.SpawnCombinedLoopingEffect(this.loopingSoundPrefab, base.gameObject.transform); }
public GameObject GetPart(BasePart.PartType type) { foreach (GameObject gameObject in this.m_parts) { if (gameObject.GetComponent <BasePart>().m_partType == type) { return(gameObject); } } return(null); }
private void SetRewardGiven(BasePart.PartType type, bool given) { if (given && this.rewards.Contains(type)) { this.rewards.Remove(type); } if (given) { this.RewardsGiven++; } GameProgress.SetBool("Pre_RewardGiven_" + type.ToString(), given, GameProgress.Location.Local); }
public static BasePart.PartType CombinedTypeForGadgetButtonOrdering(BasePart.PartType originalType) { BasePart.PartType partType = BasePart.BaseType(originalType); if (partType == BasePart.PartType.EngineBig) { partType = BasePart.PartType.Engine; } else if (partType == BasePart.PartType.EngineSmall) { partType = BasePart.PartType.Engine; } return(partType); }
private BasePart.PartType PartNameToType(string name) { BasePart.PartType result = BasePart.PartType.Unknown; foreach (GameObject gameObject in this.m_parts) { BasePart.PartType partType = gameObject.GetComponent <BasePart>().m_partType; if (partType.ToString() == name) { result = partType; break; } } return(result); }
public CustomPartInfo GetCustomPart(BasePart.PartType type) { foreach (CustomPartInfo customPartInfo in this.m_customParts) { if (type != BasePart.PartType.Pumpkin || GameProgress.HasKey("SecretPumpkin", GameProgress.Location.Local, null)) { if (customPartInfo.PartType == type) { return(customPartInfo); } } } return(null); }
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 BasePart GetCustomPart(BasePart.PartType type, int customIndex) { if (customIndex <= 0) { GameObject part = this.GetPart(type); return((!(part == null)) ? part.GetComponent <BasePart>() : null); } CustomPartInfo customPart = this.GetCustomPart(type); if (customIndex > 0 && customIndex - 1 < customPart.PartList.Count) { return(customPart.PartList[customIndex - 1]); } return(null); }
public override int GetPartCount(BasePart.PartType type) { if (this.parts == null) { this.InitParts(); } for (int i = 0; i < this.parts.Count; i++) { if (this.parts[i].type == type) { return(this.parts[i].count); } } return(0); }
private bool IsRaceLevelUnlocked(BasePart.PartType type) { int num = GameProgress.GetAllStars() + GameProgress.GetRaceLevelUnlockedStars(); string currentLevelIdentifier = Singleton <GameManager> .Instance.CurrentLevelIdentifier; RaceLevels.LevelUnlockablePartsData levelUnlockableData = WPFMonoBehaviour.gameData.m_raceLevels.GetLevelUnlockableData(currentLevelIdentifier); foreach (RaceLevels.UnlockableTier unlockableTier in levelUnlockableData.m_tiers) { if (unlockableTier.m_part == type) { return(num >= unlockableTier.m_starLimit); } } return(true); }
private void FillPartData() { this.parts = new Dictionary <BasePart.PartType, PartData>(); for (int i = 0; i < this.PartTypeCount; i++) { BasePart.PartType partType = (BasePart.PartType)i; if (this.ValidPart(partType)) { GameObject part = this.gameData.GetPart(partType); if (part != null) { this.parts.Add(partType, new PartData(part.GetComponent <BasePart>(), this)); } } } }
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 int GetPartStarLimit(BasePart.PartType part) { string currentLevelIdentifier = Singleton <GameManager> .Instance.CurrentLevelIdentifier; RaceLevels.LevelUnlockablePartsData levelUnlockableData = this.gameData.m_raceLevels.GetLevelUnlockableData(currentLevelIdentifier); if (levelUnlockableData != null) { foreach (RaceLevels.UnlockableTier unlockableTier in levelUnlockableData.m_tiers) { if (unlockableTier.m_part == part) { return(unlockableTier.m_starLimit); } } return(-1); } return(-1); }
public virtual void NotifyGoalReachedByPart(BasePart.PartType partType) { if (!this.levelManager.PartsInGoal.Contains(partType)) { this.levelManager.PartsInGoal.Add(partType); if (partType == BasePart.PartType.Pig) { if (this.levelManager.EggRequired && !this.levelManager.PartsInGoal.Contains(BasePart.PartType.Egg)) { this.ContraptionRunning.SetCameraTarget(this.ContraptionRunning.FindPart(BasePart.PartType.Egg)); } if (this.levelManager.PumpkinRequired && !this.levelManager.PartsInGoal.Contains(BasePart.PartType.Pumpkin)) { this.ContraptionRunning.SetCameraTarget(this.ContraptionRunning.FindPart(BasePart.PartType.Pumpkin)); } } } }
public int GetCustomPartIndex(BasePart.PartType type, string partName) { GameObject part = this.GetPart(type); if (part != null && part.name.Equals(partName)) { return(0); } CustomPartInfo customPart = this.GetCustomPart(type); for (int i = 0; i < customPart.PartList.Count; i++) { if (customPart.PartList[i].name.Equals(partName)) { return(i + 1); } } return(-1); }
public static BasePart.PartType BaseType(BasePart.PartType type) { if (type == BasePart.PartType.Balloons2) { return(BasePart.PartType.Balloon); } if (type == BasePart.PartType.Balloons3) { return(BasePart.PartType.Balloon); } if (type == BasePart.PartType.Sandbag2) { return(BasePart.PartType.Sandbag); } if (type != BasePart.PartType.Sandbag3) { return(type); } return(BasePart.PartType.Sandbag); }