Scale UI correctly

This commit is contained in:
henriquenakashima 2020-09-26 16:43:30 -04:00
parent 34aad42ba7
commit 30beb96397
3 changed files with 23 additions and 17 deletions

View file

@ -21,6 +21,7 @@ public class BattlePlayerControls : MonoBehaviour
private BattleDeck<MonsterCard> monsterDeck;
private PlayArea playArea;
private InsightLevel insightLevel;
private float scale;
private HandControls<HeroCard> heroHandControls;
private HandControls<MonsterCard> monsterHandControls;
@ -28,18 +29,20 @@ public class BattlePlayerControls : MonoBehaviour
public void Init(
BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck, PlayArea playArea,
InsightLevel insightLevel, HandPlayability<HeroCard> heroHandPlayability) {
InsightLevel insightLevel, HandPlayability<HeroCard> heroHandPlayability, float scale) {
this.heroDeck = heroDeck;
this.monsterDeck = monsterDeck;
this.playArea = playArea;
this.insightLevel = insightLevel;
this.scale = scale;
this.heroHandControls = new HandControls<HeroCard>(
heroDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Bottom, TeamChoice.Heroes,
int.MaxValue, heroHandPlayability);
heroDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Bottom,
TeamChoice.Heroes, int.MaxValue, heroHandPlayability, this.scale);
this.heroHandControls.OnCardClicked += OnHeroCardClicked;
this.monsterHandControls = new HandControls<MonsterCard>(
monsterDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Top, TeamChoice.Monsters, 1, null);
monsterDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Top,
TeamChoice.Monsters, 1, null, this.scale);
this.monsterHandControls.OnCardClicked += OnMonsterCardClicked;
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
@ -135,12 +138,12 @@ public class BattlePlayerControls : MonoBehaviour
}
private Vector3 CalculatePlayAreaCardPosition(int index, int count) {
const int SPACING = 8;
const int DELTA = BattleCardPrefabConstants.CARD_HEIGHT + SPACING;
const int PADDING = 8;
float SPACING = 8 * this.scale;
float DELTA = (BattleCardPrefabConstants.CARD_HEIGHT + SPACING) * this.scale;
float PADDING = 8 * this.scale;
return new Vector3(PADDING + BattleCardPrefabConstants.CARD_WIDTH / 2,
Screen.height - PADDING - DELTA * index - BattleCardPrefabConstants.CARD_HEIGHT / 2,
return new Vector3(PADDING + BattleCardPrefabConstants.CARD_WIDTH * this.scale / 2,
Screen.height - PADDING - DELTA * index - BattleCardPrefabConstants.CARD_HEIGHT * this.scale / 2,
0);
}