Recover Mine Launcher as daemon deployable
This commit is contained in:
parent
602766ee78
commit
8c71a6379d
26 changed files with 431 additions and 492 deletions
|
|
@ -1,8 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class InstantWeaponEffectManager : MonoBehaviour
|
||||
{
|
||||
public abstract void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 947a7d0e9469d724daed03d35a0c1f4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class Mine : MonoBehaviour
|
||||
{
|
||||
public GridObject GridObject;
|
||||
public MeshRenderer MeshRenderer;
|
||||
public int EmissionSubmesh;
|
||||
public AnimationCurve EmissionCurve;
|
||||
public float ActiveCycleDuration;
|
||||
public float ArmedCycleDuration;
|
||||
public float ActiveEmission;
|
||||
public float ArmedEmission;
|
||||
public Prototype HitEffect;
|
||||
public float Lifetime;
|
||||
|
||||
public float ActivationDelay;
|
||||
public float BlastRange;
|
||||
public float BlastDelay;
|
||||
|
||||
private float _startTime;
|
||||
private float _blastTime;
|
||||
private bool _blastCountdown;
|
||||
private bool _active;
|
||||
private Material _material;
|
||||
private float _pulseLerp;
|
||||
private float _emission;
|
||||
public float ImpactIntensity { get; set; } = 1;
|
||||
public EntityInstance Source { get; set; }
|
||||
public float Range { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_material = MeshRenderer.materials[EmissionSubmesh];
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_startTime = Time.time;
|
||||
_blastCountdown = false;
|
||||
_active = false;
|
||||
_emission = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Time.time - _startTime > ActivationDelay && !_active)
|
||||
{
|
||||
_active = true;
|
||||
}
|
||||
|
||||
if(_active)
|
||||
{
|
||||
_emission = Mathf.Lerp(_emission, _blastCountdown ? ArmedEmission : ActiveEmission, Time.deltaTime * 10);
|
||||
_pulseLerp += Time.deltaTime / (_blastCountdown ? ArmedCycleDuration : ActiveCycleDuration);
|
||||
_pulseLerp %= 1;
|
||||
|
||||
if (Time.time - _startTime > Lifetime)
|
||||
{
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
_material.SetFloat("_Emission", _emission * EmissionCurve.Evaluate(_pulseLerp));
|
||||
}
|
||||
|
||||
public void Explode()
|
||||
{
|
||||
var position = transform.position;
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.position = position;
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f190191fe8c8419f85767868c50cde5f
|
||||
timeCreated: 1612545564
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MineManager : InstantWeaponEffectManager
|
||||
{
|
||||
public Prototype ProjectilePrototype;
|
||||
|
||||
public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = ProjectilePrototype.Instantiate<Mine>();
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
var angle = weapon.Spread / 2;
|
||||
p.Source = source;
|
||||
p.transform.position = barrel.position;
|
||||
p.GridObject.Velocity = Quaternion.Euler(
|
||||
Random.Range(-angle, angle),
|
||||
Random.Range(-angle, angle),
|
||||
Random.Range(-angle, angle)) *
|
||||
barrel.forward *
|
||||
weapon.Velocity;
|
||||
p.Range = weapon.Range;
|
||||
p.ImpactIntensity = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e048d9c74a84343befd496907ee2126
|
||||
timeCreated: 1612545538
|
||||
Loading…
Reference in a new issue