From cae44d0b83a685db70555aa618a07c6a5f7a7e62 Mon Sep 17 00:00:00 2001 From: Philip White Date: Tue, 2 Nov 2021 23:38:39 +0000 Subject: [PATCH] Update Enemy Sprite Change if it Steals Pastie --- Unity-Files/Assets/Scripts/Movement/EnemyReturn.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Unity-Files/Assets/Scripts/Movement/EnemyReturn.cs b/Unity-Files/Assets/Scripts/Movement/EnemyReturn.cs index 344c2f5..bf52d62 100644 --- a/Unity-Files/Assets/Scripts/Movement/EnemyReturn.cs +++ b/Unity-Files/Assets/Scripts/Movement/EnemyReturn.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.AddressableAssets; [RequireComponent(typeof(Rigidbody2D))] public class EnemyReturn : Physics2DObject @@ -14,8 +15,8 @@ public class EnemyReturn : Physics2DObject public GameObject droppedObject; [Header("Death Effect When Shot")] public GameObject deathEffect; - [Header("Has Droppable Object")] - + //[Header("Has Droppable Object")] + private Sprite shipWithPasties; private bool hasDroppableObject = false; private bool isReturning = false; private Vector2 movement = new Vector2(0f, 0f); @@ -23,7 +24,7 @@ public class EnemyReturn : Physics2DObject // Start is called before the first frame update void Start() { - + Addressables.LoadAssetAsync("pastieShip").Completed += handle => { shipWithPasties = handle.Result; }; } // Update is called once per frame @@ -77,5 +78,9 @@ public class EnemyReturn : Physics2DObject public void toggleHasDroppableObject() { hasDroppableObject = (hasDroppableObject) ? false : true; + if (hasDroppableObject) + { + this.GetComponent().sprite = shipWithPasties; + } } }