Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# =============== #
Temp/
Library/

*.apk
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
Expand Down
3 changes: 2 additions & 1 deletion Bowling/Assembly-CSharp-vs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_IPHONE;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_GENERICS;ENABLE_SUBSTANCE;INCLUDE_WP8SUPPORT;ENABLE_WWW;ENABLE_IMAGEEFFECTS;UNITY_IPHONE_API;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_GAMECENTER;UNITY_IOS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_3_4;UNITY_4_3;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_ANDROID;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_GENERICS;ENABLE_SUBSTANCE;INCLUDE_WP8SUPPORT;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;UNITY_ANDROID_API;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_3_4;UNITY_4_3;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand Down Expand Up @@ -49,6 +49,7 @@
<Compile Include="Assets\Scripts\BallThrower.cs" />
<Compile Include="Assets\Scripts\BowlingPin.cs" />
<Compile Include="Assets\Scripts\CameraController.cs" />
<Compile Include="Assets\Scripts\ColorPicker.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
3 changes: 2 additions & 1 deletion Bowling/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_IPHONE;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_GENERICS;ENABLE_SUBSTANCE;INCLUDE_WP8SUPPORT;ENABLE_WWW;ENABLE_IMAGEEFFECTS;UNITY_IPHONE_API;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_GAMECENTER;UNITY_IOS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_3_4;UNITY_4_3;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_ANDROID;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_GENERICS;ENABLE_SUBSTANCE;INCLUDE_WP8SUPPORT;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;UNITY_ANDROID_API;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_3_4;UNITY_4_3;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand Down Expand Up @@ -49,6 +49,7 @@
<Compile Include="Assets\Scripts\BallThrower.cs" />
<Compile Include="Assets\Scripts\BowlingPin.cs" />
<Compile Include="Assets\Scripts\CameraController.cs" />
<Compile Include="Assets\Scripts\ColorPicker.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Binary file added Bowling/Assets/Materials/BowlingBall.mat
Binary file not shown.
4 changes: 4 additions & 0 deletions Bowling/Assets/Materials/BowlingBall.mat.meta

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

Binary file not shown.
4 changes: 4 additions & 0 deletions Bowling/Assets/Materials/WoodFine0003_thumblarge.mat.meta

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

Binary file not shown.

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

Binary file added Bowling/Assets/Models/BowlingAlley.blend
Binary file not shown.
77 changes: 77 additions & 0 deletions Bowling/Assets/Models/BowlingAlley.blend.meta

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

Binary file added Bowling/Assets/Prefabs/BowlingBall.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Bowling/Assets/Prefabs/BowlingBall.prefab.meta

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

Binary file modified Bowling/Assets/Scenes/BowlingAlley.unity
Binary file not shown.
134 changes: 74 additions & 60 deletions Bowling/Assets/Scripts/BallThrower.cs
Original file line number Diff line number Diff line change
@@ -1,101 +1,115 @@
using UnityEngine;
using System.Collections;

