private IEnumerator Init() { if (this.alienConverter.IsAlienMachine && this.alienConverter.RoutineShown) { this.alienConverter.ConvertToAlien(); this.UpdateAlienPartSilhouette(); this.UpdateLiquidTank((float)this.currentMachineScrapAmount, (float)AlienCustomizationManager.GetPrice(), true); } this.SetMachineScrapAmount(GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null)); this.currentMachineScrapAmount = this.targetMachineScrapAmount; this.UpdateMachineScrapLabel(); this.pullChainButton.LockDragging(true); this.pullChainButton.SetPositionOffset(Vector3.up * 10f); this.machineAnimation.state.End += this.OnMachineAnimationEnd; this.machineAnimation.state.Start += this.OnMachineAnimationStart; this.machineAnimation.state.Event += this.OnAnimationEvent; this.SetMachineAnimation(this.introAnimationName, false, false, true); this.machineAnimation.timeScale = 0f; yield return(new WaitForSeconds(0.1f)); if (WorkshopMenu.isDestroyed) { yield break; } this.machineAnimation.timeScale = 1f; Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.machineIntro); int idleAnimationIndex = (int)this.GetPartTierFromAmount(GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null)); this.SetMachineAnimation(this.idleAnimationNames[idleAnimationIndex], true, true, true); if (this.collectRewardButton != null) { this.collectRewardButton.SetActive(false); } yield return(new WaitForSeconds(1f)); if (WorkshopMenu.isDestroyed) { yield break; } this.SetMachineIdleSound(idleAnimationIndex); float fade = 1f; while (fade > 0f) { fade -= Time.deltaTime; this.pullChainButton.SetPositionOffset(Vector3.up * fade * 10f); yield return(null); if (WorkshopMenu.isDestroyed) { yield break; } } this.pullChainButton.LockDragging(false); this.introPlaying = false; yield break; }
private void SetMachineScrapAmount(int newAmount) { if (this.targetMachineScrapAmount == newAmount) { return; } this.targetMachineScrapAmount = newAmount; if (!this.IsAlienMachine && this.machineArrow != null) { float num = 1f; this.machineArrowStutterStrength = 1f; if (newAmount > 0) { if (newAmount < this.commonPrice) { num = (float)newAmount / (float)this.commonPrice * 38f; this.machineArrowStutterStrength = 1f; } else if (newAmount < this.rarePrice) { num = 63f + (float)(newAmount - this.commonPrice) / (float)(this.rarePrice - this.commonPrice) * 22f; this.machineArrowStutterStrength = 2f; } else if (newAmount < this.epicPrice) { num = 116f + (float)(newAmount - this.rarePrice) / (float)(this.epicPrice - this.rarePrice) * 22f; this.machineArrowStutterStrength = 3f; } else { num = 164f; this.machineArrowStutterStrength = 4f; } this.machineArrowStutterStrength *= 3f; num = Mathf.Clamp(num, 1f, 164f); } this.machineArrowTargetAngle = -num; float num2 = this.machineArrow.localEulerAngles.z; if (Mathf.Approximately(num2, 0f) || num2 < 0f) { num2 += 360f; } this.machineArrowFromAngle = num2; this.arrowAngleFade = 0f; } else if (this.IsAlienMachine && this.liquidFillOverride != null) { this.UpdateLiquidTank((float)this.targetMachineScrapAmount, (float)AlienCustomizationManager.GetPrice(), false); } }
private BasePart.PartTier GetPartTierFromAmount(int amount) { for (int i = 3; i > 0; i--) { if (amount == AlienCustomizationManager.GetPrice()) { return(BasePart.PartTier.Legendary); } GameConfigurationManager instance = Singleton <GameConfigurationManager> .Instance; string craft_PRICE_CONFIG_KEY = WorkshopMenu.CRAFT_PRICE_CONFIG_KEY; BasePart.PartTier partTier = (BasePart.PartTier)i; if (amount >= instance.GetValue <int>(craft_PRICE_CONFIG_KEY, partTier.ToString())) { return((BasePart.PartTier)i); } } return(BasePart.PartTier.Regular); }
private void OnMachineBehindCurtain() { this.UpdateLiquidTank((float)this.currentMachineScrapAmount, (float)AlienCustomizationManager.GetPrice(), false); this.UpdateAlienPartSilhouette(); }
public void CraftSelectedPart() { if (this.IsMachineLocked) { return; } this.queuedAddScrapActions = 0; BasePart.PartTier partTierFromAmount = this.GetPartTierFromAmount(GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null)); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftLeverCrank); if (partTierFromAmount == BasePart.PartTier.Regular) { this.SetMachineAnimation(this.insufficientScrapAnimationName, false, false, true); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftEmpty); MaterialAnimation component = this.MachineLabel.GetComponent <MaterialAnimation>(); if (component != null) { component.PlayAnimation(true, 5); } return; } SnoutButton.Instance.EnableButton(false); int num = 0; BasePart basePart = null; if (partTierFromAmount == BasePart.PartTier.Legendary && AlienCustomizationManager.GetNextUnlockable(out basePart)) { num = AlienCustomizationManager.GetPrice(); } else if (partTierFromAmount != BasePart.PartTier.Legendary) { num = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, partTierFromAmount.ToString()); basePart = CustomizationManager.GetRandomCraftablePartFromTier(partTierFromAmount, true); } if (basePart && num > 0 && GameProgress.UseScrap(num)) { this.SetMachineAnimation((!this.IsAlienMachine) ? this.craftAnimationName : this.slimeCraftAnimationName, false, false, false); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftPart); CustomizationManager.UnlockPart(basePart, "crafted"); this.RemoveScrap(num); this.SetMachineIdleSound(0); PlayerProgress.ExperienceType experienceType = PlayerProgress.ExperienceType.CommonPartCrafted; if (partTierFromAmount == BasePart.PartTier.Rare) { experienceType = PlayerProgress.ExperienceType.RarePartCrafted; } if (partTierFromAmount == BasePart.PartTier.Epic) { experienceType = PlayerProgress.ExperienceType.EpicPartCrafted; } if (partTierFromAmount == BasePart.PartTier.Legendary) { experienceType = PlayerProgress.ExperienceType.LegendaryPartCrafted; } PlayerProgressBar.Instance.DelayUpdate(); int exp = Singleton <PlayerProgress> .Instance.AddExperience(experienceType); this.ShowReward(basePart, exp); string key = "CraftCount" + basePart.m_partTier.ToString(); int @int = GameProgress.GetInt(key, 0, GameProgress.Location.Local, null); GameProgress.SetInt(key, @int + 1, GameProgress.Location.Local); if (Singleton <SocialGameManager> .IsInstantiated() && basePart.m_partTier == BasePart.PartTier.Epic) { Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.CRAFT_PARTS", 100.0); } this.partsCraftedWhileInScreen++; EventManager.Send(new CraftingMachineEvent(WorkshopMenu.CraftingMachineAction.CraftPart, 0)); } else if (basePart) { } }
public void AddScrap(int addScrapAmount = 0) { this.queuedAddScrapActions++; if (this.IsMachineLocked) { return; } this.queuedAddScrapActions--; int num = GameProgress.ScrapCount(); int num2 = GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null); int num3 = num - num2; int value = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, BasePart.PartTier.Common.ToString()); int value2 = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, BasePart.PartTier.Rare.ToString()); int value3 = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, BasePart.PartTier.Epic.ToString()); int price = AlienCustomizationManager.GetPrice(); bool flag = CustomizationManager.CustomizationCount(BasePart.PartTier.Common, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0; bool flag2 = CustomizationManager.CustomizationCount(BasePart.PartTier.Rare, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0; bool flag3 = CustomizationManager.CustomizationCount(BasePart.PartTier.Epic, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0; bool flag4 = CustomizationManager.CustomizationCount(BasePart.PartTier.Legendary, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0; BasePart.PartTier nextTier = BasePart.PartTier.Regular; int num4 = 0; int num5; if (addScrapAmount > 0) { num4 = addScrapAmount; if (num4 + num2 < value) { num5 = 0; } else if (num4 + num2 < value2) { num5 = 1; } else if (num4 + num2 < value3) { num5 = 2; } else if (this.IsAlienMachine && num4 + num2 < price) { num5 = 2; } else { num5 = 3; } if (!this.IsAlienMachine && num4 + num2 > value3) { num4 = value3 - num2; } else if (this.IsAlienMachine && num4 + num2 > price) { num4 = price - num2; } } else if (!flag && num2 < value) { nextTier = BasePart.PartTier.Common; num4 = value - num2; num5 = 0; } else if (!flag2 && num2 < value2) { nextTier = BasePart.PartTier.Rare; num4 = value2 - num2; num5 = 1; } else if (!flag3 && num2 < value3) { nextTier = BasePart.PartTier.Epic; num4 = value3 - num2; num5 = 2; } else if (this.IsAlienMachine && !flag4 && num2 < price) { nextTier = BasePart.PartTier.Legendary; num4 = price - num2; num5 = 0; } else { num5 = 3; } if (num4 > 0 && num3 > 0) { if (num4 > num3) { this.ShowGetMoreScrapDialog(num4 - num3, nextTier); num4 = num3; } int partTierFromAmount = (int)this.GetPartTierFromAmount(num2); num2 += num4; GameProgress.SetInt("Machine_scrap_amount", num2, GameProgress.Location.Local); EventManager.Send(new CraftingMachineEvent(WorkshopMenu.CraftingMachineAction.AddScrap, GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null))); num5 = (int)this.GetPartTierFromAmount(num2); if (num5 >= 0) { this.SetMachineAnimation(this.chainPullAnimationName, false, true, false); this.SetMachineAnimation(this.feedAnimationNames[num5], false, false, true); this.SetMachineAnimation(this.idleAnimationNames[num5], true, true, true); if (num5 != partTierFromAmount) { this.SetMachineIdleSound(num5); } } base.StartCoroutine(this.MoveNuts(this.nutRootUpper, this.nutRootLower, num4, 0.2f)); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.insertScrap); } else { this.queuedAddScrapActions = 0; this.SetMachineAnimation(this.idleAnimationNames[num5], true, true, true); this.SetMachineIdleSound(num5); if (num4 > 0 && num3 <= 0) { this.ShowGetMoreScrapDialog(num4, nextTier); } } }