Fix lots of misc bugs

This commit is contained in:
Jens Pitkänen 2019-08-22 19:59:36 +03:00
parent 9d4171aa39
commit 5a4f744a24
17 changed files with 101 additions and 31 deletions

View File

@ -187,6 +187,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 173be6658a5fcba49b9b1f1c91fa5f33, type: 3}
m_Name:
m_EditorClassIdentifier:
SearchLayerMask:
serializedVersion: 2
m_Bits: 6145
Radius: 6.5
ForgetRadius: 10
ForgetTimer: 1

View File

@ -187,6 +187,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 173be6658a5fcba49b9b1f1c91fa5f33, type: 3}
m_Name:
m_EditorClassIdentifier:
SearchLayerMask:
serializedVersion: 2
m_Bits: 6145
Radius: 5
ForgetRadius: 6
ForgetTimer: 0

View File

@ -257,7 +257,7 @@ Rigidbody2D:
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
m_Constraints: 4
--- !u!61 &6622851958837894017
BoxCollider2D:
m_ObjectHideFlags: 0
@ -381,6 +381,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 173be6658a5fcba49b9b1f1c91fa5f33, type: 3}
m_Name:
m_EditorClassIdentifier:
SearchLayerMask:
serializedVersion: 2
m_Bits: 6145
Radius: 8
ForgetRadius: 10
ForgetTimer: 0.5

View File

@ -4766,7 +4766,7 @@ GameObject:
- component: {fileID: 2523517584660005059}
- component: {fileID: 2523517584660005060}
- component: {fileID: 2523517584660005061}
m_Layer: 0
m_Layer: 11
m_Name: Rocket Launcher
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -4882,7 +4882,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2523517584678253222}
m_Layer: 0
m_Layer: 11
m_Name: Bobbing
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -4915,7 +4915,7 @@ GameObject:
m_Component:
- component: {fileID: 2523517585734629854}
- component: {fileID: 2523517585734629853}
m_Layer: 0
m_Layer: 11
m_Name: Graphic
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -4994,7 +4994,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2523517586496120961}
m_Layer: 0
m_Layer: 11
m_Name: BulletHole
m_TagString: Untagged
m_Icon: {fileID: 0}

View File

@ -124,6 +124,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
StickyLayers:
serializedVersion: 2
m_Bits: 4919
Renderer: {fileID: 1882677610630750274}
LaunchForce: {x: 0, y: 0}
Settled: 0

View File

@ -125,6 +125,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
StickyLayers:
serializedVersion: 2
m_Bits: 4919
Renderer: {fileID: 5625006176639346186}
LaunchForce: {x: 0, y: 0}
Settled: 0

View File

@ -124,6 +124,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
StickyLayers:
serializedVersion: 2
m_Bits: 4096
Renderer: {fileID: 6669388256411233138}
LaunchForce: {x: 0, y: 0}
Settled: 0

View File

@ -124,6 +124,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
StickyLayers:
serializedVersion: 2
m_Bits: 4096
Renderer: {fileID: 8205645559196366284}
LaunchForce: {x: 0, y: 0}
Settled: 0

View File

