public IEnumerator Load()
        {
            managers = GetComponent <Managers>();
            //player = GetComponent<PlayerManager>();
            player = Managers.Player;

            //do
            //{
            //    player = GetComponent<PlayerManager>();
            //}
            //while (player == null);

            if (items == null || items.Count < 1)
            {
                ///TODO: try load List of InventoryItem from savefile
            }

            if (items != null)
            {
                foreach (var item in items)
                {
#pragma warning disable S1656 // It has validation in the set method but from the editor bypasses the set method (accessing the serialized private field)
                    item.IsEquipped = item.IsEquipped;
#pragma warning restore S1656 // It has validation in the set method but from the editor bypasses the set method (accessing the serialized private field)

                    CollectItem(item.ItemDetails, item.Quantity);
                    if (item.IsEquipped)
                    {
                        EquipItem(item); ///TODO: Add the item on specific inventory slot - helmet, chest, trinket, charm, etc.
                    }
                }
            }

            yield return(null);
        }
예제 #2
0
        public IEnumerator Load()
        {
            managers = GetComponent <Managers>();
            //inventoryManager = InventoryManager.Instance; ///TODO: more testing required: gets null but it loads it through the reference later
            inventoryManager = Managers.Inventory; ///TODO: test this or above is better

            playerGO         = GameObject.FindGameObjectWithTag("Player");
            playerController = playerGO.GetComponent <PlayerController>();
            playerCollider   = playerGO.GetComponent <BoxCollider2D>();
            scene            = SceneManager.GetActiveScene();
            playerSprites    = playerGO.GetComponentsInChildren <SpriteMeshInstance>();
            ChangeSpritesColor(playerSprites, Color.white); //to reset the original sprites' colors
            playerRigidBody   = playerGO.GetComponent <Rigidbody2D>();
            CharacterAnimator = GameObject.FindGameObjectWithTag("PlayerAnimator").GetComponent <Animator>();
            managers          = GetComponent <Managers>();

            yield return(null);
        }