NZIEX6J6Q6DSJKNSCTHNIA6EJDQEGMK3ZSP3LKX2UAEDHURQPRVQC
fileFormatVersion: 2
guid: b3c93317b2686664bb3e7d977b996d7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class UnitController : MonoBehaviour
{
[SerializeField] NavMeshAgent selectedAgent;
private void Start() {
PlayerKeyActions.OnUnitSelected += PlayerKeyActions_OnUnitSelected;
PlayerKeyActions.OnUnitMove += PlayerKeyActions_OnUnitMove;
PartyMemberPortrait.OnPartyMemberSelected += PartyMemberPortrait_OnPartyMemberSelected;
}
private void PartyMemberPortrait_OnPartyMemberSelected(object sender, PartyMemberSelectedArgs partyMemberSelectedArgs)
{
if (partyMemberSelectedArgs.PartyMember.TryGetComponent<NavMeshAgent>(out NavMeshAgent trySelectAgent)) {
selectedAgent = trySelectAgent;
}
}
private void PlayerKeyActions_OnUnitMove(object sender, UnitMoveArgs unitMoveArgs)
{
if (selectedAgent) {
selectedAgent.destination = unitMoveArgs.point;
}
}
private void PlayerKeyActions_OnUnitSelected(object sender, UnitSelectedArgs unitSelectedArgs) {
if (unitSelectedArgs.unitTransform.TryGetComponent<NavMeshAgent>(out NavMeshAgent trySelectAgent)) {
selectedAgent = trySelectAgent;
}
}
}
partyToDisplay.OnPartyCompositionChanged += OnPartyCompositionChanged;
partyToDisplay.OnCompositionChanged += Party_OnCompositionChanged;
PlayerKeyActions.OnUnitSelected += PlayerKeyActions_OnUnitSelected;
PartyMemberPortrait.OnPartyMemberSelected += PartyMemberPortrait_OnPartyMemberSelected;
Transform partyMemberPortrait = Instantiate(partyMemberPortraitPrefab, transform);
Transform memberName = partyMemberPortrait.Find("MemberName");
if (memberName) {
if (memberName.TryGetComponent<TextMeshProUGUI>(out textMeshPro)) {
textMeshPro.text = partyMember.name;
}
}
Transform partyMemberPortraitTransform = Instantiate(partyMemberPortraitPrefab, transform);
PartyMemberPortrait partyMemberPortrait = partyMemberPortraitTransform.GetComponent<PartyMemberPortrait>();
partyMemberPortrait.SetPartyMember(partyMember);
}
}
private void PlayerKeyActions_OnUnitSelected(object sender, UnitSelectedArgs unitSelectedArgs) {
PartyMember partyMember;
if (unitSelectedArgs.unitTransform.TryGetComponent<PartyMember>(out partyMember)) {
SetSelectedPortraitByCharacterName(partyMember.name);
}
}
private void PartyMemberPortrait_OnPartyMemberSelected(object sender, PartyMemberSelectedArgs partyMemberSelectedArgs)
{
SetSelectedPortraitByCharacterName(partyMemberSelectedArgs.PartyMember.name);
}
private void SetSelectedPortraitByCharacterName(string characterName) {
foreach (Transform partyMemberPortraitTransform in transform) {
PartyMemberPortrait partyMemberPortrait = partyMemberPortraitTransform.GetComponent<PartyMemberPortrait>();
partyMemberPortrait.SetSelected(partyMemberPortrait.GetPartyMemberName() == characterName);
fileFormatVersion: 2
guid: 0043abfacfaa933459b8413bd829df43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class PartyMemberSelectedArgs : EventArgs {
public PartyMember PartyMember {get;}
public PartyMemberSelectedArgs(PartyMember PartyMember) {
this.PartyMember = PartyMember;
}
}
public class PartyMemberPortrait : MonoBehaviour
{
[SerializeField] Button portrait;
[SerializeField] TextMeshProUGUI characterName;
PartyMember partyMember;
public static event EventHandler<PartyMemberSelectedArgs> OnPartyMemberSelected;
public void SetSelected(bool isSelected) {
portrait.GetComponent<Outline>().enabled = isSelected;
}
public void SetPartyMember(PartyMember partyMember) {
this.partyMember = partyMember;
SetPartyMemberName(partyMember.name);
portrait.onClick.AddListener(() => {
OnPartyMemberSelected?.Invoke(this, new PartyMemberSelectedArgs(partyMember));
});
}
private void SetPartyMemberName(string partyMemberName) {
characterName.text = partyMemberName;
}
public string GetPartyMemberName() => characterName.text;
}
--- !u!114 &1192930482 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7783687589460546184, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
m_PrefabInstance: {fileID: 710618162}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d6a87c4bb1f209a41aaa2c193053affb, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1402557471
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1402557468}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b3c93317b2686664bb3e7d977b996d7d, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedAgent: {fileID: 1501202974}
--- !u!114 &7444263205250385773
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1043900554285081972}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0043abfacfaa933459b8413bd829df43, type: 3}
m_Name:
m_EditorClassIdentifier:
portrait: {fileID: 1043900554285081970}
characterName: {fileID: 1043900554233909512}
--- !u!114 &894387656246917456
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1043900554285081972}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e19747de3f5aca642ab2be37e372fb86, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EffectColor: {r: 0.0045834924, g: 0.9716981, b: 0.2304956, a: 0.5}
m_EffectDistance: {x: 4, y: 4}
m_UseGraphicAlpha: 1