Pull request #11: Jason

Merge in CEGJ/ludumdare50 from jason to dev

* commit '20d5e2c41154660ec1aa124b9c9f9060908aec5d':
  Add minion icon on selector bar
  Check IsTargetable in FindTarget
  Added GameFlowState change update to kill velocity
  Replaced circle collider by flat capsule
  Sped up cam zoom and started when entering safe zone
  Fixed minion cooldown starting half way in build
This commit is contained in:
Jason Durand 01 2022-04-03 19:21:26 +00:00
commit 577fbcbfe4
10 changed files with 44 additions and 31 deletions

View File

@ -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:

View File

@ -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: []

View File

@ -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}

View File

@ -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

View File

@ -209,11 +209,16 @@ public class AIEntity : Entity {
float lastDist = float.MaxValue;
Transform chosenEntity = null!;
foreach (Transform other in entityParent) {// Find the closest entity
if (other.GetComponent<Entity>() 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 (lastDist <= entity.AIStats.closeEnough)
break;
}
}
}
}

View File

@ -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;
}
}

View File

@ -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<BaseState> 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) {

View File

@ -33,6 +33,7 @@ public class MinionThrower : MonoBehaviour {
foreach (Entity minion in minionPrefabs) {
minionBar.AddMinionType(minion);
}
minionBar.UpdateReload(0f);
}
void FixedUpdate() {

View File

@ -219,6 +219,7 @@ public class PlayerMovement : MonoBehaviour {
public override void EnterState() {
base.EnterState();
playerMovement.globalCamera.SetActive(true);
playerMovement.rb.SetEnabled(false);
}

View File

@ -16,10 +16,6 @@ public class MinionBar : MonoBehaviour {
minionIcons = new List<MinionIcon>();
}
void Start() {
UpdateReload(0f);
}
public void ChangeSelectedIcon(InputAction.CallbackContext context) {
float floatDelta = context.ReadValue<float>();
@ -45,9 +41,11 @@ public class MinionBar : MonoBehaviour {
public void AddMinionType(Entity newMinionPrefab) {
minionTypes.Add(newMinionPrefab);
MinionIcon newIcon = Instantiate(minionIconPrefab, transform).GetComponent<MinionIcon>();
MinionIcon newIcon = Instantiate(minionIconPrefab, transform)
.GetComponent<MinionIcon>();
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();