Shoot is function

This commit is contained in:
Kotrba Filip 2020-02-01 06:04:53 +01:00
parent df79f22a91
commit 53c4133a30
11 changed files with 4799 additions and 4777 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -50,7 +50,7 @@ MonoBehaviour:
runSpeed: 25 runSpeed: 25
rotateSpeed: 5 rotateSpeed: 5
mouseSensitive: 200 mouseSensitive: 200
fireRate: 2 fireRate: 1
buildRate: 0.5 buildRate: 0.5
barricadeMaterials: 10 barricadeMaterials: 10
weaponList: weaponList:

File diff suppressed because it is too large Load Diff

View File

@ -199,7 +199,7 @@ GameObject:
- component: {fileID: 3939897681357570884} - component: {fileID: 3939897681357570884}
- component: {fileID: 6211150992098513906} - component: {fileID: 6211150992098513906}
- component: {fileID: 1011348888752456914} - component: {fileID: 1011348888752456914}
m_Layer: 0 m_Layer: 9
m_Name: BarricadeField (2) m_Name: BarricadeField (2)
m_TagString: BarricadeField m_TagString: BarricadeField
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -362,7 +362,7 @@ GameObject:
- component: {fileID: 2481870090228344317} - component: {fileID: 2481870090228344317}
- component: {fileID: 2481870090228344318} - component: {fileID: 2481870090228344318}
- component: {fileID: 7756661855765130475} - component: {fileID: 7756661855765130475}
m_Layer: 0 m_Layer: 9
m_Name: BarricadeField m_Name: BarricadeField
m_TagString: BarricadeField m_TagString: BarricadeField
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -433,7 +433,7 @@ GameObject:
- component: {fileID: 1424603519372912802} - component: {fileID: 1424603519372912802}
- component: {fileID: 8647892185685718213} - component: {fileID: 8647892185685718213}
- component: {fileID: 7924616323306109674} - component: {fileID: 7924616323306109674}
m_Layer: 0 m_Layer: 9
m_Name: BarricadeField (1) m_Name: BarricadeField (1)
m_TagString: BarricadeField m_TagString: BarricadeField
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -1032,7 +1032,7 @@ GameObject:
- component: {fileID: 3295643941037104837} - component: {fileID: 3295643941037104837}
- component: {fileID: 7843397485630208149} - component: {fileID: 7843397485630208149}
- component: {fileID: 5587150326615621020} - component: {fileID: 5587150326615621020}
m_Layer: 0 m_Layer: 9
m_Name: BarricadeField (3) m_Name: BarricadeField (3)
m_TagString: BarricadeField m_TagString: BarricadeField
m_Icon: {fileID: 0} m_Icon: {fileID: 0}

View File

@ -387,11 +387,6 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: Player value: Player
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c,
type: 3}
propertyPath: fireRate
value: 1
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

@ -9,8 +9,6 @@ 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 = 1;
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;
@ -25,7 +23,6 @@ public class PlayerManager : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
fireTime = fireRate;
buildTime = buildRate; buildTime = buildRate;
playerCamera = GetComponentInChildren<Camera>(); playerCamera = GetComponentInChildren<Camera>();
rigidBody = GetComponent<Rigidbody>(); rigidBody = GetComponent<Rigidbody>();
@ -41,7 +38,6 @@ public class PlayerManager : MonoBehaviour
SelectWeapon(); SelectWeapon();
BuildBlock(); BuildBlock();
BuildBarricade(); BuildBarricade();
Attack();
} }
void FixedUpdate() void FixedUpdate()
@ -60,7 +56,6 @@ 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) &&
@ -165,16 +160,6 @@ 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()
{ {
Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition); Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);

View File

@ -7,41 +7,41 @@ public class WeaponManager : MonoBehaviour
public enum WeaponType { None, Shoot, Meele }; public enum WeaponType { None, Shoot, Meele };
public WeaponType weaponType = WeaponType.None; public WeaponType weaponType = WeaponType.None;
public float weaponRange = 1; public float weaponRange = 1;
public ParticleSystem particleShoot; public GameObject spawnShoot;
public GameObject particleShoot;
public float damage = 0; public float damage = 0;
public float fireRate = 0.5f;
private float fireTime;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
fireTime = fireRate;
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
WeaponAttack();
} }
public void Attack() public void WeaponAttack()
{ {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButtonDown(0) && fireTime <= Time.time) {
RaycastHit hit;
if (Physics.Raycast(ray, out hit, weaponRange))
{
}
if (weaponType == WeaponType.Shoot) if (weaponType == WeaponType.Shoot)
{ {
if (particleShoot != null && !particleShoot.isPlaying) if (particleShoot != null)
{ {
particleShoot.Stop(); Debug.Log(transform.position);
particleShoot.Play(); GameObject shoot = Instantiate(particleShoot, spawnShoot.transform.position, spawnShoot.transform.rotation);
Destroy(shoot, 0.3f);
} }
} }
else if (weaponType == WeaponType.Meele) else if (weaponType == WeaponType.Meele)
{ {
} }
fireTime = fireRate + Time.time;
}
} }
} }

View File

@ -15,7 +15,7 @@ TagManager:
- -
- -
- BuildPlace - BuildPlace
- - BarricadeField
- -
- -
- -