Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Shard Rock Stats Fix #222

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/RollCredits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ IEnumerator Wait2()
SceneManager.LoadScene("MainMenu");
}

string s1 = "ShellCoreCommand";
string s1 = $"ShellCore\nCommand";
string s2 = "REMASTERED";
string s3 = "TACTICAL RETRO COMBAT.";
[SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ protected override void OnDeath()


if (MasterNetworkAdapter.mode == MasterNetworkAdapter.NetworkMode.Client) return;

faction = lastDamagedBy.faction;

if (lastDamagedBy)
faction = lastDamagedBy.faction;

for (int i = 0; i < parts.Count; i++)
{
Expand Down
28 changes: 20 additions & 8 deletions Assets/Scripts/HUD Scripts/ReticleScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,26 +390,39 @@ private void AdjustReticleBounds(Image image, Transform ent)

private void UpdateReticleHealths(Image shellImage, Image coreImage, Transform targetCraft, Image energyImage = null)
{
if (targetCraft != null && targetCraft.GetComponent<Entity>())
if (targetCraft != null && targetCraft.TryGetComponent<ITargetable>(out var targetable))
{
var ent = targetCraft.GetComponent<Entity>();
//var ent = targetCraft.GetComponent<IDamageable>();

// show craft related information
shellImage.enabled = coreImage.enabled = true;
shellImage.color = FactionManager.GetFactionColor(ent.GetFaction().factionID);
coreImage.color = new Color(0.8F, 0.8F, 0.8F);
if (targetCraft.GetComponent<ShardRock>())
{
var shardRock = targetCraft.GetComponent<ShardRock>();

if (shardRock.tier == 2)
shellImage.color = new Color(1F, 0F, 0.0F);
else if (shardRock.tier == 1)
shellImage.color = new Color(0F, 1F, 0.0F);
else
shellImage.color = new Color(0.13725F, 0.56078F, 1F);
}
else
shellImage.color = FactionManager.GetFactionColor(targetable.GetFaction().factionID);
coreImage.color = new Color(0.8F, 0.8F, 0.8F);

float[] targHealth = ent.GetHealth(); // get the target current health
float[] targMax = ent.GetMaxHealth(); // get the target max health
float[] targHealth = targetable.GetHealth(); // get the target current health
float[] targMax = targetable.GetMaxHealth(); // get the target max health

shellImage.rectTransform.localScale = new Vector3(targHealth[0] / targMax[0], 1, 1);
coreImage.rectTransform.localScale = new Vector3(targHealth[1] / targMax[1], 1, 1);
if (energyImage && !targetCraft.GetComponent<ShardRock>())
energyImage.rectTransform.localScale = new Vector3(targHealth[2] / targMax[2], 1, 1);

// adjust the image scales according to the health ratios

// Warning: does not account for the shell/core/energy number objects not on primary reticle
if (DebugMode && energyImage)
if (DebugMode && energyImage && !targetCraft.GetComponent<ShardRock>())
{
energyImage.enabled = true;
var parent = coreImage.transform.parent.parent;
Expand All @@ -419,7 +432,6 @@ private void UpdateReticleHealths(Image shellImage, Image coreImage, Transform t
t.enabled = true;
}


parent.Find("Shell Number").GetComponentInChildren<Text>().text = Mathf.Round(targHealth[0]) + "/" + targMax[0];
parent.Find("Core Number").GetComponentInChildren<Text>().text = Mathf.Round(targHealth[1]) + "/" + targMax[1];
parent.Find("Energy Number").GetComponentInChildren<Text>().text = Mathf.Round(targHealth[2]) + "/" + targMax[2];
Expand Down