changeset 12:b55d586dd4eb

change bind from fmap.
author Kazuma Takeda
date Tue, 07 Feb 2017 20:48:57 +0900
parents cf20add31466
children e297afe0889d
files .hgignore Assets/Application/Scenes/main.unity Assets/Application/Scripts/DeathZone.cs Assets/Application/Scripts/Item.cs Assets/Application/Scripts/ItemInfo.cs Assets/Application/Scripts/ItemInfo.cs.meta Assets/Application/Scripts/Player.cs Assets/Application/Scripts/StageManager.cs Assets/Application/Scripts/Test/GetComponentTest.cs Assets/Resources/Prefabs/Box/Box.prefab Assets/Resources/Prefabs/UI/Item.prefab ProjectSettings/EditorBuildSettings.asset README.md obj/Debug/Assembly-CSharp.dll obj/Debug/Assembly-CSharp.dll.mdb
diffstat 15 files changed, 118 insertions(+), 138 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Jan 28 19:15:44 2017 +0900
+++ b/.hgignore	Tue Feb 07 20:48:57 2017 +0900
@@ -10,3 +10,4 @@
 ^Build/.*
 ^Library/.*
 ^Temp/.*
+Assets/FoodAndGrocery/.*
--- a/Assets/Application/Scenes/main.unity	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scenes/main.unity	Tue Feb 07 20:48:57 2017 +0900
@@ -178,7 +178,7 @@
   m_GameObject: {fileID: 341164809}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 13c905b30e8904afeb6af0ada5e3f8ba, type: 3}
+  m_Script: {fileID: 11500000, guid: d60bcdafb38514a3c9f1b87b560a3fc7, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
   root:
@@ -186,7 +186,7 @@
     Name: 
     m_childs: []
   objList: []
-  stageManager: {fileID: 2000853426}
+  stageManager: {fileID: 0}
 --- !u!4 &341164811
 Transform:
   m_ObjectHideFlags: 0
--- a/Assets/Application/Scripts/DeathZone.cs	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/DeathZone.cs	Tue Feb 07 20:48:57 2017 +0900
@@ -5,7 +5,7 @@
 public class DeathZone : MonoBehaviour {
 
 	private GameObject target;
-	private Vector3 firstPoint = new Vector3(0.5f, 2f, 0.5f);
+	private Vector3 firstPoint;
 
 	public delegate void HitCallback (int n);
 	public HitCallback hitcallback;
@@ -16,6 +16,7 @@
 
 	private void Start () {
 		target = GameObject.FindGameObjectWithTag ("Player");
+		firstPoint = target.transform.position;
 	}
 
 	private void Update () {
--- a/Assets/Application/Scripts/Item.cs	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/Item.cs	Tue Feb 07 20:48:57 2017 +0900
@@ -3,60 +3,28 @@
 using JungleDB;
 using System.Text;
 using System;
+
+/// <summary>
+/// Base Item Class.
+/// </summary>
 public class Item : MonoBehaviour {
 
 	public string Type;
-	public GameObject ItemImage;
-	public int Broken = 2;
-	private int nowBroken = 2;
 	public int indexID = 0;
 	public int itemID = 1;
-	public string ColorCode = "";
 
-	private Jungle jungle;
-
-	public void SetItem (ItemInfo item, int index) {
-		this.Broken = item.Broken;
-		nowBroken   = Broken;
-		Type        = item.Type;
-		itemID      = item.itemID;
-		indexID     = index;
-		ColorCode   = item.ColorCode;
-		SetColor (this.ColorCode);
-	}
-
-	public void SetItem (int broken, string type, string item_id, int index, string code) {
-		this.Broken = broken;
-		nowBroken   = Broken;
-		Type        = type;
-		itemID      = Convert.ToInt32(item_id);
-		indexID     = index;
-		SetColor (code);
-	}
+	public Jungle jungle;
 
 	public void SetPosition (Vector3 pos) {
 		this.transform.position = pos;
-		// print ("Set (" + pos.x + ", " + pos.y + ", " + pos.z + ")");
-	}
-
-	public void SetColor (string code) {
-		Color color;
-		ColorUtility.TryParseHtmlString(code, out color);
-		this.GetComponent<MeshRenderer> ().material.color = color;
 	}
 
-	public void Delete() {
-		if (nowBroken == 0) {
-			DeleteTreeNode ();
-			Destroy (this.gameObject);
-			return;
-		}
-
-		nowBroken -= 1;
+	public virtual void Delete() {
+		
 	}
 
 	public void DeleteTreeNode () {
-		jungle = SaveDataTest.jungle;
+		jungle = SaveData.jungle;
 		JungleTree tree      = jungle.getTreeByName ("SceneTree");
 		JungleTreeEditor edt = tree.getTreeEditor ();
 
@@ -74,7 +42,7 @@
 
 
 	public void SetCreateTreeNode () {
-		jungle = SaveDataTest.jungle;
+		jungle = SaveData.jungle;
 		JungleTree tree      = jungle.getTreeByName ("SceneTree");
 		JungleTreeEditor edt = tree.getTreeEditor ();
 
--- a/Assets/Application/Scripts/ItemInfo.cs	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/ItemInfo.cs	Tue Feb 07 20:48:57 2017 +0900
@@ -2,20 +2,6 @@
 using System.Collections.Generic;
 using UnityEngine;
 
-public class ItemInfo {
-
-	public string Type;
-	public int Broken = 2;
-	private int nowBroken = 2;
-	public int indexID = 0;
-	public int itemID = 1;
-	public string ColorCode = "";
-
-	public ItemInfo (int item_id, int broken, string type, string code) {
-		itemID      = item_id;
-		this.Broken = broken;
-		nowBroken   = Broken;
-		Type = type;
-		ColorCode = code;
-	}
+public interface ItemInfo {
+	
 }
--- a/Assets/Application/Scripts/ItemInfo.cs.meta	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/ItemInfo.cs.meta	Tue Feb 07 20:48:57 2017 +0900
@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 1e2feeabde4c94cc5a42dad5a04c43e9
-timeCreated: 1484863090
+guid: 849aabd8549c54925845af7c2a5f80ce
+timeCreated: 1485772629
 licenseType: Free
 MonoImporter:
   serializedVersion: 2
--- a/Assets/Application/Scripts/Player.cs	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/Player.cs	Tue Feb 07 20:48:57 2017 +0900
@@ -100,7 +100,7 @@
 	}
 
 	public void SetPlayerNode () {
-		jungle = SaveDataTest.jungle;
+		jungle = SaveData.jungle;
 		JungleTree tree = jungle.getTreeByName ("SceneTree");
 		JungleTreeEditor edt = tree.getTreeEditor ();
 
@@ -113,21 +113,25 @@
 		SetPlayerNode ();
 	}
 
-	private void Damege (int d) {
+	public void Damege (int d) {
 		this.HP -= d;
 		UpdatePlayerNode ();
 	}
 
+	public void Recovery (int d) {
+		if (this.HP < BASEHP) {
+			this.HP += d;
+			UpdatePlayerNode ();
+		}
+	}
+
 	private void UpdatePlayerNode () {
-		jungle = SaveDataTest.jungle;
+		jungle = SaveData.jungle;
 		JungleTree tree = jungle.getTreeByName ("SceneTree");
 		JungleTreeEditor edt = tree.getTreeEditor ();
 
 		NodePath playerpath = new DefaultNodePath ().add (0);
-		Either<Error, JungleTreeEditor> e = edt.putAttribute (playerpath, this);
-		// e.fmap (edt.commit ());
-
-
+		edt.putAttribute (playerpath, this).b ();
 	}
 
 }
--- a/Assets/Application/Scripts/StageManager.cs	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/StageManager.cs	Tue Feb 07 20:48:57 2017 +0900
@@ -51,7 +51,7 @@
 		baseStage.transform.position = Vector3.zero;
 		GameObject.FindGameObjectWithTag ("Player").transform.SetParent (baseStage.transform);
 
-		jungle = SaveDataTest.jungle;
+		jungle = SaveData.jungle;
 		CreateStage (15);
 	}
 
@@ -85,14 +85,34 @@
 		TreeNode item_node = getItem (box_node, ItemID);
 
 		attr = item_node.getAttributes ();
-		ItemInfo iteminfo = attr.get<ItemInfo> ("ItemInfo");
+		BoxItemInfo iteminfo = attr.get<BoxItemInfo> ("BoxItemInfo");
 
 		GameObject item = Resources.Load<GameObject> ("Prefabs/" + type + "/Box");
 		GameObject obj = Instantiate (item);
-		obj.GetComponent<Item> ().SetItem (iteminfo ,TotalIndex);
+		obj.GetComponent<BoxItem> ().SetItem (iteminfo ,TotalIndex);
 		obj.transform.position = new Vector3 (v.x, v.y, v.z);
 		obj.transform.SetParent (baseStage.transform);
-		obj.GetComponent<Item> ().SetCreateTreeNode ();
+		obj.GetComponent<BoxItem> ().SetCreateTreeNode ();
+
+		AddTotalIndex ();
+	}
+
+	public void CreateFood (GameObject target, int ItemID) {
+		TreeNode food_node = getTypeItem (1);
+		Attributes attr = food_node.getAttributes ();
+		string type = attr.getString ("Category");
+
+		TreeNode item_node = getItem (food_node, ItemID);
+
+		attr = item_node.getAttributes ();
+		FoodItemInfo iteminfo = attr.get<FoodItemInfo> ("FoodItemInfo");
+
+		GameObject item = Resources.Load<GameObject> ("Prefabs/" + type + "/" + iteminfo.Type);
+		GameObject obj = Instantiate (item);
+		obj.GetComponent<FoodItem> ().SetItem (iteminfo , TotalIndex);
+		obj.transform.position = target.transform.position + Vector3.up;
+		obj.transform.SetParent (baseStage.transform);
+		obj.GetComponent<FoodItem> ().SetCreateTreeNode ();
 
 		AddTotalIndex ();
 	}
@@ -105,13 +125,14 @@
 		GameObject obj = Instantiate (Resources.Load<GameObject> ("Prefabs/" + type + "/Box"));
 		obj.transform.position = new Vector3 (v.x, v.y, v.z);
 		obj.transform.SetParent (baseStage.transform);
-		obj.GetComponent<Item> ().SetCreateTreeNode ();
+		obj.GetComponent<BoxItem> ().SetCreateTreeNode ();
 		SetY(obj, box_node);
 		AddTotalIndex ();
 	}
 
+	// Box is 0, Food is 1.
 	public TreeNode getTypeItem (int typeID) {
-		jungle = SaveDataTest.jungle;
+		jungle = SaveData.jungle;
 		JungleTree tree = jungle.getTreeByName ("ItemTree");
 		TreeNode node = tree.getRootNode ();
 		Children child = node.getChildren ();
@@ -119,8 +140,8 @@
 	}
 
 	public TreeNode getItem (TreeNode node, int itemID) {
-		Children box_child = node.getChildren ();
-		TreeNode item_node = box_child.at (itemID).b ();
+		Children child = node.getChildren ();
+		TreeNode item_node = child.at (itemID).b ();
 		return item_node;
 	}
 
@@ -159,6 +180,8 @@
 
 		if(y > _maxHeight * 0.3f){ // grass
 			item_id = 0;
+			// Randomで回復をつくる
+			CreateRandomFood(cube);
 		}
 		else if(y > _maxHeight * 0.2f){ // maguma
 			item_id = 1;
@@ -170,12 +193,16 @@
 		TreeNode item_node = getItem (node, item_id);
 		Attributes attr = item_node.getAttributes ();
 
-//		string subType = attr.getString ("Type");
-//		string broken = attr.getString ("Broken");
-//		string color_code = attr.getString ("Color");
+		BoxItemInfo item = attr.get<BoxItemInfo>("BoxItemInfo");
+
+		cube.GetComponent<BoxItem> ().SetItem (item, TotalIndex);
+	}
 
-		ItemInfo item = attr.get<ItemInfo>("ItemInfo");
+	public void CreateRandomFood(GameObject obj) {
+		int ran = UnityEngine.Random.Range (1, 11);
 
-		cube.GetComponent<Item> ().SetItem (item, TotalIndex);
+		if (ran == 10) {
+			CreateFood (obj, 0);
+		}
 	}
 }
--- a/Assets/Application/Scripts/Test/GetComponentTest.cs	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Application/Scripts/Test/GetComponentTest.cs	Tue Feb 07 20:48:57 2017 +0900
@@ -28,29 +28,29 @@
 			st.Stop ();
 			total_as += st.Elapsed.TotalMilliseconds;
 
-//			Stopwatch st = new Stopwatch ();
-//			st.Start ();
-//			for (int i = 0; i < 10000; i++) {
-//				GameObject obj = Resources.Load<GameObject> ("Prefabs/Box/Wood");
-//			}
-//			st.Stop ();
-//			total_generic += st.Elapsed.TotalMilliseconds;
+			st = new Stopwatch ();
+			st.Start ();
+			for (int i = 0; i < 10000; i++) {
+				GameObject obj = Resources.Load<GameObject> ("Prefabs/Box/Wood");
+			}
+			st.Stop ();
+			total_generic += st.Elapsed.TotalMilliseconds;
 
-//			Stopwatch st = new Stopwatch ();
-//			st.Start ();
-//			for (int i = 0; i < 10000; i++) {
-//				GameObject obj = (GameObject) Resources.Load ("Prefabs/Box/Wood");
-//			}
-//			st.Stop ();
-//			total_basic += st.Elapsed.TotalMilliseconds;
-//
-//			Stopwatch st = new Stopwatch ();
-//			st.Start ();
-//			for (int i = 0; i < 10000; i++) {
-//				GameObject obj = (GameObject) Resources.Load ("Prefabs/Box/Wood", typeof(GameObject));
-//			}
-//			st.Stop ();
-//			total_basic_typeof += st.Elapsed.TotalMilliseconds;
+			st = new Stopwatch ();
+			st.Start ();
+			for (int i = 0; i < 10000; i++) {
+				GameObject obj = (GameObject) Resources.Load ("Prefabs/Box/Wood");
+			}
+			st.Stop ();
+			total_basic += st.Elapsed.TotalMilliseconds;
+
+			st = new Stopwatch ();
+			st.Start ();
+			for (int i = 0; i < 10000; i++) {
+				GameObject obj = (GameObject) Resources.Load ("Prefabs/Box/Wood", typeof(GameObject));
+			}
+			st.Stop ();
+			total_basic_typeof += st.Elapsed.TotalMilliseconds;
 		}
 
 		print ("as average : " + total_as / (double)times + "ms");
--- a/Assets/Resources/Prefabs/Box/Box.prefab	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Resources/Prefabs/Box/Box.prefab	Tue Feb 07 20:48:57 2017 +0900
@@ -22,7 +22,7 @@
   - component: {fileID: 33957246196885898}
   - component: {fileID: 65589921752900166}
   - component: {fileID: 23379175062371458}
-  - component: {fileID: 114663259294617812}
+  - component: {fileID: 114058153441403744}
   m_Layer: 0
   m_Name: Box
   m_TagString: Untagged
@@ -93,7 +93,7 @@
   serializedVersion: 2
   m_Size: {x: 1, y: 1, z: 1}
   m_Center: {x: 0, y: 0, z: 0}
---- !u!114 &114663259294617812
+--- !u!114 &114058153441403744
 MonoBehaviour:
   m_ObjectHideFlags: 1
   m_PrefabParentObject: {fileID: 0}
@@ -101,11 +101,11 @@
   m_GameObject: {fileID: 1842352747018166}
   m_Enabled: 1
   m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: e7da059c53f184f25b10e6cf3ab6ff50, type: 3}
+  m_Script: {fileID: 11500000, guid: 9ac54382ce059447295202f2283e0b07, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  Type: Grass
-  ItemImage: {fileID: 1000013311403138, guid: a659ec777bec841449e04d3d31b19701, type: 2}
+  Type: 
+  indexID: 0
+  itemID: 1
   Broken: 2
-  indexID: 0
-  itemID: 0
+  ColorCode: 
--- a/Assets/Resources/Prefabs/UI/Item.prefab	Sat Jan 28 19:15:44 2017 +0900
+++ b/Assets/Resources/Prefabs/UI/Item.prefab	Tue Feb 07 20:48:57 2017 +0900
@@ -16,11 +16,11 @@
   m_ObjectHideFlags: 0
   m_PrefabParentObject: {fileID: 0}
   m_PrefabInternal: {fileID: 100100000}
-  serializedVersion: 4
+  serializedVersion: 5
   m_Component:
-  - 224: {fileID: 224000014090711128}
-  - 222: {fileID: 222000011575121610}
-  - 114: {fileID: 114000011469297796}
+  - component: {fileID: 224000014090711128}
+  - component: {fileID: 222000011575121610}
+  - component: {fileID: 114000011469297796}
   m_Layer: 5
   m_Name: Text
   m_TagString: Untagged
@@ -33,13 +33,12 @@
   m_ObjectHideFlags: 0
   m_PrefabParentObject: {fileID: 0}
   m_PrefabInternal: {fileID: 100100000}
-  serializedVersion: 4
+  serializedVersion: 5
   m_Component:
-  - 224: {fileID: 224000010379115600}
-  - 222: {fileID: 222000013968116500}
-  - 114: {fileID: 114000010780315198}
-  - 114: {fileID: 114000010505465194}
-  - 114: {fileID: 114000011932139556}
+  - component: {fileID: 224000010379115600}
+  - component: {fileID: 222000013968116500}
+  - component: {fileID: 114000010780315198}
+  - component: {fileID: 114000010505465194}
   m_Layer: 5
   m_Name: Item
   m_TagString: Untagged
@@ -159,19 +158,6 @@
     m_VerticalOverflow: 0
     m_LineSpacing: 1
   m_Text: 0
---- !u!114 &114000011932139556
-MonoBehaviour:
-  m_ObjectHideFlags: 1
-  m_PrefabParentObject: {fileID: 0}
-  m_PrefabInternal: {fileID: 100100000}
-  m_GameObject: {fileID: 1000013311403138}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 11f234c01c0fd473c8a707e31a51def2, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  Attribute: 0
-  HaveCount: 0
 --- !u!222 &222000011575121610
 CanvasRenderer:
   m_ObjectHideFlags: 1
@@ -193,11 +179,11 @@
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_Children:
   - {fileID: 224000014090711128}
   m_Father: {fileID: 0}
   m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
@@ -212,10 +198,10 @@
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 0.1, y: 0.1, z: 1}
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_Children: []
   m_Father: {fileID: 224000010379115600}
   m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.8, y: 0}
   m_AnchorMax: {x: 1, y: 0.2}
   m_AnchoredPosition: {x: 0, y: 0.0000038146973}
--- a/ProjectSettings/EditorBuildSettings.asset	Sat Jan 28 19:15:44 2017 +0900
+++ b/ProjectSettings/EditorBuildSettings.asset	Tue Feb 07 20:48:57 2017 +0900
@@ -4,4 +4,6 @@
 EditorBuildSettings:
   m_ObjectHideFlags: 0
   serializedVersion: 2
-  m_Scenes: []
+  m_Scenes:
+  - enabled: 1
+    path: Assets/Application/Scenes/Test/BenchMarkTest.unity
--- a/README.md	Sat Jan 28 19:15:44 2017 +0900
+++ b/README.md	Tue Feb 07 20:48:57 2017 +0900
@@ -5,7 +5,12 @@
 $ cd Assets/
 $ hg clone http://www.cr.ie.u-ryukyu.ac.jp/hg/Database/jungle-sharp/
 
+import Asset Store
+https://www.assetstore.unity3d.com/jp/#!/content/75494
+
+do not add commit.
+
 # Unity Version
 
 Unity 5.5.0f3
-can not open before version 5.4.
+can not open before version 5.4
Binary file obj/Debug/Assembly-CSharp.dll has changed
Binary file obj/Debug/Assembly-CSharp.dll.mdb has changed