Skip to content

Commit c6bb65c

Browse files
committed
Massive improvements to core gameplay.
1 parent 2329dcb commit c6bb65c

13 files changed

+110
-77
lines changed

Assembly-UnityScript-firstpass-vs.unityproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<DebugType>full</DebugType>
1919
<Optimize>false</Optimize>
2020
<OutputPath>Temp\bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
21+
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
2222
<ErrorReport>prompt</ErrorReport>
2323
<WarningLevel>4</WarningLevel>
2424
<NoWarn>0169</NoWarn>

Assembly-UnityScript-firstpass.unityproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<DebugType>full</DebugType>
1919
<Optimize>false</Optimize>
2020
<OutputPath>Temp\bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
21+
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
2222
<ErrorReport>prompt</ErrorReport>
2323
<WarningLevel>4</WarningLevel>
2424
<NoWarn>0169</NoWarn>
8 Bytes
Binary file not shown.
Binary file not shown.

Assets/Prefabs/Cloud.prefab

24 Bytes
Binary file not shown.

Assets/Scenes/GameScene.unity

960 Bytes
Binary file not shown.

Assets/Scripts/CloudController.cs

+57-39
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
using UnityEngine;
22
using System.Collections;
3-
using System.Collections.Generic;
43

54
public class CloudController : MonoBehaviour
65
{
7-
public Transform playerTransform;
6+
public Transform playerTransform;
87
public Transform cloudMeshTransform;
98
public Transform floraPrefab;
109
public LayerMask floraRaycastMask = -1;
1110
public Material happyCloudMat;
1211
public Material rainyCloudMat;
12+
public float moveVelocity = 100;
13+
public float moveAwayForce = 1;
14+
public float lookAtPlayerForce = 1;
15+
public float pullVelocity = 10000;
16+
public float minCloudScale = 0.1f;
17+
public float minStartScale = 0.75f;
18+
public float maxStartScale = 1f;
19+
public float minShrinkSpeed = 0.2f;
20+
public float maxShrinkSpeed = 0.5f;
1321

1422
[HideInInspector]
15-
public Transform cloudColliderCenter;
23+
private float shrinkSpeed;
1624
[HideInInspector]
17-
public float runThreshold;
25+
private float cloudScale;
1826
[HideInInspector]
19-
public float runVelocity;
20-
[HideInInspector]
21-
public float normalXVelocity;
22-
[HideInInspector]
23-
public float normalZVelocity;
24-
[HideInInspector]
25-
public float pullVelocity;
26-
27-
[HideInInspector]
28-
public static List<CloudController> rainingClouds = new List<CloudController>();
27+
private Transform cloudColliderCenter;
2928

3029
public enum CloudState
3130
{
@@ -37,35 +36,42 @@ public enum CloudState
3736
[HideInInspector]
3837
public CloudState state;
3938

40-
private int flip;
41-
4239
// Use this for initialization
4340
void Start()
4441
{
45-
particleSystem.enableEmission = false;
4642
state = CloudState.Normal;
47-
flip = 1;
43+
particleSystem.enableEmission = false;
44+
ResetVelocity();
45+
46+
shrinkSpeed = Random.Range(minShrinkSpeed, maxShrinkSpeed);
47+
cloudScale = Random.Range(minStartScale, maxStartScale);
48+
transform.localScale = new Vector3(cloudScale, cloudScale, cloudScale);
49+
Quaternion newRot = Quaternion.Euler(0, Random.Range(0, 360f), 0);
50+
transform.rotation = newRot;
4851
}
52+
53+
void ResetVelocity()
54+
{
55+
rigidbody.velocity = new Vector3(Random.Range(-moveVelocity, moveVelocity), 0, Random.Range(-moveVelocity, moveVelocity));
56+
}
4957

5058
// Update is called once per frame
5159
void Update()
5260
{
53-
if (state == CloudState.Normal)
54-
{
55-
Vector3 deltaPosition = transform.position - playerTransform.position;
56-
if (deltaPosition.magnitude < runThreshold)
57-
{
58-
deltaPosition.Normalize();
59-
deltaPosition.y = 0.0f;
60-
rigidbody.velocity = deltaPosition * runVelocity;
61-
}
62-
else
63-
{
64-
65-
rigidbody.velocity = new Vector3(flip * normalXVelocity, 0, flip * normalZVelocity);
66-
}
67-
}
68-
else if (state == CloudState.Rain && cloudColliderCenter != null)
61+
if(GameController.state != GameController.GameState.play) return;
62+
63+
if (state == CloudState.Normal)
64+
{
65+
Quaternion rotation = Quaternion.LookRotation(playerTransform.position - transform.position);
66+
rotation.x = 0;
67+
rotation.z = 0;
68+
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * lookAtPlayerForce);
69+
70+
71+
Vector3 playerDir = transform.position - playerTransform.position;
72+
rigidbody.AddForce(playerDir.normalized * moveAwayForce);
73+
}
74+
else if (state == CloudState.Rain)
6975
{
7076
// Add force to keep cloud within cloudCollider
7177
float colliderRadius = cloudColliderCenter.localScale.x;
@@ -90,6 +96,18 @@ void Update()
9096
GameController.score++;
9197
}
9298
}
99+
100+
// Shrink cloud
101+
if(cloudScale > minCloudScale)
102+
{
103+
cloudScale -= Time.deltaTime * shrinkSpeed;
104+
transform.localScale = new Vector3(cloudScale, cloudScale, cloudScale);
105+
}
106+
else
107+
{
108+
CloudManager.rainingClouds.Remove(this);
109+
Destroy(gameObject);
110+
}
93111
}
94112
}
95113

@@ -111,9 +129,9 @@ public void SetDeadState()
111129

112130
void OnCollisionEnter(Collision collision)
113131
{
114-
if (collision.gameObject.name.Equals("WallPlane"))
132+
if (collision.gameObject.tag.Equals("WallTag"))
115133
{
116-
flip *= -1;
134+
ResetVelocity();
117135
}
118136
}
119137

@@ -127,7 +145,7 @@ void OnTriggerEnter(Collider collision)
127145
cloudMeshTransform.GetComponent<SkinnedMeshRenderer>().material = rainyCloudMat;
128146
particleSystem.enableEmission = true;
129147
cloudColliderCenter = collision.transform;
130-
rainingClouds.Add(this);
148+
CloudManager.rainingClouds.Add(this);
131149
}
132150
}
133151
}
@@ -138,8 +156,8 @@ void OnTriggerExit(Collider collision)
138156
{
139157
if (state == CloudState.Rain)
140158
{
141-
SetDeadState();
142-
rainingClouds.Remove(this);
159+
SetNormalState();
160+
CloudManager.rainingClouds.Remove(this);
143161
}
144162
}
145163
}

Assets/Scripts/CloudManager.cs

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
using UnityEngine;
22
using System.Collections;
3+
using System.Collections.Generic;
34

