next commit 5

This commit is contained in:
Kotrba Filip 2020-02-01 00:53:03 +01:00
parent 727fab43b2
commit e03eafaf7b
12 changed files with 7663 additions and 93 deletions

View File

@ -47,9 +47,16 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
speed: 10 speed: 10
runSpeed: 15 runSpeed: 25
rotateSpeed: 5 rotateSpeed: 5
mouseSensitive: 200 mouseSensitive: 200
fireRate: 2
buildRate: 0.5
barricadeMaterials: 10
weaponList:
- {fileID: 2179056336067526865, guid: 666835f3de085f9409e62598a45208bf, type: 3}
- {fileID: 1999182813209888360, guid: 7933df0606f61e94e9008c58a313b22c, type: 3}
selectedWeapon: 0
--- !u!136 &7985979212931499551 --- !u!136 &7985979212931499551
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 666835f3de085f9409e62598a45208bf
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -389,25 +389,9 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c, - target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c,
type: 3} type: 3}
propertyPath: weaponList.Array.size propertyPath: fireRate
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c,
type: 3}
propertyPath: runSpeed
value: 25
objectReference: {fileID: 0}
- target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c,
type: 3}
propertyPath: weaponList.Array.data[0]
value:
objectReference: {fileID: 1999182813209888360, guid: 7933df0606f61e94e9008c58a313b22c,
type: 3}
- target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c,
type: 3}
propertyPath: buildRate
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 7985979212931499549, guid: 204c7411afdd01a478b1a1e25607d50c, - target: {fileID: 7985979212931499549, guid: 204c7411afdd01a478b1a1e25607d50c,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x

View File

@ -4,6 +4,9 @@ using UnityEngine;
public class BarricadeManager : MonoBehaviour public class BarricadeManager : MonoBehaviour
{ {
public int health = 0;
public List<GameObject> barricadePlanks = new List<GameObject>();
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
@ -13,6 +16,30 @@ public class BarricadeManager : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
viewHealthAsPlanks();
}
public void addPlank()
{
if (health < (barricadePlanks.Count * 10)) {
health += 10;
}
}
void viewHealthAsPlanks()
{
if (barricadePlanks.Count > 0)
{
for (int i = 0; i < barricadePlanks.Count; i++)
{
if (i < (health / 10)) {
barricadePlanks[i].SetActive(true);
}
else
{
barricadePlanks[i].SetActive(false);
}
}
}
} }
} }

View File

