Skip to content

Commit

Permalink
Débuggage massif, passage en 4x4 pour de vrai, changement de l'obtent…
Browse files Browse the repository at this point in the history
…ion des atomes à update dans createDistrict (algorithme de Bresenham)
  • Loading branch information
FHomps committed Dec 27, 2018
1 parent a560417 commit 1d34a84
Show file tree
Hide file tree
Showing 5 changed files with 670 additions and 385 deletions.
114 changes: 114 additions & 0 deletions ReViVD_unity_project/Assets/MouseCamera.cs
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;
}
}
11 changes: 11 additions & 0 deletions ReViVD_unity_project/Assets/MouseCamera.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 55 additions & 20 deletions ReViVD_unity_project/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ LightmapSettings:
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
Expand Down Expand Up @@ -117,7 +116,8 @@ NavMeshSettings:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 170076735}
Expand All @@ -133,7 +133,8 @@ GameObject:
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 170076733}
m_Enabled: 1
serializedVersion: 8
Expand Down Expand Up @@ -170,7 +171,8 @@ Light:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 170076733}
m_LocalRotation: {x: 0.17364816, y: 0, z: 0, w: 0.9848078}
m_LocalPosition: {x: 0, y: 0, z: 0}
Expand All @@ -183,7 +185,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 534669905}
Expand All @@ -200,14 +203,16 @@ GameObject:
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 534669902}
m_Enabled: 1
--- !u!20 &534669904
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 534669902}
m_Enabled: 1
serializedVersion: 2
Expand All @@ -216,6 +221,7 @@ Camera:
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
Expand Down Expand Up @@ -247,7 +253,8 @@ Camera:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 534669902}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 2, z: 0}
Expand All @@ -260,7 +267,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 932146891}
Expand All @@ -278,7 +286,8 @@ GameObject:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 932146886}
m_Enabled: 1
m_EditorHideFlags: 0
Expand All @@ -289,7 +298,8 @@ MonoBehaviour:
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 932146886}
m_Enabled: 1
m_CastShadows: 1
Expand All @@ -299,6 +309,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 5081c4eb748de6a4c92262d798198979, type: 2}
m_StaticBatchInfo:
Expand All @@ -324,14 +335,16 @@ MeshRenderer:
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 932146886}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &932146891
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 932146886}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.92, y: 0.5, z: 5.88}
Expand All @@ -344,11 +357,13 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2015733476}
- component: {fileID: 2015733475}
- component: {fileID: 2015733477}
m_Layer: 0
m_Name: CameraHolder
m_TagString: Untagged
Expand All @@ -360,7 +375,8 @@ GameObject:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2015733474}
m_Enabled: 1
m_EditorHideFlags: 0
Expand All @@ -377,7 +393,8 @@ MonoBehaviour:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2015733474}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 2, z: 0}
Expand All @@ -387,11 +404,27 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2015733477
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2015733474}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 82895ded1d8113e469a102efaf3aca4e, type: 3}
m_Name:
m_EditorClassIdentifier:
mainSpeed: 30
camSens: 0.25
AZERTY: 1
--- !u!1 &2039570151
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2039570153}
Expand All @@ -407,7 +440,8 @@ GameObject:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2039570151}
m_Enabled: 1
m_EditorHideFlags: 0
Expand All @@ -417,12 +451,13 @@ MonoBehaviour:
material: {fileID: 2100000, guid: ff56756a7f27011408a584cb8f1e5a02, type: 2}
districtSize: {x: 30, y: 30, z: 30}
getDebugData: 0
districtToHighlight: {x: 0, y: 0, z: 0}
districtToHighlight:
--- !u!4 &2039570153
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2039570151}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.069893, y: 294.9075, z: -120.65076}
Expand Down
Loading

0 comments on commit 1d34a84

Please sign in to comment.