45
public class CloudManager : MonoBehaviour
56
{
67

78
public int totalClouds;
89
public Terrain terrain;
9-
public Transform cloud;
1010
public Transform player;
1111
public Transform cloudCollider;
12+
public Transform cloudPrefab;
1213
public float colliderPullForce;
13-
public float runThresholdLower;
14-
public float runThresholdUpper;
15-
public float runVelocityLower;
16-
public float runVelocityUpper;
17-
public float normalXVelocityLower;
18-
public float normalXVelocityUpper;
19-
public float normalZVelocityLower;
20-
public float normalZVelocityUpper;
14+
15+
[HideInInspector]
16+
public static List<CloudController> rainingClouds = new List<CloudController>();
2117

2218
// Use this for initialization
2319
void Start()
@@ -27,18 +23,12 @@ void Start()
2723
for (int i = 0; i < totalClouds; i++)
2824
{
2925
float xPos = Random.Range(terrainPosition.x + 200, terrainPosition.x - 200 + terrainSize.x);
30-
float zPos = Random.Range(terrainPosition.z + 200, terrainPosition.z - 200 + terrainSize.z);
26+
float zPos = Random.Range(terrainPosition.z + 200, terrainPosition.z - 200 + terrainSize.z);
3127

3228
Vector3 randomPos = new Vector3(xPos, 150f, zPos);
33-
Transform newCloud = (Transform)Instantiate(cloud, randomPos, Quaternion.identity);
34-
CloudController ctrl = newCloud.GetComponent<CloudController>();
35-
ctrl.playerTransform = player;
36-
ctrl.runThreshold = Random.Range(runThresholdLower, runThresholdUpper);
37-
ctrl.runVelocity = Random.Range(runVelocityLower, runVelocityUpper);
38-
ctrl.normalXVelocity = Random.Range(normalXVelocityLower, normalXVelocityUpper);
39-
ctrl.normalZVelocity = Random.Range(normalZVelocityLower, normalZVelocityUpper);
40-
ctrl.pullVelocity = colliderPullForce;
41-
}
29+
Transform cloud = (Transform)Instantiate(cloudPrefab, randomPos, Quaternion.identity);
30+
cloud.GetComponent<CloudController>().playerTransform = player;
31+
}
4232
}
4333

4434
// Update is called once per frame

Assets/Scripts/GameController.cs

+6
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ void DrawRoundOverUI()
123123
GUI.SetNextControlName("PlayerInputControl");
124124
Event e = Event.current;
125125
if (e.keyCode == KeyCode.Return)
126+
{
126127
RestartGame();
128+
}
129+
else if (e.keyCode == KeyCode.Escape)
130+
{
131+
Application.Quit();
132+
}
127133
else
128134
{
129135
Vector2 textSize = newHighScoreTextStyle.CalcSize(new GUIContent(playerName));

Assets/Scripts/LassoBar.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class LassoBar : MonoBehaviour
1010
// Use this for initialization
1111
void Start()
1212
{
13-
cam = transform.parent.GetComponentInChildren<Camera>();
13+
cam = Camera.main;
1414
lasso = transform.parent.GetComponentInChildren<LassoController>();
1515
}
1616

Assets/Scripts/LassoController.cs

+24-15
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ public class LassoController : MonoBehaviour
99
public int minCloudColliderSize;
1010
public int cloudColliderShrinkSpeed;
1111
public float trailLifetime;
12+
public Transform player;
1213
public Transform cloudCollider;
1314
public Transform lassoBar;
15+
public Transform lassoLine;
1416
public Transform lassoSpawnLocation;
1517
public LayerMask raycastMask = -1;
1618

@@ -24,10 +26,13 @@ public class LassoController : MonoBehaviour
2426

2527
private float colliderRadius;
2628
private List<Vector2> pointList;
29+
private bool hookedEffectPing;
30+
private Tweener hookedEffectTweener;
2731

2832
// Use this for initialization
2933
void Start()
3034
{
35+
player = transform.parent;
3136
HOTween.Init(false, false, true);
3237
HOTween.EnableOverwriteManager();
3338
DisengageLasso();
@@ -39,7 +44,7 @@ void Update()
3944
{
4045
if(GameController.state != GameController.GameState.play) return;
4146

42-
if (isEngaged)
47+
if (isEngaged && !isHooked)
4348
{
4449
lassoLifetime -= Time.deltaTime;
4550
if (lassoLifetime > 0)
@@ -62,13 +67,11 @@ void Update()
6267
else
6368
DisengageLasso();
6469
}
65-
else
66-
transform.position = lassoSpawnLocation.position;
6770

6871
// shrink cloud collider
6972
if(cloudCollider.gameObject.activeSelf && colliderRadius != -1)
7073
{
71-
if(colliderRadius > minCloudColliderSize && CloudController.rainingClouds.Count > 0)
74+
if(colliderRadius > minCloudColliderSize && CloudManager.rainingClouds.Count > 0)
7275
{
7376
colliderRadius -= Time.deltaTime * cloudColliderShrinkSpeed;
7477
cloudCollider.localScale = new Vector3(colliderRadius, cloudCollider.localScale.y, colliderRadius);
@@ -81,14 +84,17 @@ void Update()
8184
}
8285

8386
// Process Input
84-
if (!isEngaged && Input.GetMouseButtonDown(0))
85-
{
86-
EngageLasso();
87-
}
88-
else if (Input.GetMouseButtonUp(0))
87+
if (Input.GetMouseButtonDown(0))
8988
{
90-
DisengageLasso();
91-
UnhookLasso();
89+
if(isEngaged || isHooked)
90+
{
91+
DisengageLasso();
92+
UnhookLasso();
93+
}
94+
else
95+
{
96+
EngageLasso();
97+
}
9298
}
9399
}
94100

@@ -113,26 +119,29 @@ private void DisengageLasso()
113119
void HookLasso()
114120
{
115121
isHooked = true;
122+
lassoLine.GetComponent<LineRenderer>().enabled = true;
123+
player.GetComponent<PlayerController>().CalcLassoLineLocation();
116124
}
117125

118126
void UnhookLasso(bool killClouds = false)
119127
{
120128
isHooked = false;
129+
lassoLine.GetComponent<LineRenderer>().enabled = false;
121130

122-
foreach(CloudController cc in CloudController.rainingClouds)
131+
foreach(CloudController cc in CloudManager.rainingClouds)
123132
{
124133
if(killClouds)
125134
cc.SetDeadState();
126135
else
127136
cc.SetNormalState();
128137
}
129-
CloudController.rainingClouds = new List<CloudController>();
138+
CloudManager.rainingClouds = new List<CloudController>();
130139
}
131140

132141
// lasso becomes hooked when there is clouds within cloud collider
133142
private void CheckLassoHooked(float newRadius)
134143
{
135-
if(CloudController.rainingClouds.Count > 0)
144+
if(CloudManager.rainingClouds.Count > 0)
136145
{
137146
HookLasso();
138147
colliderRadius = newRadius;
@@ -152,7 +161,7 @@ private void CheckLineIntersection()
152161
{
153162
Vector2 newPointEndPos = pointList[pointList.Count - 1];
154163
Vector2 newPointStartPos = pointList[pointList.Count - 2];
155-
for (int i = 0; i < pointList.Count - 4; i += 2)
164+
for (int i = 0; i < pointList.Count - 16; i += 2)
156165
{
157166
Vector2 prevPointStartPos = pointList[i];
158167
Vector2 prevPointEndPos = pointList[i + 1];

Assets/Scripts/PlayerController.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ void Update()
6464
Vector3 colliderToPlayerDir = cloudCollider.position - transform.position;
6565
cloudCollider.position -= colliderToPlayerDir.normalized * distanceDelta;
6666
}
67+
68+
CalcLassoLineLocation();
6769
}
6870
else
6971
{
@@ -85,10 +87,18 @@ void Update()
8587
}
8688

8789
// Look at collider if we caught some clouds!
88-
if(cloudCollider.gameObject.activeSelf && CloudController.rainingClouds.Count > 0)
90+
if(cloudCollider.gameObject.activeSelf && CloudManager.rainingClouds.Count > 0)
8991
{
9092
Quaternion rotation = Quaternion.LookRotation(cloudCollider.position - transform.position);
9193
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * lookAtDamping);
9294
}
9395
}
96+
97+
public void CalcLassoLineLocation()
98+
{
99+
Vector3 colliderToPlayer = transform.position - cloudCollider.transform.position;
100+
Vector3 lineEndPos = cloudCollider.transform.position - (colliderToPlayer.normalized * (cloudCollider.localScale.x / 2));
101+
lassoController.lassoLine.GetComponent<LineRenderer>().SetPosition(0, lassoController.lassoSpawnLocation.position);
102+
lassoController.lassoLine.GetComponent<LineRenderer>().SetPosition(1, lineEndPos);
103+
}
94104
}

ProjectSettings/TagManager.asset

36 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)