Skip to content

Commit

Permalink
show image for current tactic
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-arndt committed Oct 15, 2022
1 parent e731c84 commit 764e7f3
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 29 deletions.
98 changes: 90 additions & 8 deletions Assets/Prefabs/UI/InGameCanvas.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,10 @@ RectTransform:
m_Father: {fileID: 8357631351516009603}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.000061035156, y: -30}
m_SizeDelta: {x: 0, y: -60}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 11.4}
m_SizeDelta: {x: 0, y: 60}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4550497038757988899
CanvasRenderer:
Expand Down Expand Up @@ -2179,6 +2179,82 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3453e345af1a490e8d2784c25338af9c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4553657496670531324
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4451400979462054790}
- component: {fileID: 329837347080630193}
- component: {fileID: 6612984319768917918}
m_Layer: 5
m_Name: TacticIcon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4451400979462054790
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4553657496670531324}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8357631351516009603}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -119.9}
m_SizeDelta: {x: 64, y: 64}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &329837347080630193
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4553657496670531324}
m_CullTransparentMesh: 1
--- !u!114 &6612984319768917918
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4553657496670531324}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &4747410011344326321
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2583,10 +2659,10 @@ RectTransform:
m_Father: {fileID: 8357631351516009603}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.000061035156, y: 30}
m_SizeDelta: {x: 0, y: -60}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 47.3}
m_SizeDelta: {x: 0, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8357631350146380567
CanvasRenderer:
Expand Down Expand Up @@ -2721,6 +2797,7 @@ RectTransform:
m_Children:
- {fileID: 8357631350146380565}
- {fileID: 8417123097516745489}
- {fileID: 4451400979462054790}
m_Father: {fileID: 4466309659932527594}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -2781,6 +2858,11 @@ MonoBehaviour:
m_EditorClassIdentifier:
tacticSystem: {fileID: 11400000, guid: 38102792ab6a18f43a63faad270b79dd, type: 2}
tacticName: {fileID: 8350673078048823725}
tacticIcon: {fileID: 6612984319768917918}
tacticIcons:
- {fileID: 0}
- {fileID: 21300000, guid: 51c4fbfd62138458390fc87fa0740b88, type: 3}
- {fileID: 21300000, guid: 520bce6a5165a46eb9040fd1adc2b406, type: 3}
--- !u!1001 &2729344726640842486
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
50 changes: 29 additions & 21 deletions Assets/Scripts/UserInterface/Overlay/TacticView.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
using Events;
using System.Collections.Generic;
using Events;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;

namespace UserInterface
namespace UserInterface.Overlay
{
public class TacticView : MonoBehaviour
{
[SerializeField] private ScriptableInt tacticSystem;
[SerializeField] private TextMeshProUGUI tacticName;

private void Start()
{
UpdateView();
MessageBroker.Default
.Receive<TacticChanged>()
.TakeUntilDestroy(this)
.Subscribe(_ => UpdateView());
}
public class TacticView : MonoBehaviour
{
[SerializeField] private ScriptableInt tacticSystem;
[SerializeField] private TextMeshProUGUI tacticName;
[SerializeField] private Image tacticIcon;
[SerializeField] private Sprite[] tacticIcons;

private void UpdateView()
{
tacticName.text = ((Tactic) tacticSystem.value).ToString();
}
}
}
private void Start()
{
UpdateView();
MessageBroker.Default
.Receive<TacticChanged>()
.TakeUntilDestroy(this)
.Subscribe(_ => UpdateView());
}

private void UpdateView()
{
tacticName.text = ((Tactic) tacticSystem.value).ToString();
if (tacticSystem.value >= 0 && tacticSystem.value < tacticIcons.Length)
{
tacticIcon.sprite = tacticIcons[tacticSystem.value];
}
}
}
}

0 comments on commit 764e7f3

Please sign in to comment.