Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous fixes #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions Assets/Resources/Prefabs/Enemies/EnemyBullet.prefab
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_SourcePrefab: {fileID: 0}
m_RootGameObject: {fileID: 1450900268397228}
m_IsPrefabAsset: 1
--- !u!1 &1450900268397228
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4751595347606912}
Expand All @@ -34,9 +24,10 @@ GameObject:
m_IsActive: 1
--- !u!4 &4751595347606912
Transform:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10, y: 0, z: 0}
Expand All @@ -45,11 +36,33 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &33400229563558274
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!135 &135749938694432774
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &23089738467735914
MeshRenderer:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
m_Enabled: 1
m_CastShadows: 1
Expand All @@ -58,7 +71,9 @@ MeshRenderer:
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 10301, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
Expand All @@ -68,6 +83,7 @@ MeshRenderer:
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
Expand All @@ -80,18 +96,12 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33400229563558274
MeshFilter:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1450900268397228}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!54 &54991123750342892
Rigidbody:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
serializedVersion: 2
m_Mass: 1
Expand All @@ -102,11 +112,29 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &114055429372661458
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 030aa1d69d4cb584b93da3fbb2ad4d50, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 5
pointsValue: 5
damage: 0
attackSfx: {fileID: 8300000, guid: b407b11420329cc4dbb66f8c7efd7682, type: 3}
explosion: {fileID: 0}
--- !u!82 &82303918006919376
AudioSource:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450900268397228}
m_Enabled: 1
serializedVersion: 4
Expand Down Expand Up @@ -197,31 +225,3 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &114055429372661458
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1450900268397228}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 030aa1d69d4cb584b93da3fbb2ad4d50, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 5
pointsValue: 5
damage: 0
attackSfx: {fileID: 8300000, guid: b407b11420329cc4dbb66f8c7efd7682, type: 3}
explosion: {fileID: 1039357608938372, guid: 808fe7b924b97c4408c4df3d46323643, type: 2}
--- !u!135 &135749938694432774
SphereCollider:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1450900268397228}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
1 change: 1 addition & 0 deletions Assets/Scripts/Game/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected void OnTriggerEnter(Collider other) {
Spawnable o;
if ((o = other.GetComponent<Enemies.Enemy>()) != null
|| (o = other.GetComponent<Capsule>()) != null) {
o.GrantsReward = true; // To let the object know it was destroyed by player
o.Destroy();
Destroy();
}
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Game/Capsules/Capsule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ private void Update() {
}

public override void Destroy() {
GivePowerUp();
pickUpSfx?.Play();
if (GrantsReward) {
GivePowerUp();
pickUpSfx?.Play();
}
}

protected abstract void GivePowerUp();
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Game/Enemies/Crasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ protected override void Harm(Player target) {
z: Random.Range(-25f, 25f) * cameraForward.z
);
}

StopMoving();
}

protected void FixedUpdate() {
Expand Down
8 changes: 5 additions & 3 deletions Assets/Scripts/Game/Enemies/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ protected virtual void OnEnable() {
}

public override void Destroy() {
score?.AddScore(PointsValue);
if (explosion != null)
Instantiate(explosion, transform.position, transform.rotation);
if (GrantsReward) {
score?.AddScore(PointsValue);
if (explosion != null)
Instantiate(explosion, transform.position, transform.rotation);
}
}

protected virtual void OnDisable() {
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Game/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private void OnGameOver() {
if (ui != null) {
ui.MessageOnScreen.text =
$"Game Over\n\n" +
$"Rounds Survived : {gameState.Level}";
$"Rounds Survived : {gameState.Level - 1}";
}

// Stop all spawners from spawning
Expand Down
6 changes: 6 additions & 0 deletions Assets/Scripts/Game/Spawnable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public float Speed {
}
}

/// <summary>
/// States if the requirements are met for rewarding player
/// </summary>
public bool GrantsReward { get; set; }

/// <summary>
/// Contains object pools that hold already instantiated objects ready
/// to be used when requested.
Expand Down Expand Up @@ -140,6 +145,7 @@ public void Empty() {
/// the type of pool the object will be returned to
/// </typeparam>
public void ReturnToPool<T>() where T : Spawnable {
GrantsReward = false;
gameObject.SetActive(false);
Pool<T>.Instance.objectStack.Push((T)this);
ResetState();
Expand Down
1 change: 1 addition & 0 deletions Assets/Tests/CapsuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public IEnumerator CapsuleGivesBullets() {

yield return new WaitForSecondsRealtime(5f);
//Perform Test
capsule.GrantsReward = true;
capsule.Destroy();

//Assert
Expand Down
Loading