forked from AmigoCap/ReViVD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Débuggage massif, passage en 4x4 pour de vrai, changement de l'obtent…
…ion des atomes à update dans createDistrict (algorithme de Bresenham)
- Loading branch information
Showing
5 changed files
with
670 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class MouseCamera : MonoBehaviour | ||
{ | ||
|
||
/* | ||
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care. | ||
Converted to C# 27-02-13 - no credit wanted. | ||
Simple flycam I made, since I couldn't find any others made public. | ||
Made simple to use (drag and drop, done) for regular keyboard layout | ||
wasd : basic movement | ||
shift : Makes camera accelerate | ||
space : Moves camera on X and Z axis only. So camera doesn't gain any height*/ | ||
|
||
|
||
public float mainSpeed = 50.0f; //regular speed | ||
float shiftAdd = 100.0f; //multiplied by how long shift is held. Basically running | ||
float maxShift = 1000.0f; //Maximum speed when holdin gshift | ||
public float camSens = 0.2f; //How sensitive it with mouse | ||
private Vector2 mouse; | ||
private float totalRun = 1.0f; | ||
public bool AZERTY = true; | ||
|
||
private void Start() | ||
{ | ||
Cursor.lockState = CursorLockMode.Locked; | ||
} | ||
|
||
void Update() | ||
{ | ||
if (Cursor.lockState == CursorLockMode.Locked) { | ||
mouse.x = Input.GetAxis("Mouse X"); | ||
mouse.y = Input.GetAxis("Mouse Y"); | ||
mouse = new Vector3(-mouse.y * camSens, mouse.x * camSens, 0); | ||
float vertAngle = transform.eulerAngles.x + mouse.x; | ||
if (vertAngle > 90 && vertAngle <= 180) | ||
vertAngle = 90; | ||
else if (vertAngle < 270 && vertAngle >= 180) | ||
vertAngle = 270; | ||
mouse = new Vector3(vertAngle, transform.eulerAngles.y + mouse.y, 0); | ||
transform.eulerAngles = mouse; | ||
mouse = Input.mousePosition; | ||
//Mouse camera angle done. | ||
} | ||
|
||
//Keyboard commands | ||
Vector3 p = GetBaseInput(); | ||
if (Input.GetKey(KeyCode.LeftShift)) | ||
{ | ||
totalRun += Time.deltaTime; | ||
p = p * totalRun * shiftAdd; | ||
p.x = Mathf.Clamp(p.x, -maxShift, maxShift); | ||
p.y = Mathf.Clamp(p.y, -maxShift, maxShift); | ||
p.z = Mathf.Clamp(p.z, -maxShift, maxShift); | ||
} | ||
else | ||
{ | ||
totalRun = Mathf.Clamp(totalRun * 0.5f, 1f, 1000f); | ||
p = p * mainSpeed; | ||
} | ||
|
||
p = p * Time.deltaTime; | ||
Vector3 newPosition = transform.position; | ||
if (Input.GetKey(KeyCode.Space)) | ||
{ //If player wants to move on X and Z axis only | ||
transform.Translate(p); | ||
newPosition.x = transform.position.x; | ||
newPosition.z = transform.position.z; | ||
transform.position = newPosition; | ||
} | ||
else | ||
{ | ||
transform.Translate(p); | ||
} | ||
|
||
if (Input.GetKey(KeyCode.Escape)) | ||
{ | ||
Cursor.lockState = CursorLockMode.None; | ||
} | ||
|
||
if (Input.GetMouseButton(0)) { | ||
Cursor.lockState = CursorLockMode.Locked; | ||
} | ||
} | ||
|
||
private Vector3 GetBaseInput() | ||
{ //returns the basic values, if it's 0 than it's not active. | ||
Vector3 p_Velocity = new Vector3(); | ||
if (Input.GetKey(AZERTY ? KeyCode.Z : KeyCode.W)) | ||
{ | ||
p_Velocity += new Vector3(0, 0, 1); | ||
} | ||
if (Input.GetKey(KeyCode.S)) | ||
{ | ||
p_Velocity += new Vector3(0, 0, -1); | ||
} | ||
if (Input.GetKey(AZERTY ? KeyCode.Q : KeyCode.A)) | ||
{ | ||
p_Velocity += new Vector3(-1, 0, 0); | ||
} | ||
if (Input.GetKey(KeyCode.D)) | ||
{ | ||
p_Velocity += new Vector3(1, 0, 0); | ||
} | ||
if (Input.GetKey(AZERTY ? KeyCode.A : KeyCode.Q)) { | ||
p_Velocity += new Vector3(0, 1, 0); | ||
} | ||
if (Input.GetKey(KeyCode.E)) { | ||
p_Velocity += new Vector3(0, -1, 0); | ||
} | ||
return p_Velocity; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.