├── ProjectSettings ├── ProjectVersion.txt ├── ClusterInputManager.asset ├── NetworkManager.asset ├── TimeManager.asset ├── EditorBuildSettings.asset ├── AudioManager.asset ├── TagManager.asset ├── EditorSettings.asset ├── PresetManager.asset ├── UnityConnectSettings.asset ├── DynamicsManager.asset ├── Physics2DSettings.asset ├── NavMeshAreas.asset ├── GraphicsSettings.asset └── QualitySettings.asset ├── Assets ├── RLCreature │ ├── Sample │ │ ├── SimpleHunting │ │ │ ├── README.md │ │ │ ├── SimpleHuntingEntrypoint.cs.meta │ │ │ ├── 20180712_oss_move.gif │ │ │ ├── food_hunting_simple.gif │ │ │ ├── README.md.meta │ │ │ ├── SimpleHunting.unity.meta │ │ │ ├── 20180712_oss_move.gif.meta │ │ │ ├── food_hunting_simple.gif.meta │ │ │ └── SimpleHuntingEntrypoint.cs │ │ ├── Common.meta │ │ ├── Common │ │ │ ├── UI.meta │ │ │ ├── Agent.cs.meta │ │ │ ├── UI │ │ │ │ ├── Actions.meta │ │ │ │ ├── Actions │ │ │ │ │ ├── SystemActions.cs.meta │ │ │ │ │ └── SystemActions.cs │ │ │ │ ├── UIComponents │ │ │ │ │ ├── IToolBarActions.cs.meta │ │ │ │ │ ├── IToolBarActions.cs │ │ │ │ │ ├── CreatureInfoCell.cs.meta │ │ │ │ │ ├── CreatureInfoList.cs.meta │ │ │ │ │ ├── ToolBar.cs.meta │ │ │ │ │ ├── CastUIView.cs.meta │ │ │ │ │ ├── ToolBarCell.cs.meta │ │ │ │ │ ├── ToolBarCell.cs │ │ │ │ │ ├── CastUIView.cs │ │ │ │ │ ├── CreatureInfoCell.cs │ │ │ │ │ ├── CreatureInfoList.cs │ │ │ │ │ └── ToolBar.cs │ │ │ │ ├── Cameras │ │ │ │ │ ├── SubCameras │ │ │ │ │ │ ├── IFocusStrategy.cs │ │ │ │ │ │ ├── SubCamera.cs.meta │ │ │ │ │ │ ├── AgentFocusStrategy.cs.meta │ │ │ │ │ │ ├── IFocusStrategy.cs.meta │ │ │ │ │ │ ├── SubCamera.cs │ │ │ │ │ │ └── AgentFocusStrategy.cs │ │ │ │ │ ├── SubCameras.meta │ │ │ │ │ ├── OperatableCameras.meta │ │ │ │ │ ├── CameraAttitude.cs.meta │ │ │ │ │ ├── OperatableCameras │ │ │ │ │ │ ├── FocusCamera.cs.meta │ │ │ │ │ │ ├── MonitoringCamera.cs.meta │ │ │ │ │ │ ├── RokuroCamera.cs.meta │ │ │ │ │ │ ├── IOperatableCamera.cs.meta │ │ │ │ │ │ ├── PolarCoordinatesAttitude.cs.meta │ │ │ │ │ │ ├── IOperatableCamera.cs │ │ │ │ │ │ ├── RokuroCamera.cs │ │ │ │ │ │ ├── MonitoringCamera.cs │ │ │ │ │ │ ├── PolarCoordinatesAttitude.cs │ │ │ │ │ │ └── FocusCamera.cs │ │ │ │ │ └── CameraAttitude.cs │ │ │ │ ├── Cameras.meta │ │ │ │ ├── UIComponents.meta │ │ │ │ ├── FallbackedEventReceiver.cs.meta │ │ │ │ ├── CastUIPresenter.cs.meta │ │ │ │ ├── CastCameraController.cs.meta │ │ │ │ ├── SelectableCreature.cs.meta │ │ │ │ ├── FallbackPhysicsRaycaster.cs.meta │ │ │ │ ├── FallbackPhysicsRaycaster.cs │ │ │ │ ├── SelectableCreature.cs │ │ │ │ ├── FallbackedEventReceiver.cs │ │ │ │ ├── CastCameraController.cs │ │ │ │ └── CastUIPresenter.cs │ │ │ ├── EntryPointUtility.cs.meta │ │ │ ├── TimescaleSwitcher.cs.meta │ │ │ ├── ManipulatableInitializer.cs.meta │ │ │ ├── TimescaleSwitcher.cs │ │ │ ├── ManipulatableInitializer.cs │ │ │ ├── EntryPointUtility.cs │ │ │ └── Agent.cs │ │ ├── UI │ │ │ ├── Cursor.psd │ │ │ ├── Resources.meta │ │ │ ├── Resources │ │ │ │ ├── CreatureListElement.prefab.meta │ │ │ │ ├── SampleServerUICanvas.prefab.meta │ │ │ │ ├── ToolBarElement.prefab.meta │ │ │ │ └── ToolBarCategoryElement.prefab.meta │ │ │ ├── ReservedUIMaterial.mat.meta │ │ │ ├── Cursor.psd.meta │ │ │ └── ReservedUIMaterial.mat │ │ ├── SimpleHunting.meta │ │ ├── VariousHeights.meta │ │ ├── DesignedCreatures.meta │ │ ├── Driving │ │ │ ├── CarControlManipulatable.cs.meta │ │ │ ├── driving.gif │ │ │ ├── README.md │ │ │ ├── README.md.meta │ │ │ ├── Driving.unity.meta │ │ │ ├── Resources.meta │ │ │ ├── Resources │ │ │ │ ├── Prefabs.meta │ │ │ │ └── Prefabs │ │ │ │ │ └── Car.prefab.meta │ │ │ ├── DrivingEntrypoint.cs.meta │ │ │ ├── CarControlManipulatable.cs │ │ │ ├── driving.gif.meta │ │ │ └── DrivingEntrypoint.cs │ │ ├── RandomCreatures │ │ │ ├── RandomNameGenerator.cs.meta │ │ │ ├── RandomCreatures.unity.meta │ │ │ ├── Resources.meta │ │ │ ├── Resources │ │ │ │ ├── Prefabs.meta │ │ │ │ └── Prefabs │ │ │ │ │ ├── CubeArm.prefab.meta │ │ │ │ │ ├── CubeArm2.prefab.meta │ │ │ │ │ ├── CubeBody 1.prefab.meta │ │ │ │ │ ├── CubeBody.prefab.meta │ │ │ │ │ ├── CubeBody2.prefab.meta │ │ │ │ │ ├── CapsuleBody1.prefab.meta │ │ │ │ │ ├── CylinderBody1.prefab.meta │ │ │ │ │ └── SphereBody1.prefab.meta │ │ │ ├── RandomCreaturesEntryPoint.cs.meta │ │ │ ├── RandomNameGenerator.cs │ │ │ └── RandomCreaturesEntryPoint.cs │ │ ├── Resources │ │ │ ├── Materials │ │ │ │ ├── Block.psd │ │ │ │ ├── Body.mat.meta │ │ │ │ ├── Food.mat.meta │ │ │ │ ├── Ground.mat.meta │ │ │ │ ├── Body.mat │ │ │ │ ├── Food.mat │ │ │ │ ├── Ground.mat │ │ │ │ └── Block.psd.meta │ │ │ └── Materials.meta │ │ ├── VariousHeights │ │ │ ├── VariousHeightsEntrypoint.cs.meta │ │ │ ├── VariousHeights.gif │ │ │ ├── README.md.meta │ │ │ ├── VariousHeights.unity.meta │ │ │ ├── README.md │ │ │ ├── VariousHeights.gif.meta │ │ │ └── VariousHeightsEntrypoint.cs │ │ ├── DesignedCreatures │ │ │ ├── DesignedCreaturesEntryPoint.cs.meta │ │ │ ├── DesignedCreatures.unity.meta │ │ │ ├── CreaturePrefabs.meta │ │ │ ├── Trail.mat.meta │ │ │ ├── Agent.physicMaterial.meta │ │ │ ├── Ground.physicMaterial.meta │ │ │ ├── CreaturePrefabs │ │ │ │ ├── GymAnt.prefab.meta │ │ │ │ ├── CapsuleCreature.prefab.meta │ │ │ │ ├── PlaneCubesCreature.prefab.meta │ │ │ │ └── VerticalCubesCreature.prefab.meta │ │ │ ├── Agent.physicMaterial │ │ │ ├── Ground.physicMaterial │ │ │ ├── Trail.mat │ │ │ └── DesignedCreaturesEntryPoint.cs │ │ ├── UI.meta │ │ ├── Driving.meta │ │ ├── Resources.meta │ │ └── RandomCreatures.meta │ ├── BodyGenerator │ │ ├── Body.cs.meta │ │ ├── Manipulatables.meta │ │ ├── Manipulatables │ │ │ ├── Joint.cs.meta │ │ │ ├── Mouth.cs.meta │ │ │ ├── Sensor.cs.meta │ │ │ ├── ManipulatableBase.cs.meta │ │ │ ├── SuperFlexibleMove.cs.meta │ │ │ ├── IManipulatable.cs.meta │ │ │ ├── IManipulatable.cs │ │ │ ├── ManipulatableBase.cs │ │ │ ├── Mouth.cs │ │ │ ├── Sensor.cs │ │ │ ├── SuperFlexibleMove.cs │ │ │ └── Joint.cs │ │ ├── JointGenerator │ │ │ ├── BodyComponent.cs.meta │ │ │ ├── JointGenerator.cs.meta │ │ │ ├── MasterConnector.cs.meta │ │ │ ├── SlaveConnector.cs.meta │ │ │ ├── TreeJointGenerator.cs.meta │ │ │ ├── SlaveConnector.cs │ │ │ ├── MasterConnector.cs │ │ │ ├── JointGenerator.cs │ │ │ ├── TreeJointGenerator.cs │ │ │ └── BodyComponent.cs │ │ ├── JointGenerator.meta │ │ └── Body.cs │ ├── Sample.meta │ └── BodyGenerator.meta ├── Packages │ ├── MathNet.Numerics │ │ ├── net40 │ │ │ ├── MathNet.Numerics.dll.mdb │ │ │ ├── MathNet.Numerics.dll │ │ │ ├── MathNet.Numerics.dll.mdb.meta │ │ │ ├── MathNet.Numerics.xml.meta │ │ │ └── MathNet.Numerics.dll.meta │ │ ├── license.txt.meta │ │ ├── readme.txt.meta │ │ ├── MathNet.Numerics.fsx.meta │ │ ├── net40.meta │ │ ├── MathNet.Numerics.IfSharp.fsx.meta │ │ ├── MathNet.Numerics.fsx │ │ ├── license.txt │ │ └── MathNet.Numerics.IfSharp.fsx │ ├── SimpleJSON.meta │ └── MathNet.Numerics.meta ├── Scripts.meta ├── Packages.meta ├── RLCreature.meta ├── Scenes │ └── SampleScene.unity.meta ├── MotionGenerator.meta └── Scenes.meta ├── .gitattributes ├── docs ├── 20180801_OSS_showcase.gif └── README_ja.md ├── .gitmodules ├── .gitignore ├── LICENSE ├── Packages └── manifest.json └── README.md /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.1.0f2 2 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/README.md: -------------------------------------------------------------------------------- 1 | ![](food_hunting_simple.gif) 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.dll filter=lfs diff=lfs merge=lfs -text 2 | *.gif filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc44b5ad879944688afed489107f4720 3 | timeCreated: 1532776668 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a802192e7834d41828c42657d2e34f5 3 | timeCreated: 1532776725 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Cursor.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwango/RLCreature/HEAD/Assets/RLCreature/Sample/UI/Cursor.psd -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Body.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 012fe544293d4048a075d45cb0e3597a 3 | timeCreated: 1531323874 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/Agent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7c30ae52086498f9b1039c9e7888d24 3 | timeCreated: 1531324329 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b49407d38af04bdf923ccd23d721169b 3 | timeCreated: 1531382754 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8440af9167942aea509656aaf91e249 3 | timeCreated: 1533397698 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Actions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ffdcf090d3343d9b2fb657d0c6ec47c 3 | timeCreated: 1533398441 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 942f709709ee43c79a5680ab014d611f 3 | timeCreated: 1531926404 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46d3adb8045a411eb9d8b3fdbf6fa2ae 3 | timeCreated: 1531323393 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/Joint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: befe7ec36eec4f92a44928435d6020eb 3 | timeCreated: 1531981803 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/Mouth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8f3e7cebbf54d8188ae12f44d1b3bef 3 | timeCreated: 1531745587 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/EntryPointUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6104040c19ce4077b4a78a7686483016 3 | timeCreated: 1533467655 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/Sensor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 904ceb8be4ac468685a6efbf1f37e9fa 3 | timeCreated: 1531728729 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Actions/SystemActions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2354a8a71a164460a3a0d27f21b90196 3 | timeCreated: 1533398602 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/CarControlManipulatable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34f1c2dae7bf419c8e5f287bab0b893c 3 | timeCreated: 1531843475 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/BodyComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eafb84fdf48a4660a0a4285d57896168 3 | timeCreated: 1532239535 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/JointGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7eb87ecae7964846aaee8ca6f7b3c9eb 3 | timeCreated: 1532239258 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/MasterConnector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35391281ca7947febc3689261c16ae96 3 | timeCreated: 1532017649 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/SlaveConnector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ddb8694d8ca4794a4f97dd81ef8f698 3 | timeCreated: 1532017711 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/IToolBarActions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 343ebdcbaa9e461b86dd77150d819dea 3 | timeCreated: 1512023557 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/RandomNameGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0707ea0f72948beacf70d49b12d7452 3 | timeCreated: 1533055348 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Block.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwango/RLCreature/HEAD/Assets/RLCreature/Sample/Resources/Materials/Block.psd -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/SimpleHuntingEntrypoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 423d351394ab40e5911e0dacaa1494c5 3 | timeCreated: 1531382708 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/TreeJointGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd71b79bae3e47258e01a0db78bf2f85 3 | timeCreated: 1533469989 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/ManipulatableBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 948e316e763043b69087ead5fd801b5e 3 | timeCreated: 1531325753 -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/SuperFlexibleMove.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2df5b7205fb46dabca9fd1d7ccc5b0a 3 | timeCreated: 1531323406 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/VariousHeightsEntrypoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72c6360a3c774cd5a795957941979d98 3 | timeCreated: 1533397722 -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/DesignedCreaturesEntryPoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1402115957f4bcdbbc8b751cf89957c 3 | timeCreated: 1531926786 -------------------------------------------------------------------------------- /docs/20180801_OSS_showcase.gif: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fd7480dd0fb16250439d140d77a02dcce8bb0f64e2e8401560b47f9252639521 3 | size 5201982 4 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/net40/MathNet.Numerics.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwango/RLCreature/HEAD/Assets/Packages/MathNet.Numerics/net40/MathNet.Numerics.dll.mdb -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/driving.gif: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c93117d4f52098c96bca2668003a6e31d28823f28d47d540ff8f99542395dc89 3 | size 9920537 4 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/README.md: -------------------------------------------------------------------------------- 1 | ![](driving.gif) 2 | 3 | ## 依存 4 | 5 | - Standard Assets 6 | - https://assetstore.unity.com/packages/essentials/asset-packs/standard-assets-32351 -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/net40/MathNet.Numerics.dll: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:460061091e5228b7c8ba9765a3190eb03af724f0cdd7d2815729dbb7bf94b3bf 3 | size 1544208 4 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/20180712_oss_move.gif: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6987f6dda87cc34ed5cddbe4617928f808f1df050846b83142fb45f57c385da5 3 | size 429454 4 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/VariousHeights.gif: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e473b25d4db7a4d7f17f2b9871b188850237eee07975b357f40f9de0c370ee72 3 | size 861329 4 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/food_hunting_simple.gif: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:874189d31d26591a9427eae826ca5cdb99bd75818421d949ec0aec18af7b4f9e 3 | size 1091430 4 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd692686f95a24f0eae22d2499175a32 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61be14e972a34424090fb28a17b6fca0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed26222bc96c45beb6aebeb1e415b2f3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/SlaveConnector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.BodyGenerator.JointGenerator 4 | { 5 | public class SlaveConnector: MonoBehaviour 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /Assets/MotionGenerator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18069dceeb92c44f7bc05ae81651a1dc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 723b396ea85df4277aec95c0f289564b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a723be14b752f413e942a30e8bf97161 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f704ae4b4f98ae41a0bce26658850c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/license.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d67d78d37db74130aa3c53960a94f76 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/readme.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f38ab9d2129f486ea106c6e8e962709 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Packages/SimpleJSON.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc7584f534f5f459286d1a52deb30647 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras/IFocusStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace RLCreature.Sample.Common.UI.Cameras.SubCameras 2 | { 3 | public interface IFocusStrategy 4 | { 5 | CameraAttitude Update(); 6 | } 7 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/Driving.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf8ce7ebe8abb4796a1c0e707b0dbc5d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92f2b17a3f85f4628a1c1ed1def19572 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88c6c1343269e4795b90da00827cbb6c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/MathNet.Numerics.fsx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69c0d883128404521a8c1069381b1aed 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b5c08c8c2f944e6386ac91e6dc7c5b1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86b5ae0f3778b49a89f9475a8dd76a4c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1beeff46150f414bbe307a9dc218d22 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d548c431e0e3486180af6bef7e89c2a 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa637a163c2564437953c144e3f8fa3c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/net40.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 061e57d8f20c8454f883234430f1de29 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/SimpleHunting.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6a1e7078b3804fc8ab3a17eb9f928be 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35db9e35a8c944f1db4df9f6c2efa7f9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/VariousHeights.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 242034d839a504adeb0b524fd704eaed 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/MathNet.Numerics.IfSharp.fsx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d9cbb6ba1b44482a9038dde545bb46c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/net40/MathNet.Numerics.dll.mdb.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76a1d6dfcf4839c4abd9f8def90335e8 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/net40/MathNet.Numerics.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fe77a79440a60d48ac579640e209284 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d935ecaa33404d45b84cb1d9b2db9ce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31867463946594fd89d0d81190b65178 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/RandomCreatures.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f7575ca902d54637905263f452374fd 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2905282d240654a1eae63a4f5efe4ccc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09431656950dc4c74adb3447762c730c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/DesignedCreatures.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5887d280b83cb4da19a27623f1f211c1 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/Resources/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c4cedcbce7414423b06858f74219a09 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ae966f166fe642698779731ebcb7836 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1602f46e0b95e4b68bae8fef3437a108 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c44125094432470cb81d6c8e7606f6f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/Trail.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 690f7603ae90b4c238a05045b21a9286 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Body.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92b814ae3ee2e4aad92bbd7f38f3417f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Food.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2824b0de978d4a8fa4ff83c3f351dc0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Assets/Packages/SimpleJSON"] 2 | path = Assets/Packages/SimpleJSON 3 | url = https://github.com/Bunny83/SimpleJSON.git 4 | [submodule "Assets/MotionGenerator"] 5 | path = Assets/MotionGenerator 6 | url = https://github.com/dwango/MotionGenerator.git 7 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/Resources/Prefabs/Car.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e1ad1e23d8b94ce9af1737c356d32fb 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Resources/CreatureListElement.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32d70299ce6f95948ba6739831c47c0f 3 | timeCreated: 1490276792 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Resources/SampleServerUICanvas.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ab0842c01f493b4fb4c0b18742a30c2 3 | timeCreated: 1490157488 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f11a24b31e8f34587825f726c5bddcef 3 | folderAsset: yes 4 | timeCreated: 1496032913 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.0167 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1559e8cf9624a0842b85779b85084dfe 3 | folderAsset: yes 4 | timeCreated: 1490357112 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/Agent.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb884964db8004c9ca1f1a21a1b5f3ce 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 13400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/Ground.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 287d3f4bf010a4ffd99b89a127b1ae0b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 13400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02db6e1b6210a4c15966b9e40b2ddc64 3 | folderAsset: yes 4 | timeCreated: 1496116880 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67d932882304448e6bfae6ead86957ab 3 | folderAsset: yes 4 | timeCreated: 1496116880 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs/GymAnt.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8062e29c34d74638a5c8b714104d2f7 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CubeArm.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a9d71e3a0ee0467a86c24d7163e2bd3 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CubeArm2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b98d247f807346a2b337eae27247c62 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CubeBody 1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 361354a2eebb344dc8823af0ade41bc0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CubeBody.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5433f69e566be40bf8c42712047cc66f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CubeBody2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9adeccbcda2a049d6b347386795fbad2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs/CapsuleCreature.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cee15a4c6adc045c89130d4c5f32846c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CapsuleBody1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 247cf5c12fc38407898447cb71931cf5 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/CylinderBody1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 650f01326988242d28375c2918f93728 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/Resources/Prefabs/SphereBody1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2803fe6c298d2436091fc2ee6e483245 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/ReservedUIMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acf43d8a9cf1e5647ba94765bda14f1c 3 | timeCreated: 1505361313 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs/PlaneCubesCreature.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ce3031cc8b1a446eae116aba55d6003 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs/VerticalCubesCreature.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15252296d4a5c4ba78bb33b9b35f9bea 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Resources/ToolBarElement.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 270a5d63efbf2eb498e07b68122f06ba 3 | timeCreated: 1505200104 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/MasterConnector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.BodyGenerator.JointGenerator 4 | { 5 | public class MasterConnector: MonoBehaviour 6 | { 7 | public bool available = true; 8 | public BodyComponent ConnectedComponent; 9 | } 10 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Ground.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c33840d7dbd1134bb08310bce9e951f 3 | timeCreated: 1516602734 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 2100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/IToolBarActions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace RLCreature.Sample.Common.UI.UIComponents 5 | { 6 | public interface IToolBarActions 7 | { 8 | string GetCategory(); 9 | Dictionary GetActions(); 10 | } 11 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/TimescaleSwitcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 960355a77c26d48f0982f661f58cd4d9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/DrivingEntrypoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed63fbb08124d452986c2aa1f0842134 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Resources/ToolBarCategoryElement.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52ab73bdf7dd8fa48adc2d8847477fab 3 | timeCreated: 1512021102 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/ManipulatableInitializer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ff109cffbfd94318b1e8c7c77a1d7b9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/IManipulatable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff2514d4b638475c8e0c6e5c0e1a0d6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/FallbackedEventReceiver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48a4dece30e724a8abfee4c231c1dc84 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/CreatureInfoCell.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbb8872e0707f4d6e9420ef463ac7070 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/CreatureInfoList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9252594648fc455b9f14d55713e88af 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/RandomCreaturesEntryPoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1366c6b11f46649c79d2e03ee44dd619 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/CastUIPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f60aad5319dc03944ac7561c211d873a 3 | timeCreated: 1490157236 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/CameraAttitude.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3aa1ea6f66ba046f28b0b187f50c4be7 3 | timeCreated: 1496116881 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/CastCameraController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ebcd1b2dbd9fdb4983d8c09e2298d6c 3 | timeCreated: 1490339837 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/SelectableCreature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff8d8154d5be5414a8dd52c819c145ba 3 | timeCreated: 1490342880 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/ToolBar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6965f4d94bd60bc43a08a2d1ee442ca1 3 | timeCreated: 1505199017 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/FallbackPhysicsRaycaster.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bf26aebdd307b144a4f297be063dd63 3 | timeCreated: 1490350095 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/CastUIView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5eeff7ee2fe03124284402cce26edfbe 3 | timeCreated: 1490157236 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/ToolBarCell.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae5bd9e217d42af49965eb7b5ed17e0c 3 | timeCreated: 1505199402 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras/SubCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 366c46fa095334c7988648db4ff8cad0 3 | timeCreated: 1496034613 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/FocusCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3290ea94001b435409fcd7ff3dec4182 3 | timeCreated: 1490344113 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras/AgentFocusStrategy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34e2f0aedbfc64023964f6aef311d41e 3 | timeCreated: 1496034613 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras/IFocusStrategy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5c23a4b82d4849758fe55a6937c8219 3 | timeCreated: 1496034614 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/MonitoringCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 842b35906d5f2d64499dad16f62140e2 3 | timeCreated: 1495691560 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/RokuroCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 485b5966ddb4dd74e8e8e065bdbe4e0e 3 | timeCreated: 1490338687 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/IOperatableCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d3d5bf26b427b24385ed44ddc807610 3 | timeCreated: 1490359756 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/PolarCoordinatesAttitude.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b12233f66f3de4743acf853e92be52d0 3 | timeCreated: 1490861619 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/Agent.physicMaterial: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!134 &13400000 4 | PhysicMaterial: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: Agent 9 | dynamicFriction: 1e+21 10 | staticFriction: 1e+32 11 | bounciness: 0 12 | frictionCombine: 0 13 | bounceCombine: 0 14 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/Ground.physicMaterial: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!134 &13400000 4 | PhysicMaterial: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: Ground 9 | dynamicFriction: 1e+23 10 | staticFriction: 1e+31 11 | bounciness: 0 12 | frictionCombine: 0 13 | bounceCombine: 0 14 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/README.md: -------------------------------------------------------------------------------- 1 | ![](./VariousHeights.gif) 2 | 3 | 強化学習エージェント(赤)と、単に近くのフードに向かうルールベースエージェント(黄)との比較。 4 | ただし、フードはランダムな高さに発生するために高さによっては各エージェントは届かない。 5 | わかりやすさのために各フードの高さを緑から赤のグラデーションで表現している。 6 | 7 | ここで強化学習エージェントは"獲得したフード数を最大化する"というシンプルな目標のみを与えられている。 8 | 開始直後は強化学習エージェントは経験が少ないためフードの獲得方法がわからないが、 9 | 時間とともにフードの方へ移動して獲得できるようになり、 10 | 最終的には獲得不可能な高い位置のフードは避けることもできるようになるため、ルールベースエージェントよりも獲得量が多くなる。 11 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/IManipulatable.cs: -------------------------------------------------------------------------------- 1 | using MotionGenerator; 2 | 3 | namespace RLCreature.BodyGenerator.Manipulatables 4 | { 5 | public interface IManipulatable 6 | { 7 | void Init(); 8 | void SetManipulatableId(int value); 9 | int GetManipulatableDimention(); 10 | int GetManipulatableId(); 11 | State GetState(); 12 | bool IsMoving(); 13 | void Manipulate(MotionSequence sequence); 14 | void UpdateFixedFrame(); 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/TimescaleSwitcher.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.Sample.DesignedCreatures 4 | { 5 | public class TimescaleSwitcher : MonoBehaviour 6 | { 7 | public float TimeScaleFastMode = 20; 8 | 9 | private void Update () 10 | { 11 | if (Input.GetKeyDown(KeyCode.Space)) 12 | { 13 | Time.timeScale = 1; 14 | } 15 | if (Input.GetKeyDown(KeyCode.S)) 16 | { 17 | Time.timeScale = TimeScaleFastMode; 18 | } 19 | Debug.Log(Time.time); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/IOperatableCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.Sample.Common.UI.Cameras.OperatableCameras 4 | { 5 | public interface IOperatableCamera 6 | { 7 | CameraAttitude Update(float deltaTime); 8 | void Initialize(CameraAttitude attitude); 9 | void SubDragOperation(Vector2 diff); 10 | void MainDragOperation(Vector2 diff); 11 | void ScrollOperation(Vector2 diff); 12 | bool NeedsSubDragOperation { get; } 13 | bool NeedsMainDragOperation { get; } 14 | bool NeedsScrollOperation { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/ToolBarCell.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace RLCreature.Sample.Common.UI.UIComponents 5 | { 6 | public class ToolBarCell : MonoBehaviour 7 | { 8 | public Button Button; 9 | public Text Name; 10 | public Image Background; 11 | public Color OddColor; 12 | public Color EvenColor; 13 | 14 | public void SetColor(int listIndex) 15 | { 16 | if (listIndex % 2 == 0) 17 | { 18 | Background.color = EvenColor; 19 | } 20 | else 21 | { 22 | Background.color = OddColor; 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Assets/Scripts/MessagePack* 2 | 3 | ### https://raw.github.com/github/gitignore/18e28746b0862059dbee8694fd366a679cb812fb/Unity.gitignore 4 | 5 | [Ll]ibrary/ 6 | [Tt]emp/ 7 | [Oo]bj/ 8 | [Bb]uild/ 9 | [Bb]uilds/ 10 | Assets/AssetStoreTools* 11 | 12 | # Visual Studio cache directory 13 | .vs/ 14 | 15 | # Autogenerated VS/MD/Consulo solution and project files 16 | ExportedObj/ 17 | .consulo/ 18 | *.csproj 19 | *.unityproj 20 | *.sln 21 | *.suo 22 | *.tmp 23 | *.user 24 | *.userprefs 25 | *.pidb 26 | *.booproj 27 | *.svd 28 | *.pdb 29 | *.opendb 30 | 31 | # Unity3D generated meta files 32 | *.pidb.meta 33 | *.pdb.meta 34 | 35 | # Unity3D Generated File On Crash Reports 36 | sysinfo.txt 37 | 38 | # Builds 39 | *.apk 40 | *.unitypackage 41 | 42 | 43 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/net40/MathNet.Numerics.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7db764009ec22ec48a99cef24c93b41e 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | isPreloaded: 0 9 | isOverridable: 0 10 | platformData: 11 | - first: 12 | Any: 13 | second: 14 | enabled: 1 15 | settings: {} 16 | - first: 17 | Editor: Editor 18 | second: 19 | enabled: 0 20 | settings: 21 | DefaultValueInitialized: true 22 | - first: 23 | Windows Store Apps: WindowsStoreApps 24 | second: 25 | enabled: 0 26 | settings: 27 | CPU: AnyCPU 28 | userData: 29 | assetBundleName: 30 | assetBundleVariant: 31 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/MathNet.Numerics.fsx: -------------------------------------------------------------------------------- 1 | #nowarn "211" 2 | #I "Net40" 3 | #I "../Net40" 4 | #I "../../Net40" 5 | #r "MathNet.Numerics.dll" 6 | #r "MathNet.Numerics.FSharp.dll" 7 | 8 | open MathNet.Numerics 9 | open MathNet.Numerics.LinearAlgebra 10 | 11 | fsi.AddPrinter(fun (matrix:Matrix) -> matrix.ToString()) 12 | fsi.AddPrinter(fun (matrix:Matrix) -> matrix.ToString()) 13 | fsi.AddPrinter(fun (matrix:Matrix) -> matrix.ToString()) 14 | fsi.AddPrinter(fun (matrix:Matrix) -> matrix.ToString()) 15 | fsi.AddPrinter(fun (vector:Vector) -> vector.ToString()) 16 | fsi.AddPrinter(fun (vector:Vector) -> vector.ToString()) 17 | fsi.AddPrinter(fun (vector:Vector) -> vector.ToString()) 18 | fsi.AddPrinter(fun (vector:Vector) -> vector.ToString()) -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/CastUIView.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace RLCreature.Sample.Common.UI.UIComponents 5 | { 6 | public class CastUIView : MonoBehaviour 7 | { 8 | public Text Time; 9 | 10 | public Text CreatureCount; 11 | public Text FoodCount; 12 | 13 | public Button CreatureListToggleButton; 14 | public RectTransform CreatureListRoot; 15 | public RectTransform CreatureList; 16 | 17 | public Button SubCameraToggleButton; 18 | public RectTransform SubCameraRoot; 19 | public RawImage SubCameraRawImage; 20 | 21 | public RectTransform ToolBarCategoryList; 22 | public RectTransform ToolBarListRoot; 23 | public RectTransform ToolBarList; 24 | 25 | public RectTransform Cursor; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/ManipulatableInitializer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Joint = RLCreature.BodyGenerator.Manipulatables.Joint; 3 | 4 | namespace RLCreature.Sample.DesignedCreatures 5 | { 6 | public class ManipulatableInitializer : MonoBehaviour 7 | { 8 | public float JointForcePower = 1; 9 | 10 | private void Awake() 11 | { 12 | var joints = transform.GetComponentsInChildren(); 13 | foreach (var joint in joints) 14 | { 15 | Joint.CreateComponent(joint, JointForcePower); 16 | } 17 | 18 | var rigidbodies = transform.GetComponentsInChildren(); 19 | foreach (var rigidbody in rigidbodies) 20 | { 21 | rigidbody.solverIterations = 30; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/EntryPointUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using RLCreature.BodyGenerator; 3 | using RLCreature.BodyGenerator.Manipulatables; 4 | using RLCreature.Sample.Common.UI.UIComponents; 5 | using UnityEngine; 6 | 7 | namespace RLCreature.Sample.Common 8 | { 9 | public static class EntryPointUtility 10 | { 11 | public static IEnumerator Rename(CreatureInfoCell cell, Agent agent, Mouth mouth) 12 | { 13 | while (true) 14 | { 15 | yield return new WaitForSeconds(10); 16 | cell.DisplayName = agent.name + ":" + mouth.EatenCount; 17 | } 18 | } 19 | 20 | public static IEnumerator DeleteTimer(GameObject targetObject, int seconds) 21 | { 22 | yield return new WaitForSeconds(seconds); 23 | GameObject.Destroy(targetObject); 24 | } 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate 14 | m_Enabled: 0 15 | m_CaptureEditorExceptions: 1 16 | UnityPurchasingSettings: 17 | m_Enabled: 0 18 | m_TestMode: 0 19 | UnityAnalyticsSettings: 20 | m_Enabled: 1 21 | m_InitializeOnStartup: 1 22 | m_TestMode: 0 23 | m_TestEventUrl: 24 | m_TestConfigUrl: 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/CameraAttitude.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.Sample.Common.UI.Cameras 4 | { 5 | public struct CameraAttitude 6 | { 7 | public Vector3 Position; 8 | public Vector3 LookAt; 9 | 10 | public static CameraAttitude Lerp(CameraAttitude a, CameraAttitude b, float t) 11 | { 12 | return new CameraAttitude 13 | { 14 | LookAt = Vector3.Lerp(a.LookAt, b.LookAt, t), 15 | Position = Vector3.Lerp(a.Position, b.Position, t), 16 | }; 17 | } 18 | 19 | public static CameraAttitude Slerp(CameraAttitude a, CameraAttitude b, float t) 20 | { 21 | var va = a.Position - a.LookAt; 22 | var vb = b.Position - b.LookAt; 23 | var v = Vector3.Slerp(va, vb, t); 24 | 25 | var look = Vector3.Lerp(a.LookAt, b.LookAt, t); 26 | 27 | return new CameraAttitude 28 | { 29 | LookAt = look, 30 | Position = look + v, 31 | }; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 DWANGO Co., Ltd. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/license.txt: -------------------------------------------------------------------------------- 1 | Math.NET Numerics License (MIT/X11) 2 | =================================== 3 | 4 | Copyright (c) 2002-2018 Math.NET 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Actions/SystemActions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using RLCreature.Sample.Common.UI.UIComponents; 5 | using UnityEngine; 6 | 7 | namespace RLCreature.Sample.Common.UI.Actions 8 | { 9 | public class SystemActions : IToolBarActions 10 | { 11 | public SystemActions() 12 | { 13 | } 14 | 15 | public string GetCategory() 16 | { 17 | return "System"; 18 | } 19 | 20 | public Dictionary GetActions() 21 | { 22 | return new Dictionary 23 | { 24 | { 25 | "TimeScale x1", () => { Time.timeScale = 1; } 26 | }, 27 | { 28 | "TimeScale x3", () => { Time.timeScale = 3; } 29 | }, 30 | { 31 | "TimeScale x5", () => { Time.timeScale = 5; } 32 | }, 33 | { 34 | "TimeScale x10", () => { Time.timeScale = 10; } 35 | }, 36 | { 37 | "TimeScale x30", () => { Time.timeScale = 30; } 38 | } 39 | }; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/ManipulatableBase.cs: -------------------------------------------------------------------------------- 1 | using MotionGenerator; 2 | using UnityEngine; 3 | 4 | namespace RLCreature.BodyGenerator.Manipulatables 5 | { 6 | public abstract class ManipulatableBase : MonoBehaviour, IManipulatable 7 | { 8 | private int _manipulatableId; 9 | protected readonly State EmptyState = new State(); 10 | 11 | protected bool _isMoving = false; 12 | 13 | // TODO(ogaki): Monobehaviourを外して抽象化したい。。。 14 | protected virtual GameObject ThisGameObject() 15 | { 16 | return gameObject; 17 | } 18 | 19 | public virtual void Init() 20 | { 21 | } 22 | 23 | public void SetManipulatableId(int value) 24 | { 25 | _manipulatableId = value; 26 | } 27 | 28 | public virtual int GetManipulatableDimention() 29 | { 30 | return 0; 31 | } 32 | 33 | public int GetManipulatableId() 34 | { 35 | return _manipulatableId; 36 | } 37 | 38 | public virtual State GetState() 39 | { 40 | return EmptyState; 41 | } 42 | 43 | public bool IsMoving() 44 | { 45 | return _isMoving; 46 | } 47 | 48 | public virtual void Manipulate(MotionSequence sequence) 49 | { 50 | } 51 | 52 | public virtual void UpdateFixedFrame() 53 | { 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/Mouth.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MathNet.Numerics.LinearAlgebra.Double; 3 | using MotionGenerator; 4 | using MotionGenerator.Entity.Soul; 5 | using UnityEngine; 6 | 7 | namespace RLCreature.BodyGenerator.Manipulatables 8 | { 9 | public class Mouth : ManipulatableBase 10 | { 11 | private Type _type; 12 | private readonly State _state = new State(); 13 | public int EatenCount { get; private set; } 14 | 15 | private Mouth() 16 | { 17 | } 18 | 19 | public static Mouth CreateComponent(GameObject obj, Type type) 20 | { 21 | return obj.AddComponent()._CreateComponent(type); 22 | } 23 | 24 | private Mouth _CreateComponent(Type type) 25 | { 26 | _type = type; 27 | _state[GluttonySoul.Key] = new DenseVector(1); 28 | 29 | var collider = gameObject.AddComponent(); 30 | collider.isTrigger = true; 31 | 32 | return this; 33 | } 34 | 35 | public override State GetState() 36 | { 37 | _state.Set(GluttonySoul.Key, EatenCount); 38 | return _state; 39 | } 40 | 41 | private void OnTriggerEnter(Collider other) 42 | { 43 | if (other.gameObject.GetComponent(_type) != null) 44 | { 45 | Destroy(other.gameObject); 46 | EatenCount += 1; 47 | } 48 | } 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/FallbackPhysicsRaycaster.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace RLCreature.Sample.Common.UI 6 | { 7 | public class FallbackPhysicsRaycaster : PhysicsRaycaster 8 | { 9 | private GameObject _fallback; 10 | 11 | public static FallbackPhysicsRaycaster CreateComponent(GameObject attachedCamera, GameObject fallback) 12 | { 13 | var self = attachedCamera.AddComponent(); 14 | self._fallback = fallback; 15 | self.eventMask = 0; 16 | return self; 17 | } 18 | 19 | public override void Raycast(PointerEventData eventData, List resultAppendList) 20 | { 21 | var count = resultAppendList.Count; 22 | base.Raycast(eventData, resultAppendList); 23 | if (count != resultAppendList.Count && !(eventData.IsScrolling() || eventData.dragging)) return; 24 | 25 | var result = new RaycastResult 26 | { 27 | gameObject = _fallback, 28 | module = (BaseRaycaster) this, 29 | distance = 0, 30 | worldPosition = _fallback.transform.position, 31 | worldNormal = _fallback.transform.up, 32 | screenPosition = eventData.position, 33 | index = (float) resultAppendList.Count, 34 | sortingLayer = 0, 35 | sortingOrder = 0 36 | }; 37 | resultAppendList.Add(result); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/RokuroCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.Sample.Common.UI.Cameras.OperatableCameras 4 | { 5 | public class RokuroCamera : IOperatableCamera 6 | { 7 | private CameraAttitude _currentAttitude; 8 | 9 | private PolarCoordinatesAttitude _goalAttitude; 10 | 11 | CameraAttitude IOperatableCamera.Update(float deltaTime) 12 | { 13 | _currentAttitude = CameraAttitude.Lerp(_currentAttitude, _goalAttitude.ToCameraAttitude(), 0.98f); 14 | return _currentAttitude; 15 | } 16 | 17 | void IOperatableCamera.Initialize(CameraAttitude attitude) 18 | { 19 | _currentAttitude = attitude; 20 | _goalAttitude = new PolarCoordinatesAttitude(_currentAttitude); 21 | } 22 | 23 | void IOperatableCamera.SubDragOperation(Vector2 diff) 24 | { 25 | _goalAttitude.Grab(diff); 26 | } 27 | 28 | void IOperatableCamera.MainDragOperation(Vector2 diff) 29 | { 30 | _goalAttitude.Rotate(diff); 31 | } 32 | 33 | void IOperatableCamera.ScrollOperation(Vector2 diff) 34 | { 35 | _goalAttitude.Dolly(diff); 36 | } 37 | 38 | bool IOperatableCamera.NeedsSubDragOperation 39 | { 40 | get { return true; } 41 | } 42 | 43 | bool IOperatableCamera.NeedsMainDragOperation 44 | { 45 | get { return true; } 46 | } 47 | 48 | bool IOperatableCamera.NeedsScrollOperation 49 | { 50 | get { return true; } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras/SubCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.Sample.Common.UI.Cameras.SubCameras 4 | { 5 | public class SubCamera : MonoBehaviour 6 | { 7 | private Camera _camera; 8 | private RenderTexture _texture; 9 | 10 | public IFocusStrategy Strategy { get; set; } 11 | 12 | public bool IsActive 13 | { 14 | get { return _camera.enabled; } 15 | set { _camera.enabled = value; } 16 | } 17 | 18 | public static SubCamera CreateComponent(GameObject gameObject, IFocusStrategy strategy, RenderTexture texture, float aspect) 19 | { 20 | var self = gameObject.AddComponent(); 21 | self._CreateComponent(texture, aspect); 22 | self.Strategy = strategy; 23 | return self; 24 | } 25 | private void _CreateComponent(RenderTexture texture, float aspect) 26 | { 27 | var obje = new GameObject("SubCamera"); 28 | obje.transform.parent = gameObject.transform; 29 | _camera = obje.AddComponent(); 30 | _camera.targetTexture = texture; 31 | _camera.aspect = aspect; 32 | _texture = texture; 33 | } 34 | 35 | private void Update() 36 | { 37 | var attitude = Strategy.Update(); 38 | _camera.transform.position = attitude.Position; 39 | _camera.transform.LookAt(attitude.LookAt); 40 | } 41 | 42 | private void OnDestroy() 43 | { 44 | Destroy(_texture); 45 | Destroy(_camera.gameObject); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.0.8", 4 | "com.unity.analytics": "2.0.16", 5 | "com.unity.package-manager-ui": "1.9.11", 6 | "com.unity.purchasing": "2.0.3", 7 | "com.unity.textmeshpro": "1.2.4", 8 | "com.unity.modules.ai": "1.0.0", 9 | "com.unity.modules.animation": "1.0.0", 10 | "com.unity.modules.assetbundle": "1.0.0", 11 | "com.unity.modules.audio": "1.0.0", 12 | "com.unity.modules.cloth": "1.0.0", 13 | "com.unity.modules.director": "1.0.0", 14 | "com.unity.modules.imageconversion": "1.0.0", 15 | "com.unity.modules.imgui": "1.0.0", 16 | "com.unity.modules.jsonserialize": "1.0.0", 17 | "com.unity.modules.particlesystem": "1.0.0", 18 | "com.unity.modules.physics": "1.0.0", 19 | "com.unity.modules.physics2d": "1.0.0", 20 | "com.unity.modules.screencapture": "1.0.0", 21 | "com.unity.modules.terrain": "1.0.0", 22 | "com.unity.modules.terrainphysics": "1.0.0", 23 | "com.unity.modules.tilemap": "1.0.0", 24 | "com.unity.modules.ui": "1.0.0", 25 | "com.unity.modules.uielements": "1.0.0", 26 | "com.unity.modules.umbra": "1.0.0", 27 | "com.unity.modules.unityanalytics": "1.0.0", 28 | "com.unity.modules.unitywebrequest": "1.0.0", 29 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 30 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 31 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 32 | "com.unity.modules.unitywebrequestwww": "1.0.0", 33 | "com.unity.modules.vehicles": "1.0.0", 34 | "com.unity.modules.video": "1.0.0", 35 | "com.unity.modules.vr": "1.0.0", 36 | "com.unity.modules.wind": "1.0.0", 37 | "com.unity.modules.xr": "1.0.0" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/MonitoringCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace RLCreature.Sample.Common.UI.Cameras.OperatableCameras 5 | { 6 | public class MonitoringCamera : IOperatableCamera 7 | { 8 | private readonly CameraAttitude _targetAttitude; 9 | 10 | private readonly float _transitionTime; 11 | 12 | private CameraAttitude _currentAttitude; 13 | 14 | private float _elapsedTime; 15 | 16 | public MonitoringCamera(CameraAttitude targetAttitude, float transitionTime = 1.0f) 17 | { 18 | _targetAttitude = targetAttitude; 19 | _transitionTime = transitionTime; 20 | } 21 | 22 | public CameraAttitude Update(float deltaTime) 23 | { 24 | _elapsedTime += deltaTime; 25 | var t = Math.Abs(_transitionTime) < 0.01f ? 1.0f : Mathf.Clamp01(_elapsedTime / _transitionTime); 26 | _currentAttitude = CameraAttitude.Slerp(_currentAttitude, _targetAttitude, t); 27 | return _currentAttitude; 28 | } 29 | 30 | void IOperatableCamera.Initialize(CameraAttitude attitude) 31 | { 32 | _currentAttitude = attitude; 33 | _elapsedTime = 0.0f; 34 | } 35 | 36 | void IOperatableCamera.SubDragOperation(Vector2 diff) 37 | { 38 | } 39 | 40 | void IOperatableCamera.MainDragOperation(Vector2 diff) 41 | { 42 | } 43 | 44 | void IOperatableCamera.ScrollOperation(Vector2 diff) 45 | { 46 | } 47 | 48 | bool IOperatableCamera.NeedsSubDragOperation 49 | { 50 | get { return false; } 51 | } 52 | 53 | bool IOperatableCamera.NeedsMainDragOperation 54 | { 55 | get { return false; } 56 | } 57 | 58 | bool IOperatableCamera.NeedsScrollOperation 59 | { 60 | get { return false; } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/CarControlManipulatable.cs: -------------------------------------------------------------------------------- 1 | using MotionGenerator; 2 | using RLCreature.BodyGenerator.Manipulatables; 3 | using UnityEngine; 4 | using UnityStandardAssets.Vehicles.Car; 5 | 6 | namespace RLCreature.Sample.Driving 7 | { 8 | public class CarControlManipulatable : ManipulatableBase 9 | { 10 | private CarController _control; 11 | private int _consumedFrames; 12 | private MotionSequence _sequence = new MotionSequence(); 13 | 14 | public static CarControlManipulatable CreateComponent(GameObject car) 15 | { 16 | return car.AddComponent()._CreateComponent(); 17 | } 18 | 19 | 20 | private CarControlManipulatable _CreateComponent() 21 | { 22 | _control = GetComponent(); 23 | GetComponent().enabled = false; 24 | return this; 25 | } 26 | 27 | public override int GetManipulatableDimention() 28 | { 29 | return 2; 30 | } 31 | 32 | public override void Manipulate(MotionSequence sequence) 33 | { 34 | _consumedFrames = 0; 35 | _isMoving = true; 36 | _sequence = new MotionSequence(sequence); 37 | } 38 | 39 | public override void UpdateFixedFrame() 40 | { 41 | if (_sequence.Sequence.Count > 0) 42 | { 43 | if (_sequence[0].time < _consumedFrames) 44 | { 45 | _sequence.Sequence.RemoveAt(0); 46 | } 47 | else 48 | { 49 | _control.Move(_sequence[0].value[0]*2-1, _sequence[0].value[1]*2-1, _sequence[0].value[1]*2-1, 0); 50 | } 51 | } 52 | else 53 | { 54 | _isMoving = false; 55 | } 56 | 57 | _consumedFrames += 1; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/Sensor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using MathNet.Numerics.LinearAlgebra.Double; 4 | using MotionGenerator; 5 | using UnityEngine; 6 | 7 | namespace RLCreature.BodyGenerator.Manipulatables 8 | { 9 | public class Sensor : ManipulatableBase 10 | { 11 | private string _key; 12 | private float _range; 13 | private readonly State _state = new State(); 14 | private Type _type; 15 | 16 | private Sensor() 17 | { 18 | } 19 | 20 | public static Sensor CreateComponent(GameObject obj, Type type, string key, float range) 21 | { 22 | return obj.AddComponent()._CreateComponent(type, key, range); 23 | } 24 | 25 | private Sensor _CreateComponent(Type type, string key, float range) 26 | { 27 | _key = key; 28 | _range = range; 29 | _state[_key] = new DenseVector(3); 30 | _type = type; 31 | return this; 32 | } 33 | 34 | public override State GetState() 35 | { 36 | var minDistance = float.MaxValue; 37 | _state.Set(_key, -Vector3.one); // when no candidate found 38 | foreach (var candidate in FindObjectsOfType(_type).Select(o => o as MonoBehaviour)) 39 | { 40 | var distance = Vector3.Distance(transform.position, candidate.transform.position); 41 | if (distance < minDistance) 42 | { 43 | minDistance = distance; 44 | var inversedMyRotation = Quaternion.Inverse(transform.rotation); 45 | var relativeEachTargetPosition = 46 | inversedMyRotation * (candidate.transform.position - transform.position) / _range; 47 | _state.Set(_key, relativeEachTargetPosition); 48 | } 49 | } 50 | 51 | return _state; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/SelectableCreature.cs: -------------------------------------------------------------------------------- 1 | using UniRx; 2 | using UnityEngine; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace RLCreature.Sample.Common.UI 6 | { 7 | public class SelectableCreature : MonoBehaviour, IPointerClickHandler 8 | { 9 | public static readonly string Name = "UICollider"; 10 | 11 | private GameObject _clickableCreature; 12 | private GameObject _referencedCreature; 13 | 14 | private ReactiveProperty _target; 15 | 16 | [SerializeField] 17 | private Transform _camera; 18 | 19 | [SerializeField] 20 | private SphereCollider _collider; 21 | 22 | public static SelectableCreature CreateComponent( 23 | GameObject clickableCreatureRoot, 24 | Transform camera, 25 | ReactiveProperty observer, 26 | GameObject referencedCreatureRoot = null) 27 | { 28 | var obj = new GameObject(Name); 29 | var central = clickableCreatureRoot.transform.GetChild(0); 30 | obj.transform.SetParent(central, false); 31 | var self = obj.AddComponent(); 32 | self._clickableCreature = clickableCreatureRoot; 33 | self._camera = camera; 34 | self._collider = obj.AddComponent(); 35 | self._collider.isTrigger = true; 36 | self._target = observer; 37 | self._referencedCreature = referencedCreatureRoot ?? self._clickableCreature; 38 | return self; 39 | } 40 | 41 | void Update() 42 | { 43 | var distance = Vector3.Distance(_camera.position, transform.position); 44 | var coef = Mathf.Max(1.0f, Mathf.Sqrt(distance) - 5.0f); 45 | _collider.radius = coef; 46 | } 47 | 48 | void IPointerClickHandler.OnPointerClick(PointerEventData eventData) 49 | { 50 | if (_target == null) return; 51 | _target.Value = _referencedCreature; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/CreatureInfoCell.cs: -------------------------------------------------------------------------------- 1 | using UniRx; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace RLCreature.Sample.Common.UI.UIComponents 6 | { 7 | public class CreatureInfoCell : MonoBehaviour 8 | { 9 | [SerializeField] private Color DefaultColor = Color.white; 10 | 11 | public RectTransform Header; 12 | 13 | public Text HeaderName; 14 | 15 | public Image BackgroundImage; 16 | 17 | public Color Default; 18 | 19 | public Color SelectedColor; 20 | 21 | public GameObject Creature; 22 | 23 | private string _displayName; 24 | 25 | public string DisplayName 26 | { 27 | get { return _displayName; } 28 | set 29 | { 30 | _displayName = value; 31 | HeaderName.text = _displayName; 32 | } 33 | } 34 | 35 | public bool IsLastCreatureInFamily { get; set; } 36 | 37 | public readonly BoolReactiveProperty Selected = new BoolReactiveProperty(false); 38 | 39 | private void Awake() 40 | { 41 | Deselect(); 42 | 43 | Selected.Subscribe(x => 44 | { 45 | if (x) 46 | { 47 | Select(); 48 | } 49 | else 50 | { 51 | Deselect(); 52 | } 53 | }).AddTo(this); 54 | } 55 | 56 | private void Select() 57 | { 58 | BackgroundImage.color = SelectedColor; 59 | } 60 | 61 | private void Deselect() 62 | { 63 | BackgroundImage.color = Default; 64 | } 65 | 66 | public void OnPressed() 67 | { 68 | Selected.Value = true; 69 | } 70 | 71 | private Color GetHeaderColor() 72 | { 73 | return DefaultColor; 74 | } 75 | 76 | public bool IsActive() 77 | { 78 | return true; 79 | } 80 | 81 | private void Update() 82 | { 83 | HeaderName.color = GetHeaderColor(); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/Cursor.psd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f3aec87370ba0f489faf600ba77cb9f 3 | timeCreated: 1505208547 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapsPreserveCoverage: 0 16 | alphaTestReferenceValue: 0.5 17 | mipMapFadeDistanceStart: 1 18 | mipMapFadeDistanceEnd: 3 19 | bumpmap: 20 | convertToNormalMap: 0 21 | externalNormalMap: 0 22 | heightScale: 0.25 23 | normalMapFilter: 0 24 | isReadable: 0 25 | grayScaleToAlpha: 0 26 | generateCubemap: 6 27 | cubemapConvolution: 0 28 | seamlessCubemap: 0 29 | textureFormat: 1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | serializedVersion: 2 33 | filterMode: -1 34 | aniso: -1 35 | mipBias: -1 36 | wrapU: 1 37 | wrapV: -1 38 | wrapW: -1 39 | nPOTScale: 0 40 | lightmap: 0 41 | compressionQuality: 50 42 | spriteMode: 1 43 | spriteExtrude: 1 44 | spriteMeshType: 1 45 | alignment: 0 46 | spritePivot: {x: 0.5, y: 0.5} 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spritePixelsToUnits: 100 49 | alphaUsage: 1 50 | alphaIsTransparency: 1 51 | spriteTessellationDetail: -1 52 | textureType: 8 53 | textureShape: 1 54 | maxTextureSizeSet: 0 55 | compressionQualitySet: 0 56 | textureFormatSet: 0 57 | platformSettings: 58 | - buildTarget: DefaultTexturePlatform 59 | maxTextureSize: 2048 60 | textureFormat: -1 61 | textureCompression: 1 62 | compressionQuality: 50 63 | crunchedCompression: 0 64 | allowsAlphaSplitting: 0 65 | overridden: 0 66 | - buildTarget: Standalone 67 | maxTextureSize: 2048 68 | textureFormat: -1 69 | textureCompression: 1 70 | compressionQuality: 50 71 | crunchedCompression: 0 72 | allowsAlphaSplitting: 0 73 | overridden: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | spritePackingTag: 80 | userData: 81 | assetBundleName: 82 | assetBundleVariant: 83 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/driving.gif.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b62748d0d027545d9bb547019eb63fdb 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 5 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | seamlessCubemap: 0 28 | textureFormat: 1 29 | maxTextureSize: 2048 30 | textureSettings: 31 | serializedVersion: 2 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapU: -1 36 | wrapV: -1 37 | wrapW: -1 38 | nPOTScale: 1 39 | lightmap: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spritePixelsToUnits: 100 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spriteGenerateFallbackPhysicsShape: 1 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | singleChannelComponent: 0 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - serializedVersion: 2 60 | buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | resizeAlgorithm: 0 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | androidETC2FallbackOverride: 0 70 | spriteSheet: 71 | serializedVersion: 2 72 | sprites: [] 73 | outline: [] 74 | physicsShape: [] 75 | bones: [] 76 | spriteID: 77 | vertices: [] 78 | indices: 79 | edges: [] 80 | weights: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/20180712_oss_move.gif.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adb591fb49c744f308e3e5e16af5a7f5 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 5 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | seamlessCubemap: 0 28 | textureFormat: 1 29 | maxTextureSize: 2048 30 | textureSettings: 31 | serializedVersion: 2 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapU: -1 36 | wrapV: -1 37 | wrapW: -1 38 | nPOTScale: 1 39 | lightmap: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spritePixelsToUnits: 100 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spriteGenerateFallbackPhysicsShape: 1 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | singleChannelComponent: 0 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - serializedVersion: 2 60 | buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | resizeAlgorithm: 0 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | androidETC2FallbackOverride: 0 70 | spriteSheet: 71 | serializedVersion: 2 72 | sprites: [] 73 | outline: [] 74 | physicsShape: [] 75 | bones: [] 76 | spriteID: 77 | vertices: [] 78 | indices: 79 | edges: [] 80 | weights: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/VariousHeights.gif.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3bb5c47f1b3f4c4ea19f80afd853f22 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 5 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | seamlessCubemap: 0 28 | textureFormat: 1 29 | maxTextureSize: 2048 30 | textureSettings: 31 | serializedVersion: 2 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapU: -1 36 | wrapV: -1 37 | wrapW: -1 38 | nPOTScale: 1 39 | lightmap: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spritePixelsToUnits: 100 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spriteGenerateFallbackPhysicsShape: 1 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | singleChannelComponent: 0 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - serializedVersion: 2 60 | buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | resizeAlgorithm: 0 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | androidETC2FallbackOverride: 0 70 | spriteSheet: 71 | serializedVersion: 2 72 | sprites: [] 73 | outline: [] 74 | physicsShape: [] 75 | bones: [] 76 | spriteID: 77 | vertices: [] 78 | indices: 79 | edges: [] 80 | weights: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/food_hunting_simple.gif.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49865650ae46b400297808c9b1988cd1 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 5 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | seamlessCubemap: 0 28 | textureFormat: 1 29 | maxTextureSize: 2048 30 | textureSettings: 31 | serializedVersion: 2 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapU: -1 36 | wrapV: -1 37 | wrapW: -1 38 | nPOTScale: 1 39 | lightmap: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spritePixelsToUnits: 100 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spriteGenerateFallbackPhysicsShape: 1 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | singleChannelComponent: 0 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - serializedVersion: 2 60 | buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | resizeAlgorithm: 0 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | androidETC2FallbackOverride: 0 70 | spriteSheet: 71 | serializedVersion: 2 72 | sprites: [] 73 | outline: [] 74 | physicsShape: [] 75 | bones: [] 76 | spriteID: 77 | vertices: [] 78 | indices: 79 | edges: [] 80 | weights: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/Trail.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Trail 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/PolarCoordinatesAttitude.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RLCreature.Sample.Common.UI.Cameras.OperatableCameras 4 | { 5 | public class PolarCoordinatesAttitude 6 | { 7 | public Vector3 LookAt; 8 | public float Theta; 9 | public float Phi; 10 | public float Distance; 11 | 12 | public PolarCoordinatesAttitude() { } 13 | 14 | public PolarCoordinatesAttitude(CameraAttitude attitude) 15 | { 16 | SetFromAttitude(attitude); 17 | } 18 | 19 | public void SetFromAttitude(CameraAttitude attitude) 20 | { 21 | var dir = attitude.Position - attitude.LookAt; 22 | Theta = Mathf.Atan2(dir.z, dir.x); 23 | Phi = Mathf.Atan2(dir.y, Mathf.Sqrt(dir.x * dir.x + dir.z * dir.z)); 24 | Distance = dir.magnitude; 25 | LookAt = attitude.LookAt; 26 | } 27 | 28 | public CameraAttitude ToCameraAttitude() 29 | { 30 | return new CameraAttitude 31 | { 32 | LookAt = LookAt, 33 | Position = LookAt + GetDir(), 34 | }; 35 | } 36 | 37 | public void Rotate(Vector2 diff, float lowerLimitAngle = 10.0f, float higherLimitAngle = 89.0f) 38 | { 39 | diff *= 0.1f * Mathf.Deg2Rad; 40 | Theta -= diff.x; 41 | Phi -= diff.y; 42 | Phi = Mathf.Clamp(Phi, lowerLimitAngle * Mathf.Deg2Rad, higherLimitAngle * Mathf.Deg2Rad); 43 | } 44 | 45 | public void Grab(Vector2 diff) 46 | { 47 | diff *= 0.001f * Distance; 48 | var dir = GetDir(); 49 | var right = Vector3.Cross(dir, Vector3.up).normalized; 50 | var up = Vector3.Cross(right, Vector3.up); 51 | LookAt -= right * diff.x + up * diff.y; 52 | } 53 | 54 | public void Dolly(Vector2 diff, float minDistance = 1.5f, float maxDistance = 1000.0f) 55 | { 56 | Distance = Mathf.Clamp(Distance - diff.y * Distance * 0.1f, minDistance, maxDistance); 57 | } 58 | 59 | private Vector3 GetDir() 60 | { 61 | var c = Mathf.Cos(Phi); 62 | return new Vector3(c * Mathf.Cos(Theta), Mathf.Sin(Phi), c * Mathf.Sin(Theta)) * Distance; 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Body.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Body 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.1 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.7686275, g: 0.7254902, b: 0.70980394, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Food.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Food 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.1 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.35686275, g: 0.5529412, b: 0.227451, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/JointGenerator.cs: -------------------------------------------------------------------------------- 1 | using Boo.Lang; 2 | using UnityEngine; 3 | 4 | namespace RLCreature.BodyGenerator.JointGenerator 5 | { 6 | public class JointGenerator 7 | { 8 | protected readonly GameObject[] BodyPrefabs; 9 | protected readonly GameObject[] ArmPrefabs; 10 | private readonly float _baseMass; 11 | private readonly float _targetForce; 12 | 13 | public JointGenerator(GameObject[] bodyPrefabs, GameObject[] armPrefabs, float baseMass = 20, float targetForce = 1) 14 | { 15 | BodyPrefabs = bodyPrefabs; 16 | ArmPrefabs = armPrefabs; 17 | _baseMass = baseMass; 18 | _targetForce = targetForce; 19 | } 20 | 21 | public virtual GameObject Instantiate(Vector3 pos) 22 | { 23 | var components = new List(); 24 | var rootComponent = 25 | new BodyComponent(BodyPrefabs[UnityEngine.Random.Range(0, BodyPrefabs.Length)], pos: pos, baseMass: _baseMass, targetForce: _targetForce); 26 | components.Add(rootComponent); 27 | for (int i = 0; i < UnityEngine.Random.Range(1, 20); i++) 28 | { 29 | // choose parent component 30 | for (int j = 0; j < 100; j++) 31 | { 32 | var parent = components[Random.Range(0, components.Count)]; 33 | if (parent.HasAvailableConnector()) 34 | { 35 | var child = new BodyComponent( 36 | ArmPrefabs[UnityEngine.Random.Range(0, ArmPrefabs.Length)], 37 | parent: parent); 38 | components.Add(child); 39 | break; 40 | } 41 | } 42 | } 43 | 44 | 45 | 46 | rootComponent.CentralBody.GetComponent().centerOfMass = new Vector3(0f, -10f, 0f);; 47 | rootComponent.CentralBody.GetComponent().mass *= 5; 48 | 49 | var rootObject = new GameObject(); 50 | foreach (var component in components) 51 | { 52 | component.CentralBody.transform.parent = rootObject.transform; 53 | 54 | } 55 | return rootObject; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Assets/Packages/MathNet.Numerics/MathNet.Numerics.IfSharp.fsx: -------------------------------------------------------------------------------- 1 | 2 | // This file is intended for the IfSharp F# profile for iPython only. See: 3 | // http://numerics.mathdotnet.com/docs/IFSharpNotebook.html 4 | // http://github.com/BayardRock/IfSharp 5 | // http://ipython.org/ 6 | 7 | // Assumption: MathNet.Numerics and MathNet.Numerics.FSharp have been referenced already, using 8 | // #N "MathNet.Numerics" 9 | // #N "MathNet.Numerics.FSharp" 10 | 11 | open System 12 | open MathNet.Numerics 13 | open MathNet.Numerics.LinearAlgebra 14 | 15 | let inline (|Float|_|) (v:obj) = if v :? float then Some(v :?> float) else None 16 | let inline (|Float32|_|) (v:obj) = if v :? float32 then Some(v :?> float32) else None 17 | let inline (|PositiveInfinity|_|) (v: ^T) = if (^T : (static member IsPositiveInfinity: 'T -> bool) (v)) then Some PositiveInfinity else None 18 | let inline (|NegativeInfinity|_|) (v: ^T) = if (^T : (static member IsNegativeInfinity: 'T -> bool) (v)) then Some NegativeInfinity else None 19 | let inline (|NaN|_|) (v: ^T) = if (^T : (static member IsNaN: 'T -> bool) (v)) then Some NaN else None 20 | 21 | let inline formatMathValue (floatFormat:string) = function 22 | | PositiveInfinity -> "\\infty" 23 | | NegativeInfinity -> "-\\infty" 24 | | NaN -> "\\times" 25 | | Float v -> v.ToString(floatFormat) 26 | | Float32 v -> v.ToString(floatFormat) 27 | | v -> v.ToString() 28 | 29 | let inline formatMatrix (matrix: Matrix<'T>) = 30 | String.concat Environment.NewLine 31 | [ "\\begin{bmatrix}" 32 | matrix.ToMatrixString(10, 4, 7, 2, "\\cdots", "\\vdots", "\\ddots", " & ", "\\\\ " + Environment.NewLine, (fun x -> formatMathValue "G4" x)) 33 | "\\end{bmatrix}" ] 34 | 35 | let inline formatVector (vector: Vector<'T>) = 36 | String.concat Environment.NewLine 37 | [ "\\begin{bmatrix}" 38 | vector.ToVectorString(12, 80, "\\vdots", " & ", "\\\\ " + Environment.NewLine, (fun x -> formatMathValue "G4" x)) 39 | "\\end{bmatrix}" ] 40 | 41 | App.AddDisplayPrinter (fun (x:Matrix) -> { ContentType = "text/latex"; Data = formatMatrix x }) 42 | App.AddDisplayPrinter (fun (x:Matrix) -> { ContentType = "text/latex"; Data = formatMatrix x }) 43 | App.AddDisplayPrinter (fun (x:Vector) -> { ContentType = "text/latex"; Data = formatVector x }) 44 | App.AddDisplayPrinter (fun (x:Vector) -> { ContentType = "text/latex"; Data = formatVector x }) -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Ground.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Ground 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 70, y: 70} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 2800000, guid: 16bb7757de826a448b844a2eacd51d0c, type: 3} 43 | m_Scale: {x: 70, y: 70} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.24 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/FallbackedEventReceiver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx; 3 | using UnityEngine; 4 | using UnityEngine.EventSystems; 5 | #if NET_4_6 6 | 7 | #endif 8 | 9 | namespace RLCreature.Sample.Common.UI 10 | { 11 | public class FallbackedEventReceiver : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IScrollHandler, IPointerClickHandler 12 | { 13 | public enum FallbackedEvents 14 | { 15 | DragBegin, 16 | Dragging, 17 | DragEnd, 18 | Scroll, 19 | LeftClick, 20 | RightClick, 21 | } 22 | 23 | public IObservable> EventObservable 24 | { 25 | get { return _eventSubject; } 26 | } 27 | 28 | private readonly Subject> _eventSubject = new Subject>(); 29 | 30 | void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) 31 | { 32 | _eventSubject.OnNext(new Tuple(FallbackedEvents.DragBegin, eventData)); 33 | } 34 | 35 | void IDragHandler.OnDrag(PointerEventData eventData) 36 | { 37 | _eventSubject.OnNext(new Tuple(FallbackedEvents.Dragging, eventData)); 38 | } 39 | 40 | void IEndDragHandler.OnEndDrag(PointerEventData eventData) 41 | { 42 | _eventSubject.OnNext(new Tuple(FallbackedEvents.DragEnd, eventData)); 43 | } 44 | 45 | void IScrollHandler.OnScroll(PointerEventData eventData) 46 | { 47 | _eventSubject.OnNext(new Tuple(FallbackedEvents.Scroll, eventData)); 48 | } 49 | 50 | public void OnPointerClick(PointerEventData eventData) 51 | { 52 | if (eventData.button == PointerEventData.InputButton.Left) 53 | { 54 | _eventSubject.OnNext( 55 | new Tuple(FallbackedEvents.LeftClick, eventData)); 56 | } 57 | else if (eventData.button == PointerEventData.InputButton.Right) 58 | { 59 | _eventSubject.OnNext( 60 | new Tuple(FallbackedEvents.RightClick, eventData)); 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RLCreature for Unity ([日本語](./docs/README_ja.md)) 2 | 3 | ### [Project Page](https://dmv.nico/ja/casestudy/alife/) 4 | ### [Paper](https://dmv.nico/assets/img/casestudy/alife/siggraph2018_alife.pdf) 5 | 6 | ![](./docs/20180801_OSS_showcase.gif) 7 | 8 | Install 9 | =========================== 10 | 11 | ### 0. Install Unity 12 | 13 | - We are using 2018 14 | - Set ScriptingRuntimeVersion to .NET4.X 15 | 16 | ### 1. Clone Repository 17 | 18 | - `git clone --recursive https://github.com/dwango/RLCreature.git` 19 | - git-lfs is required 20 | 21 | ### 2. Install Dependencies 22 | 23 | - MessagePack-CSharp 24 | - https://github.com/neuecc/MessagePack-CSharp/releases 25 | - UniRX 26 | - https://assetstore.unity.com/packages/tools/integration/unirx-reactive-extensions-for-unity-17276 27 | - Standard Assets 28 | - https://assetstore.unity.com/packages/essentials/asset-packs/standard-assets-32351 29 | 30 | ### 3. Open Demo Scenes 31 | 32 | - Assets/RLCreature/Sample/RandomCreatures 33 | - Assets/RLCreature/Sample/DesignedCreatures 34 | - Assets/RLCreature/Sample/VariousHeights 35 | - Assets/RLCreature/Sample/Driving 36 | - Assets/RLCreature/Sample/SimpleHunting 37 | 38 | Create Original Creatures 39 | =========================== 40 | 41 | see `Assets/RLCreature/Sample/DesignedCreatures/DesignedCreaturesEntryPoint.cs` 42 | 43 | ``` 44 | // Instantiate prefab (see Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs) 45 | var centralBody = Instantiate(creaturePrefab); 46 | 47 | // Add Sensor and Mouth for food 48 | Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 49 | Mouth.CreateComponent(centralBody, typeof(Food)); 50 | 51 | // Initialize Brain 52 | var actions = LocomotionAction.EightDirections(); 53 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.1f, minimumCandidates: 30); 54 | var decisionMaker = new ReinforcementDecisionMaker(); 55 | var souls = new List() {new GluttonySoul()}; 56 | 57 | var brain = new Brain(decisionMaker, sequenceMaker); 58 | var agent = Agent.CreateComponent(creatureRootGameObject, brain, new Body(centralBody), actions, souls); 59 | ``` 60 | 61 | 62 | Reference 63 | =============== 64 | 65 | ```bibtex 66 | @inproceedings{ogaki2018, 67 | author = {Keisuke Ogaki and Masayoshi Nakamura}, 68 | title = {Real-Time Motion Generation for Imaginary Creatures Using Hierarchical Reinforcement Learning}, 69 | booktitle = {ACM SIGGRAPH 2018 Studio}, 70 | year = {2018}, 71 | publisher = {ACM} 72 | } 73 | ``` 74 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/TreeJointGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEngine; 3 | 4 | namespace RLCreature.BodyGenerator.JointGenerator 5 | { 6 | public class TreeJointGenerator : JointGenerator 7 | { 8 | public TreeJointGenerator(GameObject[] bodyPrefabs, GameObject[] armPrefabs) : base(bodyPrefabs, armPrefabs) 9 | { 10 | } 11 | 12 | public override GameObject Instantiate(Vector3 pos) 13 | { 14 | var rootObject = new GameObject(); 15 | var rootComponent = 16 | new BodyComponent(BodyPrefabs[UnityEngine.Random.Range(0, BodyPrefabs.Length)], pos: pos); 17 | rootComponent.CentralBody.transform.parent = rootObject.transform; 18 | for (int i = 0; i < UnityEngine.Random.Range(1, 20); i++) 19 | { 20 | var current = rootComponent; 21 | while (true) 22 | { 23 | if (current.GetSlaves().Count() == 0) 24 | { 25 | var component = new BodyComponent( 26 | ArmPrefabs[UnityEngine.Random.Range(0, ArmPrefabs.Length)], 27 | parent: current); 28 | component.CentralBody.transform.parent = rootObject.transform; 29 | break; 30 | } 31 | 32 | if (Random.value < 0.8 && current.HasAvailableConnector()) 33 | { 34 | UnityEngine.Debug.Log("branch"); 35 | var component = new BodyComponent( 36 | ArmPrefabs[UnityEngine.Random.Range(0, ArmPrefabs.Length)], 37 | parent: current); 38 | component.CentralBody.transform.parent = rootObject.transform; 39 | break; 40 | } 41 | else 42 | { 43 | UnityEngine.Debug.Log("edge"); 44 | var candidates = current.GetSlaves().ToList(); 45 | current = candidates[Random.Range(0, candidates.Count)]; 46 | } 47 | } 48 | } 49 | 50 | rootComponent.CentralBody.GetComponent().centerOfMass = new Vector3(0f, -10f, 0f);; 51 | rootComponent.CentralBody.GetComponent().mass *= 1; 52 | 53 | return rootObject; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/Agent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using MotionGenerator; 4 | using MotionGenerator.Entity.Soul; 5 | using RLCreature.BodyGenerator.Manipulatables; 6 | using UnityEngine; 7 | 8 | namespace RLCreature.BodyGenerator 9 | { 10 | public class Agent : MonoBehaviour 11 | { 12 | Body body; 13 | IBrain brain; 14 | 15 | 16 | private List GetChildrenManipulatables() 17 | { 18 | return transform.gameObject.GetComponentsInChildren().ToList(); 19 | } 20 | 21 | public static Agent CreateComponent(GameObject obj, IBrain brain, Body body, List actions, List souls = null) 22 | { 23 | return obj.AddComponent()._CreateComponent(brain, body, actions, souls); 24 | } 25 | 26 | private Agent _CreateComponent(IBrain brain, Body body, List actions, List souls = null) 27 | { 28 | List manipulatables = GetChildrenManipulatables(); 29 | for (int i = 0; i < manipulatables.Count; i++) 30 | { 31 | manipulatables[i].SetManipulatableId(i); // just an ID 32 | } 33 | 34 | if (souls == null) 35 | { 36 | souls = new List() {new GluttonySoul()}; 37 | } 38 | 39 | body.Init(manipulatables, actions); 40 | brain.Init( 41 | manipulatables 42 | .Where(m => m.GetManipulatableDimention() > 0) 43 | .Select(m => m.GetManipulatableDimention()).ToList(), 44 | actions, 45 | souls); 46 | this.brain = brain; 47 | this.body = body; 48 | return this; 49 | } 50 | 51 | void GoNextAction() 52 | { 53 | State state = body.GetState(); 54 | var ms = brain.GenerateMotionSequence(state); 55 | body.Manipulate(ms); 56 | } 57 | 58 | void FixedUpdate() 59 | { 60 | if (transform.position.y < 0) // out from ground 61 | { 62 | Destroy(this.gameObject); 63 | } 64 | 65 | UpdateAction(); 66 | } 67 | 68 | 69 | void UpdateAction() 70 | { 71 | body.Update(); 72 | if (body != null && !body.IsMoving()) 73 | { 74 | GoNextAction(); 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /docs/README_ja.md: -------------------------------------------------------------------------------- 1 | # RLCreature for Unity 2 | 3 | スマートフォンで人工生命数十体がリアルタイムに学習可能な深層強化学習 4 | 5 | ### [詳細ページ](https://dmv.nico/ja/casestudy/alife/) 6 | ### [論文](https://dmv.nico/assets/img/casestudy/alife/siggraph2018_alife.pdf) 7 | 8 | ![](./20180801_OSS_showcase.gif) 9 | 10 | サンプルデモを動かす 11 | =========================== 12 | 13 | ### 0. Unityを用意 14 | 15 | - 2018が推奨 16 | - ScriptingRuntimeVersionを必ず.NET4.Xにして動かして下さい 17 | 18 | ### 1. レポジトリをクローン 19 | 20 | - `git clone --recursive https://github.com/dwango/RLCreature.git` 21 | - git-lfsが必要です 22 | 23 | ### 2. 依存ライブラリをインストール 24 | 25 | - MessagePack-CSharp 26 | - https://github.com/neuecc/MessagePack-CSharp/releases 27 | - unitypackageをダウンロードしてインストールしてください 28 | - UniRX 29 | - https://assetstore.unity.com/packages/tools/integration/unirx-reactive-extensions-for-unity-17276 30 | - Standard Assets 31 | - https://assetstore.unity.com/packages/essentials/asset-packs/standard-assets-32351 32 | 33 | ### 3. デモシーンを開く 34 | 35 | - Assets/RLCreature/Sample/RandomCreatures 36 | - Assets/RLCreature/Sample/DesignedCreatures 37 | - Assets/RLCreature/Sample/VariousHeights 38 | - Assets/RLCreature/Sample/Driving 39 | - Assets/RLCreature/Sample/SimpleHunting 40 | 41 | Create Original Creatures 42 | =========================== 43 | 44 | see `Assets/RLCreature/Sample/DesignedCreatures/DesignedCreaturesEntryPoint.cs` 45 | 46 | ``` 47 | // Instantiate prefab (see Assets/RLCreature/Sample/DesignedCreatures/CreaturePrefabs) 48 | var centralBody = Instantiate(creaturePrefab); 49 | 50 | // Add Sensor and Mouth for food 51 | Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 52 | Mouth.CreateComponent(centralBody, typeof(Food)); 53 | 54 | // Initialize Brain 55 | var actions = LocomotionAction.EightDirections(); 56 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.1f, minimumCandidates: 30); 57 | var decisionMaker = new ReinforcementDecisionMaker(); 58 | var souls = new List() {new GluttonySoul()}; 59 | 60 | var brain = new Brain(decisionMaker, sequenceMaker); 61 | var agent = Agent.CreateComponent(creatureRootGameObject, brain, new Body(centralBody), actions, souls); 62 | ``` 63 | 64 | 65 | Reference 66 | =============== 67 | 68 | ```bibtex 69 | @inproceedings{ogaki2018, 70 | author = {Keisuke Ogaki and Masayoshi Nakamura}, 71 | title = {Real-Time Motion Generation for Imaginary Creatures Using Hierarchical Reinforcement Learning}, 72 | booktitle = {ACM SIGGRAPH 2018 Studio}, 73 | year = {2018}, 74 | publisher = {ACM} 75 | } 76 | ``` 77 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/SuperFlexibleMove.cs: -------------------------------------------------------------------------------- 1 | using MotionGenerator; 2 | using UnityEngine; 3 | using UnityEngine.Assertions; 4 | 5 | namespace RLCreature.BodyGenerator.Manipulatables 6 | { 7 | public class SuperFlexibleMove : ManipulatableBase 8 | { 9 | private int _consumedFrames; 10 | private float _speed = 0.1f; 11 | private MotionSequence _sequence = new MotionSequence(); 12 | private Rigidbody _rigidbody; 13 | 14 | private SuperFlexibleMove() 15 | { 16 | } 17 | 18 | public static SuperFlexibleMove CreateComponent(GameObject obj, float speed) 19 | { 20 | var created = obj.AddComponent(); 21 | created._speed = speed; 22 | return created; 23 | } 24 | 25 | public override void Manipulate(MotionSequence sequence) 26 | { 27 | _consumedFrames = 0; 28 | _isMoving = true; 29 | _sequence = new MotionSequence(sequence); 30 | } 31 | 32 | public override void UpdateFixedFrame() 33 | { 34 | if (_sequence.Sequence.Count > 0) 35 | { 36 | if (_sequence[0].time < _consumedFrames) 37 | { 38 | Assert.AreEqual( 39 | _sequence[0].value.Count, 40 | 2 41 | ); 42 | var towardVector = new Vector3( 43 | _sequence[0].value[0] > 0.5f ? -1 : 1, 44 | 0, 45 | _sequence[0].value[1] > 0.5f ? -1 : 1 46 | ); 47 | _rigidbody.AddRelativeForce(towardVector * _speed * 1000000, ForceMode.Impulse); 48 | // _rigidbody.MovePosition(gameObject.transform.position + towardVector * _speed); 49 | _sequence.Sequence.RemoveAt(0); 50 | } 51 | } 52 | else 53 | { 54 | _isMoving = false; 55 | } 56 | 57 | _consumedFrames += 1; 58 | } 59 | 60 | public override void Init() 61 | { 62 | _rigidbody = gameObject.GetComponent(); 63 | _rigidbody.maxDepenetrationVelocity = Mathf.Infinity; 64 | _rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; 65 | } 66 | 67 | public override int GetManipulatableDimention() 68 | { 69 | return 2; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/UI/ReservedUIMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: ReservedUIMaterial 10 | m_Shader: {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _ColorMask: 15 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _Stencil: 0 74 | - _StencilComp: 8 75 | - _StencilOp: 0 76 | - _StencilReadMask: 255 77 | - _StencilWriteMask: 255 78 | - _UVSec: 0 79 | - _UseUIAlphaClip: 0 80 | - _ZWrite: 1 81 | m_Colors: 82 | - _Color: {r: 1, g: 1, b: 1, a: 1} 83 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 84 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Resources/Materials/Block.psd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16bb7757de826a448b844a2eacd51d0c 3 | timeCreated: 1512563971 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | externalObjects: {} 8 | serializedVersion: 4 9 | mipmaps: 10 | mipMapMode: 0 11 | enableMipMap: 1 12 | sRGBTexture: 1 13 | linearTexture: 0 14 | fadeOut: 0 15 | borderMipMap: 0 16 | mipMapsPreserveCoverage: 0 17 | alphaTestReferenceValue: 0.5 18 | mipMapFadeDistanceStart: 1 19 | mipMapFadeDistanceEnd: 3 20 | bumpmap: 21 | convertToNormalMap: 0 22 | externalNormalMap: 0 23 | heightScale: 0.25 24 | normalMapFilter: 0 25 | isReadable: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 1 35 | aniso: -1 36 | mipBias: -1 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 49 | spritePixelsToUnits: 100 50 | alphaUsage: 1 51 | alphaIsTransparency: 1 52 | spriteTessellationDetail: -1 53 | textureType: 0 54 | textureShape: 1 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - buildTarget: DefaultTexturePlatform 60 | maxTextureSize: 2048 61 | resizeAlgorithm: 0 62 | textureFormat: -1 63 | textureCompression: 1 64 | compressionQuality: 50 65 | crunchedCompression: 0 66 | allowsAlphaSplitting: 0 67 | overridden: 0 68 | androidETC2FallbackOverride: 0 69 | - buildTarget: Standalone 70 | maxTextureSize: 2048 71 | resizeAlgorithm: 0 72 | textureFormat: -1 73 | textureCompression: 1 74 | compressionQuality: 50 75 | crunchedCompression: 0 76 | allowsAlphaSplitting: 0 77 | overridden: 0 78 | androidETC2FallbackOverride: 0 79 | - buildTarget: PS4 80 | maxTextureSize: 2048 81 | resizeAlgorithm: 0 82 | textureFormat: -1 83 | textureCompression: 1 84 | compressionQuality: 50 85 | crunchedCompression: 0 86 | allowsAlphaSplitting: 0 87 | overridden: 0 88 | androidETC2FallbackOverride: 0 89 | spriteSheet: 90 | serializedVersion: 2 91 | sprites: [] 92 | outline: [] 93 | physicsShape: [] 94 | spritePackingTag: 95 | userData: 96 | assetBundleName: 97 | assetBundleVariant: 98 | -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/SubCameras/AgentFocusStrategy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using RLCreature.BodyGenerator; 4 | using RLCreature.Sample.Common.UI.Cameras.OperatableCameras; 5 | using UnityEngine; 6 | 7 | namespace RLCreature.Sample.Common.UI.Cameras.SubCameras 8 | { 9 | public class AgentFocusStrategy : IFocusStrategy 10 | { 11 | private const float TransitionTime = 6f; 12 | private const float InitialDistance = 3f; 13 | private const float FarAwayDistance = 5; 14 | 15 | private readonly int _interval; 16 | private readonly List _creatures; 17 | private int _currentIndex; 18 | private float _lastChangedTime; 19 | private CameraAttitude _lastCameraAttitude; 20 | private IOperatableCamera _camera; 21 | 22 | public AgentFocusStrategy(int interval = 5) 23 | { 24 | _interval = interval; 25 | _creatures = new List(); 26 | _lastCameraAttitude = new CameraAttitude 27 | { 28 | LookAt = new Vector3(-1f, 0, -10f), 29 | Position = new Vector3(0.0f, 10.0f, -40.0f), 30 | }; 31 | // 最初は対象がいないので定点を見ておく 32 | _camera = new MonitoringCamera(_lastCameraAttitude); 33 | } 34 | 35 | public void Add(Agent creature) 36 | { 37 | _creatures.Add(creature); 38 | } 39 | 40 | public void Remove(Agent creature) 41 | { 42 | if (!_creatures.Contains(creature)) 43 | { 44 | return; 45 | } 46 | 47 | _creatures.Remove(creature); 48 | } 49 | 50 | public CameraAttitude Update() 51 | { 52 | var time = Time.unscaledTime - _lastChangedTime; 53 | if (time > _interval) 54 | { 55 | _lastChangedTime = Time.unscaledTime; 56 | if (!_creatures.Any()) 57 | { 58 | return _lastCameraAttitude; 59 | } 60 | 61 | _currentIndex++; 62 | if (_currentIndex >= _creatures.Count) 63 | { 64 | _currentIndex = 0; 65 | } 66 | 67 | var creature = _creatures[_currentIndex]; 68 | 69 | var transform = creature.transform.GetChild(0).transform; 70 | _camera = new FocusCamera(transform, 71 | transitionTime: TransitionTime, initialDistance: InitialDistance, farAwayDistance: FarAwayDistance); 72 | _camera.Initialize(_lastCameraAttitude); 73 | } 74 | 75 | _lastCameraAttitude = _camera.Update(Time.unscaledDeltaTime); 76 | return _lastCameraAttitude; 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/SimpleHunting/SimpleHuntingEntrypoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using MotionGenerator; 3 | using RLCreature.BodyGenerator; 4 | using RLCreature.BodyGenerator.Manipulatables; 5 | using UnityEngine; 6 | 7 | namespace RLCreature.Sample.SimpleHunting 8 | { 9 | public class Food : MonoBehaviour 10 | { 11 | } 12 | 13 | 14 | public class SimpleHuntingEntrypoint : MonoBehaviour 15 | { 16 | private Rect _size; 17 | public int FoodCount = 100; 18 | 19 | private void Start() 20 | { 21 | var plane = GameObject.CreatePrimitive(PrimitiveType.Plane); 22 | plane.transform.position = Vector3.zero; 23 | plane.transform.localScale = Vector3.one * 20; 24 | var unitPlaneSize = 10; 25 | _size = new Rect( 26 | (plane.transform.position.x - plane.transform.lossyScale.x * unitPlaneSize) / 2, 27 | (plane.transform.position.y - plane.transform.lossyScale.y * unitPlaneSize) / 2, 28 | plane.transform.lossyScale.x * unitPlaneSize, 29 | plane.transform.lossyScale.y * unitPlaneSize 30 | ); 31 | var creature = SpawnCreature(); 32 | 33 | var camera = Camera.main; 34 | camera.transform.parent = creature.transform; 35 | camera.transform.position = creature.transform.position - creature.transform.forward * 30 + 36 | creature.transform.up * 10; 37 | 38 | StartCoroutine(Feeder()); 39 | } 40 | 41 | 42 | private IEnumerator Feeder() 43 | { 44 | while (true) 45 | { 46 | var foodCount = FindObjectsOfType().Length; 47 | for (int i = 0; i < FoodCount - foodCount; i++) 48 | { 49 | Feed(); 50 | } 51 | 52 | yield return new WaitForSeconds(5); 53 | } 54 | } 55 | 56 | private void Feed() 57 | { 58 | var foodObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); 59 | var food = foodObject.AddComponent(); 60 | food.GetComponent().material.color = Color.green; 61 | food.GetComponent().isTrigger = true; 62 | food.transform.position = new Vector3( 63 | x: _size.xMin + Random.value * _size.width, 64 | y: 0, 65 | z: _size.yMin + Random.value * _size.height 66 | ); 67 | } 68 | 69 | private GameObject SpawnCreature() 70 | { 71 | var rootObject = GameObject.CreatePrimitive(PrimitiveType.Cube); 72 | SuperFlexibleMove.CreateComponent(rootObject, speed: 1f); 73 | rootObject.AddComponent().freezeRotation = true; 74 | rootObject.GetComponent().material.color = Color.red; 75 | Sensor.CreateComponent(rootObject, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 76 | Mouth.CreateComponent(rootObject, typeof(Food)); 77 | var actions = LocomotionAction.EightDirections(); 78 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); 79 | var brain = new Brain( 80 | new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition), 81 | sequenceMaker 82 | ); 83 | Agent.CreateComponent(rootObject, brain, new Body(rootObject), actions); 84 | return rootObject; 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Manipulatables/Joint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using MotionGenerator; 3 | using UnityEngine; 4 | 5 | namespace RLCreature.BodyGenerator.Manipulatables 6 | { 7 | public class Joint : ManipulatableBase 8 | { 9 | private const int MaximumForce = 10000; 10 | private const float PositionDamper = 20; 11 | private const float PositionSpring = 1000; 12 | private float _targetForce; 13 | public List TargetAngle = new List {0, 0, 0}; 14 | private int _consumedFrames = 0; 15 | 16 | private ConfigurableJoint _joint; 17 | private MotionSequence _sequence = new MotionSequence(); 18 | 19 | 20 | public static Joint CreateComponent(ConfigurableJoint joint, float targetForce) 21 | { 22 | return joint.gameObject.AddComponent()._CreateComponent(joint, targetForce); 23 | } 24 | 25 | private Joint _CreateComponent(ConfigurableJoint joint, float targetForce) 26 | { 27 | _joint = joint; 28 | _joint.xMotion = ConfigurableJointMotion.Locked; 29 | _joint.yMotion = ConfigurableJointMotion.Locked; 30 | _joint.zMotion = ConfigurableJointMotion.Locked; 31 | _joint.angularXMotion = ConfigurableJointMotion.Limited; 32 | _joint.angularYMotion = ConfigurableJointMotion.Limited; 33 | _joint.angularZMotion = ConfigurableJointMotion.Limited; 34 | _targetForce = targetForce; 35 | return this; 36 | } 37 | 38 | public override void Manipulate(MotionSequence sequence) 39 | { 40 | _consumedFrames = 0; 41 | _isMoving = true; 42 | _sequence = new MotionSequence(sequence); 43 | } 44 | 45 | void UpdateJointMotor(List targetAngle) 46 | { 47 | if (targetAngle.Count != 3) 48 | throw new System.ArgumentException("need 3D input"); 49 | _joint.targetRotation = Quaternion.Euler( 50 | targetAngle[0] * (_joint.highAngularXLimit.limit - _joint.lowAngularXLimit.limit) 51 | + _joint.lowAngularXLimit.limit, 52 | (targetAngle[1] * 2f - 1f) * _joint.angularYLimit.limit, 53 | (targetAngle[2] * 2f - 1f) * _joint.angularZLimit.limit); 54 | 55 | var jd = _joint.angularXDrive; 56 | jd.maximumForce = MaximumForce; 57 | jd.positionDamper = PositionDamper * _targetForce; 58 | jd.positionSpring = PositionSpring * _targetForce; 59 | _joint.angularXDrive = jd; 60 | var jdYZ = _joint.angularYZDrive; 61 | jdYZ.maximumForce = MaximumForce; 62 | jdYZ.positionDamper = PositionDamper * _targetForce; 63 | jdYZ.positionSpring = PositionSpring * _targetForce; 64 | _joint.angularYZDrive = jdYZ; 65 | 66 | _joint.projectionMode = JointProjectionMode.PositionAndRotation; 67 | } 68 | 69 | public void FixedUpdate() 70 | { 71 | if (_sequence.Sequence.Count > 0) 72 | { 73 | this.TargetAngle = _sequence[0].value; 74 | if (_sequence[0].time < _consumedFrames) 75 | { 76 | _sequence.Sequence.RemoveAt(0); 77 | } 78 | } 79 | else 80 | { 81 | _isMoving = false; 82 | } 83 | 84 | UpdateJointMotor(TargetAngle); 85 | _consumedFrames += 1; 86 | } 87 | 88 | public override int GetManipulatableDimention() 89 | { 90 | return 3; 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/CreatureInfoList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UniRx; 5 | using UnityEngine; 6 | using Object = UnityEngine.Object; 7 | 8 | #if NET_4_6 9 | 10 | #endif 11 | 12 | namespace RLCreature.Sample.Common.UI.UIComponents 13 | { 14 | public class CreatureInfoList 15 | { 16 | public IObservable SelectedCell 17 | { 18 | get { return _selectedCellSubject; } 19 | } 20 | 21 | private readonly ReactiveProperty _selectedCellSubject = 22 | new ReactiveProperty(); 23 | 24 | private readonly RectTransform _contentRect; 25 | 26 | private readonly Dictionary _cells = 27 | new Dictionary(); 28 | 29 | private static readonly string CreatureCellPrefabPath = "CreatureListElement"; 30 | 31 | public CreatureInfoList(RectTransform content) 32 | { 33 | _contentRect = content; 34 | } 35 | 36 | public void Select(GameObject creature) 37 | { 38 | if (creature == null || !_cells.ContainsKey(creature)) 39 | { 40 | foreach (var cell in _cells) 41 | { 42 | cell.Value.Selected.Value = false; 43 | } 44 | 45 | _selectedCellSubject.Value = null; 46 | } 47 | else 48 | { 49 | _cells[creature].Selected.Value = true; 50 | } 51 | } 52 | 53 | public CreatureInfoCell Add(GameObject creature, string name) 54 | { 55 | var cell = Object.Instantiate(Resources.Load(CreatureCellPrefabPath)); 56 | cell.Creature = creature; 57 | cell.DisplayName = name; 58 | var cellRect = cell.GetComponent(); 59 | cellRect.SetParent(_contentRect, false); 60 | cell.Selected 61 | .Where(x => x) 62 | .Subscribe(_ => 63 | { 64 | foreach (var c in _cells.Values.Where(c => c != cell)) 65 | { 66 | c.Selected.Value = false; 67 | } 68 | 69 | _selectedCellSubject.Value = cell; 70 | }) 71 | .AddTo(cell); 72 | _cells.Add(creature, cell); 73 | if (_cells.Count == 1) 74 | { 75 | _cells[creature].Selected.Value = true; 76 | } 77 | 78 | return cell; 79 | } 80 | 81 | public void Remove(GameObject creature) 82 | { 83 | if (!_cells.ContainsKey(creature)) return; 84 | 85 | var cell = _cells[creature]; 86 | _cells.Remove(creature); 87 | DestroyRecursive(cell.transform); 88 | } 89 | 90 | public int CurrentCreaturesCount() 91 | { 92 | return _cells.Count; 93 | } 94 | 95 | public void UpdateList() 96 | { 97 | foreach (var cell in _cells.Select(p => p.Value)) 98 | { 99 | cell.gameObject.SetActive(cell.IsActive()); 100 | } 101 | } 102 | 103 | private void DestroyRecursive(Transform target) 104 | { 105 | foreach (Transform child in target) 106 | { 107 | DestroyRecursive(child); 108 | } 109 | 110 | Object.Destroy(target.gameObject); 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/Body.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using MathNet.Numerics.LinearAlgebra.Double; 4 | using MotionGenerator; 5 | using RLCreature.BodyGenerator.Manipulatables; 6 | using UnityEngine; 7 | 8 | namespace RLCreature.BodyGenerator 9 | { 10 | public class Motor 11 | { 12 | List _manipulatables; 13 | 14 | public Motor(List manipulatables) 15 | { 16 | this._manipulatables = manipulatables; 17 | } 18 | 19 | public void Manipulate(List motionSequences) 20 | { 21 | UnityEngine.Assertions.Assert.AreEqual(motionSequences.Count, _manipulatables.Count); 22 | for (int i = 0; i < _manipulatables.Count; i++) 23 | { 24 | _manipulatables[i].Manipulate(motionSequences[i]); 25 | } 26 | } 27 | } 28 | 29 | public class Body 30 | { 31 | GameObject rootObject; 32 | List manipulatables; 33 | Motor motor; 34 | private DenseVector _birthPosition; 35 | 36 | public Body(GameObject rootObject) 37 | { 38 | this.rootObject = rootObject; 39 | } 40 | 41 | public void Init(List manipulatables, List actions) 42 | { 43 | var position = rootObject.transform.position; 44 | _birthPosition = new DenseVector(new double[]{position.x, position.y, position.z}); 45 | this.manipulatables = manipulatables; 46 | foreach (var manipulatable in this.manipulatables) 47 | { 48 | manipulatable.Init(); 49 | } 50 | 51 | var manipulatablesMovables = manipulatables.Where(m => m.GetManipulatableDimention() > 0).ToList(); 52 | motor = new Motor(manipulatablesMovables); 53 | } 54 | 55 | public State GetState() 56 | { 57 | var state = new State(); 58 | foreach (var manipulatable in manipulatables) 59 | { 60 | foreach (var kv in manipulatable.GetState()) 61 | { 62 | state[kv.Key] = kv.Value; 63 | } 64 | } 65 | 66 | var position = rootObject.transform.position; 67 | var rotation = rootObject.transform.rotation; 68 | var forward = rootObject.transform.forward; 69 | state[State.BasicKeys.Time] = new DenseVector(new double[]{Time.time}); 70 | state[State.BasicKeys.BirthPosition] = _birthPosition; 71 | state[State.BasicKeys.Position] = new DenseVector(new double[] {position.x, position.y, position.z}); 72 | state[State.BasicKeys.Rotation] = 73 | new DenseVector(new double[] {rotation.x, rotation.y, rotation.z, rotation.w}); 74 | state[State.BasicKeys.Forward] = new DenseVector(new double[] {forward.x, forward.y, forward.z}); 75 | return state; 76 | } 77 | 78 | public List GetJoints() 79 | { 80 | return manipulatables; 81 | } 82 | 83 | public void Manipulate(List sequence) 84 | { 85 | motor.Manipulate(sequence); 86 | } 87 | 88 | public bool IsMoving() 89 | { 90 | return manipulatables.Any(manipulable => manipulable.IsMoving()); 91 | } 92 | 93 | 94 | public void Update() 95 | { 96 | for (var i = 0; i < manipulatables.Count; i++) 97 | { 98 | manipulatables[i].UpdateFixedFrame(); 99 | } 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Driving/DrivingEntrypoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using MotionGenerator; 3 | using RLCreature.BodyGenerator; 4 | using RLCreature.BodyGenerator.Manipulatables; 5 | using RLCreature.Sample.SimpleHunting; 6 | using UnityEngine; 7 | 8 | namespace RLCreature.Sample.Driving 9 | { 10 | public class DrivingEntrypoint : MonoBehaviour 11 | { 12 | private Rect _size; 13 | public int FoodCount = 800; 14 | 15 | private void Start() 16 | { 17 | var plane = GameObject.CreatePrimitive(PrimitiveType.Plane); 18 | plane.transform.position = Vector3.zero; 19 | plane.transform.localScale = Vector3.one * 100; 20 | var unitPlaneSize = 10; 21 | _size = new Rect( 22 | (plane.transform.position.x - plane.transform.lossyScale.x * unitPlaneSize) / 2, 23 | (plane.transform.position.y - plane.transform.lossyScale.y * unitPlaneSize) / 2, 24 | plane.transform.lossyScale.x * unitPlaneSize, 25 | plane.transform.lossyScale.y * unitPlaneSize 26 | ); 27 | var creature = SpawnCreature(); 28 | 29 | var camera = Camera.main; 30 | camera.transform.parent = creature.transform; 31 | camera.transform.position = creature.transform.position - creature.transform.forward * 30 + 32 | creature.transform.up * 10; 33 | StartCoroutine(Feeder()); 34 | StartCoroutine(SpawnSome()); 35 | } 36 | 37 | private IEnumerator SpawnSome() 38 | { 39 | yield return new WaitForSeconds(60); 40 | SpawnCreature(); 41 | yield return new WaitForSeconds(60); 42 | SpawnCreature(); 43 | yield return new WaitForSeconds(60); 44 | SpawnCreature(); 45 | yield return new WaitForSeconds(60); 46 | SpawnCreature(); 47 | } 48 | 49 | 50 | private IEnumerator Feeder() 51 | { 52 | while (true) 53 | { 54 | var foodCount = FindObjectsOfType().Length; 55 | for (int i = 0; i < FoodCount - foodCount; i++) 56 | { 57 | Feed(); 58 | } 59 | 60 | yield return new WaitForSeconds(5); 61 | } 62 | } 63 | 64 | private void Feed() 65 | { 66 | var foodObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); 67 | foodObject.transform.localScale = Vector3.one * 5; 68 | var food = foodObject.AddComponent(); 69 | food.GetComponent().material.color = Color.green; 70 | food.GetComponent().isTrigger = true; 71 | food.transform.position = new Vector3( 72 | x: _size.xMin + Random.value * _size.width, 73 | y: 0, 74 | z: _size.yMin + Random.value * _size.height 75 | ); 76 | } 77 | 78 | private GameObject SpawnCreature() 79 | { 80 | var prefab = (GameObject) Resources.Load("Prefabs/Car"); 81 | var car = Instantiate(prefab, Vector3.zero, Quaternion.identity); 82 | CarControlManipulatable.CreateComponent(car); 83 | Sensor.CreateComponent(car, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 84 | Mouth.CreateComponent(car, typeof(Food)); 85 | 86 | var actions = LocomotionAction.EightDirections(); 87 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); 88 | var brain = new Brain( 89 | new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition), 90 | sequenceMaker 91 | ); 92 | Agent.CreateComponent(car, brain, new Body(car), actions); 93 | 94 | return car; 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/RandomNameGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEngine; 3 | 4 | namespace RLCreature.Sample.RandomCreatures 5 | { 6 | public class RandomNameGenerator 7 | { 8 | // this list is derived from docker names generator https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go 9 | // Copyright 2013-2017 Docker, Inc. 10 | private static readonly string[] Adjectives = 11 | { 12 | "admiring", 13 | "adoring", 14 | "affectionate", 15 | "agitated", 16 | "amazing", 17 | "angry", 18 | "awesome", 19 | "blissful", 20 | "boring", 21 | "brave", 22 | "clever", 23 | "cocky", 24 | "compassionate", 25 | "competent", 26 | "condescending", 27 | "confident", 28 | "cranky", 29 | "dazzling", 30 | "determined", 31 | "distracted", 32 | "dreamy", 33 | "eager", 34 | "ecstatic", 35 | "elastic", 36 | "elated", 37 | "elegant", 38 | "eloquent", 39 | "epic", 40 | "fervent", 41 | "festive", 42 | "flamboyant", 43 | "focused", 44 | "friendly", 45 | "frosty", 46 | "gallant", 47 | "gifted", 48 | "goofy", 49 | "gracious", 50 | "happy", 51 | "hardcore", 52 | "heuristic", 53 | "hopeful", 54 | "hungry", 55 | "infallible", 56 | "inspiring", 57 | "jolly", 58 | "jovial", 59 | "keen", 60 | "kind", 61 | "laughing", 62 | "loving", 63 | "lucid", 64 | "mystifying", 65 | "modest", 66 | "musing", 67 | "naughty", 68 | "nervous", 69 | "nifty", 70 | "nostalgic", 71 | "objective", 72 | "optimistic", 73 | "peaceful", 74 | "pedantic", 75 | "pensive", 76 | "practical", 77 | "priceless", 78 | "quirky", 79 | "quizzical", 80 | "relaxed", 81 | "reverent", 82 | "romantic", 83 | "sad", 84 | "serene", 85 | "sharp", 86 | "silly", 87 | "sleepy", 88 | "stoic", 89 | "stupefied", 90 | "suspicious", 91 | "tender", 92 | "thirsty", 93 | "trusting", 94 | "unruffled", 95 | "upbeat", 96 | "vibrant", 97 | "vigilant", 98 | "vigorous", 99 | "wizardly", 100 | "wonderful", 101 | "xenodochial", 102 | "youthful", 103 | "zealous", 104 | "zen", 105 | }; 106 | 107 | 108 | private static readonly string[] Nouns = new string[] 109 | { 110 | "cat", 111 | "dog", 112 | "creature", 113 | "parrot", 114 | "horse", 115 | "bug", 116 | "snake", 117 | "gorilla", 118 | "bird", 119 | "squirrel", 120 | "bear", 121 | }; 122 | 123 | public static string EnglishName() 124 | { 125 | return Adjectives[Random.Range(0, Adjectives.Length)] + "_" + Nouns[Random.Range(0, Nouns.Length)]; 126 | } 127 | 128 | public static string JapaneseName() 129 | { 130 | const string charas = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"; 131 | return Enumerable.Range(0, Random.Range(3, 7)) 132 | .Select(_ => charas[Random.Range(0, charas.Length)].ToString()).Aggregate((x, y) => x + y); 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/UIComponents/ToolBar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace RLCreature.Sample.Common.UI.UIComponents 6 | { 7 | public class ToolBar 8 | { 9 | private const string ToolBarCategoryButtonPrefabPath = "ToolBarCategoryElement"; 10 | private const string ToolBarButtonPrefabPath = "ToolBarElement"; 11 | 12 | private readonly Dictionary> _actions = new Dictionary>(); 13 | 14 | private readonly RectTransform _categoryListContent; 15 | private readonly RectTransform _listContent; 16 | private readonly RectTransform _listRoot; 17 | 18 | private readonly ToolBarCell _hideListButton; 19 | 20 | public bool ListVisible 21 | { 22 | get { return _listRoot.gameObject.activeSelf; } 23 | set 24 | { 25 | _listRoot.gameObject.SetActive(value); 26 | } 27 | } 28 | 29 | public ToolBar(RectTransform categoryListContent, RectTransform listContent, RectTransform listRoot) 30 | { 31 | _categoryListContent = categoryListContent; 32 | _listContent = listContent; 33 | _listRoot = listRoot; 34 | 35 | // Menu Off Button 36 | _hideListButton = CreateButton(); 37 | _hideListButton.Button.onClick.AddListener(() => 38 | { 39 | ListVisible = false; 40 | }); 41 | _hideListButton.Name.text = "OFF"; 42 | ListVisible = false; 43 | } 44 | 45 | public void Add(IToolBarActions actions) 46 | { 47 | var category = actions.GetCategory(); 48 | CreateCategory(category); 49 | foreach (var kv in actions.GetActions()) 50 | { 51 | _actions[category].Add(kv.Key, kv.Value); 52 | } 53 | } 54 | 55 | public void Add(string category, string name, Action action) 56 | { 57 | CreateCategory(category); 58 | _actions[category].Add(name, action); 59 | } 60 | 61 | private ToolBarCell CreateButton() 62 | { 63 | var btn = UnityEngine.Object.Instantiate(Resources.Load(ToolBarCategoryButtonPrefabPath)); 64 | btn.GetComponent().SetParent(_categoryListContent, false); 65 | return btn; 66 | } 67 | 68 | private void CreateCategory(string category) 69 | { 70 | if (_actions.ContainsKey(category)) return; 71 | 72 | _actions.Add(category, new Dictionary()); 73 | 74 | var btn = CreateButton(); 75 | btn.Button.onClick.AddListener(() => Select(category)); 76 | btn.Name.text = category; 77 | } 78 | 79 | public void Select(string category) 80 | { 81 | if (!_actions.ContainsKey(category)) return; 82 | 83 | RemoveAllTools(); 84 | _listContent.anchoredPosition = Vector2.zero; 85 | foreach (var kv in _actions[category]) 86 | { 87 | AddTool(kv.Key, kv.Value); 88 | } 89 | if (!ListVisible) 90 | { 91 | ListVisible = true; 92 | } 93 | } 94 | 95 | private void RemoveAllTools() 96 | { 97 | var children = new List(); 98 | for (var i = 0; i < _listContent.childCount; ++i) 99 | { 100 | children.Add(_listContent.GetChild(i).gameObject); 101 | } 102 | foreach (var child in children) 103 | { 104 | GameObject.Destroy(child); 105 | } 106 | } 107 | 108 | private void AddTool(string name, Action action) 109 | { 110 | var button = UnityEngine.Object.Instantiate(Resources.Load(ToolBarButtonPrefabPath)); 111 | button.GetComponent().SetParent(_listContent, false); 112 | button.Button.onClick.AddListener(() => action()); 113 | button.Name.text = name; 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/DesignedCreatures/DesignedCreaturesEntryPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using MotionGenerator; 4 | using MotionGenerator.Entity.Soul; 5 | using RLCreature.BodyGenerator; 6 | using RLCreature.BodyGenerator.Manipulatables; 7 | using RLCreature.Sample.Common; 8 | using RLCreature.Sample.Common.UI; 9 | using RLCreature.Sample.Common.UI.Actions; 10 | using RLCreature.Sample.SimpleHunting; 11 | using UnityEngine; 12 | 13 | namespace RLCreature.Sample.DesignedCreatures 14 | { 15 | public class DesignedCreaturesEntryPoint : MonoBehaviour 16 | { 17 | private Rect _size; 18 | public int FoodCount = 800; 19 | public int CreatureCountPerPrefab = 10; 20 | public GameObject Plane; 21 | public List CreaturePrefabs; 22 | private CastUIPresenter GameUI; 23 | 24 | private void Start() 25 | { 26 | GameUI = CastUIPresenter.CreateComponent(Camera.main, gameObject); 27 | CastCameraController.CreateComponent(Camera.main, GameUI.SelectedCreature, 28 | GameUI.FallbackedEventsObservable); 29 | GameUI.LeftToolBar.Add(new SystemActions()); 30 | 31 | Plane.transform.position = Vector3.zero; 32 | Plane.transform.localScale = Vector3.one * 100; 33 | var unitPlaneSize = 10; 34 | _size = new Rect( 35 | (Plane.transform.position.x - Plane.transform.lossyScale.x * unitPlaneSize) / 2, 36 | (Plane.transform.position.y - Plane.transform.lossyScale.y * unitPlaneSize) / 2, 37 | Plane.transform.lossyScale.x * unitPlaneSize, 38 | Plane.transform.lossyScale.y * unitPlaneSize 39 | ); 40 | StartCoroutine(Feeder()); 41 | 42 | foreach (var creaturePrefab in CreaturePrefabs) 43 | { 44 | for (var i = 0; i < CreatureCountPerPrefab; i++) 45 | { 46 | var pos = new Vector3( 47 | x: _size.xMin + Random.value * _size.width, 48 | y: 0, 49 | z: _size.yMin + Random.value * _size.height); 50 | var creatureRootGameObject = Instantiate(creaturePrefab, pos, Quaternion.identity); 51 | var creature = StartCreature(creatureRootGameObject, 52 | creatureRootGameObject.transform.GetChild(0).gameObject); 53 | creature.name = creaturePrefab.name.Substring(0, Mathf.Min(15, creaturePrefab.name.Length)); 54 | } 55 | } 56 | } 57 | 58 | 59 | private Agent StartCreature(GameObject creatureRootGameObject, GameObject centralBody) 60 | { 61 | // Add Sensor and Mouth for food 62 | Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 63 | var mouth = Mouth.CreateComponent(centralBody, typeof(Food)); 64 | 65 | // Initialize Brain 66 | var actions = LocomotionAction.EightDirections(); 67 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.1f, minimumCandidates: 30); 68 | var decisionMaker = new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition); 69 | var souls = new List() {new GluttonySoul()}; 70 | 71 | var brain = new Brain(decisionMaker, sequenceMaker); 72 | var agent = Agent.CreateComponent(creatureRootGameObject, brain, new Body(centralBody), actions, souls); 73 | 74 | var info = GameUI.AddAgent(agent); 75 | 76 | StartCoroutine(EntryPointUtility.Rename(info, agent, mouth)); 77 | return agent; 78 | } 79 | 80 | 81 | private IEnumerator Feeder() 82 | { 83 | while (true) 84 | { 85 | var foodCount = FindObjectsOfType().Length; 86 | for (int i = 0; i < FoodCount - foodCount; i++) 87 | { 88 | Feed(); 89 | } 90 | 91 | yield return new WaitForSeconds(5); 92 | } 93 | } 94 | 95 | private void Feed() 96 | { 97 | var foodObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); 98 | foodObject.transform.localScale = Vector3.one; 99 | var food = foodObject.AddComponent(); 100 | food.GetComponent().material = Resources.Load("Materials/Food", typeof(Material)) as Material; 101 | food.GetComponent().isTrigger = true; 102 | food.transform.position = new Vector3( 103 | x: _size.xMin + Random.value * _size.width, 104 | y: 0, 105 | z: _size.yMin + Random.value * _size.height 106 | ); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/VariousHeights/VariousHeightsEntrypoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using MotionGenerator; 3 | using RLCreature.BodyGenerator; 4 | using RLCreature.BodyGenerator.Manipulatables; 5 | using RLCreature.Sample.Common; 6 | using RLCreature.Sample.Common.UI; 7 | using RLCreature.Sample.Common.UI.Actions; 8 | using RLCreature.Sample.Common.UI.UIComponents; 9 | using UnityEngine; 10 | 11 | namespace RLCreature.Sample.VariousHeights 12 | { 13 | public class Food : MonoBehaviour 14 | { 15 | } 16 | 17 | 18 | public class VariousHeightsEntrypoint : MonoBehaviour 19 | { 20 | private Rect _size; 21 | public int FoodCount = 100; 22 | private CastUIPresenter GameUI; 23 | public GameObject Plane; 24 | 25 | private void Start() 26 | { 27 | GameUI = CastUIPresenter.CreateComponent(Camera.main, gameObject); 28 | CastCameraController.CreateComponent(Camera.main, GameUI.SelectedCreature, 29 | GameUI.FallbackedEventsObservable); 30 | GameUI.LeftToolBar.Add(new SystemActions()); 31 | 32 | Plane.transform.position = Vector3.zero; 33 | Plane.transform.localScale = Vector3.one * 10; 34 | var unitPlaneSize = 10; 35 | _size = new Rect( 36 | (Plane.transform.position.x - Plane.transform.lossyScale.x * unitPlaneSize) / 2, 37 | (Plane.transform.position.y - Plane.transform.lossyScale.y * unitPlaneSize) / 2, 38 | Plane.transform.lossyScale.x * unitPlaneSize, 39 | Plane.transform.lossyScale.y * unitPlaneSize 40 | ); 41 | SpawnCreature(reinforcement: true); 42 | SpawnCreature(reinforcement: true); 43 | SpawnCreature(reinforcement: false); 44 | SpawnCreature(reinforcement: false); 45 | 46 | 47 | StartCoroutine(Feeder()); 48 | } 49 | 50 | 51 | private IEnumerator Feeder() 52 | { 53 | while (true) 54 | { 55 | var foodCount = FindObjectsOfType().Length; 56 | for (int i = 0; i < FoodCount - foodCount; i++) 57 | { 58 | Feed(); 59 | } 60 | 61 | yield return new WaitForSeconds(5); 62 | } 63 | } 64 | 65 | private void Feed() 66 | { 67 | var foodObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); 68 | var food = foodObject.AddComponent(); 69 | var heightRatio = Random.value; 70 | food.GetComponent().material.color = Color.green * (1 - heightRatio) + Color.red * heightRatio; 71 | food.GetComponent().isTrigger = true; 72 | food.transform.position = new Vector3( 73 | x: _size.xMin + Random.value * _size.width, 74 | y: heightRatio * 3, 75 | z: _size.yMin + Random.value * _size.height 76 | ); 77 | StartCoroutine(EntryPointUtility.DeleteTimer(foodObject, 60 * 5)); 78 | } 79 | 80 | private GameObject SpawnCreature(bool reinforcement = true) 81 | { 82 | var rootObject = new GameObject(); 83 | var creature = GameObject.CreatePrimitive(PrimitiveType.Cube); 84 | creature.transform.position = new Vector3( 85 | x: _size.xMin + Random.value * _size.width, 86 | y: 1, 87 | z: _size.yMin + Random.value * _size.height 88 | ); 89 | creature.transform.parent = rootObject.transform; 90 | SuperFlexibleMove.CreateComponent(creature, speed: 1f); 91 | creature.AddComponent().freezeRotation = true; 92 | creature.GetComponent().material.color = reinforcement ? Color.red : Color.yellow; 93 | Sensor.CreateComponent(creature, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 94 | var mouth = Mouth.CreateComponent(creature, typeof(Food)); 95 | var actions = LocomotionAction.EightDirections(); 96 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); 97 | if (reinforcement) 98 | { 99 | } 100 | 101 | var decisonMaker = reinforcement 102 | ? (IDecisionMaker) new ReinforcementDecisionMaker() 103 | : (IDecisionMaker) new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition); 104 | var brain = new Brain( 105 | decisonMaker, 106 | sequenceMaker 107 | ); 108 | var agent = Agent.CreateComponent(rootObject, brain, new Body(creature), actions); 109 | var info = GameUI.AddAgent(agent); 110 | agent.name = reinforcement ? "Reinforce" : "Rule"; 111 | StartCoroutine(EntryPointUtility.Rename(info, agent, mouth)); 112 | return creature; 113 | } 114 | 115 | } 116 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/CastCameraController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using RLCreature.Sample.Common.UI.Cameras; 3 | using RLCreature.Sample.Common.UI.Cameras.OperatableCameras; 4 | using UniRx; 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace RLCreature.Sample.Common.UI 9 | { 10 | public class CastCameraController : MonoBehaviour 11 | { 12 | [Range(0.1f, 10.0f)] public float RotateSpeed = 1.0f; 13 | 14 | [Range(0.1f, 10.0f)] public float GrabSpeed = 1.0f; 15 | 16 | [Range(0.1f, 10.0f)] public float ScrollSpeed = 1.0f; 17 | 18 | private IOperatableCamera _currentCamera; 19 | 20 | private CameraAttitude _defaultAttitude; 21 | 22 | private ReactiveProperty _selectedCreatureExtrenalProperty; 23 | 24 | public static CastCameraController CreateComponent(Camera target, 25 | ReactiveProperty selectedCreature, 26 | IObservable> eventObservable, 27 | CameraAttitude? defaultAttitude = null) 28 | { 29 | var self = target.gameObject.AddComponent(); 30 | self.Init(target, selectedCreature, eventObservable, defaultAttitude); 31 | return self; 32 | } 33 | 34 | 35 | private Camera _target; 36 | 37 | private void Init(Camera target, 38 | ReactiveProperty selectedCreature, 39 | IObservable> eventObservable, 40 | CameraAttitude? defaultAttitude = null) 41 | { 42 | _selectedCreatureExtrenalProperty = selectedCreature; 43 | _target = target; 44 | _defaultAttitude = defaultAttitude ?? new CameraAttitude 45 | { 46 | LookAt = Vector3.zero, 47 | Position = new Vector3(0.0f, 10.0f, -40.0f), 48 | }; 49 | 50 | eventObservable 51 | .Where(x => x.Item1 == FallbackedEventReceiver.FallbackedEvents.Dragging) 52 | .Select(x => x.Item2) 53 | .Where(x => x.button == PointerEventData.InputButton.Left) 54 | .Select(x => x.delta) 55 | .Subscribe(LeftDragOperation) 56 | .AddTo(this); 57 | 58 | eventObservable 59 | .Where(x => x.Item1 == FallbackedEventReceiver.FallbackedEvents.Dragging) 60 | .Select(x => x.Item2) 61 | .Where(x => x.button == PointerEventData.InputButton.Right) 62 | .Select(x => x.delta) 63 | .Subscribe(RightDragOperation) 64 | .AddTo(this); 65 | 66 | eventObservable 67 | .Where(x => x.Item1 == FallbackedEventReceiver.FallbackedEvents.Scroll) 68 | .Select(x => x.Item2.scrollDelta) 69 | .Subscribe(ScrollOperation) 70 | .AddTo(this); 71 | 72 | selectedCreature 73 | .Subscribe(SelectOperation) 74 | .AddTo(this); 75 | } 76 | 77 | private void Update() 78 | { 79 | if (_currentCamera == null) 80 | { 81 | Fallback(); 82 | } 83 | 84 | var attitude = _currentCamera.Update(Time.unscaledDeltaTime); 85 | _target.transform.position = attitude.Position; 86 | _target.transform.LookAt(attitude.LookAt); 87 | } 88 | 89 | public void Transition(IOperatableCamera next, bool keepSelectingCreature = false) 90 | { 91 | var currentAttitude = _currentCamera != null ? _currentCamera.Update(0.0f) : _defaultAttitude; 92 | next.Initialize(currentAttitude); 93 | _currentCamera = next; 94 | 95 | if (!keepSelectingCreature) 96 | { 97 | _selectedCreatureExtrenalProperty.Value = null; 98 | } 99 | } 100 | 101 | private void LeftDragOperation(Vector2 diff) 102 | { 103 | if (_currentCamera == null || !(_currentCamera.NeedsMainDragOperation)) 104 | { 105 | Fallback(); 106 | } 107 | 108 | _currentCamera.MainDragOperation(diff * RotateSpeed); 109 | } 110 | 111 | private void RightDragOperation(Vector2 diff) 112 | { 113 | if (_currentCamera == null || !(_currentCamera.NeedsSubDragOperation)) 114 | { 115 | Fallback(); 116 | } 117 | 118 | _currentCamera.SubDragOperation(diff * GrabSpeed); 119 | } 120 | 121 | private void ScrollOperation(Vector2 diff) 122 | { 123 | if (_currentCamera == null || !(_currentCamera.NeedsScrollOperation)) 124 | { 125 | Fallback(); 126 | } 127 | 128 | _currentCamera.ScrollOperation(diff * ScrollSpeed); 129 | } 130 | 131 | private void SelectOperation(GameObject creatureRoot) 132 | { 133 | if (creatureRoot == null) return; 134 | if (creatureRoot.transform.childCount < 1) return; 135 | Transition(new FocusCamera(creatureRoot.transform.GetChild(0)), true); 136 | } 137 | 138 | private void Fallback() 139 | { 140 | Transition(new RokuroCamera()); 141 | } 142 | } 143 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/RandomCreatures/RandomCreaturesEntryPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Linq; 3 | using MotionGenerator; 4 | using RLCreature.BodyGenerator; 5 | using RLCreature.BodyGenerator.JointGenerator; 6 | using RLCreature.BodyGenerator.Manipulatables; 7 | using RLCreature.Sample.Common; 8 | using RLCreature.Sample.Common.UI; 9 | using RLCreature.Sample.Common.UI.Actions; 10 | using RLCreature.Sample.SimpleHunting; 11 | using UnityEngine; 12 | 13 | namespace RLCreature.Sample.RandomCreatures 14 | { 15 | public class RandomCreaturesEntryPoint : MonoBehaviour 16 | { 17 | private Rect _size; 18 | public int FoodCount = 800; 19 | public GameObject Plane; 20 | private CastUIPresenter GameUI; 21 | 22 | private void Start() 23 | { 24 | GameUI = CastUIPresenter.CreateComponent(Camera.main, gameObject); 25 | CastCameraController.CreateComponent(Camera.main, GameUI.SelectedCreature, 26 | GameUI.FallbackedEventsObservable); 27 | GameUI.LeftToolBar.Add(new SystemActions()); 28 | 29 | Plane.GetComponent().material = Resources.Load("Materials/Ground", typeof(Material)) as Material; 30 | Plane.transform.position = Vector3.zero; 31 | Plane.transform.localScale = Vector3.one * 100; 32 | var unitPlaneSize = 10; 33 | _size = new Rect( 34 | (Plane.transform.position.x - Plane.transform.lossyScale.x * unitPlaneSize) / 2, 35 | (Plane.transform.position.y - Plane.transform.lossyScale.y * unitPlaneSize) / 2, 36 | Plane.transform.lossyScale.x * unitPlaneSize, 37 | Plane.transform.lossyScale.y * unitPlaneSize 38 | ); 39 | 40 | 41 | var generator = new TreeJointGenerator(new[] 42 | { 43 | Resources.Load("Prefabs/CubeBody"), 44 | Resources.Load("Prefabs/CubeBody2"), 45 | Resources.Load("Prefabs/CylinderBody1"), 46 | Resources.Load("Prefabs/SphereBody1"), 47 | Resources.Load("Prefabs/CapsuleBody1") 48 | }, new[] 49 | { 50 | Resources.Load("Prefabs/CubeArm"), 51 | Resources.Load("Prefabs/CubeArm2") 52 | }); 53 | 54 | StartCoroutine(Feeder()); 55 | StartCoroutine(SpawnSome(generator)); 56 | } 57 | 58 | 59 | private IEnumerator SpawnSome(JointGenerator generator) 60 | { 61 | for (int i = 0; i < 5; i++) 62 | { 63 | SpawnCreature(generator); 64 | yield return new WaitForSeconds(10); 65 | } 66 | } 67 | 68 | 69 | private string RandomName() 70 | { 71 | return RandomNameGenerator.EnglishName(); 72 | } 73 | 74 | private void SpawnCreature(JointGenerator generator) 75 | { 76 | var pos = new Vector3( 77 | x: _size.xMin + Random.value * _size.width, 78 | y: 3, 79 | z: _size.yMin + Random.value * _size.height 80 | ); 81 | var rootObject = generator.Instantiate(pos); 82 | var centralBody = rootObject.transform.GetChild(0).gameObject; 83 | Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); 84 | var mouth = Mouth.CreateComponent(centralBody, typeof(Food)); 85 | 86 | var actions = LocomotionAction.EightDirections(); 87 | var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); 88 | var brain = new Brain( 89 | new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition), 90 | sequenceMaker 91 | ); 92 | 93 | var agent = Agent.CreateComponent(rootObject, brain, new Body(rootObject), actions); 94 | agent.name = RandomName(); 95 | var info = GameUI.AddAgent(agent); 96 | StartCoroutine(EntryPointUtility.Rename(info, agent, mouth)); 97 | } 98 | 99 | private IEnumerator Feeder() 100 | { 101 | while (true) 102 | { 103 | var foodCount = FindObjectsOfType().Length; 104 | for (int i = 0; i < FoodCount - foodCount; i++) 105 | { 106 | Feed(); 107 | } 108 | 109 | yield return new WaitForSeconds(5); 110 | } 111 | } 112 | 113 | private void Feed() 114 | { 115 | var foodObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); 116 | foodObject.transform.localScale = Vector3.one * 5; 117 | var food = foodObject.AddComponent(); 118 | food.GetComponent().material = Resources.Load("Materials/Food", typeof(Material)) as Material; 119 | food.GetComponent().isTrigger = true; 120 | food.transform.position = new Vector3( 121 | x: _size.xMin + Random.value * _size.width, 122 | y: 0, 123 | z: _size.yMin + Random.value * _size.height 124 | ); 125 | StartCoroutine(EntryPointUtility.DeleteTimer(foodObject, 60 * 10)); 126 | } 127 | } 128 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/Cameras/OperatableCameras/FocusCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace RLCreature.Sample.Common.UI.Cameras.OperatableCameras 5 | { 6 | public class FocusCamera : IOperatableCamera 7 | { 8 | private readonly Transform _focusTarget; 9 | 10 | private CameraAttitude _currentAttitude; 11 | 12 | private CameraAttitude _goalAttitude; 13 | 14 | private float _elapsedTime; 15 | 16 | private float _targetDistance; 17 | 18 | private readonly float _farAwayDistance; 19 | 20 | private readonly float _transitionTime; 21 | 22 | private readonly float _inSightAngle; 23 | 24 | private readonly float _outSightAngle; 25 | 26 | private float _minDamper = 0.1f; 27 | 28 | private float _maxDamper = 0.99f; 29 | 30 | private readonly PolarCoordinatesAttitude _tempPolarAttitude = new PolarCoordinatesAttitude(); 31 | 32 | public FocusCamera(Transform focusTarget, float transitionTime = 0.6f, float initialDistance = 10.0f, float farAwayDistance = 40.0f, float inSightAngle = 10.0f, float outSightAngle = 30.0f) 33 | { 34 | _focusTarget = focusTarget; 35 | _transitionTime = transitionTime; 36 | _targetDistance = initialDistance; 37 | _farAwayDistance = farAwayDistance; 38 | _inSightAngle = inSightAngle; 39 | _outSightAngle = outSightAngle; 40 | 41 | _elapsedTime = 0.0f; 42 | } 43 | 44 | private void Dolly(Vector2 diff) 45 | { 46 | _tempPolarAttitude.Distance = _targetDistance; 47 | _tempPolarAttitude.Dolly(diff); 48 | _targetDistance = _tempPolarAttitude.Distance; 49 | } 50 | 51 | private void Rotate(Vector2 diff) 52 | { 53 | _tempPolarAttitude.SetFromAttitude(_goalAttitude); 54 | _tempPolarAttitude.Rotate(diff); 55 | _goalAttitude = _tempPolarAttitude.ToCameraAttitude(); 56 | } 57 | 58 | private CameraAttitude LookAtLate(CameraAttitude attitude, Vector3 focus) 59 | { 60 | var nowV = attitude.LookAt - attitude.Position; 61 | var goalV = focus - attitude.Position; 62 | var angle = Vector3.Angle(nowV, goalV); 63 | var t = Mathf.Clamp((_maxDamper - _minDamper) * (angle - _inSightAngle) / (_outSightAngle - _inSightAngle) + _minDamper, 64 | _minDamper, 65 | _maxDamper); 66 | attitude.LookAt = Vector3.Lerp(attitude.LookAt, focus, t); 67 | return attitude; 68 | } 69 | 70 | private CameraAttitude LookAtImmediately(CameraAttitude attitude, Vector3 focus) 71 | { 72 | attitude.LookAt = focus; 73 | return attitude; 74 | } 75 | 76 | private CameraAttitude Follow(CameraAttitude attitude, float targetDistance, float transitionTime, float elapsedTime) 77 | { 78 | _tempPolarAttitude.SetFromAttitude(attitude); 79 | var t = Math.Abs(transitionTime) < 0.01f ? 1.0f : Mathf.Clamp01(elapsedTime / transitionTime); 80 | _tempPolarAttitude.Distance = Mathf.Lerp(_tempPolarAttitude.Distance, targetDistance, t); 81 | _tempPolarAttitude.Rotate(Vector2.zero); 82 | return _tempPolarAttitude.ToCameraAttitude(); 83 | } 84 | 85 | private CameraAttitude FollowImmediately(CameraAttitude attitude, float distance) 86 | { 87 | _tempPolarAttitude.SetFromAttitude(attitude); 88 | _tempPolarAttitude.Distance = distance; 89 | _tempPolarAttitude.Rotate(Vector2.zero); 90 | return _tempPolarAttitude.ToCameraAttitude(); 91 | } 92 | 93 | CameraAttitude IOperatableCamera.Update(float deltaTime) 94 | { 95 | var focus = _focusTarget != null ? _focusTarget.position : _goalAttitude.LookAt; 96 | _elapsedTime += deltaTime; 97 | 98 | if (_elapsedTime < _transitionTime && Vector3.Distance(_currentAttitude.Position, focus) > _farAwayDistance) 99 | { 100 | _goalAttitude = LookAtImmediately(_goalAttitude, focus); 101 | _goalAttitude = FollowImmediately(_goalAttitude, _farAwayDistance - 1.0f); 102 | } 103 | else 104 | { 105 | _goalAttitude = LookAtLate(_goalAttitude, focus); 106 | _goalAttitude = Follow(_goalAttitude, _targetDistance, _transitionTime, _elapsedTime); 107 | } 108 | 109 | _currentAttitude = CameraAttitude.Slerp(_currentAttitude, _goalAttitude, 0.99f); 110 | 111 | return _currentAttitude; 112 | } 113 | 114 | void IOperatableCamera.Initialize(CameraAttitude attitude) 115 | { 116 | _currentAttitude = attitude; 117 | _goalAttitude = attitude; 118 | } 119 | 120 | void IOperatableCamera.SubDragOperation(Vector2 diff) 121 | { 122 | } 123 | 124 | void IOperatableCamera.MainDragOperation(Vector2 diff) 125 | { 126 | Rotate(diff); 127 | } 128 | 129 | void IOperatableCamera.ScrollOperation(Vector2 diff) 130 | { 131 | Dolly(diff); 132 | } 133 | 134 | bool IOperatableCamera.NeedsSubDragOperation 135 | { 136 | get { return false; } 137 | } 138 | 139 | bool IOperatableCamera.NeedsMainDragOperation 140 | { 141 | get { return true; } 142 | } 143 | 144 | bool IOperatableCamera.NeedsScrollOperation 145 | { 146 | get { return true; } 147 | } 148 | } 149 | } -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 4 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 1 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 1 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 2 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 1 108 | antiAliasing: 2 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 1 112 | billboardsFaceCameraPosition: 1 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 2 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 40 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 1 136 | antiAliasing: 4 137 | softParticles: 1 138 | softVegetation: 1 139 | realtimeReflectionProbes: 1 140 | billboardsFaceCameraPosition: 1 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 1 164 | antiAliasing: 4 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSP2: 2 183 | Standalone: 5 184 | Tizen: 2 185 | WebGL: 3 186 | WiiU: 5 187 | Windows Store Apps: 5 188 | XboxOne: 5 189 | iPhone: 2 190 | tvOS: 2 191 | -------------------------------------------------------------------------------- /Assets/RLCreature/BodyGenerator/JointGenerator/BodyComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using MessagePack.Decoders; 5 | using UnityEngine; 6 | using UnityEngine.Assertions; 7 | using Joint = RLCreature.BodyGenerator.Manipulatables.Joint; 8 | using Random = UnityEngine.Random; 9 | 10 | namespace RLCreature.BodyGenerator.JointGenerator 11 | { 12 | public class BodyComponent 13 | { 14 | private readonly float _baseMass; 15 | private readonly float _targetForce; 16 | private readonly MasterConnector[] _masterConnectors; 17 | private readonly SlaveConnector _slaveConnector; 18 | public readonly GameObject CentralBody; 19 | 20 | public BodyComponent(GameObject prefab, Vector3 pos, int connectorId = -1, BodyComponent parent = null, float baseMass = 20, float targetForce = 1) 21 | { 22 | _baseMass = baseMass; 23 | _targetForce = targetForce; 24 | CentralBody = GameObject.Instantiate(prefab, pos, Quaternion.identity); 25 | _masterConnectors = CentralBody.GetComponentsInChildren(); 26 | foreach (var connector in _masterConnectors) 27 | { 28 | connector.gameObject.SetActive(false); 29 | } 30 | 31 | _slaveConnector = CentralBody.GetComponentInChildren(); 32 | _slaveConnector.gameObject.SetActive(false); 33 | 34 | 35 | if (parent != null) 36 | { 37 | if (connectorId >= 0) 38 | { 39 | parent.Connect(connectorId, this); 40 | } 41 | else 42 | { 43 | parent.ConnectRandom(this); 44 | } 45 | } 46 | else 47 | { 48 | ToRigid(); 49 | } 50 | } 51 | 52 | public BodyComponent(GameObject prefab, int connectorId = -1, BodyComponent parent = null, float baseMass = 20, float targetForce = 1) : this( 53 | prefab, Vector3.up * 10, connectorId, parent, baseMass: baseMass, targetForce:targetForce) 54 | { 55 | } 56 | 57 | 58 | private void ToRigid() 59 | { 60 | if (CentralBody.GetComponent() == null) 61 | { 62 | CentralBody.AddComponent(); 63 | } 64 | 65 | foreach (var rigid in CentralBody.GetComponentsInChildren()) 66 | { 67 | rigid.solverIterations = 30; 68 | rigid.mass = _baseMass; 69 | rigid.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; 70 | } 71 | } 72 | 73 | 74 | private MasterConnector EnableConnector(int connectorId) 75 | { 76 | var connector = _masterConnectors[connectorId]; 77 | GameObject.Destroy(connector.GetComponent()); 78 | connector.gameObject.SetActive(true); 79 | return connector; 80 | } 81 | 82 | private void EnableSlaveConnector() 83 | { 84 | _slaveConnector.gameObject.SetActive(true); 85 | GameObject.Destroy(_slaveConnector.GetComponent()); 86 | } 87 | 88 | private void Connect(int connectorId, BodyComponent otherComponent) 89 | { 90 | Assert.IsTrue(connectorId < _masterConnectors.Length); 91 | var connector = EnableConnector(connectorId); 92 | otherComponent.EnableSlaveConnector(); 93 | var rot = connector.transform.rotation * Quaternion.Inverse(otherComponent 94 | ._slaveConnector.transform.rotation); 95 | otherComponent.CentralBody.transform.rotation = rot * otherComponent.CentralBody.transform.rotation; 96 | var diff = (connector.transform.position - otherComponent._slaveConnector.transform.position); 97 | otherComponent.CentralBody.transform.position += diff; 98 | 99 | otherComponent.ToRigid(); 100 | 101 | var joint = otherComponent.CentralBody.gameObject.AddComponent(); 102 | // joint.lowAngularXLimit = new SoftJointLimit {limit = -60}; 103 | // joint.highAngularXLimit = new SoftJointLimit {limit = 60}; 104 | // joint.angularYLimit = new SoftJointLimit {limit = 60}; 105 | // joint.angularZLimit = new SoftJointLimit {limit = 60}; 106 | joint.lowAngularXLimit = new SoftJointLimit {limit = -60}; 107 | joint.highAngularXLimit = new SoftJointLimit {limit = 60}; 108 | joint.angularYLimit = new SoftJointLimit {limit = 30}; 109 | joint.angularZLimit = new SoftJointLimit {limit = 0}; 110 | joint.projectionMode = JointProjectionMode.PositionAndRotation; // 爆発防止 111 | joint.connectedBody = CentralBody.GetComponent(); 112 | joint.anchor = otherComponent._slaveConnector.transform.localPosition; 113 | Joint.CreateComponent(joint, targetForce: _targetForce); 114 | Physics.IgnoreCollision(CentralBody.GetComponent(), 115 | otherComponent.CentralBody.GetComponent()); 116 | connector.available = false; 117 | connector.ConnectedComponent = otherComponent; 118 | } 119 | 120 | public IEnumerable GetSlaves() 121 | { 122 | return _masterConnectors.Where(c => !c.available).Select(c => c.ConnectedComponent); 123 | } 124 | 125 | public bool HasAvailableConnector() 126 | { 127 | return _masterConnectors.Any(x => x.available); 128 | } 129 | 130 | public void ConnectRandom(BodyComponent otherComponent) 131 | { 132 | var avairableConnectorIDs = _masterConnectors 133 | .Select((i, x) => new Tuple(x, i)) 134 | .Where(x => x.Item2.available) 135 | .Select(x => x.Item1) 136 | .ToList(); 137 | 138 | Connect(avairableConnectorIDs[Random.Range(0, avairableConnectorIDs.Count)], otherComponent); 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /Assets/RLCreature/Sample/Common/UI/CastUIPresenter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using RLCreature.BodyGenerator; 3 | using RLCreature.Sample.Common.UI.Cameras.SubCameras; 4 | using RLCreature.Sample.Common.UI.UIComponents; 5 | using UniRx; 6 | using UnityEngine; 7 | using UnityEngine.EventSystems; 8 | 9 | namespace RLCreature.Sample.Common.UI 10 | { 11 | public class CastUIPresenter : MonoBehaviour 12 | { 13 | private const string EnergySummaryFormat = "+{0:f0} -{1:f0}"; 14 | public static readonly string PrefabPath = "SampleServerUICanvas"; 15 | 16 | private SubCamera _subCamera; 17 | private AgentFocusStrategy _subCameraStrategy; 18 | 19 | 20 | public static CastUIPresenter CreateComponent(Camera targetCamera, GameObject rootObject) 21 | { 22 | var es = Transform.FindObjectOfType(); 23 | if (es == null) 24 | { 25 | var obj = new GameObject("EventSystem"); 26 | obj.AddComponent(); 27 | obj.AddComponent(); 28 | } 29 | var presenter = targetCamera.gameObject.AddComponent(); 30 | presenter._targetCamera = targetCamera; 31 | presenter.Init(rootObject); 32 | return presenter; 33 | } 34 | 35 | public IObservable> 36 | FallbackedEventsObservable { get; private set; } 37 | 38 | public readonly ReactiveProperty SelectedCreature = new ReactiveProperty(); 39 | 40 | public ToolBar LeftToolBar { get; private set; } 41 | 42 | private Camera _targetCamera; 43 | private CreatureInfoList _creatureInfoList; 44 | 45 | private GameObject _currentTargetCreature = null; 46 | 47 | private CastUIView _canvasUi; 48 | 49 | public bool Visible 50 | { 51 | get { return _canvasUi.gameObject.activeSelf; } 52 | set { _canvasUi.gameObject.SetActive(value); } 53 | } 54 | 55 | public bool SubCameraIsActive 56 | { 57 | get { return _subCamera.IsActive; } 58 | set 59 | { 60 | _subCamera.IsActive = value; 61 | _canvasUi.SubCameraRoot.gameObject.SetActive(value); 62 | } 63 | } 64 | 65 | public void SelectCreature(GameObject creature) 66 | { 67 | SelectedCreature.Value = creature; 68 | } 69 | 70 | public Vector3 GetCursorPosition() 71 | { 72 | return _canvasUi.Cursor.transform.position; 73 | } 74 | 75 | public void ResetCursorPosition() 76 | { 77 | _canvasUi.Cursor.anchoredPosition = Vector2.zero; 78 | } 79 | 80 | private void OnDestroy() 81 | { 82 | Destroy(_subCamera); 83 | } 84 | 85 | public CreatureInfoCell AddAgent(Agent agent) 86 | { 87 | var displayName = agent.name; 88 | var cell = _creatureInfoList.Add(agent.gameObject, displayName); 89 | SelectableCreature.CreateComponent(agent.gameObject, _targetCamera.transform, SelectedCreature); 90 | _subCameraStrategy.Add(agent); 91 | return cell; 92 | } 93 | 94 | 95 | private void Init(GameObject rootObject) 96 | { 97 | var receiver = new GameObject("FallbackedEvent").AddComponent(); 98 | receiver.transform.SetParent(transform, false); 99 | var raycaster = FallbackPhysicsRaycaster.CreateComponent(gameObject, receiver.gameObject); 100 | FallbackedEventsObservable = receiver.EventObservable; 101 | 102 | _canvasUi = Instantiate(Resources.Load(PrefabPath)); 103 | _canvasUi.transform.SetParent(transform, false); 104 | 105 | // SubCamera View 106 | var texture = new RenderTexture(200, 110, 24); 107 | _canvasUi.SubCameraRawImage.texture = texture; 108 | var rect = _canvasUi.SubCameraRawImage.GetComponent().rect; 109 | var aspect = rect.width / rect.height; 110 | _subCameraStrategy = new AgentFocusStrategy(); 111 | _subCamera = 112 | SubCamera.CreateComponent(rootObject, _subCameraStrategy, texture, aspect); 113 | _canvasUi.SubCameraToggleButton.onClick.AddListener(() => 114 | { 115 | SubCameraIsActive = !SubCameraIsActive; 116 | }); 117 | SubCameraIsActive = false; 118 | 119 | _creatureInfoList = new CreatureInfoList(_canvasUi.CreatureList); 120 | _creatureInfoList.SelectedCell 121 | .Where(x => x != null) 122 | .Subscribe(x => SelectedCreature.Value = x.Creature) 123 | .AddTo(this); 124 | 125 | // Selected Creature 126 | SelectedCreature.Subscribe(OnSelected).AddTo(this); 127 | 128 | // Cursor 129 | FallbackedEventsObservable 130 | .Where(x => x.Item1 == FallbackedEventReceiver.FallbackedEvents.RightClick) 131 | .Where(x => Vector2.Distance(x.Item2.position, x.Item2.pressPosition) < 0.1f) 132 | .Subscribe(x => _canvasUi.Cursor.position = x.Item2.position) 133 | .AddTo(this); 134 | 135 | // ToolBar 136 | LeftToolBar = new ToolBar(_canvasUi.ToolBarCategoryList, _canvasUi.ToolBarList, _canvasUi.ToolBarListRoot); 137 | LeftToolBar.ListVisible = false; 138 | } 139 | 140 | private void OnSelected(GameObject creature) 141 | { 142 | _creatureInfoList.Select(creature); 143 | _currentTargetCreature = creature; 144 | } 145 | 146 | 147 | private void Update() 148 | { 149 | if (Input.GetKeyDown(KeyCode.Tab)) 150 | { 151 | _canvasUi.gameObject.SetActive(!_canvasUi.gameObject.activeSelf); 152 | } 153 | } 154 | 155 | private void LateUpdate() 156 | { 157 | var timeRate = Time.deltaTime / Time.unscaledDeltaTime; 158 | 159 | _canvasUi.Time.text = TimeFormatFromSeconds(Time.time) + " (x" + timeRate.ToString("0.0") + ")"; 160 | _canvasUi.CreatureCount.text = _creatureInfoList.CurrentCreaturesCount().ToString(); 161 | // _canvasUi.FoodCount.text = status.CurrentFoodCount.ToString(); 162 | 163 | _creatureInfoList.UpdateList(); 164 | } 165 | 166 | private string TimeFormatFromSeconds(double seconds) 167 | { 168 | var secInt = (int) Math.Floor(seconds); 169 | var hour = secInt / 3600; 170 | var min = (secInt % 3600) / 60; 171 | var sec = seconds % 60.0f; 172 | return string.Format("{0:00}:{1:00}:{2:00.0}", hour, min, sec); 173 | } 174 | } 175 | } --------------------------------------------------------------------------------