On load, i need to check if an item was instantiated at the symbolSlot location during…
- User
On load, i need to check if an item was instantiated at the symbolSlot location during the PlaceItem method. So that if a player has begun the puzzle and made some placement, saved the game, then when he returns, the instantiated items are still there.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class LovecraftianPuzzle : MonoBehaviour, IDataPersistence { public enum EldritchSymbols { Nyarlathotep, Azathoth, Cthulhu, ShubNiggurath, YogSothoth } public Transform[] symbolSlots; public GameObject[] eldritchSymbolPrefabs; public GameObject[] glyphsGameObject; public List glyphs; public List books; public GameObject portal; public Animator portalAnimator; public AudioSource gatewayAudio; public AudioClip placeSymbolSound; public AudioClip puzzleSolvedSound; public GameObject bookParticlePrefab; public GameObject shadowPeoplePrefab; private GameObject player; private AudioSource playerAudioSource; private InventoryManager InvManager; private AudioSource puzzleAudio; private FearSystem fearSystem; private QuestSystem questSystem;
private void Awake() { glyphs = new List<Glyphs> { new Glyphs { symbolType = EldritchSymbols.Nyarlathotep, symbolGlyph = glyphsGameObject[0], isActive = false}, new Glyphs { symbolType = EldritchSymbols.Azathoth,symbolGlyph = glyphsGameObject[1], isActive = false}, new Glyphs { symbolType = EldritchSymbols.Cthulhu, symbolGlyph = glyphsGameObject[2], isActive = false}, new Glyphs { symbolType = EldritchSymbols.ShubNiggurath, symbolGlyph = glyphsGameObject[3], isActive = false}, new Glyphs { symbolType = EldritchSymbols.YogSothoth, symbolGlyph = glyphsGameObject[4], isActive = false} }; } private void Start() { player = GameObject.Find("Player"); playerAudioSource = player.GetComponent<AudioSource>(); puzzleAudio = GetComponent<AudioSource>(); InvManager = FindAnyObjectByType(typeof(InventoryManager)) as InventoryManager; fearSystem = FindAnyObjectByType(typeof(FearSystem)) as FearSystem; questSystem = FindAnyObjectByType(typeof(QuestSystem)) as QuestSystem; books = new List<Book> { new Book { title = "Invocations of The Cosmic Horror", symbolType = EldritchSymbols.Nyarlathotep, symbolPrefab = eldritchSymbolPrefabs[0] }, new Book { title = "Mark Of The Old Gods", symbolType = EldritchSymbols.Azathoth, symbolPrefab = eldritchSymbolPrefabs[1] }, new Book { title = "The House Of R'lyeh", symbolType = EldritchSymbols.Cthulhu, symbolPrefab = eldritchSymbolPrefabs[2] }, new Book { title = "The Shadow People", symbolType = EldritchSymbols.ShubNiggurath, symbolPrefab = eldritchSymbolPrefabs[3] }, new Book { title = "The Unknown and The Deep Void", symbolType = EldritchSymbols.YogSothoth, symbolPrefab = eldritchSymbolPrefabs[4] } }; } private List<EldritchSymbols> correctOrder = new List<EldritchSymbols>() { EldritchSymbols.Nyarlathotep, EldritchSymbols.Azathoth, EldritchSymbols.Cthulhu, EldritchSymbols.ShubNiggurath, EldritchSymbols.YogSothoth }; public List<EldritchSymbols> currentOrder = new List<EldritchSymbols>(); private Dictionary<EldritchSymbols, int> symbolToSlotIndex = new Dictionary<EldritchSymbols, int>() - Assistant