# HG changeset patch # User Kazuma Takeda # Date 1486468166 -32400 # Node ID e297afe0889d64ce0e532d5218ae838392d0a6b7 # Parent b55d586dd4ebb2ca06c35061d51d40b5b322f12b Add Prefab. diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/BoxItem.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/BoxItem.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,37 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BoxItem : Item { + + public int Broken = 2; + private int nowBroken = 2; + public string ColorCode = ""; + + public void SetItem (BoxItemInfo item, int index) { + Broken = item.Broken; + nowBroken = Broken; + Type = item.Type; + itemID = item.itemID; + indexID = index; + ColorCode = item.ColorCode; + SetColor (this.ColorCode); + } + + public override void Delete() { + if (nowBroken == 0) { + DeleteTreeNode (); + Destroy (this.gameObject); + return; + } + nowBroken -= 1; + } + + public void SetColor (string code) { + Color color; + ColorUtility.TryParseHtmlString(code, out color); + this.GetComponent ().material.color = color; + } + + +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/BoxItem.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/BoxItem.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9ac54382ce059447295202f2283e0b07 +timeCreated: 1485770559 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/BoxItemInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/BoxItemInfo.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BoxItemInfo : ItemInfo { + + public string Type; + public int Broken = 2; + public int indexID = 0; + public int itemID = 1; + public string ColorCode = ""; + + public BoxItemInfo (int item_id, int broken, string type, string code) { + itemID = item_id; + this.Broken = broken; + Type = type; + ColorCode = code; + } +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/BoxItemInfo.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/BoxItemInfo.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7fd93b8aac5a64035afefaa020c062d7 +timeCreated: 1485772616 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/FoodItem.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/FoodItem.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FoodItem : Item { + + public int Recovery = 1; + + public void SetItem (FoodItemInfo item, int index) + { + Recovery = item.Recover; + itemID = item.itemID; + } + + private void OnTriggerEnter (Collider col) { + Player.Instance.Recovery (Recovery); + Destroy (this.gameObject); + } +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/FoodItem.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/FoodItem.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7d2f3d374a80647ba8e234bdc4730923 +timeCreated: 1485771025 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/FoodItemInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/FoodItemInfo.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FoodItemInfo : ItemInfo { + + public string Type; + public int Recover = 1; + public int indexID = 0; + public int itemID = 1; + + public FoodItemInfo (int item_id, int recover, string type) { + itemID = item_id; + Recover = recover; + Type = type; + } +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/FoodItemInfo.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/FoodItemInfo.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f1891153e1b7b4e2aaccdcce648ae686 +timeCreated: 1485772852 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/Test/Functor.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/Test/Functor.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +public class Functor { + + public static List map (System.Func f, List list) { + List newList = new List (); + foreach (var num in list) { + newList.Add (f (num)); + } + return newList; + } +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/Test/Functor.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/Test/Functor.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6325dea50cfc426c857b48368e8c0b2 +timeCreated: 1485784321 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/Test/FunctorTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/Test/FunctorTest.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,37 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FunctorTest : MonoBehaviour { + + private List list = new List(){ 1, 2, 3, 4, 5 }; + private List slist = new List() { "Hello", "World" }; + + private void Start () { + System.Func f = (int arg) => { + return arg * 2; + }; + + list = Functor.map (f, list); + + print (getString (list)); + + System.Func fs = (string arg) => { + return arg + "(ΦωΦ)"; + }; + + slist = Functor.map (fs, slist); + + print (getString(slist)); + } + + private string getString (List l) { + string s = "["; + foreach (T n in l) { + s += n + ", "; + } + s = s.Remove (s.Length - 1); + s += "]"; + return s; + } +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/Test/FunctorTest.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/Test/FunctorTest.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ba8e8b8be663349ba93ce85137e02b04 +timeCreated: 1485786719 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/Test/SaveData.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/Test/SaveData.cs Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,210 @@ +using UnityEngine; +using UnityEditor; +using System.Collections; +using UnityEngine.SceneManagement; +using JungleDB; +using System.Text; +using Default = System.Collections.Generic; +using System.Linq; + +public class SaveData : MonoBehaviour { + + public static SaveData instance; + + public SceneNode root; + public System.Collections.Generic.List objList; + public StageManager stageManager; + + public static Jungle jungle; + private JungleTree tree; + private JungleTreeEditor editor; + private NodePath rootPath; + + public delegate void Callback (); + public Callback callback; + + /// + /// Jungleの木を構築し終わった時に実行するメソッドをセット + /// + public void AddCallback (Callback c) { + this.callback = c; + print ("Add : " + callback.Method); + } + + private void initJungle () { + jungle = new DefaultJungle (null, "Game", new DefaultTreeEditor(new DefaultTraverser())); + tree = jungle.createNewTree ("Scene"); + rootPath = new DefaultNodePath (); + // 編集を可能にする + editor = tree.getTreeEditor (); + editor = editor.addNewChildAt (rootPath, 0).b(); + } + + private void Awake () { + if (instance == null) + instance = this; + } + + private void Start () { + initJungle (); + CreateSceneTree (); + CreateItemTree (); + } + + private void CreateTree () { + GameObject rootObj = new GameObject (); + rootObj.name = "Root"; + root = new SceneNode(rootObj, null); + } + + private void Check () { + int i = 0; + foreach (GameObject obj in UnityEngine.Resources.FindObjectsOfTypeAll(typeof(GameObject))) { + string path = AssetDatabase.GetAssetOrScenePath (obj); + bool isScene = path.Contains (".unity"); + if (isScene) { // このシーンの中のオブジェクトかどうか。 + if (obj.transform.childCount == 0 && obj.transform.parent == null || obj.transform.childCount > 0 && obj.transform.parent == null) { // 親を取得 + objList.Add(obj); + i++; + } + } + } + + foreach (var obj in objList) { + SceneNode node = new SceneNode (obj, root); + root.AddChild (node); + CheckChild (obj.transform, node); + } + } + + private void CheckChild (Transform obj, SceneNode parent) { + if (obj.childCount == 0) + return; + + for (int i = 0; i < obj.childCount; i++) { + SceneNode node = new SceneNode (obj.GetChild (i).gameObject, parent); + parent.AddChild (node); + CheckChild (obj.GetChild (i), node); + } + } + + private bool CreateNode (NodePath path, int num) { + Either e = editor.addNewChildAt (path, num); + if (e.isA ()) { + e.a (); + return false; + } + editor = e.b (); + return true; + } + + private bool SetAttribute (NodePath path, GameObject obj) { + // Either e = editor.putAttribute (path, key, Encoding.UTF8.GetBytes(val)); + Either e = editor.putAttribute (path, "NodeName", Encoding.UTF8.GetBytes(obj.name)); + if (e.isA ()) { + e.a (); + return false; + } + editor = e.b (); + return true; + } + + private void CreateItemTree () { + JungleTree tree = jungle.createNewTree ("ItemTree"); + JungleTreeEditor edt = tree.getTreeEditor (); + + + Either either = edt.putAttribute (rootPath, "TreeName", "Item"); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.addNewChildAt (rootPath, 0); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute ("Category", "Box"); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.addNewChildAt (rootPath, 1); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute ("Category", "Food"); + }); + + NodePath path = rootPath.add(0); + + Default.List infoList = new Default.List (); + infoList.Add (new BoxItemInfo (1, 2, "Grass", "#019540FF")); + infoList.Add (new BoxItemInfo (2, 4, "Wood", "#7F3C01FF")); + infoList.Add (new BoxItemInfo (3, 1, "Sand", "#D4500EFF")); + infoList.Add (new BoxItemInfo (4, 5, "Water", "#2432ADFF")); + + foreach (var info in infoList.Select((v, i) => new {v, i})) { + either = either.bind ((JungleTreeEditor arg) => { + return arg.addNewChildAt (path, info.i); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute (info.v); + }); + } + + + + Default.List foodinfoList = new Default.List(); + + foodinfoList.Add (new FoodItemInfo (1, 1, "Apple")); + foodinfoList.Add (new FoodItemInfo (1, 2, "Apple")); + + path = rootPath.add(1); + + foreach (var info in foodinfoList.Select((v, i) => new {v, i})) { + either = either.bind ((JungleTreeEditor arg) => { + return arg.addNewChildAt (path, info.i); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute (info.v); + }); + } + + either = either.bind ((JungleTreeEditor arg) => { + return arg.commit(); + }); + + StageManager.Instance.Init (); + } + + private void CreateSceneTree () { + JungleTree tree = jungle.createNewTree ("SceneTree"); + JungleTreeEditor edt = tree.getTreeEditor (); + + Either either = edt.addNewChildAt (rootPath, 0); + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute ("NodeName", "Player"); + }); + + NodePath playerpath = rootPath.add (0); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.addNewChildAt (playerpath, 0); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute ("NodeName", "HaveItems"); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.addNewChildAt (rootPath, 1); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.putAttribute ("NodeName", "Stage"); + }); + + either = either.bind ((JungleTreeEditor arg) => { + return arg.commit(); + }); + } +} diff -r b55d586dd4eb -r e297afe0889d Assets/Application/Scripts/Test/SaveData.cs.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/Test/SaveData.cs.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d60bcdafb38514a3c9f1b87b560a3fc7 +timeCreated: 1486458740 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/FoodAndGrocery.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/FoodAndGrocery.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0bba42349dc9844ab89964bacb121ac3 +folderAsset: yes +timeCreated: 1485769270 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff -r b55d586dd4eb -r e297afe0889d Assets/Resources/Prefabs/Food/Apple.prefab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Resources/Prefabs/Food/Apple.prefab Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,180 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1869640907416072} + m_IsPrefabParent: 1 +--- !u!1 &1739482974270848 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4054705966430378} + - component: {fileID: 33034695268266552} + - component: {fileID: 23155390794677728} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1869640907416072 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4682682350430226} + - component: {fileID: 33806217672893342} + - component: {fileID: 23764967093415192} + - component: {fileID: 114995837577296548} + - component: {fileID: 136090960781236260} + m_Layer: 0 + m_Name: Apple + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4054705966430378 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1739482974270848} + 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_Children: [] + m_Father: {fileID: 4682682350430226} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4682682350430226 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1869640907416072} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 10, y: 10, z: 10} + m_Children: + - {fileID: 4054705966430378} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23155390794677728 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1739482974270848} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: c6be255c1425f6e4d9a49a40d9f32910, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!23 &23764967093415192 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1869640907416072} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: fd84161baee1c8447a56f61f2c071246, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &33034695268266552 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1739482974270848} + m_Mesh: {fileID: 4300002, guid: 094627802cc8b7849aed1eb1a64bbe75, type: 3} +--- !u!33 &33806217672893342 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1869640907416072} + m_Mesh: {fileID: 4300000, guid: 094627802cc8b7849aed1eb1a64bbe75, type: 3} +--- !u!114 &114995837577296548 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1869640907416072} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7d2f3d374a80647ba8e234bdc4730923, type: 3} + m_Name: + m_EditorClassIdentifier: + Type: Apple + indexID: 0 + itemID: 1 + Recovery: 1 +--- !u!136 &136090960781236260 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1869640907416072} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + m_Radius: 0.040475793 + m_Height: 0.058183663 + m_Direction: 1 + m_Center: {x: 0, y: 0.029248841, z: -0.000000016763806} diff -r b55d586dd4eb -r e297afe0889d Assets/Resources/Prefabs/Food/Apple.prefab.meta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Resources/Prefabs/Food/Apple.prefab.meta Tue Feb 07 20:49:26 2017 +0900 @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 271cb05a5979246ba89d65dee6bceb76 +timeCreated: 1485772317 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: