Skip to content

Commit

Permalink
Add UnitRewards and ItemRewards
Browse files Browse the repository at this point in the history
  • Loading branch information
lotuuu committed Jun 11, 2024
1 parent 10db0d4 commit eb1ddc2
Show file tree
Hide file tree
Showing 11 changed files with 772 additions and 99 deletions.
2 changes: 1 addition & 1 deletion client/Assets/Scenes/Overworld.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.3708708, g: 0.37838137, b: 0.35725543, a: 1}
m_IndirectSpecularColor: {r: 0.3710032, g: 0.3785125, b: 0.35738343, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down
12 changes: 11 additions & 1 deletion client/Assets/Scripts/BackendConnection/SocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,17 @@ private List<Campaign> ParseCampaignsFromResponse(Protobuf.Messages.Campaigns ca
levelNumber = (int)level.LevelNumber,
campaignId = level.CampaignId,
units = levelUnits,
rewards = GetLevelCurrencyRewards(level),
currencyRewards = GetLevelCurrencyRewards(level),
itemRewards = level.ItemRewards.Select(itemReward => new ItemReward
{
itemTemplate = GlobalUserData.Instance.AvailableItemTemplates.Find(itemTemplate => itemTemplate.name.ToLower() == itemReward.ItemTemplateName.ToLower()),
level = (int)itemReward.Level
}).ToList(),
unitRewards = level.UnitRewards.Select(unitReward => new UnitReward
{
character = availableCharacters.Find(character => character.name.ToLower() == unitReward.CharacterName.ToLower()),
rank = (int)unitReward.Rank
}).ToList(),
status = levelStatus
});

Expand Down
17 changes: 13 additions & 4 deletions client/Assets/Scripts/Battle/BattleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ private void HandleBattleResult(bool result)
}
GlobalUserData user = GlobalUserData.Instance;
user.AddCurrencies(GetLevelRewards());
user.User.afkMaxCurrencyReward = LevelProgress.selectedLevelData.afkCurrencyRate;
user.User.afkMaxExperienceReward = LevelProgress.selectedLevelData.afkExperienceRate;
victorySplash.GetComponentInChildren<RewardsUIContainer>().Populate(CreateRewardsList());
victorySplash.SetActive(true);
victorySplash.GetComponent<AudioSource>().Play();
Expand Down Expand Up @@ -307,7 +305,7 @@ private void ProcessExecutionsReceived(IEnumerable<Protobuf.Messages.Action> act

private Dictionary<string, int> GetLevelRewards()
{
Dictionary<string, int> rewards = LevelProgress.selectedLevelData.rewards;
Dictionary<string, int> rewards = LevelProgress.selectedLevelData.currencyRewards;
if (LevelProgress.selectedLevelData.experienceReward > 0)
{
rewards.Add("Experience", LevelProgress.selectedLevelData.experienceReward);
Expand Down Expand Up @@ -337,13 +335,24 @@ private List<UIReward> CreateRewardsList()
{
List<UIReward> rewards = new List<UIReward>();

foreach (var currencyReward in LevelProgress.selectedLevelData.rewards)
foreach (var currencyReward in LevelProgress.selectedLevelData.currencyRewards)
{
if (currencyReward.Value > 0)
{
rewards.Add(new CurrencyUIReward(currencyReward.Key, currencyReward.Value));
}
}

foreach (var unitReward in LevelProgress.selectedLevelData.unitRewards)
{
rewards.Add(new UnitUIReward(unitReward));
}

foreach (var itemReward in LevelProgress.selectedLevelData.itemRewards)
{
rewards.Add(new ItemUIReward(itemReward));
}

return rewards;
}

Expand Down
8 changes: 8 additions & 0 deletions client/Assets/Scripts/Campaign/ItemReward.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;

public class ItemReward
{
public ItemTemplate itemTemplate;
public int level;
}
11 changes: 11 additions & 0 deletions client/Assets/Scripts/Campaign/ItemReward.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions client/Assets/Scripts/Campaign/LevelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ public class LevelData
public string campaignId;
public List<Unit> units;

public Dictionary<string, int> rewards = new Dictionary<string, int>();
public Dictionary<string, int> currencyRewards = new Dictionary<string, int>();

// AFK Rewards daily_rate granted
// These are how many a player makes in the maximum timespan available (12h now)
public Dictionary<Currency, int> afkCurrencyRate = new Dictionary<Currency, int>();

public int afkExperienceRate;
public List<ItemReward> itemRewards = new();
public List<UnitReward> unitRewards = new();

public int experienceReward;

Expand Down
8 changes: 8 additions & 0 deletions client/Assets/Scripts/Campaign/UnitReward.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;

public class UnitReward
{
public Character character;
public int rank;
}
11 changes: 11 additions & 0 deletions client/Assets/Scripts/Campaign/UnitReward.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb1ddc2

Please sign in to comment.