@ -15702,7 +15702,7 @@ Transform:
- {fileID: 628992541}
- {fileID: 1125139377}
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &402096464
PrefabInstance:
@ -16464,6 +16464,36 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1a0e05447c8cf2a4fa9b9dc697884a66, type: 3}
--- !u!1 &551258498
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 551258499}
m_Layer: 0
m_Name: Bodyparts
m_TagString: BodypartContainer
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &551258499
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 551258498}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &557699463 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 592487110401094196, guid: 1a0e05447c8cf2a4fa9b9dc697884a66,
@ -21876,7 +21906,7 @@ Transform:
- {fileID: 562795619}
- {fileID: 107939636}
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &729817018 stripped
Transform:
@ -112719,6 +112749,12 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 83a316fa6e4719d47b1428b9cd630922, type: 3}
--- !u!4 &1530237516 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
m_PrefabInstance: {fileID: 11699644215422960}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1572063890
PrefabInstance:
m_ObjectHideFlags: 0
@ -113157,7 +113193,7 @@ Transform:
- {fileID: 1822937580}
- {fileID: 1619207830}
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1616078557 stripped
Transform:
@ -114424,7 +114460,7 @@ Transform:
- {fileID: 1684548384}
- {fileID: 162941294}
m_Father: {fileID: 0}
m_RootOrder: 13
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1852192920
PrefabInstance:
@ -115321,8 +115357,9 @@ Transform:
- {fileID: 380476815}
- {fileID: 166998417}
- {fileID: 695076217}
- {fileID: 1530237516}
m_Father: {fileID: 0}
m_RootOrder: 12
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2099407198
PrefabInstance:
@ -115589,7 +115626,7 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_TransformParent: {fileID: 2086257545}
m_Modifications:
- target: {fileID: 11699643827672081, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
@ -115609,17 +115646,17 @@ PrefabInstance:
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
@ -115629,7 +115666,7 @@ PrefabInstance:
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}
propertyPath: m_RootOrder
value: 8
value: 9
objectReference: {fileID: 0}
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
type: 3}

View File

