Skip to content

Commit

Permalink
fix bugged star pos & spawn leo puzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
ameliajmoser committed Sep 27, 2024
1 parent 631804f commit f11a274
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Assets/Project/Data/CelestialObjects/Leo/7-AlJabhah.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ MonoBehaviour:
m_Name: 7-AlJabhah
m_EditorClassIdentifier:
m_name: Al Jabhah
m_rightAscension: {x: 11, y: 14, z: 6.5}
m_declination: {x: 20, y: 31, z: 25.4}
m_rightAscension: {x: 10, y: 7, z: 20}
m_declination: {x: 16, y: 45, z: 45.6}
m_constellation: Leo
m_useRadianRADecl: 0
m_rightAscensionRadian: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void HandleItemButtonClicked(int idx) {
CurrItem = CurrCategory.Items[idx].Name;
Log.Msg("Current item: {0}_{1}", CurrCategory.Title, CurrItem);
// Enable identify button
if (FocusMgr.Instance.LastSelectedFocusable) {
if (FocusMgr.Instance.LastSelectedFocusable && !FocusMgr.Instance.LastSelectedFocusable.CelestialObj.Identified) {
m_identifyButton.interactable = true;
}
}
Expand All @@ -137,12 +137,13 @@ private void HandleCloseClicked()
private void HandleIdentifyClicked()
{
if (!FocusMgr.Instance.LastSelectedFocusable || CurrCategory == null) { return; }

if (FocusMgr.Instance.LastSelectedFocusable.CelestialObj.Identified) { return; }

string guessId = CurrCategory.Title + "_" + CurrItem;
string realId = FocusMgr.Instance.LastSelectedFocusable.CelestialObj.Data.IdentifyEntryID;

// TODO: dynamic points assignment
ReviewQueue.Instance.AddNewCelestialItem(guessId, FocusMgr.Instance.LastSelectedFocusable.CelestialObj, 7f, 3);
ReviewQueue.Instance.AddNewCelestialItem(guessId, FocusMgr.Instance.LastSelectedFocusable.CelestialObj, 7f, 5);
//if (guessId.Equals(realId))
//{
// FocusMgr.Instance.LastSelectedFocusable.CelestialObj.Identified = true;
Expand Down
26 changes: 23 additions & 3 deletions Assets/Project/Scripts/UI/Interface/UIDocumentsModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BeauUtil;
using BeauUtil.Debugger;
using System;
using System.Collections;
using System.Collections.Generic;
Expand All @@ -17,6 +18,7 @@ public class UIDocumentsModule : UIInterfaceModule
public float MainScreenScale;

public Postcard[] PostcardsToSpawn;
private BitArray PostcardsSpawned;

[SerializeField] private Button m_CloseButton;
[SerializeField] private RectTransform m_SwapZone;
Expand All @@ -34,16 +36,18 @@ private void Awake() {
Destroy(this.gameObject);
return;
}

SpawnPostcard(0);
SpawnPostcard(1);

}

public override void Init()
{
base.Init();
m_CloseButton.onClick.AddListener(HandleCloseClicked);
m_IconNum.SetText(NewPostcards.ToStringLookup());
GameMgr.Events.Register(GameEvents.InstrumentUnlocksChanged, TrySpawnPuzzle);
PostcardsSpawned = new BitArray(PostcardsToSpawn.Length);
SpawnPostcard(0);
SpawnPostcard(1);
}

public override void Open() {
Expand All @@ -57,9 +61,18 @@ public override void Close()
}

public void SpawnPostcard(int index) {
if (index < 0 || index >= PostcardsToSpawn.Length) {
Log.Warn("[UIDocumentsModule] SpawnPostcard({0}) out of bounds", index);
return;
}
if (PostcardsSpawned[index]) {
Log.Warn("[UIDocumentsModule] Attempted to spawn postcard {0} but it was already spawned", index);
return;
}
Postcard newCard = Instantiate(PostcardsToSpawn[index], this.transform);
newCard.Initialize();
newCard.transform.localPosition = new Vector3(UnityEngine.Random.Range(-300, 300), UnityEngine.Random.Range(-100, 100), 0);
PostcardsSpawned[index] = true;
ChangeNewPostcardNum(+1);
}

Expand All @@ -85,6 +98,13 @@ private void HandleUnfocus()
if (wasOpen) { this.Open(); }
}

private void TrySpawnPuzzle() {
if (InstrumentsMgr.Instance.UnlockedInstruments.HasFlag(InstrumentFlags.Spectrometer) &&
InstrumentsMgr.Instance.UnlockedInstruments.HasFlag(InstrumentFlags.Photometer)) {
SpawnPostcard(2);
}
}

#endregion // Handlers

}
Expand Down

0 comments on commit f11a274

Please sign in to comment.