random items + monster draw script for home

This commit is contained in:
Darrel Marek 2018-04-26 10:38:28 -05:00
parent aff276ff78
commit c8777e958a
4 changed files with 53 additions and 0 deletions

Binary file not shown.

View file

@ -4,11 +4,13 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Text;
//Pretty much a copy of GetData...
namespace PedometerU.Tests {
public class GetGoals : MonoBehaviour {
private string[] items = { "circle_eye", "crazy_hair", "circle_head", "gap_mouth", "pig_nose", "crown" };
public Text goalText;
public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
@ -156,6 +158,12 @@ public class GetGoals : MonoBehaviour {
savedPoints += stepsGoal*10;
PlayerPrefs.SetInt("totalPoints", savedPoints);
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
//Random item
StringBuilder invList = new StringBuilder ();
invList.Append(PlayerPrefs.GetString ("inventory"));
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
PlayerPrefs.SetString ("inventory", invList.ToString());
}
//only applies if "daily" goal

View file

@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonsterDraw : MonoBehaviour {
public GameObject anchorPoint;
private Vector2 anchorPos;
void Start()
{
anchorPos = new Vector2 (anchorPoint.transform.position.x, anchorPoint.transform.position.y);
loadMonster();
}
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(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 Vector2(float.Parse(values[0]), float.Parse(values[1]));
}
}
}

View file

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