diff --git a/Assets/Prefabs/Minion Icon.prefab b/Assets/Prefabs/Minion Icon.prefab index 120ee85..f001afc 100644 --- a/Assets/Prefabs/Minion Icon.prefab +++ b/Assets/Prefabs/Minion Icon.prefab @@ -114,7 +114,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 1} + m_Color: {r: 0, g: 0, b: 0, a: 0.5019608} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -158,7 +158,7 @@ RectTransform: m_GameObject: {fileID: 1979632679604795357} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalScale: {x: 2.5, y: 2.5, z: 1} m_Children: [] m_Father: {fileID: 1979632678310270258} m_RootOrder: 1 @@ -166,7 +166,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: -20, y: -20} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &1979632679604795352 CanvasRenderer: diff --git a/Assets/Prefabs/SceneStuff.prefab b/Assets/Prefabs/SceneStuff.prefab index 08f966c..b9256de 100644 --- a/Assets/Prefabs/SceneStuff.prefab +++ b/Assets/Prefabs/SceneStuff.prefab @@ -652,7 +652,7 @@ MonoBehaviour: m_BlendUpdateMethod: 0 m_DefaultBlend: m_Style: 1 - m_Time: 2 + m_Time: 1 m_CustomCurve: serializedVersion: 2 m_Curve: [] diff --git a/Assets/Prefabs/Vampire.prefab b/Assets/Prefabs/Vampire.prefab index 3e3215f..7737c13 100644 --- a/Assets/Prefabs/Vampire.prefab +++ b/Assets/Prefabs/Vampire.prefab @@ -15,7 +15,7 @@ GameObject: - component: {fileID: 7967951869135974023} - component: {fileID: 1214567908930553477} - component: {fileID: 945832017} - - component: {fileID: 945832018} + - component: {fileID: 7270464587938865433} m_Layer: 0 m_Name: Vampire m_TagString: Untagged @@ -337,8 +337,8 @@ Rigidbody2D: m_SleepingMode: 1 m_CollisionDetection: 0 m_Constraints: 4 ---- !u!58 &945832018 -CircleCollider2D: +--- !u!70 &7270464587938865433 +CapsuleCollider2D: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -350,9 +350,9 @@ CircleCollider2D: m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - serializedVersion: 2 - m_Radius: 0.5 + m_Offset: {x: 0, y: -0.25} + m_Size: {x: 1.25, y: 0.5} + m_Direction: 1 --- !u!1 &5124059627794595469 GameObject: m_ObjectHideFlags: 0 @@ -409,8 +409,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 5933636161494595212} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -1, z: 0} - m_LocalScale: {x: 1, y: 0.3, z: 1} + m_LocalPosition: {x: 0, y: -0.5, z: 0} + m_LocalScale: {x: 1.2, y: 0.3, z: 1} m_Children: [] m_Father: {fileID: 1214567908930553594} m_RootOrder: 3 @@ -492,7 +492,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6851233285413272648} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1214567908930553594} diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index eb6d8d1..80cb6cb 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -208,10 +208,6 @@ PrefabInstance: propertyPath: m_Name value: SceneStuff objectReference: {fileID: 0} - - target: {fileID: 8365024802335227869, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3} - propertyPath: orthographic size - value: 10.5 - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3} --- !u!4 &720678398 stripped diff --git a/Assets/Scripts/AIEntity.cs b/Assets/Scripts/AIEntity.cs index 5aa7fd1..93c86c8 100644 --- a/Assets/Scripts/AIEntity.cs +++ b/Assets/Scripts/AIEntity.cs @@ -209,12 +209,17 @@ public class AIEntity : Entity { float lastDist = float.MaxValue; Transform chosenEntity = null!; foreach (Transform other in entityParent) {// Find the closest entity - float distance = Vector2.Distance(other.position, entity.transform.position); - if (distance < lastDist) { - lastDist = distance; - chosenEntity = other; - if (lastDist <= entity.AIStats.closeEnough) break; - } + if (other.GetComponent() is {} otherEntity) { + if (entity.IsTargetable(otherEntity)) { + float distance = Vector2.Distance(other.position, entity.transform.position); + if (distance < lastDist) { + lastDist = distance; + chosenEntity = other; + if (lastDist <= entity.AIStats.closeEnough) + break; + } + } + } } if (chosenEntity != null) { diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index 8c24ae3..f0c2422 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -54,6 +54,7 @@ public class Entity : MonoBehaviour { protected virtual void Start() { if (direction == Vector3.zero && !(this is VampireEntity)) Debug.LogWarning("Entity had null direction."); + gameFlowManager.stateChanged += OnGameFlowStateChanged; attackTimer = attackCooldown; initialHealth = Health; @@ -66,6 +67,8 @@ public class Entity : MonoBehaviour { protected virtual void FixedUpdate() {} + protected void OnDestroy() => gameFlowManager.stateChanged -= OnGameFlowStateChanged; + protected virtual void Attack() { } @@ -156,4 +159,9 @@ public class Entity : MonoBehaviour { public void DisableHalo() { halo.SetActive(false); } + + void OnGameFlowStateChanged(BaseState newState) { + if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.NothingMoves) + rb.velocity = Vector2.zero; + } } diff --git a/Assets/Scripts/GameFlowManager.cs b/Assets/Scripts/GameFlowManager.cs index cfdf213..82557a6 100644 --- a/Assets/Scripts/GameFlowManager.cs +++ b/Assets/Scripts/GameFlowManager.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using NaughtyAttributes; using UnityEngine; using UnityEngine.InputSystem; @@ -37,6 +38,8 @@ public class GameFlowManager : MonoBehaviour { [field: SerializeField] TMP_Text startTxt; [field: SerializeField] TMP_Text endTxt; + public event Action stateChanged; + #region Unity Messages void Awake() { @@ -129,9 +132,10 @@ public class GameFlowManager : MonoBehaviour { CurrentState.LeaveState(); CurrentState = newState; newState.EnterState(); + stateChanged?.Invoke(newState); } - abstract class GameFlowState : BaseState { + public abstract class GameFlowState : BaseState { readonly protected GameFlowManager gameFlowManager; protected GameFlowState(GameFlowManager gameFlowManager) { diff --git a/Assets/Scripts/MinionThrower.cs b/Assets/Scripts/MinionThrower.cs index ca9bfb9..d79f265 100644 --- a/Assets/Scripts/MinionThrower.cs +++ b/Assets/Scripts/MinionThrower.cs @@ -33,6 +33,7 @@ public class MinionThrower : MonoBehaviour { foreach (Entity minion in minionPrefabs) { minionBar.AddMinionType(minion); } + minionBar.UpdateReload(0f); } void FixedUpdate() { diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index 266ed16..6925826 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -218,7 +218,8 @@ public class PlayerMovement : MonoBehaviour { public override void EnterState() { base.EnterState(); - + + playerMovement.globalCamera.SetActive(true); playerMovement.rb.SetEnabled(false); } diff --git a/Assets/Scripts/UI/MinionBar.cs b/Assets/Scripts/UI/MinionBar.cs index 7f1b4c4..0d899de 100644 --- a/Assets/Scripts/UI/MinionBar.cs +++ b/Assets/Scripts/UI/MinionBar.cs @@ -16,10 +16,6 @@ public class MinionBar : MonoBehaviour { minionIcons = new List(); } - void Start() { - UpdateReload(0f); - } - public void ChangeSelectedIcon(InputAction.CallbackContext context) { float floatDelta = context.ReadValue(); @@ -45,9 +41,11 @@ public class MinionBar : MonoBehaviour { public void AddMinionType(Entity newMinionPrefab) { minionTypes.Add(newMinionPrefab); - MinionIcon newIcon = Instantiate(minionIconPrefab, transform).GetComponent(); + MinionIcon newIcon = Instantiate(minionIconPrefab, transform) + .GetComponent(); minionIcons.Add(newIcon); - // minionIcons[i].icon = minionTypes.icon; // TODO + newIcon.icon.sprite = newMinionPrefab.renderer.sprite; + newIcon.icon.preserveAspect = true; newIcon.indexInMinionList = minionIcons.Count; if (currentIndex == minionIcons.Count - 1) { newIcon.Select();