This commit is contained in:
Patrick Kitchens 2018-04-26 10:14:11 -05:00
commit a50979a502
55 changed files with 491 additions and 32 deletions

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,10 @@
fileFormatVersion: 2
guid: 8b09d9a7c0cb3ca42a798802c96d28c8
timeCreated: 1524748932
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 326b00dfcab7e8c4da45c990cef3c9b6
timeCreated: 1524679668
timeCreated: 1524753018
licenseType: Free
NativeFormatImporter:
externalObjects: {}

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 441f50f7e865a4e9c937038cedf667ee
timeCreated: 1524703581
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 00e35244fddf9aa4fa427e547aec158d
folderAsset: yes
timeCreated: 1524683565
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 49942256293e57045bbb9b1a407a1667
timeCreated: 1524683726
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 645789e883e1d3c40aabb865a433d896
timeCreated: 1524683718
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6bca5c058cbd15c41815ef2924191049
timeCreated: 1524683721
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6d657f3d9cb80c94d86fed7d0acbcdd7
timeCreated: 1524683723
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 07c92442f33cfbb448eff50b204aaefa
timeCreated: 1524683727
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 5bb017abc66da2e4bb908eb3c97d29b4
timeCreated: 1524683729
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -4,6 +4,7 @@ using UnityEngine.EventSystems;
public class DragAndDrop : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public static GameObject DraggedInstance;
public Inventory inventory;
Vector3 _startPosition;
Vector3 _offsetToMouse;
@ -34,8 +35,12 @@ public class DragAndDrop : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
public void OnEndDrag (PointerEventData eventData)
{
DraggedInstance = null;
_offsetToMouse = Vector3.zero;
if (Input.mousePosition.y < 75) {
DraggedInstance.SetActive (false);
inventory.AddItem (DraggedInstance.name);
}
DraggedInstance = null;
}
#endregion

View file

