Initial commit
This commit is contained in:
50
Assets/Scripts/Chytac.cs
Normal file
50
Assets/Scripts/Chytac.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Chytac : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public Rigidbody hrac;
|
||||
|
||||
public Vector3 rozdiel;
|
||||
|
||||
public Pohybovac mover;
|
||||
|
||||
public GameObject chytene;
|
||||
|
||||
bool caught = false;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(Input.GetButtonDown("Fire1")){
|
||||
//rozdiel = hrac.position -
|
||||
RaycastHit[] hits = Physics.RaycastAll(transform.position, new Vector3(mover.xrot, 0f, mover.zrot));
|
||||
float mindist = 15f;
|
||||
|
||||
foreach (RaycastHit hit in hits){
|
||||
if (hit.collider.gameObject.name != "Bean"){
|
||||
Debug.Log(hit.distance);
|
||||
if (hit.distance < mindist){
|
||||
mindist = hit.distance;
|
||||
if(hit.collider.gameObject.tag == "NotToRoot"){
|
||||
chytene = hit.collider.gameObject;
|
||||
}
|
||||
else{
|
||||
chytene = hit.collider.gameObject.transform.root.gameObject;
|
||||
}
|
||||
rozdiel = hrac.position - chytene.GetComponent<Rigidbody>().position;
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Input.GetButton("Fire1")){
|
||||
if(caught){
|
||||
chytene.GetComponent<Rigidbody>().position = new Vector3(hrac.position.x + rozdiel.x, hrac.position.y + 4, hrac.position.z + rozdiel.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Chytac.cs.meta
Normal file
11
Assets/Scripts/Chytac.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 443718008e90fbe4bae24d20d6ece588
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Assets/Scripts/Pohybovac.cs
Normal file
37
Assets/Scripts/Pohybovac.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Pohybovac : MonoBehaviour
|
||||
{
|
||||
public Rigidbody rb;
|
||||
public Transform kamera;
|
||||
|
||||
public float look_speed = 50f;
|
||||
|
||||
public float walk_speed = 100f;
|
||||
public float xrot = 0f;
|
||||
public float zrot = 0f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
xrot += Input.GetAxisRaw("Mouse Y") * Time.deltaTime * look_speed;
|
||||
xrot = Mathf.Clamp(xrot, -10f, 10f);
|
||||
kamera.localRotation = Quaternion.AngleAxis(xrot, new Vector3(-1f, 0f, 0f));
|
||||
zrot += Input.GetAxisRaw("Mouse X") * Time.deltaTime * look_speed;
|
||||
if (zrot >= 180 || zrot <= -180){
|
||||
zrot = 0;
|
||||
}
|
||||
rb.rotation = Quaternion.AngleAxis(zrot, new Vector3(0f, 1f, 0f));
|
||||
|
||||
float xmove = Input.GetAxisRaw("Horizontal") * Time.deltaTime * walk_speed * 5000f;
|
||||
float zmove = Input.GetAxisRaw("Vertical") * Time.deltaTime * walk_speed * 10000f;
|
||||
rb.AddRelativeForce(new Vector3(xmove, 0f, zmove));
|
||||
}
|
||||
}
|
11
Assets/Scripts/Pohybovac.cs.meta
Normal file
11
Assets/Scripts/Pohybovac.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b101ca4faa564941a1db2e8af8c1ded
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Assets/Scripts/Rozbitie.cs
Normal file
23
Assets/Scripts/Rozbitie.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Rozbitie : MonoBehaviour
|
||||
|
||||
{
|
||||
public bool broken = false;
|
||||
public GameObject rozbite;
|
||||
// Start is called before the first frame update
|
||||
|
||||
void OnCollisionEnter(Collision coll) {
|
||||
Debug.Log(coll.relativeVelocity.magnitude);
|
||||
if(!broken && coll.gameObject.name != "Bean"){
|
||||
if(coll.relativeVelocity.magnitude > 3f || coll.relativeVelocity.magnitude < -3f){
|
||||
Instantiate(rozbite, transform.position, transform.rotation);
|
||||
Destroy(transform.gameObject);
|
||||
broken = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/Rozbitie.cs.meta
Normal file
11
Assets/Scripts/Rozbitie.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 044d8a7a211314d4c941d52e992ae38b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
47
Assets/Scripts/Strielac.cs
Normal file
47
Assets/Scripts/Strielac.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Strielac : MonoBehaviour
|
||||
{
|
||||
public Rigidbody rb;
|
||||
public float force = 0;
|
||||
public int run = 0;
|
||||
public int length = 10;
|
||||
public int cnt = 0;
|
||||
public Transform spawner;
|
||||
public GameObject naboj;
|
||||
|
||||
public AudioSource vystrel;
|
||||
|
||||
public AudioSource doraz;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (run == 1 && cnt == 0){
|
||||
vystrel.Play();
|
||||
}
|
||||
if(run == 1 && length > cnt){
|
||||
rb.AddTorque(new Vector3(force, 0, 0));
|
||||
cnt++;
|
||||
}
|
||||
if(length <= cnt){
|
||||
run = -1;
|
||||
doraz.Play();
|
||||
}
|
||||
if(run == -1 && 0 < cnt){
|
||||
rb.AddTorque(new Vector3(-force, 0, 0));
|
||||
cnt--;
|
||||
}
|
||||
if(0 == cnt){
|
||||
run = 1;
|
||||
Instantiate(naboj, spawner.position, spawner.rotation);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Strielac.cs.meta
Normal file
11
Assets/Scripts/Strielac.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77fe5ee3f92d53444a4ecee0736ebf68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user