protected override void OnMainButtonClicked() { var player = Player.m_localPlayer; if (player == null) { return; } var treasureMap = GetSelectedItem(); if (treasureMap != null) { player.StartCoroutine(AdventureDataManager.TreasureMaps.SpawnTreasureChest(treasureMap.Biome, player, (success, position) => { if (success) { var inventory = player.GetInventory(); inventory.RemoveItem(MerchantPanel.GetCoinsName(), treasureMap.Price); StoreGui.instance.m_trader.OnBought(null); StoreGui.instance.m_buyEffects.Create(player.transform.position, Quaternion.identity); } })); } }
public SecretStashListPanel(MerchantPanel merchantPanel, BuyListElement elementPrefab) : base( merchantPanel.transform.Find("SecretStash/Panel/ItemList") as RectTransform, elementPrefab, merchantPanel.transform.Find("SecretStash/SecretStashBuyButton").GetComponent <Button>(), merchantPanel.transform.Find("SecretStash/TimeLeft").GetComponent <Text>()) { _merchantPanel = merchantPanel; }
private static void AddTreasureAndBountiesPage(TextsDialog textsDialog, Player player) { var t = new StringBuilder(); var saveData = player.GetAdventureSaveData(); t.AppendLine("<color=orange><size=30>Treasure Maps</size></color>"); t.AppendLine(); var sortedTreasureMaps = saveData.TreasureMaps.Where(x => x.State == TreasureMapState.Purchased).OrderBy(x => GetBiomeOrder(x.Biome)); foreach (var treasureMap in sortedTreasureMaps) { t.AppendLine(Localization.instance.Localize($"Treasure Map: <color={GetBiomeColor(treasureMap.Biome)}>$biome_{treasureMap.Biome.ToString().ToLower()} #{treasureMap.Interval + 1}</color>")); } t.AppendLine(); t.AppendLine(); t.AppendLine("<color=orange><size=30>Active Bounties</size></color>"); t.AppendLine(); var sortedBounties = saveData.Bounties.OrderBy(x => x.State); foreach (var bounty in sortedBounties) { if (bounty.State == BountyState.Claimed) { continue; } var targetName = AdventureDataManager.GetBountyName(bounty); t.AppendLine($"<size=24>{targetName}</size>"); t.Append($" <color=silver>Classification: <color=#d66660>{AdventureDataManager.GetMonsterName(bounty.Target.MonsterID)}</color>, "); t.AppendLine($" Biome: <color={GetBiomeColor(bounty.Biome)}>$biome_{bounty.Biome.ToString().ToLower()}</color>"); var status = ""; switch (bounty.State) { case BountyState.InProgress: status = ("<color=#00f0ff>In Progress</color>"); break; case BountyState.Complete: status = ("<color=#70f56c>Vanquished!</color>"); break; } t.Append($" Status: {status}"); var iron = bounty.RewardIron; var gold = bounty.RewardGold; t.AppendLine($", Reward: {(iron > 0 ? $"<color=white>{MerchantPanel.GetIronBountyTokenName()} x{iron}</color>" : "")}{(iron > 0 && gold > 0 ? ", " : "")}{(gold > 0 ? $"<color=#f5da53>{MerchantPanel.GetGoldBountyTokenName()} x{gold}</color>" : "")}</color>"); t.AppendLine(); } textsDialog.m_texts.Insert(3, new TextsDialog.TextInfo("Treasure & Bounties", t.ToString())); }
public GambleListPanel(MerchantPanel merchantPanel, BuyListElement elementPrefab) : base( merchantPanel.transform.Find("Gamble/Panel/ItemList") as RectTransform, elementPrefab, merchantPanel.transform.Find("Gamble/GambleBuyButton").GetComponent <Button>(), merchantPanel.transform.Find("Gamble/TimeLeft").GetComponent <Text>()) { _merchantPanel = merchantPanel; }
public AvailableBountiesListPanel(MerchantPanel merchantPanel, BountyListElement elementPrefab) : base( merchantPanel.transform.Find("Bounties/AvailableBountiesPanel/ItemList") as RectTransform, elementPrefab, merchantPanel.transform.Find("Bounties/AcceptBountyButton").GetComponent <Button>(), merchantPanel.transform.Find("Bounties/TimeLeft").GetComponent <Text>()) { _merchantPanel = merchantPanel; }
public TreasureMapListPanel(MerchantPanel merchantPanel, TreasureMapListElement elementPrefab) : base( merchantPanel.transform.Find("TreasureMap/Panel/ItemList") as RectTransform, elementPrefab, merchantPanel.transform.Find("TreasureMap/TreasureMapBuyButton").GetComponent <Button>(), merchantPanel.transform.Find("TreasureMap/TimeLeft").GetComponent <Text>()) { _merchantPanel = merchantPanel; }
public ClaimableBountiesListPanel(MerchantPanel merchantPanel, BountyListElement elementPrefab) : base( merchantPanel.transform.Find("Bounties/ClaimableBountiesPanel/ItemList") as RectTransform, elementPrefab, merchantPanel.transform.Find("Bounties/ClaimBountyButton").GetComponent <Button>(), null) { _merchantPanel = merchantPanel; AbandonButton = merchantPanel.transform.Find("Bounties/AbandonBountyButton").GetComponent <Button>(); AbandonButton.onClick.AddListener(OnAbandonButtonClicked); AbandonButtonIcon = AbandonButton.transform.Find("Icon").GetComponent <Image>(); }
protected static IEnumerator GetRandomPointInBiome(Heightmap.Biome biome, AdventureSaveData saveData, Action <bool, Vector3, Vector3> onComplete) { const int maxRangeIncreases = 10; const int maxPointsInRange = 15; MerchantPanel.ShowInputBlocker(true); var rangeTries = 0; var radiusRange = GetTreasureMapSpawnRadiusRange(biome, saveData); while (rangeTries < maxRangeIncreases) { rangeTries++; var tries = 0; while (tries < maxPointsInRange) { tries++; var randomPoint = UnityEngine.Random.insideUnitCircle; var mag = randomPoint.magnitude; var normalized = randomPoint.normalized; var actualMag = Mathf.Lerp(radiusRange.Item1, radiusRange.Item2, mag); randomPoint = normalized * actualMag; var spawnPoint = new Vector3(randomPoint.x, 0, randomPoint.y); var zoneId = ZoneSystem.instance.GetZone(spawnPoint); while (!ZoneSystem.instance.SpawnZone(zoneId, ZoneSystem.SpawnMode.Client, out _)) { EpicLoot.LogWarning($"Spawning Zone ({zoneId})..."); yield return(null); } ZoneSystem.instance.GetGroundData(ref spawnPoint, out var normal, out var foundBiome, out _, out _); var groundHeight = spawnPoint.y; EpicLoot.Log($"Checking biome at ({randomPoint}): {foundBiome} (try {tries})"); if (foundBiome != biome) { // Wrong biome continue; } var solidHeight = ZoneSystem.instance.GetSolidHeight(spawnPoint); var offsetFromGround = Math.Abs(solidHeight - groundHeight); if (offsetFromGround > 5) { // Don't place too high off the ground (on top of tree or something? EpicLoot.Log($"Spawn Point rejected: too high off of ground (groundHeight:{groundHeight}, solidHeight:{solidHeight})"); continue; } // But also don't place inside rocks spawnPoint.y = solidHeight; var placedNearPlayerBase = EffectArea.IsPointInsideArea(spawnPoint, EffectArea.Type.PlayerBase, AdventureDataManager.Config.TreasureMap.MinimapAreaRadius); if (placedNearPlayerBase) { // Don't place near player base EpicLoot.Log("Spawn Point rejected: too close to player base"); continue; } EpicLoot.Log($"Wards: {PrivateArea.m_allAreas.Count}"); var tooCloseToWard = PrivateArea.m_allAreas.Any(x => x.IsInside(spawnPoint, AdventureDataManager.Config.TreasureMap.MinimapAreaRadius)); if (tooCloseToWard) { EpicLoot.Log("Spawn Point rejected: too close to player ward"); continue; } var waterLevel = ZoneSystem.instance.m_waterLevel; if (waterLevel > groundHeight + 1.0f) { // Too deep, try again EpicLoot.Log($"Spawn Point rejected: too deep underwater (waterLevel:{waterLevel}, groundHeight:{groundHeight})"); continue; } EpicLoot.Log($"Success! (ground={groundHeight} water={waterLevel} placed={spawnPoint.y})"); onComplete?.Invoke(true, spawnPoint, normal); MerchantPanel.ShowInputBlocker(false); yield break; } radiusRange = new Tuple <float, float>(radiusRange.Item1 + 500, radiusRange.Item2 + 500); } onComplete?.Invoke(false, new Vector3(), new Vector3()); MerchantPanel.ShowInputBlocker(false); }
public static void AddTreasureAndBountiesPage(TextsDialog textsDialog, Player player) { var t = new StringBuilder(); var saveData = player.GetAdventureSaveData(); t.AppendLine("<color=orange><size=30>$mod_epicloot_merchant_treasuremaps</size></color>"); t.AppendLine(); var sortedTreasureMaps = saveData.TreasureMaps.Where(x => x.State == TreasureMapState.Purchased).OrderBy(x => GetBiomeOrder(x.Biome)); foreach (var treasureMap in sortedTreasureMaps) { t.AppendLine(Localization.instance.Localize($"$mod_epicloot_merchant_treasuremaps: <color={GetBiomeColor(treasureMap.Biome)}>$biome_{treasureMap.Biome.ToString().ToLower()} #{treasureMap.Interval + 1}</color>")); } t.AppendLine(); t.AppendLine(); t.AppendLine("<color=orange><size=30>$mod_epicloot_activebounties</size></color>"); t.AppendLine(); var sortedBounties = saveData.Bounties.OrderBy(x => x.State); foreach (var bounty in sortedBounties) { if (bounty.State == BountyState.Claimed) { continue; } var targetName = AdventureDataManager.GetBountyName(bounty); t.AppendLine($"<size=24>{targetName}</size>"); t.Append($" <color=silver>$mod_epicloot_activebounties_classification: <color=#d66660>{AdventureDataManager.GetMonsterName(bounty.Target.MonsterID)}</color>, "); t.AppendLine($" $mod_epicloot_activebounties_biome: <color={GetBiomeColor(bounty.Biome)}>$biome_{bounty.Biome.ToString().ToLower()}</color></color>"); var status = ""; switch (bounty.State) { case BountyState.InProgress: status = ("<color=#00f0ff>$mod_epicloot_bounties_tooltip_inprogress</color>"); break; case BountyState.Complete: status = ("<color=#70f56c>$mod_epicloot_bounties_tooltip_vanquished</color>"); break; } t.Append($" <color=silver>$mod_epicloot_bounties_tooltip_status {status}"); var iron = bounty.RewardIron; var gold = bounty.RewardGold; t.AppendLine($", $mod_epicloot_bounties_tooltip_rewards {(iron > 0 ? $"<color=white>{MerchantPanel.GetIronBountyTokenName()} x{iron}</color>" : "")}{(iron > 0 && gold > 0 ? ", " : "")}{(gold > 0 ? $"<color=#f5da53>{MerchantPanel.GetGoldBountyTokenName()} x{gold}</color>" : "")}</color>"); t.AppendLine(); } textsDialog.m_texts.Insert(EpicLoot.HasAuga ? 2 : 4, new TextsDialog.TextInfo( Localization.instance.Localize($"{EpicLoot.GetMagicEffectPip(false)} $mod_epicloot_adventure_title"), Localization.instance.Localize(t.ToString()))); }
public bool CanAddRewardToInventory(BountyListElement selectedItem) { if (selectedItem == null) { return(false); } var rewardCount = (selectedItem.BountyInfo.RewardIron > 0 ? 1 : 0) + (selectedItem.BountyInfo.RewardGold > 0 ? 1 : 0); var hasEmptySlots = Player.m_localPlayer.GetInventory().GetEmptySlots() >= rewardCount; if (hasEmptySlots) { return(true); } if (selectedItem.BountyInfo.RewardIron > 0) { var haveSpace = Player.m_localPlayer.GetInventory().FindFreeStackSpace(MerchantPanel.GetIronBountyTokenName()) > selectedItem.BountyInfo.RewardIron; if (!haveSpace) { return(false); } } if (selectedItem.BountyInfo.RewardGold > 0) { var haveSpace = Player.m_localPlayer.GetInventory().FindFreeStackSpace(MerchantPanel.GetGoldBountyTokenName()) > selectedItem.BountyInfo.RewardGold; if (!haveSpace) { return(false); } } return(true); }