public class BallThrower : MonoBehaviour {

public float _power = 0;
public class BallThrower : MonoBehaviour
{
public float _throw = 20;
public bool _hittingPins = false;
bool thrown = false;
bool changingLocation = true;
bool changingRotation = true;
int maxLaneWidth = 1;
int minLaneWidth = -1;
bool increasingWidth = true;
bool increasingRotation = true;
int maxRotation = 30;
int minRotation = 330;
public float maxPower = 10f;
private float _power = 0;
private bool thrown = false;
private bool changingLocation = true;
private bool changingRotation = true;
private int maxLaneWidth = 1;
private int minLaneWidth = -1;
private bool increasingWidth = true;
private bool increasingRotation = true;
private int maxRotation = 30;
private int minRotation = 330;

private bool isTouched = false;
private bool isReleased = false;


// Use this for initialization
void Start () {
void Start ()
{
}

// Update is called once per frame
void Update () {

// if (Input.touchCount == 1) {
// Touch touch = Input.GetTouch(0);
if (changingLocation) {
if (Input.GetKey (KeyCode.Space)) {
// if (touch.phase == TouchPhase.Began) {
changingLocation = false;
}
ChangeBallLocation ();
} else if (changingRotation) {
if (Input.GetKey (KeyCode.Space)) {
// if (touch.phase == TouchPhase.Began) {
changingRotation = false;
}
changeBallRotation();
void Update ()
{
if(Input.touchCount>0 || Input.GetKey(KeyCode.Space)){
isTouched = true;
} else {
if(isTouched)
isReleased = true;
isTouched = false;
}
if (changingLocation) {
if (isTouched) {
// if (touch.phase == TouchPhase.Began) {
changingLocation = false;
Debug.Log ("Location locked");
}
ChangeBallLocation ();
} else if (changingRotation) {
if (isTouched) {
// if (touch.phase == TouchPhase.Began) {
changingRotation = false;
Debug.Log ("Rotation locked");
}
changeBallRotation ();
} else {
if (Input.GetKey (KeyCode.Space)) {
// if (touch.phase == TouchPhase.Began) {
_power += _throw * Time.deltaTime;
}
if (Input.GetKeyUp (KeyCode.Space)) {
// if (touch.phase == TouchPhase.Ended) {
StartCoroutine(ThrowBall());
}
if (isTouched) {
// if (touch.phase == TouchPhase.Began) {
_power += _throw * Time.deltaTime;
//Debug.Log ("Adding power");
}
// }
if (isReleased) {
// if (touch.phase == TouchPhase.Ended) {
_power = Mathf.Min (_power, maxPower);
StartCoroutine (ThrowBall ());
Debug.Log ("Throwing with power: "+_power);
}
}
}

void ChangeBallLocation() {
Vector3 offset = new Vector3(0.04f, 0, 0);
void ChangeBallLocation ()
{
Vector3 offset = new Vector3 (0.04f, 0, 0);
if (increasingWidth) {
this.transform.position += offset;
if (this.transform.position.x > maxLaneWidth) {
if (this.transform.position.x > maxLaneWidth) {
increasingWidth = false;
this.transform.position -= offset;
}
} else if (!increasingWidth) {
this.transform.position -= offset;
if (this.transform.position.x < minLaneWidth) {
if (this.transform.position.x < minLaneWidth) {
increasingWidth = true;
this.transform.position += offset;
}
}
}

void changeBallRotation() {
void changeBallRotation ()
{
if (increasingRotation) {
transform.rotation = transform.rotation * Quaternion.Euler(0f, 1f, 0f);
// Debug.Log(transform.rotation.eulerAngles.y);
if (transform.rotation.eulerAngles.y > maxRotation && transform.rotation.eulerAngles.y < 60) {
transform.rotation = transform.rotation * Quaternion.Euler (0f, 1f, 0f);
// Debug.Log(transform.rotation.eulerAngles.y);
if (transform.rotation.eulerAngles.y > maxRotation && transform.rotation.eulerAngles.y < 60) {
increasingRotation = false;
}
} else if (!increasingRotation) {
transform.rotation = transform.rotation * Quaternion.Euler(0f, (-1f), 0f);
if (transform.rotation.eulerAngles.y < minRotation && transform.rotation.eulerAngles.y > 300) {
transform.rotation = transform.rotation * Quaternion.Euler (0f, (-1f), 0f);
if (transform.rotation.eulerAngles.y < minRotation && transform.rotation.eulerAngles.y > 300) {
increasingRotation = true;
}
}
}

void OnCollisionEnter(Collision collision) {
void OnCollisionEnter (Collision collision)
{
if (collision.collider.gameObject.name == "Cylinder") {
_hittingPins = true;
}
}

public IEnumerator ThrowBall() {

public IEnumerator ThrowBall ()
{
if (!thrown) {
//Do not throw anymore
thrown = true;
thrown = true;
//Rotate the throw by the rotation angle
rigidbody.velocity = transform.forward * _power;
yield return new WaitForSeconds(5);
Application.LoadLevel(Application.loadedLevel);
yield return new WaitForSeconds (5);
Application.LoadLevel (Application.loadedLevel);
}
}
}
}
4 changes: 2 additions & 2 deletions Bowling/Assets/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public class CameraController : MonoBehaviour {

// Use this for initialization
void Start () {
_target = GameObject.Find ("Ball"); // Follow the ball
_target = GameObject.Find ("BowlingBall"); // Follow the ball
ballScript = _target.GetComponent<BallThrower> ();
}

// Update is called once per frame
void Update () {
if (!ballScript._hittingPins) {
transform.rotation = _target.transform.rotation;
//transform.rotation = _target.transform.rotation;
transform.position = _target.transform.position + (transform.forward * _rotationOffset);
transform.position += new Vector3 (0, 1, 0);
}
Expand Down
16 changes: 16 additions & 0 deletions Bowling/Assets/Scripts/ColorPicker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnityEngine;
using System.Collections;

public class ColorPicker : MonoBehaviour {

public Color color;
public bool isRandom;
void Start () {
//color = null;
if(isRandom)
color = new Color(Random.Range(0,100)/100f,Random.Range(0,100)/100f,Random.Range(0,100)/100f);
this.gameObject.renderer.material.color = color;

}

}
8 changes: 8 additions & 0 deletions Bowling/Assets/Scripts/ColorPicker.cs.meta

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading