random items + monster draw script for home
This commit is contained in:
parent
aff276ff78
commit
c8777e958a
4 changed files with 53 additions and 0 deletions
Binary file not shown.
|
@ -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
|
||||
|
|
32
MoCha/Assets/Scripts/MonsterDraw.cs
Normal file
32
MoCha/Assets/Scripts/MonsterDraw.cs
Normal 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]));
|
||||
}
|
||||
}
|
||||
}
|
13
MoCha/Assets/Scripts/MonsterDraw.cs.meta
Normal file
13
MoCha/Assets/Scripts/MonsterDraw.cs.meta
Normal 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:
|
Reference in a new issue