Added things
This commit is contained in:
47
Assets/Scripts/Character/CameraMouseScript.cs
Normal file
47
Assets/Scripts/Character/CameraMouseScript.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraMouseScript : MonoBehaviour
|
||||
{
|
||||
public float moveSpeed;
|
||||
public float shiftAdditionalSpeed;
|
||||
public float mouseSensitivity;
|
||||
public bool invertMouse;
|
||||
public bool autoLockCursor;
|
||||
|
||||
public Camera cam;
|
||||
|
||||
public GameObject character;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
cam = this.gameObject.GetComponent<Camera>();
|
||||
this.gameObject.name = "SpectatorCamera";
|
||||
Cursor.lockState = (autoLockCursor) ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if (character.transform.rotation.x < 15 && character.transform.rotation.x > -15)
|
||||
{
|
||||
float speed = (moveSpeed + (Input.GetAxis("Fire3") * shiftAdditionalSpeed));
|
||||
this.gameObject.transform.Translate(Vector3.forward * speed * Input.GetAxis("Vertical"));
|
||||
this.gameObject.transform.Translate(Vector3.right * speed * Input.GetAxis("Horizontal"));
|
||||
this.gameObject.transform.Translate(Vector3.up * speed *
|
||||
(Input.GetAxis("Jump") + (Input.GetAxis("Fire1") * -1)));
|
||||
this.gameObject.transform.Rotate(Input.GetAxis("Mouse Y") * mouseSensitivity * ((invertMouse) ? 1 : -1),
|
||||
Input.GetAxis("Mouse X") * mouseSensitivity * ((invertMouse) ? -1 : 1), 0);
|
||||
this.gameObject.transform.localEulerAngles = new Vector3(this.gameObject.transform.localEulerAngles.x,
|
||||
this.gameObject.transform.localEulerAngles.y, 0);
|
||||
|
||||
if (Cursor.lockState == CursorLockMode.None && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
else if (Cursor.lockState == CursorLockMode.Locked && Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Character/CameraMouseScript.cs.meta
generated
Normal file
11
Assets/Scripts/Character/CameraMouseScript.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e63e19e155f6b6348897150b67863072
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/Scripts/Character/HealthBarScript.cs
Normal file
27
Assets/Scripts/Character/HealthBarScript.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Animators.Leonid_Animator;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem.XR.Haptics;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
public class HealthBarScript : MonoBehaviour
|
||||
{
|
||||
public Image HealthBar;
|
||||
public float CurrentHealth;
|
||||
public float MaxHealth = 100f;
|
||||
public CharacterLocomotion Player;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//HealthBar = GetComponent<Image>();
|
||||
//Player = FindObjectOfType<CharacterLocomotion>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
CurrentHealth = Player.health;
|
||||
HealthBar.fillAmount = CurrentHealth / MaxHealth;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Character/HealthBarScript.cs.meta
generated
Normal file
11
Assets/Scripts/Character/HealthBarScript.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b91f3cc71f5c4a343b1ec3269f69a9d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/Weapons/AutoAim.cs
Normal file
29
Assets/Scripts/Weapons/AutoAim.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AutoAim : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public GameObject enemy;
|
||||
|
||||
public float lookSpeed = 200f;
|
||||
|
||||
public GameObject player;
|
||||
public Camera camera;
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 direction = enemy.transform.position - camera.transform.position;
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
||||
Quaternion lookAt = Quaternion.RotateTowards(camera.transform.rotation, targetRotation, Time.deltaTime * lookSpeed);
|
||||
camera.transform.rotation = lookAt;
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Weapons/AutoAim.cs.meta
generated
Normal file
11
Assets/Scripts/Weapons/AutoAim.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5f5f761e43327448b64038300d71e5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
67
Assets/Scripts/Weapons/Shooting.cs
Normal file
67
Assets/Scripts/Weapons/Shooting.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Shooting : MonoBehaviour
|
||||
{
|
||||
public float damage = 10f;
|
||||
public float range = 100f;
|
||||
|
||||
public GameObject raycast;
|
||||
|
||||
public GameObject FirePoint;
|
||||
public GameObject[] Prefabs;
|
||||
|
||||
private float hSliderValue = 0.1f;
|
||||
private float fireCountdown = 0f;
|
||||
|
||||
private int Prefab = 1;
|
||||
|
||||
private Ray RayMouse;
|
||||
private Vector3 direction;
|
||||
private Quaternion rotation;
|
||||
|
||||
public GameObject gun;
|
||||
void Update()
|
||||
{
|
||||
/*if (Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
Prefab = Random.Range(0, 1);
|
||||
Instantiate(Prefabs[Prefab], FirePoint.transform.position, FirePoint.transform.rotation);
|
||||
Shoot();
|
||||
}*/
|
||||
//if(Input.GetButtonDown("")
|
||||
if (Input.GetMouseButton(0) && fireCountdown <= 0f)
|
||||
{
|
||||
Instantiate(Prefabs[Prefab], FirePoint.transform.position, FirePoint.transform.rotation);
|
||||
fireCountdown = 0;
|
||||
fireCountdown += hSliderValue;
|
||||
Shoot();
|
||||
}
|
||||
fireCountdown -= Time.deltaTime;
|
||||
}
|
||||
|
||||
void Shoot()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(raycast.transform.position, raycast.transform.forward, out hit, range))
|
||||
{
|
||||
Debug.Log(hit.transform.name);
|
||||
|
||||
Target target = hit.transform.GetComponent<Target>();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
target.TakeDamage(damage);
|
||||
}
|
||||
RotateToGunDirection(gun, hit.point);
|
||||
}
|
||||
}
|
||||
|
||||
void RotateToGunDirection(GameObject obj, Vector3 destination)
|
||||
{
|
||||
direction = destination - obj.transform.position;
|
||||
rotation = Quaternion.LookRotation(direction);
|
||||
obj.transform.localRotation = Quaternion.Lerp(obj.transform.rotation, rotation, 1);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Weapons/Shooting.cs.meta
generated
Normal file
11
Assets/Scripts/Weapons/Shooting.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52f87dd051395614ebf0004d18d43bba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Scripts/Weapons/Target.cs
Normal file
24
Assets/Scripts/Weapons/Target.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Target : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public float health = 50f;
|
||||
|
||||
public void TakeDamage(float amount)
|
||||
{
|
||||
health -= amount;
|
||||
if (health <= 0f)
|
||||
{
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
void Die()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Weapons/Target.cs.meta
generated
Normal file
11
Assets/Scripts/Weapons/Target.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 954fb0076c55707429047d7d4a3e8ded
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user