@ -9,15 +9,16 @@ public class PlayerManager : MonoBehaviour
public float runSpeed = 25; public float runSpeed = 25;
public float rotateSpeed = 5; public float rotateSpeed = 5;
public float mouseSensitive = 200; public float mouseSensitive = 200;
public float fireRate = 2; public float fireRate = 1;
private float fireTime; private float fireTime;
public float buildRate = 0.5f; public float buildRate = 0.5f;
private float buildTime; private float buildTime;
private bool run = false; private bool run = false;
private Camera playerCamera; private Camera playerCamera;
private Rigidbody rigidBody; private Rigidbody rigidBody;
public int baricadeMaterials = 10; public int barricadeMaterials = 10;
public List<GameObject> weaponList = new List<GameObject>(); public List<GameObject> weaponList = new List<GameObject>();
private GameObject createWeapon;
[HideInInspector]public int selectedWeapon = 0; [HideInInspector]public int selectedWeapon = 0;
@ -39,6 +40,8 @@ public class PlayerManager : MonoBehaviour
RunSwitch(); RunSwitch();
SelectWeapon(); SelectWeapon();
BuildBlock(); BuildBlock();
BuildBarricade();
Attack();
} }
void FixedUpdate() void FixedUpdate()
@ -57,6 +60,7 @@ public class PlayerManager : MonoBehaviour
void Rotate() void Rotate()
{ {
Debug.Log(playerCamera.transform.localEulerAngles);
transform.Rotate(new Vector3(0, rotateSpeed * Input.GetAxis("Mouse X") * mouseSensitive * Time.deltaTime, 0)); transform.Rotate(new Vector3(0, rotateSpeed * Input.GetAxis("Mouse X") * mouseSensitive * Time.deltaTime, 0));
if ( if (
((playerCamera.transform.localEulerAngles.x >= 270 && playerCamera.transform.localEulerAngles.x <= 360) && ((playerCamera.transform.localEulerAngles.x >= 270 && playerCamera.transform.localEulerAngles.x <= 360) &&
@ -80,6 +84,10 @@ public class PlayerManager : MonoBehaviour
) { ) {
playerCamera.transform.Rotate(new Vector3(rotateSpeed * (-Input.GetAxis("Mouse Y") < 0 ? -Input.GetAxis("Mouse Y") : 0) * mouseSensitive * Time.deltaTime, 0, 0)); playerCamera.transform.Rotate(new Vector3(rotateSpeed * (-Input.GetAxis("Mouse Y") < 0 ? -Input.GetAxis("Mouse Y") : 0) * mouseSensitive * Time.deltaTime, 0, 0));
} }
else
{
playerCamera.transform.Rotate(new Vector3(rotateSpeed * -Input.GetAxis("Mouse Y") * mouseSensitive * Time.deltaTime, 0, 0));
}
} }
void RunSwitch() void RunSwitch()
@ -100,6 +108,11 @@ public class PlayerManager : MonoBehaviour
{ {
if (Input.mouseScrollDelta.y > 0) if (Input.mouseScrollDelta.y > 0)
{ {
WeaponManager weaponManager = weaponList[selectedWeapon].GetComponent<WeaponManager>();
if (weaponManager != null && createWeapon != null)
{
Destroy(createWeapon);
}
if (weaponList.Count > selectedWeapon + 1) { if (weaponList.Count > selectedWeapon + 1) {
selectedWeapon++; selectedWeapon++;
} }
@ -110,6 +123,11 @@ public class PlayerManager : MonoBehaviour
} }
else if (Input.mouseScrollDelta.y < 0) else if (Input.mouseScrollDelta.y < 0)
{ {
WeaponManager weaponManager = weaponList[selectedWeapon].GetComponent<WeaponManager>();
if (weaponManager != null && createWeapon != null)
{
Destroy(createWeapon);
}
if (selectedWeapon > 0) if (selectedWeapon > 0)
{ {
selectedWeapon--; selectedWeapon--;
@ -119,6 +137,14 @@ public class PlayerManager : MonoBehaviour
selectedWeapon = weaponList.Count - 1; selectedWeapon = weaponList.Count - 1;
} }
} }
WeaponManager weaponManager2 = weaponList[selectedWeapon].GetComponent<WeaponManager>();
if (weaponManager2 != null && createWeapon == null)
{
createWeapon = Instantiate(weaponList[selectedWeapon]) as GameObject;
createWeapon.transform.parent = playerCamera.transform;
createWeapon.transform.localPosition = Vector3.zero;
createWeapon.transform.localEulerAngles = Vector3.zero;
}
} }
} }
@ -139,11 +165,29 @@ public class PlayerManager : MonoBehaviour
} }
} }
void Attack()
{
WeaponManager weaponManager = weaponList[selectedWeapon].GetComponent<WeaponManager>();
if (weaponManager != null && Input.GetMouseButtonDown(0) && fireTime < Time.time)
{
weaponManager.Attack();
fireTime = fireRate * Time.time;
}
}
void BuildBarricade() void BuildBarricade()
{ {
if () Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1))
{ {
if (Input.GetAxisRaw("Build") > 0 && buildTime < Time.time && barricadeMaterials > 0 && hit.transform.tag == "BarricadeField")
{
BarricadeManager barricadeManager = hit.transform.GetComponent<BarricadeManager>();
barricadeManager.addPlank();
barricadeMaterials--;
buildTime = buildRate + Time.time;
}
} }
} }
} }

View File

@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeaponManager : MonoBehaviour
{
public enum WeaponType { None, Shoot, Meele };
public WeaponType weaponType = WeaponType.None;
public float weaponRange = 1;
public ParticleSystem particleShoot;
public float damage = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Attack()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, weaponRange))
{
}
if (weaponType == WeaponType.Shoot)
{
if (particleShoot != null && !particleShoot.isPlaying)
{
particleShoot.Stop();
particleShoot.Play();
}
}
else if (weaponType == WeaponType.Meele)
{
}
}
}

View File

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

View File

@ -53,6 +53,22 @@ InputManager:
type: 0 type: 0
axis: 0 axis: 0
joyNum: 0 joyNum: 0
- serializedVersion: 3
m_Name: Build
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: e
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3 - serializedVersion: 3
m_Name: Fire2 m_Name: Fire2
descriptiveName: descriptiveName: