mr lazer done

This commit is contained in:
Sveske Juice 2024-04-21 00:14:46 +02:00
parent b13cdcd02d
commit 1315f5c035
6 changed files with 1423 additions and 43 deletions

View File

@ -498,14 +498,14 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4485246138553412395}
serializedVersion: 2
m_LocalRotation: {x: -0.5, y: 0.5, z: 0.5, w: 0.5}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0.074043155, z: 0}
m_LocalScale: {x: 188.2847, y: 188.2847, z: 188.2847}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3536756844151575023}
m_Father: {fileID: 7233238969736204230}
m_LocalEulerAnglesHint: {x: -90, y: 90, z: 0}
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!33 &743831284301368974
MeshFilter:
m_ObjectHideFlags: 0
@ -1092,7 +1092,7 @@ MonoBehaviour:
visualRadius: 1
knob: {fileID: 5534604080396206135}
knobSensitiviy: 4
rotationMinMax: {x: -30, y: 30}
rotationMinMax: {x: 60, y: 120}
--- !u!1 &8464167623480225098
GameObject:
m_ObjectHideFlags: 0
@ -1187,17 +1187,17 @@ PrefabInstance:
- target: {fileID: 527409087646353271, guid: f54a14318952c90c5b47a300aedb0d15,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
value: 1.22
objectReference: {fileID: 0}
- target: {fileID: 527409087646353271, guid: f54a14318952c90c5b47a300aedb0d15,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: 0.517
objectReference: {fileID: 0}
- target: {fileID: 527409087646353271, guid: f54a14318952c90c5b47a300aedb0d15,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: -0.14
objectReference: {fileID: 0}
- target: {fileID: 527409087646353271, guid: f54a14318952c90c5b47a300aedb0d15,
type: 3}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4e5e3131ea2a78cfd93219be3806da6d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -477,41 +477,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2600338399449118553, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 2600338399449118553, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 2600338399449118553, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2600338399449118553, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2600338399449118553, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8606494081824023083, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: rotationMinMax.x
value: 60
objectReference: {fileID: 0}
- target: {fileID: 8606494081824023083, guid: 91554800af50ec827822f376e2fc5f64,
type: 3}
propertyPath: rotationMinMax.y
value: 120
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
@ -1329,7 +1294,7 @@ PrefabInstance:
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.13805284
value: -0.1380528
objectReference: {fileID: 0}
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
@ -1344,7 +1309,7 @@ PrefabInstance:
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.13815573
value: -0.13815574
objectReference: {fileID: 0}
- target: {fileID: 8882344377078016156, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
@ -1541,6 +1506,84 @@ Camera:
type: 3}
m_PrefabInstance: {fileID: 1732242001}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &2047642824
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalPosition.x
value: 2.33
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.08219504
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.07
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 269373318190900745, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 645933633211530419, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: m_Name
value: MrLazer
objectReference: {fileID: 0}
- target: {fileID: 7605001933718563855, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: startHealth
value: 1e+14
objectReference: {fileID: 0}
- target: {fileID: 7605001933718563855, guid: 4e5e3131ea2a78cfd93219be3806da6d,
type: 3}
propertyPath: OnHealthZero.m_PersistentCalls.m_Calls.Array.size
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4e5e3131ea2a78cfd93219be3806da6d, type: 3}
--- !u!1001 &667212637924654954
PrefabInstance:
m_ObjectHideFlags: 0
@ -1628,3 +1671,4 @@ SceneRoots:
- {fileID: 504816165}
- {fileID: 1395991987}
- {fileID: 658701657}
- {fileID: 2047642824}

View File

@ -0,0 +1,85 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BeamTower : AimTower
{
[SerializeField] private int maxBounces = 4;
[SerializeField, Range(0f, 50f)] private float damage = 5f;
[SerializeField] private LayerMask beamMask;
private const float k_maxBeamDist = 100f;
[SerializeField] private LineRenderer beam;
[SerializeField, Range(0.01f, 20f)] private float attackSecondsDelay = 1f;
protected override void Awake()
{
base.Awake();
horizontalArc.Value.AddListener(UpdateBeam);
verticalArc.Value.AddListener(UpdateBeam);
StartCoroutine(AttackLoop());
}
private IEnumerator AttackLoop()
{
do {
Vector3 origin = barrel.Tip.position;
Vector3 rayDir = barrel.transform.forward;
List<Vector3> hitPoints = new();
hitPoints.Add(origin);
for (int i = 0; i < maxBounces; i++)
{
Debug.DrawRay(origin, rayDir.normalized * k_maxBeamDist, Color.red, 5f);
RaycastHit hit;
if (!Physics.Raycast(origin, rayDir, out hit, k_maxBeamDist, beamMask))
break;
// Is damagable?
HealthComponent healthComp = hit.collider.gameObject.GetComponent<HealthComponent>();
if (healthComp != null)
{
Debug.Log($"hitting {healthComp.name} {i}");
healthComp.TakeDamage(damage);
break;
}
hitPoints.Add(hit.point);
rayDir = Vector3.Reflect(rayDir, hit.normal);
origin = hit.point;
}
beam.positionCount = hitPoints.Count;
beam.SetPositions(hitPoints.ToArray());
yield return new WaitForSeconds(attackSecondsDelay);
} while (true);
}
private void UpdateBeam(float unused) => UpdateBeam();
private void UpdateBeam()
{
Vector3 origin = barrel.Tip.position;
Vector3 rayDir = barrel.transform.forward;
List<Vector3> hitPoints = new();
hitPoints.Add(origin);
for (int i = 0; i < maxBounces; i++)
{
Debug.DrawRay(origin, rayDir.normalized * k_maxBeamDist, Color.red, 5f);
RaycastHit hit;
if (!Physics.Raycast(origin, rayDir, out hit, k_maxBeamDist, beamMask))
break;
hitPoints.Add(hit.point);
rayDir = Vector3.Reflect(rayDir, hit.normal);
origin = hit.point;
}
beam.positionCount = hitPoints.Count;
beam.SetPositions(hitPoints.ToArray());
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eee68a5f6c2f68de58dce57219fb9068
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: