Initial Commit

Exp bar and Levels.
Rethink ExperienceBar and ToggleMenus scripts
This commit is contained in:
Shaun Reed 2017-08-22 13:29:01 -04:00
parent 932d544349
commit 91a7f533a1
41 changed files with 560 additions and 0 deletions

31
.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
# =============== #
# Unity generated #
# =============== #
Temp/
Library/
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
obj/
*.svd
*.userprefs
/*.csproj
*.pidb
*.suo
/*.sln
*.user
*.unityproj
*.booproj
# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

9
Assets/Materials.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 93f0c0b90aab84aa9a74b8e3defe3d29
folderAsset: yes
timeCreated: 1461076928
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Materials/Cube.mat Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8f638013a0cfa4a398f00d05518a0b41
timeCreated: 1460724879
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Prefabs.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fa5c4a77f2f968b49a9f41e20228e034
folderAsset: yes
timeCreated: 1479956424
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f4e57775724951a4cb915a7d1af37e74
timeCreated: 1478187092
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefabs/Cube.prefab Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 00e22d1ed21d14248801d764a0f6a057
timeCreated: 1478187146
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1a3ac787c5643744ea61ad4e26781184
timeCreated: 1478187095
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e73bfacc06717b4dbdb58cbd2c59d0b
timeCreated: 1478187077
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Scenes.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c4224d764d2c54c08b55c7e014ad9c61
folderAsset: yes
timeCreated: 1460724855
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scenes/Main.unity Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23203d52fcae84949a0ef84a04c62222
timeCreated: 1460724850
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Scripts.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2a6613e3208f248c4b54a3283ef5fe06
folderAsset: yes
timeCreated: 1460724861
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,117 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ExperienceBar : MonoBehaviour {
public int Exp = 0;
public string level = "1";
public int nextLevel = 1;
public int Increment = 10;
public GameObject levelText;
public float barWidth;
public float barHeight;
GameObject expBar;
// Eventually.. public RectTransform gainedExp
//Array used as expRequired[leveldesired]
public int[] expRequired = {0,0,100,250,450,700,1000,1350,1700,2150,2650 };
public float clicksNeeded = 10;
float barMovement;
float barPosition;
// Use this for initialization
void Start () {
expBar = this.gameObject;
}
// Update is called once per frame
void Update () {
checkExpGain();
//Check if Exp bar is full
if(this.gameObject.GetComponent<RectTransform>().sizeDelta.x == barWidth || expBar.GetComponent<RectTransform>().sizeDelta.x > barWidth)
{
this.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector3(0, barHeight);
barPosition = 0;
levelText.GetComponent<Text>().text = level;
}
}
public void ExpGain()
{
Exp = Exp + Increment;
//10 clicks per level DIVDED BY clicks required for exp gain
barMovement = 10 / clicksNeeded;
barPosition = barMovement + barPosition;
Debug.Log("barPosition = " + barPosition);
//use time.deltatime to smooth this out to make it look better?
this.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector3(barPosition * 10, barHeight);
}
public void checkExpGain()
{
switch(Exp)
{
case (100):
level = "2";
nextLevel = 3;
clicksNeeded = (expRequired[nextLevel] - Exp)/10;
break;
case (250):
level = "3";
nextLevel = 4;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (450):
level = "4";
nextLevel = 5;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (700):
level = "5";
nextLevel = 6;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (1000):
level = "6";
nextLevel = 7;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (1350):
level = "7";
nextLevel = 8;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (1700):
level = "8";
nextLevel = 9;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (2150):
level = "9";
nextLevel = 10;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
case (2650):
level = "10";
// nextLevel = 10;
clicksNeeded = (expRequired[nextLevel] - Exp) / 10;
break;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3512fb1b4f77da34aa574b8675dd5f91
timeCreated: 1503403150
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,116 @@
using UnityEngine;
using System.Collections;
public class SpinningCube : MonoBehaviour
{
public float m_Speed = 20f;
public float increments = 10f;
private string RotationDirection = "Up";
private Vector3 m_RotationDirection = Vector3.up;
private Vector3 stopRotation = Vector3.zero;
private Vector3 tempRotation;
public void ToggleRotationDirection()
{
if (m_RotationDirection == Vector3.up)
{
m_RotationDirection = Vector3.down;
RotationDirection = "Down";
}
else
{
m_RotationDirection = Vector3.up;
RotationDirection = "Up";
}
Debug.Log("Toggled rotation direction: " + RotationDirection);
}
public void ToggleRotation()
{
Debug.Log("Stopping Rotation. Last known rotation direction: " + RotationDirection);
stopRotation = Vector3.zero;
if (m_RotationDirection == stopRotation)
{
m_RotationDirection = tempRotation;
}
else {
tempRotation = m_RotationDirection;
m_RotationDirection = stopRotation;
}
}
public void RaiseRotationSpeed()
{
m_Speed = m_Speed + increments;
Debug.Log("Rotation Speed: " + m_Speed);
}
public void LowerRotationSpeed()
{
m_Speed = m_Speed - increments;
Debug.Log("Rotation Speed: " + m_Speed);
}
public void ResetRotationSpeed()
{
m_Speed = 20.0f;
Debug.Log("Rotation Speed Reset");
}
public void ChangeColorWhite()
{
GameObject.FindGameObjectsWithTag("Player");
gameObject.GetComponent<Renderer>().material.color = Color.white;
}
public void ChangeColorBlue()
{
gameObject.GetComponent<Renderer>().material.color = Color.blue;
}
public void ChangeColorBlack()
{
gameObject.GetComponent<Renderer>().material.color = Color.black;
}
public void ChangeColorGreen()
{
gameObject.GetComponent<Renderer>().material.color = Color.green;
}
public void ChangeColorRed()
{
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
public void ChangeColorMagenta()
{
gameObject.GetComponent<Renderer>().material.color = Color.magenta;
}
public void ChangeColorYellow()
{
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
}
public void ChangeColorCyan()
{
gameObject.GetComponent<Renderer>().material.color = Color.cyan;
}
void Update()
{
transform.Rotate(m_RotationDirection * Time.deltaTime * m_Speed);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f3f0c4784be6c460585c1b77fb5cf8bf
timeCreated: 1461145580
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,175 @@
using UnityEngine;
using System.Collections;
public class ToggleMenus : MonoBehaviour
{
public GameObject RotMenu;
public GameObject ColorMenu;
public GameObject ShapesMenu;
public GameObject LightingMenu;
public GameObject ExpMenu;
public GameObject Square;
public GameObject Sphere;
public GameObject Cylinder;
public GameObject Capsule;
public GameObject Temp;
public GameObject mySpawn;
private string Spawn = "Spawn";
private string Active = "Cube";
private bool ActiveMenu = false;
// Use this for initialization
void Start()
{
Temp = Square;
}
public void ToggleRotationMenu()
{
if (RotMenu.gameObject.active)
{
RotMenu.gameObject.SetActive(false);
ActiveMenu = !ActiveMenu;
}
else if (!RotMenu.gameObject.active && ActiveMenu)
{
CloseAll();
RotMenu.gameObject.SetActive(true);
}
else
{
RotMenu.gameObject.SetActive(true);
ActiveMenu = !ActiveMenu;
}
}
public void ToggleColorMenu()
{
if (ColorMenu.gameObject.active)
{
ColorMenu.gameObject.SetActive(false);
ActiveMenu = !ActiveMenu;
}
else if (!ColorMenu.gameObject.active && ActiveMenu)
{
CloseAll();
ColorMenu.gameObject.SetActive(true);
}
else
{
ColorMenu.gameObject.SetActive(true);
ActiveMenu = !ActiveMenu;
}
}
public void ToggleShapesMenu()
{
if (ShapesMenu.gameObject.active)
{
ShapesMenu.gameObject.SetActive(false);
ActiveMenu = !ActiveMenu;
}
else if (!ShapesMenu.gameObject.active && ActiveMenu)
{
CloseAll();
ShapesMenu.gameObject.SetActive(true);
}
else
{
ShapesMenu.gameObject.SetActive(true);
ActiveMenu = !ActiveMenu;
}
}
public void ToggleLightingMenu()
{
if (LightingMenu.gameObject.active)
{
LightingMenu.gameObject.SetActive(false);
ActiveMenu = !ActiveMenu;
}
else if (!LightingMenu.gameObject.active && ActiveMenu)
{
CloseAll();
LightingMenu.gameObject.SetActive(true);
}
else
{
LightingMenu.gameObject.SetActive(true);
ActiveMenu = !ActiveMenu;
}
}
public void ToggleExpMenu()
{
if (ExpMenu.gameObject.active)
{
ExpMenu.gameObject.SetActive(false);
//check if another menu is open to avoid overlapping
ActiveMenu = !ActiveMenu;
}
else if (!ExpMenu.gameObject.active && ActiveMenu)
{
CloseAll();
ExpMenu.gameObject.SetActive(true);
}
else
{
ExpMenu.gameObject.SetActive(true);
ActiveMenu = !ActiveMenu;
}
}
public void CloseAll()
{
ShapesMenu.gameObject.SetActive(false);
RotMenu.gameObject.SetActive(false);
ColorMenu.gameObject.SetActive(false);
LightingMenu.gameObject.SetActive(false);
ExpMenu.gameObject.SetActive(false);
}
public void ChangeShapeSquare()
{
Instantiate(Square, mySpawn.transform.position, mySpawn.transform.rotation);
Debug.Log("Destroy " + Active);
Destroy(GameObject.Find(Active));
Active = "Cube(Clone)";
Debug.Log(Active);
}
public void ChangeShapeSphere()
{
Instantiate(Sphere, mySpawn.transform.position, mySpawn.transform.rotation);
Debug.Log("Destroy " + Active);
Destroy(GameObject.Find(Active));
Active = "Sphere(Clone)";
Debug.Log(Active);
}
public void ChangeShapeCapsule()
{
Instantiate(Capsule, mySpawn.transform.position, mySpawn.transform.rotation);
Debug.Log("Destroy " + Active);
Destroy(GameObject.Find(Active));
Active = "Capsule(Clone)";
Debug.Log(Active);
}
public void ChangeShapeCylinder()
{
Instantiate(Cylinder, mySpawn.transform.position, mySpawn.transform.rotation);
Debug.Log("Destroy " + Active);
Destroy(GameObject.Find(Active));
Active = "Cylinder(Clone)";
Debug.Log(Active);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9e370590024e5584cbd068cab625f69b
timeCreated: 1478116406
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

BIN
Builds/First.apk Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
m_EditorVersion: 2017.1.0f3

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.