@ -0,0 +1,174 @@
using System;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//Pretty much a copy of GetData...
namespace PedometerU.Tests {
public class GetGoals : MonoBehaviour {
public Text goalText;
public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
public string prefKey;
//Progress Bar...
public float barDisplay; //current progress
private Vector2 barPos;
private Vector2 barSize = new Vector2(227,20);
//Pedometer
private Pedometer pedometer;
int userSteps;
int userPoints;
double userDistance;
int stepsGoal = 100;
public Text stepText;
public Text pointsText;
private int savedSteps;
private int savedPoints;
void OnStep (int steps, double distance) {
userDistance = (distance * 3.28084);
userSteps = steps + savedSteps;
PlayerPrefs.SetInt("currentSteps",userSteps);
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
userPoints = steps*5 + savedPoints;
PlayerPrefs.SetInt("totalPoints",userPoints);
pointsText.text = "Points: " + userPoints.ToString ();
}
private void OnDisable () {
// Release the pedometer
pedometer.Dispose();
pedometer = null;
}
//saved value from last session loads in on START
//write usersteps + saved val to pref in ONSTEP
void Start () {
savedSteps = PlayerPrefs.GetInt("currentSteps");
savedPoints = PlayerPrefs.GetInt("totalPoints");
// Create a new pedometer
pedometer = new Pedometer(OnStep);
// Reset UI
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
if(PlayerPrefs.HasKey("totalPoints"))
{
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
}
else
{
PlayerPrefs.SetInt("totalPoints", 0);
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
}
userSteps = savedSteps;
userPoints = savedPoints;
//OnStep(savedSteps, 0);
Debug.Log(savedSteps);
//goalText.text = prefKey;
goalText.color = new Color(0f, 0f, 0f);
Debug.Log(goalText.transform.position.x.ToString() + " " + goalText.transform.position.y.ToString());
barPos = new Vector2(goalText.transform.position.x, goalText.transform.position.y);
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
Debug.Log(goalDayStr);
if(prefKey == "daily")
savePersistantGoalDate("daily");
}
//Texture the progress bar using these parameters
public Texture2D emptyTex;
public Texture2D fullTex;
//on a button press? begin a goal?
void startGoal()
{
}
void savePersistantGoalDate(string key)
{
PlayerPrefs.SetString(key, goalDayStr);
}
bool checkNewDay(string key)
{
string checkDay = PlayerPrefs.GetString(key);
if(checkDay == currentDayStr)
return false;
return true;
}
void OnGUI() {
//draw the background:
GUI.BeginGroup(new Rect(barPos.x, barPos.y, barSize.x, barSize.y));
GUI.Box(new Rect(0,0, barSize.x, barSize.y), emptyTex);
//draw the filled-in part:
GUI.BeginGroup(new Rect(0,0, barSize.x * barDisplay, barSize.y));
GUI.Box(new Rect(0,0, barSize.x, barSize.y), fullTex);
GUI.EndGroup();
GUI.EndGroup();
}
void Update() {
//needs current points counting toward this goal (daily?)
//needs the total required points for this goal
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
//barDisplay = Time.time*0.05f; //put actual progress here (current/total)
barDisplay = (float)userSteps/(float)stepsGoal;
//failed to complete goal
if(currentDayStr != goalDayStr)
{
Debug.Log(currentDayStr);
Debug.Log(goalDayStr);
Debug.Log("DAY HAS PASSED!!");
//make it so user dismisses the goal instead!
//Destroy(this);
//destroy the goal and set a new one?
}
//goal complete
if(barDisplay >= 1.0f)
{
Debug.Log("Goal complete! +100pts!");
userSteps = 0;
PlayerPrefs.SetInt("currentSteps", userSteps);
savedSteps = 0;
//OnStep(0,0);
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
//destroy the goal and set a new one?
savedPoints += stepsGoal*10;
PlayerPrefs.SetInt("totalPoints", savedPoints);
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
}
//only applies if "daily" goal
if(prefKey == "daily")
{
if(checkNewDay(prefKey))
{
Debug.Log("You failed your goal"); //not true if progress is actually complete!
goalDayStr = currentDayStr;
savePersistantGoalDate("daily");
}
}
}
}
}

View file

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 5f138b644c262457385474b2256308a7
timeCreated: 1524165858
guid: 040f99a891f1b4fed92f5a44e33fc47f
timeCreated: 1524166714
licenseType: Free
MonoImporter:
externalObjects: {}

View file

@ -1,16 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Goals : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}

View file

