updated start menu, added beacon
This commit is contained in:
43
Assets/Scripts/Item/FlareBeacon.cs
Normal file
43
Assets/Scripts/Item/FlareBeacon.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FlareBeacon : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float range = 1;
|
||||
[SerializeField]
|
||||
private float duration = 5f;
|
||||
|
||||
private List<GameObject> inRange= new List<GameObject>();
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
// Draw a yellow sphere at the transform's position
|
||||
Gizmos.color = Color.yellow;
|
||||
|
||||
Gizmos.DrawWireSphere(transform.position, range);
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
inRange.Add(other.gameObject);
|
||||
}
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
inRange.Remove(other.gameObject);
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/Item/FlareBeacon.cs.meta
Normal file
11
Assets/Scripts/Item/FlareBeacon.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 210701b0acc3ff542b0d114370d98777
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Item/Pistol.meta
Normal file
8
Assets/Scripts/Item/Pistol.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cd9f53a6ff4b6443b3d5b95e50767e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
Assets/Scripts/Item/Pistol/BulletComponent.cs
Normal file
30
Assets/Scripts/Item/Pistol/BulletComponent.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BulletComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float duration = 5f;
|
||||
private float existed = 0f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if(existed >= duration)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
existed += Time.fixedDeltaTime;
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Item/Pistol/BulletComponent.cs.meta
Normal file
11
Assets/Scripts/Item/Pistol/BulletComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ea1ee4df8019a143b013f8837aa48d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/Item/Pistol/PistolAnimationAimAssist.cs
Normal file
44
Assets/Scripts/Item/Pistol/PistolAnimationAimAssist.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PistolAnimationAimAssist : MonoBehaviour
|
||||
{
|
||||
public Transform leftShoulder;
|
||||
public Transform rightShoulder;
|
||||
[SerializeField]
|
||||
private bool isEnabled = false;
|
||||
|
||||
Vector3 lTarget;
|
||||
Vector3 rTarget;
|
||||
private Animator anim;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
lTarget = new Vector3(72.9f, 122.2f, -129.9f);
|
||||
rTarget = new Vector3(82f, 11f, -88f);
|
||||
anim =GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (isEnabled)
|
||||
{
|
||||
anim.StopPlayback();
|
||||
leftShoulder.transform.eulerAngles = lTarget;
|
||||
rightShoulder.transform.eulerAngles = rTarget;
|
||||
print("Applying!");
|
||||
anim.StartPlayback();
|
||||
}
|
||||
}
|
||||
public void Enable()
|
||||
{
|
||||
isEnabled = true;
|
||||
}
|
||||
public void Disable()
|
||||
{
|
||||
isEnabled = false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Item/Pistol/PistolAnimationAimAssist.cs.meta
Normal file
11
Assets/Scripts/Item/Pistol/PistolAnimationAimAssist.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4463cddde602cde4b8fab345649839c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
110
Assets/Scripts/Item/Pistol/PistolComponent.cs
Normal file
110
Assets/Scripts/Item/Pistol/PistolComponent.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.UI.Image;
|
||||
|
||||
public class PistolComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Light targetingLight;
|
||||
|
||||
private bool IsEnabled = false;
|
||||
|
||||
GameObject targetObject;
|
||||
|
||||
[SerializeField]
|
||||
GameObject targetObjectPrefab;
|
||||
[SerializeField]
|
||||
private GameObject projectilePrefab;
|
||||
[SerializeField]
|
||||
private Transform bulletSpawnPoint;
|
||||
[SerializeField]
|
||||
private float firePower = 20f;
|
||||
[SerializeField]
|
||||
private float maxProjectileDuration = 5f;
|
||||
|
||||
|
||||
|
||||
//private Dictionary<int,float> projectiles = new Dictionary<int, float>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
private float CalculateDrop(Vector3 origin,Vector3 destination,Vector3 force)
|
||||
{
|
||||
// Calculate the initial velocity required to reach the destination.
|
||||
Vector3 displacement = destination - origin;
|
||||
float time = Mathf.Sqrt(2f * displacement.magnitude / Physics.gravity.magnitude);
|
||||
Vector3 velocity = (displacement - 0.5f * Physics.gravity * time * time) / time + force;
|
||||
|
||||
// Calculate the height the object will reach during its flight.
|
||||
float maxHeight = origin.y + velocity.y * time - 0.5f * Physics.gravity.y * time * time;
|
||||
|
||||
// Calculate the distance the object will drop during its flight.
|
||||
float dropDistance = maxHeight - destination.y;
|
||||
|
||||
return dropDistance;
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (this.IsEnabled)
|
||||
{
|
||||
Ray ray = new Ray(transform.position, transform.up);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 50))
|
||||
{
|
||||
targetObject.gameObject.transform.position = hit.point;
|
||||
float drop = CalculateDrop(this.bulletSpawnPoint.position, hit.point, this.transform.up * this.firePower);
|
||||
print(drop);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void Fire()
|
||||
{
|
||||
GameObject projectile = Instantiate(projectilePrefab, this.bulletSpawnPoint);
|
||||
projectile.transform.localPosition = Vector3.zero;
|
||||
projectile.transform.localEulerAngles = Vector3.zero;
|
||||
projectile.transform.localScale = Vector3.one;
|
||||
Rigidbody pRigid = projectile.GetComponent<Rigidbody>();
|
||||
pRigid.AddForce(pRigid.transform.up*this.firePower, ForceMode.Impulse);
|
||||
projectile.transform.parent = null;
|
||||
|
||||
}
|
||||
public void Enable()
|
||||
{
|
||||
IsEnabled = true;
|
||||
if (targetObject == null)
|
||||
{
|
||||
targetObject = Instantiate(targetObjectPrefab);
|
||||
|
||||
}
|
||||
}
|
||||
public void Disable()
|
||||
{
|
||||
IsEnabled = false;
|
||||
if (targetObject != null)
|
||||
{
|
||||
Destroy(targetObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void LightToggle() {
|
||||
this.targetingLight.gameObject.SetActive(!this.targetingLight.gameObject.activeSelf);
|
||||
}
|
||||
public bool IsLightOn { get { return this.targetingLight.gameObject.activeSelf; } }
|
||||
|
||||
}
|
11
Assets/Scripts/Item/Pistol/PistolComponent.cs.meta
Normal file
11
Assets/Scripts/Item/Pistol/PistolComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0bc8aa373bfbe44e91f0625324088be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user