This commit is contained in:
Kotrba Filip
2020-01-31 22:32:05 +01:00
parent 55c87eaf4c
commit ecb85cc68f
14 changed files with 1295 additions and 329 deletions

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BarricadeManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@@ -6,7 +6,7 @@ public class BlockManager : MonoBehaviour
{
public enum BlockType {None, Barricade};
public BlockType blockType = BlockType.None;
public GameObject block;
public float health = 100;
// Start is called before the first frame update
void Start()

View File

@@ -9,17 +9,23 @@ public class PlayerManager : MonoBehaviour
public float runSpeed = 25;
public float rotateSpeed = 5;
public float mouseSensitive = 200;
public float fireRate = 2;
private float fireTime;
public float buildRate = 0.5f;
private float buildTime;
private bool run = false;
private Camera playerCamera;
private Rigidbody rigidBody;
public int baricadeMaterials = 10;
public List<GameObject> weaponList = new List<GameObject>();
[HideInInspector]public int selectedWeapon = 0;
public List<GameObject> weaponHandList = new List<GameObject>();
// Start is called before the first frame update
void Start()
{
fireTime = fireRate;
buildTime = buildRate;
playerCamera = GetComponentInChildren<Camera>();
rigidBody = GetComponent<Rigidbody>();
Cursor.lockState = CursorLockMode.Locked;
@@ -31,7 +37,8 @@ public class PlayerManager : MonoBehaviour
{
Move();
RunSwitch();
selectWeapon();
SelectWeapon();
BuildBlock();
}
void FixedUpdate()
@@ -87,11 +94,10 @@ public class PlayerManager : MonoBehaviour
}
}
void selectWeapon()
void SelectWeapon()
{
if (weaponList.Count > 0 && weaponHandList.Count == weaponList.Count)
if (weaponList.Count > 0)
{
weaponHandList[selectedWeapon].SetActive(false);
if (Input.mouseScrollDelta.y > 0)
{
if (weaponList.Count > selectedWeapon + 1) {
@@ -113,7 +119,31 @@ public class PlayerManager : MonoBehaviour
selectedWeapon = weaponList.Count - 1;
}
}
weaponHandList[selectedWeapon].SetActive(true);
}
}
void BuildBlock ()
{
if (Input.GetAxisRaw("Fire1") > 0 && buildTime < Time.time && weaponList.Count > 0)
{
Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("BuildPlace")))
{
BlockManager blockManager = weaponList[selectedWeapon].GetComponent<BlockManager>();
if (blockManager != null) {
Instantiate(weaponList[selectedWeapon], hit.point, transform.rotation);
buildTime = buildRate + Time.time;
}
}
}
}
void BuildBarricade()
{
if ()
{
}
}
}