Commit fa25ac13 authored by Adam Štěpánek's avatar Adam Štěpánek
Browse files

Add midair shot collisions

parent 5794a54d
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ GameObject:
  - component: {fileID: 9128151237816576343}
  - component: {fileID: 5600432880949330072}
  - component: {fileID: 2235509757678965776}
  - component: {fileID: 2668559280149355104}
  m_Layer: 0
  m_Name: Shot
  m_TagString: Untagged
@@ -74,8 +75,8 @@ SphereCollider:
  m_IsTrigger: 1
  m_Enabled: 1
  serializedVersion: 2
  m_Radius: 0.3
  m_Center: {x: 0, y: 0.2, z: 0}
  m_Radius: 0.2
  m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &2235509757678965776
MonoBehaviour:
  m_ObjectHideFlags: 0
@@ -94,6 +95,18 @@ MonoBehaviour:
    y: -25
    width: 50
    height: 50
--- !u!114 &2668559280149355104
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 5498966872552307195}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 2d2cf9e21a1bcf5408c6c35627b67bcb, type: 3}
  m_Name: 
  m_EditorClassIdentifier: 
--- !u!1001 &3334848915704436926
PrefabInstance:
  m_ObjectHideFlags: 0
@@ -109,7 +122,7 @@ PrefabInstance:
    - target: {fileID: -8679921383154817045, guid: 0e3b06c3389e57a478b0b8bdf3754de6,
        type: 3}
      propertyPath: m_LocalPosition.y
      value: 0
      value: -0.15
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: 0e3b06c3389e57a478b0b8bdf3754de6,
        type: 3}
+4 −4
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ MonoBehaviour:
  m_EditorClassIdentifier: 
  Player: {fileID: 396046095}
  GameOverOverlay: {fileID: 877347517}
  FadeInLength: 1
  FadeInLength: 2
--- !u!114 &345976538
MonoBehaviour:
  m_ObjectHideFlags: 0
@@ -266,8 +266,8 @@ MonoBehaviour:
  m_Script: {fileID: 11500000, guid: 99a58730276379740af6fd4fdf4c50ea, type: 3}
  m_Name: 
  m_EditorClassIdentifier: 
  DmgFromEnemy: 20
  DmgFromOther: 10
  DmgFromEnemy: 10
  DmgFromOther: 5
--- !u!54 &396046098
Rigidbody:
  m_ObjectHideFlags: 0
@@ -331,7 +331,7 @@ SphereCollider:
  m_IsTrigger: 1
  m_Enabled: 1
  serializedVersion: 2
  m_Radius: 2
  m_Radius: 1
  m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &620763333
GameObject:
+3 −7
Original line number Diff line number Diff line
@@ -26,14 +26,10 @@ public class EnemyCollision : MonoBehaviour
        {
            enemy.Health -= DmgFromPlayer;
        }
        else
        else if (enemy is object)
        {
            if (enemy is object)
            {
                // Ehm. Prevents race conditions. Ehm.
            // Ehm. Race condition averted. Ehm.
            enemy.Health -= DmgFromOther;
        }
            Destroy(other.gameObject);
        }
    }
}
+3 −9
Original line number Diff line number Diff line
@@ -17,14 +17,8 @@ public class PlayerCollision : MonoBehaviour
    public void OnTriggerEnter(Collider other)
{
        var enemy = other.GetComponent<IEnemy>();
        if (enemy is object)
        {
            player.Health -= DmgFromEnemy;
        }
        else
        {
            player.Health -= DmgFromOther;
            Destroy(other.gameObject);
        }
        player.Health -= enemy is object
            ? DmgFromEnemy
            : DmgFromOther;
    }
}
+11 −0
Original line number Diff line number Diff line
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShotCollision : MonoBehaviour
{
    public void OnTriggerEnter(Collider other)
    {
        Destroy(gameObject);
    }
}
Loading