@ -1,13 +1,15 @@
using UnityEngine;
using Saltosion.OneWeapon.Utils;
using Saltosion.OneWeapon.Enemies;
namespace Saltosion.OneWeapon.AI.Triggers {
public class EnemySighted : Trigger {
public LayerMask SearchLayerMask;
public float Radius;
public Enemy ClosestEnemy { get; private set; }
public override bool IsTriggered() {
ClosestEnemy = Util.GetClosestTo<Enemy>(transform, Radius);
ClosestEnemy = Util.GetClosestTo<Enemy>(transform, Radius, SearchLayerMask);
return ClosestEnemy != null;
}
}

View File

@ -5,6 +5,7 @@ using Saltosion.OneWeapon.Enemies;
namespace Saltosion.OneWeapon.AI.Triggers {
public class PlayerSighted : Trigger {
public LayerMask SearchLayerMask;
[Tooltip("How close the player needs to be for the AI to notice them.")]
public float Radius;
[Tooltip("How far the player needs to escape for the AI to \"forget\" them.")]
@ -17,7 +18,7 @@ namespace Saltosion.OneWeapon.AI.Triggers {
private float ForgetCountdownStartTime = 0.0f;
public override bool IsTriggered() {
PlayerController Sighted = Util.GetClosestTo<PlayerController>(transform, Player == null ? Radius : ForgetRadius, true);
PlayerController Sighted = Util.GetClosestTo<PlayerController>(transform, Player == null ? Radius : ForgetRadius, SearchLayerMask, true);
if (Sighted != null) {
CountdownStarted = false;
Player = Sighted;

View File

@ -2,6 +2,8 @@
namespace Saltosion.OneWeapon.Effects {
public class DebrisParticle : MonoBehaviour {
public LayerMask StickyLayers;
public SpriteRenderer Renderer;
public Vector2 LaunchForce = new Vector2();
@ -43,7 +45,7 @@ namespace Saltosion.OneWeapon.Effects {
Vector2 AppliedMovement = Velocity * Time.fixedDeltaTime;
RaycastHit2D Hit = Physics2D.Raycast(transform.position, AppliedMovement, AppliedMovement.magnitude, LayerMask.NameToLayer("Bloodphobic"));
RaycastHit2D Hit = Physics2D.Raycast(transform.position, AppliedMovement, AppliedMovement.magnitude, StickyLayers);
if (Hit.rigidbody != null && Hit.rigidbody.gameObject == Hit.collider.gameObject) {
bool IsStatic = Hit.rigidbody.bodyType == RigidbodyType2D.Static;
Velocity = Velocity.normalized * Mathf.Min(IsStatic ? 15.0f : 60.0f, Velocity.magnitude);

View File

@ -13,6 +13,7 @@ namespace Saltosion.OneWeapon.Effects {
private CameraFX CameraFX;
private PlayerFun PlayerFun;
private Transform ExplodableContainer;
private bool DestroyedAlready = false;
@ -28,6 +29,7 @@ namespace Saltosion.OneWeapon.Effects {
CameraFX = Camera.main.GetComponent<CameraFX>();
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
ExplodableContainer = GameObject.FindGameObjectWithTag("BodypartContainer").transform;
}
private void Update() {
@ -38,14 +40,10 @@ namespace Saltosion.OneWeapon.Effects {
}
public void Explode(bool destroyGameObject) {
if (destroyGameObject) {
// Destroying the object during explosion implies that it can explode only once,
// but Destroy() doesn't happen instantly, so here's a guard for that.
if (DestroyedAlready) {
if (destroyGameObject && DestroyedAlready) {
return;
} else {
DestroyedAlready = true;
}
}
int Count = (int)(BodypartMinCount + (BodypartMaxCount - BodypartMinCount) * Random.value);
@ -55,7 +53,7 @@ namespace Saltosion.OneWeapon.Effects {
float DirectionRadians = Random.value * Mathf.PI * 2.0f;
Vector2 Direction = new Vector2(Mathf.Cos(DirectionRadians), Mathf.Sin(DirectionRadians));
if (!Options.CensorGore || DebrisType != DebrisType.Blood) {
GameObject NewObj = Instantiate(Obj, transform.position, new Quaternion(), null);
GameObject NewObj = Instantiate(Obj, transform.position, new Quaternion(), ExplodableContainer);
Rigidbody2D Bodypart = NewObj.GetComponent<Rigidbody2D>();
if (Bodypart == null) {
continue;
@ -73,6 +71,7 @@ namespace Saltosion.OneWeapon.Effects {
if (destroyGameObject) {
Destroy(gameObject);
DestroyedAlready = true;
}
}
}

View File

@ -69,10 +69,16 @@ namespace Saltosion.OneWeapon.Player {
}
public void TakeDamage() {
if (GodMode) {
return;
}
AddFun(-5f);
}
public void TakeExplosionDamage() {
if (GodMode) {
return;
}
AddFun(-10f);
}

View File

@ -2,7 +2,7 @@ using UnityEngine;
namespace Saltosion.OneWeapon.Utils {
public class Util {
public static T GetClosestTo<T>(Transform Searcher, float radius, bool needsLineOfSight = false) where T : MonoBehaviour {
public static T GetClosestTo<T>(Transform Searcher, float radius, LayerMask layerMask, bool needsLineOfSight = false) where T : MonoBehaviour {
Collider2D[] NearbyColliders = Physics2D.OverlapCircleAll(Searcher.position, radius);
float LowestDistance = float.PositiveInfinity;
T FoundTarget = null;
@ -14,7 +14,7 @@ namespace Saltosion.OneWeapon.Utils {
Vector2 Delta = (Collider.transform.position - Searcher.position);
float Distance = Delta.magnitude;
T TargetComponent = Collider.GetComponent<T>();
RaycastHit2D[] Hits = Physics2D.RaycastAll(Searcher.position, Delta.normalized, Distance);
RaycastHit2D[] Hits = Physics2D.RaycastAll(Searcher.position, Delta.normalized, Distance, layerMask);
bool LineOfSightObstructed;
if (needsLineOfSight) {

View File

@ -81,8 +81,9 @@
fixed4 curr_light_col = tex2D(_LightTexture, location) * _LightIntensities[i];
curr_light_col = fixed4(curr_light_col.rgb * _LightColors[i].rgb * curr_light_col.a, 0);
total_light_col += curr_light_col;
total_light_col += pow(curr_light_col, 2);
}
total_light_col = sqrt(total_light_col);
fixed4 sprite_col = tex2D(_MainTex, input.uv);
sprite_col = sprite_col * input.color;

View File

@ -7,6 +7,7 @@ TagManager:
- Environment
- Enemy
- LightUpdater
- BodypartContainer
layers:
- Default
- TransparentFX