@ -1,15 +1,40 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Text;
public class Inventory : MonoBehaviour
{
public Image[] itemImages = new Image[numItemSlots];
public Item[] items = new Item[numItemSlots];
public const int numItemSlots = 25;
void Awake()
{
//PlayerPrefs.SetString("inventory", "");
string savedString = PlayerPrefs.GetString("inventory");
string[] itemNames = savedString.Split(' ');
Debug.Log (itemNames [itemNames.Length-1]);
for (int i = 0; i < itemNames.Length - 1; i++)
{
Sprite sprite = (Resources.Load<Sprite>(itemNames[i] + "_sprite"));
Item itm = new Item ();
itm.name = itemNames [i];
itm.sprite = sprite;
items[i] = itm;
itemImages[i].sprite = itm.sprite;
itemImages[i].enabled = true;
}
}
public void AddItem(Item itemToAdd)
{
StringBuilder invList = new StringBuilder ();
invList.Append(PlayerPrefs.GetString ("inventory"));
invList.Append(itemToAdd.name).Append(" ");
PlayerPrefs.SetString ("inventory", invList.ToString());
for (int i = 0; i < items.Length; i++)
{
if (items[i] == null)
@ -21,11 +46,43 @@ public class Inventory : MonoBehaviour
}
}
}
public void RemoveItem (Item itemToRemove)
public void AddItem(string itemName)
{
StringBuilder invList = new StringBuilder ();
invList.Append(PlayerPrefs.GetString ("inventory"));
invList.Append(itemName).Append(" ");
PlayerPrefs.SetString ("inventory", invList.ToString());
for (int i = 0; i < items.Length; i++)
{
if (items[i] == itemToRemove)
if (items[i] == null)
{
Sprite sprite = (Resources.Load<Sprite>(itemName + "_sprite"));
Item itm = new Item ();
itm.name = itemName;
itm.sprite = sprite;
items[i] = itm;
itemImages[i].sprite = itm.sprite;
itemImages[i].enabled = true;
return;
}
}
}
public void RemoveItem (Item itemToRemove)
{
StringBuilder invList = new StringBuilder ();
invList.Append(PlayerPrefs.GetString ("inventory"));
int index = invList.ToString ().IndexOf (itemToRemove.name + " ");
invList.Remove(index, (itemToRemove.name + " ").Length);
PlayerPrefs.SetString ("inventory", invList.ToString());
GameObject instance = (GameObject)Instantiate(Resources.Load(itemToRemove.name));
instance.name = itemToRemove.name;
for (int i = 0; i < items.Length; i++)
{
if (items[i].name == itemToRemove.name)
{
items[i] = null;
itemImages[i].sprite = null;
@ -34,4 +91,30 @@ public class Inventory : MonoBehaviour
}
}
}
public void RemoveItem (string itemName)
{
StringBuilder invList = new StringBuilder ();
invList.Append(PlayerPrefs.GetString ("inventory"));
int index = invList.ToString ().IndexOf (itemName + " ");
invList.Remove(index, (itemName + " ").Length);
PlayerPrefs.SetString ("inventory", invList.ToString());
GameObject instance = (GameObject)Instantiate(Resources.Load(itemName));
instance.GetComponent<DragAndDrop> ().inventory = this;
instance.name = itemName;
for (int i = 0; i < items.Length - 1; i++)
{
if (items [i] != null) {
Debug.Log (items [i].name + " == " + itemName);
if (items [i].name == itemName) {
items [i] = null;
itemImages [i].sprite = null;
itemImages [i].enabled = false;
return;
}
}
}
}
}

View file

@ -4,4 +4,6 @@
public class Item : ScriptableObject {
public Sprite sprite;
public string name;
}

View file

