Baricade edit

This commit is contained in:
Kotrba Filip
2020-02-01 20:53:49 +01:00
parent 41a534cd5f
commit edaec6c91f
10 changed files with 311 additions and 88 deletions

View File

@@ -22,17 +22,13 @@ public class DayManager : MonoBehaviour
{
float sunRotationX = transform.localEulerAngles.x;
sunRotationX = (sunRotationX > 180) ? sunRotationX - 360 : sunRotationX;
Debug.Log(sunRotationX.ToString());
if (sunRotationX < 0 && !night)
{
Debug.Log("It is a Night");
mainSource.PlayOneShot(nigtClip);
night = true;
}
else if (sunRotationX > 0 && night)
{
Debug.Log("It is a Day");
mainSource.PlayOneShot(dayClip);
night = false;
}

View File

@@ -22,12 +22,15 @@ public class PlayerManager : MonoBehaviour
public List<GameObject> weaponList = new List<GameObject>();
private GameObject createWeapon;
public GuiManager guiManager;
[HideInInspector]public int selectedWeapon = 0;
public int selectedWeapon = 0;
private float selectRate = 1;
private float selectTime = 1;
// Start is called before the first frame update
void Start()
{
selectTime = selectRate;
actualHealth = health;
buildTime = buildRate;
playerCamera = GetComponentInChildren<Camera>();
@@ -121,47 +124,56 @@ public class PlayerManager : MonoBehaviour
{
if (weaponList.Count > 0)
{
if (Input.mouseScrollDelta.y > 0)
{
WeaponManager weaponManager = weaponList[selectedWeapon].GetComponent<WeaponManager>();
WeaponManager weaponManager = weaponList[selectedWeapon].GetComponent<WeaponManager>();
if (weaponManager != null) {
weaponManager.player = this;
if (weaponManager != null && createWeapon != null)
Debug.Log(weaponList.Count);
if (Input.GetAxis("Mouse ScrollWheel") > 0 && selectTime < Time.time)
{
Destroy(createWeapon);
if (weaponManager != null && createWeapon != null)
{
Destroy(createWeapon);
}
}
if (weaponList.Count > selectedWeapon + 1) {
selectedWeapon++;
else if (Input.GetAxis("Mouse ScrollWheel") < 0 && selectTime < Time.time)
{
if (weaponManager != null && createWeapon != null)
{
Destroy(createWeapon);
}
}
weaponManager.player = this;
if (weaponManager != null && createWeapon == null)
{
createWeapon = Instantiate(weaponList[selectedWeapon]) as GameObject;
createWeapon.transform.parent = playerCamera.transform;
createWeapon.transform.localPosition = Vector3.zero;
createWeapon.transform.localEulerAngles = Vector3.zero;
}
}
if (Input.GetAxis("Mouse ScrollWheel") > 0 && selectTime < Time.time)
{
if (weaponList.Count - 1 > selectedWeapon)
{
selectedWeapon += 1;
}
else
{
selectedWeapon = 0;
}
selectTime = selectRate + Time.time;
}
else if (Input.mouseScrollDelta.y < 0)
else if (Input.GetAxis("Mouse ScrollWheel") < 0 && selectTime < Time.time)
{
WeaponManager weaponManager = weaponList[selectedWeapon].GetComponent<WeaponManager>();
weaponManager.player = this;
if (weaponManager != null && createWeapon != null)
{
Destroy(createWeapon);
}
if (selectedWeapon > 0)
{
selectedWeapon--;
selectedWeapon -= 1;
}
else
{
selectedWeapon = weaponList.Count - 1;
}
}
WeaponManager weaponManager2 = weaponList[selectedWeapon].GetComponent<WeaponManager>();
weaponManager2.player = this;
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;
selectTime = selectRate + Time.time;
}
}
}

View File

@@ -25,13 +25,10 @@ public class SpawnManager : MonoBehaviour
float sunRotationX = Sun.transform.localEulerAngles.x;
sunRotationX = (sunRotationX > 180) ? sunRotationX - 360 : sunRotationX;
Debug.Log(sunRotationX.ToString());
if (sunRotationX < 0)
{
Debug.Log("It is a Night");
night = true;
} else {
Debug.Log("It is a Day");
night = false;
}