Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Day 21. first unity game
  • Loading branch information
jahmezz committed Aug 31, 2016
1 parent 0d9f002 commit a2f88dc
Show file tree
Hide file tree
Showing 1,264 changed files with 140,599 additions and 14 deletions.
1 change: 1 addition & 0 deletions unityroll/Rollaball/Assembly-CSharp.csproj
Expand Up @@ -47,6 +47,7 @@
<ItemGroup>
<Compile Include="Assets\Scripts\CameraController.cs" />
<Compile Include="Assets\Scripts\PlayerController.cs" />
<Compile Include="Assets\Scripts\Rotator.cs" />
<Reference Include="UnityEngine.Networking">
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll</HintPath>
</Reference>
Expand Down
Binary file added unityroll/Rollaball/Assets/Materials/Pick Up.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions unityroll/Rollaball/Assets/Materials/Pick Up.mat.meta

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

9 changes: 9 additions & 0 deletions unityroll/Rollaball/Assets/Prefabs.meta

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

Binary file added unityroll/Rollaball/Assets/Prefabs/Pick Up.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions unityroll/Rollaball/Assets/Prefabs/Pick Up.prefab.meta

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

27 changes: 24 additions & 3 deletions unityroll/Rollaball/Assets/Scripts/PlayerController.cs
@@ -1,15 +1,21 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {
public float speed;

public Text countText;
public Text winText;

private Rigidbody rb;
private int count;

void Start() {
rb = GetComponent<Rigidbody> ();
}

void Update() {
count = 0;
SetCountText ();
winText.text = "";
}

void FixedUpdate() {
Expand All @@ -19,4 +25,19 @@ public class PlayerController : MonoBehaviour {
Vector3 movement = new Vector3 (moveHorizontal, 0, moveVertical);
rb.AddForce (movement * speed);
}

void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag("Pick Up")) {
other.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
}
}

void SetCountText() {
countText.text = "Count: " + count.ToString ();
if (count >= 14) {
winText.text = "You Win!";
}
}
}
9 changes: 9 additions & 0 deletions unityroll/Rollaball/Assets/Scripts/Rotator.cs
@@ -0,0 +1,9 @@
using UnityEngine;
using System.Collections;

public class Rotator : MonoBehaviour {
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
}
}
12 changes: 12 additions & 0 deletions unityroll/Rollaball/Assets/Scripts/Rotator.cs.meta

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

Binary file modified unityroll/Rollaball/Assets/_Scenes/minigame.unity
Binary file not shown.

0 comments on commit a2f88dc

Please sign in to comment.