@ -0,0 +1,34 @@
using UnityEngine;
using UnityEngine.EventSystems;
using Image = UnityEngine.UI.Image;
public class ItemSlotBehavior : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public static GameObject DraggedInstance;
public Inventory inventory;
Vector3 _startPosition;
Vector3 _offsetToMouse;
float _zDistanceToCamera;
#region Interface Implementations
public void OnBeginDrag (PointerEventData eventData)
{
DraggedInstance = gameObject;
Debug.Log ("Removing: " + DraggedInstance.GetComponent<Image> ().sprite.name.Remove (DraggedInstance.GetComponent<Image> ().sprite.name.Length - 7));
inventory.RemoveItem(DraggedInstance.GetComponent<Image>().sprite.name.Remove(DraggedInstance.GetComponent<Image>().sprite.name.Length-7));
}
public void OnDrag (PointerEventData eventData)
{
}
public void OnEndDrag (PointerEventData eventData)
{
}
#endregion
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 062d9f417b017b445bd5b92d657b31d1
timeCreated: 1524730867
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -9,17 +9,11 @@ public class MonsterManager : MonoBehaviour {
public GameObject inventory;
public Item item;
private Inventory inv;
public Inventory inv;
void Start()
{
inv = FindObjectOfType<Inventory> ();
giveItem (item);
}
public void giveItem(Item itm)
{
inv.AddItem (itm);
loadMonster();
}
public void showItems()
@ -31,6 +25,21 @@ public class MonsterManager : MonoBehaviour {
public void saveMonster()
{
GameObject[] monsterParts = GameObject.FindGameObjectsWithTag("MonsterPart");
StringBuilder pos = new StringBuilder ();
string savedString;
string equippedString = "";
for (int i = 0; i < monsterParts.Length; i++) {
pos = new StringBuilder ();
pos.Append(GameObject.Find(monsterParts[i].name).transform.position.x).Append(" ").Append(GameObject.Find(monsterParts[i].name).transform.position.y).Append(" ").Append(GameObject.Find(monsterParts[i].name).transform.position.z);
equippedString = equippedString + monsterParts [i].name + " ";
savedString = pos.ToString ();
PlayerPrefs.SetString(/*SceneManager.GetActiveScene().name + */monsterParts[i].name, savedString);
}
PlayerPrefs.SetString ("Equipped", equippedString);
/*
StringBuilder eyePos = new StringBuilder();
eyePos.Append(GameObject.Find("circle_eye").transform.position.x).Append(" ").Append(GameObject.Find("circle_eye").transform.position.y).Append(" ").Append(GameObject.Find("circle_eye").transform.position.z);
@ -66,10 +75,25 @@ public class MonsterManager : MonoBehaviour {
nosePos.Append(GameObject.Find("pig_nose").transform.position.x).Append(" ").Append(GameObject.Find("pig_nose").transform.position.y).Append(" ").Append(GameObject.Find("pig_nose").transform.position.z);
savedString = nosePos.ToString();
PlayerPrefs.SetString(SceneManager.GetActiveScene().name + "nosePosition", savedString);
*/
}
public void loadMonster ()
{
string equippedString = PlayerPrefs.GetString("Equipped");
string[] equipped = equippedString.Split (' ');
for (int i = 0; i < equipped.Length - 1; i++) {
string savedString = PlayerPrefs.GetString(/*SceneManager.GetActiveScene().name + */equipped[i]);
string[] values = savedString.Split ();
GameObject instance = (GameObject)Instantiate(Resources.Load(equipped[i]));
instance.name = equipped [i];
instance.GetComponent<DragAndDrop> ().inventory = inv;
instance.transform.position = new Vector3(float.Parse(values[0]),float.Parse(values[1]),float.Parse(values[2]));
}
/*
string savedString = PlayerPrefs.GetString(SceneManager.GetActiveScene().name + "eyePosition");
string[] values = savedString.Split(' ');
@ -99,6 +123,6 @@ public class MonsterManager : MonoBehaviour {
values = savedString.Split(' ');
GameObject.Find("pig_nose").transform.position = new Vector3(float.Parse(values[0]),float.Parse(values[1]),float.Parse(values[2]));
*/
}
}

View file

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NavigationManager : MonoBehaviour
{
private GameObject navMenu;
public void Start()
{
//navMenu = GameObject.Find("Navigation Menu");
navMenu = gameObject.transform.Find("Navigation Menu").gameObject;
}
public void OpenNavMenu()
{
navMenu.SetActive (true);
}
public void CloseNavMenu()
{
navMenu.SetActive (false);
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 658e48ac784a5d543bc76161835f7156
timeCreated: 1524750227
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -26,6 +26,14 @@ public class SceneLoader : MonoBehaviour {
if (!(SceneManager.GetActiveScene ().name == "StepCounter"))
SceneManager.LoadScene ("StepCounter");
break;
case "Profile":
if (!(SceneManager.GetActiveScene ().name == "Stats"))
SceneManager.LoadScene ("Stats");
break;
case "Monster Creator":
if (!(SceneManager.GetActiveScene ().name == "MonsterCreator"))
SceneManager.LoadScene ("MonsterCreator");
break;
default:
if (!(SceneManager.GetActiveScene ().name == scenetext))
SceneManager.LoadScene (scenetext);

View file

@ -1 +1,5 @@
<<<<<<< HEAD
m_EditorVersion: 2017.4.0f1
=======
m_EditorVersion: 2017.3.1f1
>>>>>>> alex