-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemyDescriptions.cs
More file actions
78 lines (66 loc) · 2.61 KB
/
EnemyDescriptions.cs
File metadata and controls
78 lines (66 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using FunkEngine;
using Godot;
public partial class EnemyDescriptions : Control
{
[Export]
private VBoxContainer DescriptionsContainer;
private const string _loopIconPath = "res://Scenes/BattleDirector/Assets/LoopSymbol.png";
private const string _damageInstanceIconPath =
"res://Scenes/BattleDirector/Assets/DamageInstanceSymbol.png";
private const string _battleStartIconPath =
"res://Scenes/BattleDirector/Assets/BattleStartSymbol.png";
private const string _battleEndIconPath =
"res://Scenes/BattleDirector/Assets/BattleEndSymbol.png";
private bool _isVisible = false;
private const string TranslationKeySuffix = "_NOTE_DESCRIPTION";
public void Setup(EnemyPuppet enemy)
{
if (enemy.InitialNote.Amount > 0)
{
string desc = NoteDescBuilder(Scribe.NoteDictionary[enemy.InitialNote.NoteId].Name);
AddDescriptionRow(Scribe.NoteDictionary[enemy.InitialNote.NoteId].Texture, desc);
_isVisible = true;
}
foreach (var effect in enemy.GetBattleEvents())
{
if (effect.Description == null)
continue;
Texture2D icon = GetTriggerIcon(effect.GetTrigger());
AddDescriptionRow(icon, effect.Description);
_isVisible = true;
}
Visible = _isVisible;
}
private void AddDescriptionRow(Texture2D iconTexture, string text)
{
HBoxContainer hbox = new HBoxContainer();
TextureRect icon = new TextureRect();
icon.Texture = iconTexture;
icon.StretchMode = TextureRect.StretchModeEnum.Keep;
Label desc = new Label();
desc.Text = text;
desc.SizeFlagsHorizontal = SizeFlags.ExpandFill;
desc.AutowrapMode = TextServer.AutowrapMode.WordSmart;
hbox.AddChild(icon);
hbox.AddChild(desc);
DescriptionsContainer.AddChild(hbox);
}
private string NoteDescBuilder(string noteName)
{
return noteName.ToUpper() + TranslationKeySuffix;
}
private Texture2D GetTriggerIcon(BattleEffectTrigger trigger)
{
//TODO: add more as we get more enemy effect triggers
return trigger switch
{
BattleEffectTrigger.OnLoop => GD.Load<Texture2D>(_loopIconPath),
BattleEffectTrigger.OnDamageInstance => GD.Load<Texture2D>(_damageInstanceIconPath),
BattleEffectTrigger.OnBattleStart => GD.Load<Texture2D>(_battleStartIconPath),
BattleEffectTrigger.OnBattleEnd => GD.Load<Texture2D>(_battleEndIconPath),
_ => null,
};
}
}