Skip to content

Commit 90c8b6d

Browse files
authored
Merge pull request #29 from Dacarpe03/Stage2/Implementation
Stage2/implementation
2 parents ec2f0de + 4a7a567 commit 90c8b6d

File tree

321 files changed

+14381
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+14381
-515
lines changed

EcoSim/.vsconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.ManagedGame"
5+
]
6+
}

EcoSim/Assets/Controller/Controller.cs

Lines changed: 291 additions & 74 deletions
Large diffs are not rendered by default.

EcoSim/Assets/Controller/ControllerPrefab.prefab

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ MonoBehaviour:
4343
m_Script: {fileID: 11500000, guid: 50fb9d235a90c4e4696ef79b8d3e5796, type: 3}
4444
m_Name:
4545
m_EditorClassIdentifier:
46+
ready: 1
47+
firstTime: 1
48+
menu: {fileID: 1936411909009720315, guid: 9be69d7278b611041bf4a75e19c11b48, type: 3}
49+
reprodPredator: {fileID: 0}
50+
speedPredator: {fileID: 0}
51+
visionPredator: {fileID: 0}
52+
initialPredator: {fileID: 0}
4653
MyView: {fileID: 2794609854212894643, guid: 8f63e7ba571ac8944916ce5938334baf, type: 3}

EcoSim/Assets/FlyCamera.cs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
public class FlyCamera : MonoBehaviour
5+
{
6+
7+
/*
8+
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care.
9+
Converted to C# 27-02-13 - no credit wanted.
10+
Simple flycam I made, since I couldn't find any others made public.
11+
Made simple to use (drag and drop, done) for regular keyboard layout
12+
wasd : basic movement
13+
shift : Makes camera accelerate
14+
space : Moves camera on X and Z axis only. So camera doesn't gain any height*/
15+
16+
17+
float mainSpeed = 100.0f; //regular speed
18+
float shiftAdd = 250.0f; //multiplied by how long shift is held. Basically running
19+
float maxShift = 1000.0f; //Maximum speed when holdin gshift
20+
float camSens = 0.25f; //How sensitive it with mouse
21+
private Vector3 lastMouse = new Vector3(255, 255, 255); //kind of in the middle of the screen, rather than at the top (play)
22+
private float totalRun = 1.0f;
23+
24+
void Update()
25+
{
26+
lastMouse = Input.mousePosition - lastMouse;
27+
lastMouse = new Vector3(-lastMouse.y * camSens, lastMouse.x * camSens, 0);
28+
lastMouse = new Vector3(transform.eulerAngles.x + lastMouse.x, transform.eulerAngles.y + lastMouse.y, 0);
29+
transform.eulerAngles = lastMouse;
30+
lastMouse = Input.mousePosition;
31+
//Mouse camera angle done.
32+
33+
//Keyboard commands
34+
float f = 0.0f;
35+
Vector3 p = GetBaseInput();
36+
if (p.sqrMagnitude > 0)
37+
{ // only move while a direction key is pressed
38+
if (Input.GetKey(KeyCode.LeftShift))
39+
{
40+
totalRun += Time.deltaTime;
41+
p = p * totalRun * shiftAdd;
42+
p.x = Mathf.Clamp(p.x, -maxShift, maxShift);
43+
p.y = Mathf.Clamp(p.y, -maxShift, maxShift);
44+
p.z = Mathf.Clamp(p.z, -maxShift, maxShift);
45+
}
46+
else
47+
{
48+
totalRun = Mathf.Clamp(totalRun * 0.5f, 1f, 1000f);
49+
p = p * mainSpeed;
50+
}
51+
52+
p = p * Time.deltaTime;
53+
Vector3 newPosition = transform.position;
54+
if (Input.GetKey(KeyCode.Space))
55+
{ //If player wants to move on X and Z axis only
56+
transform.Translate(p);
57+
newPosition.x = transform.position.x;
58+
newPosition.z = transform.position.z;
59+
transform.position = newPosition;
60+
}
61+
else
62+
{
63+
transform.Translate(p);
64+
}
65+
}
66+
}
67+
68+
private Vector3 GetBaseInput()
69+
{ //returns the basic values, if it's 0 than it's not active.
70+
Vector3 p_Velocity = new Vector3();
71+
if (Input.GetKey(KeyCode.W))
72+
{
73+
p_Velocity += new Vector3(0, 0, 1);
74+
}
75+
if (Input.GetKey(KeyCode.S))
76+
{
77+
p_Velocity += new Vector3(0, 0, -1);
78+
}
79+
if (Input.GetKey(KeyCode.A))
80+
{
81+
p_Velocity += new Vector3(-1, 0, 0);
82+
}
83+
if (Input.GetKey(KeyCode.D))
84+
{
85+
p_Velocity += new Vector3(1, 0, 0);
86+
}
87+
return p_Velocity;
88+
}
89+
}

EcoSim/Assets/FlyCamera.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)