//SharedComponentDataの読み込み public static void ReadySharedComponentData() { //スプライトからメッシュの作成 charaMeshMat = new MeshMatList(); charaMeshMat.Init(); const int DEKUNUM = 1; for (int i = 0; i < DEKUNUM; i++) { var res = charaMeshMat.Load("deku" + i.ToString("d2"), false, "Sprites/CharaSprite"); // Debug.Log(res); if (res == 0) { break; } } geoMeshMat = new MeshMatList(); geoMeshMat.Init(); for (int i = 0; i < 1; i++) { var res = geoMeshMat.Load("tip" + i.ToString("d2"), true, "Sprites/GeoSprite"); if (res == 0) { break; } } foodMeshMat = new MeshMatList(); foodMeshMat.Init(); foodMeshMat.Load("food", true, "Sprites/FoodSprite"); //スクリプタブルオブジェクトの読み込み aniScriptSheet = new AniScriptSheet(); if (Resources.FindObjectsOfTypeAll <AniScriptSheetObject>().Length == 0) { Debug.LogError("aniScriptSheet 0"); } aniScriptSheet.scripts = (Resources.FindObjectsOfTypeAll <AniScriptSheetObject>().First() as AniScriptSheetObject).scripts; aniBasePos = new AniBasePos(); if (Resources.FindObjectsOfTypeAll <AniBasePosObject>().Length == 0) { Debug.LogError("aniBasePos 0"); } aniBasePos = (Resources.FindObjectsOfTypeAll <AniBasePosObject>().First() as AniBasePosObject).aniBasePos; }
/// <summary> /// キャラエンティティ作成 /// </summary> /// <param name="i"></param> /// <param name="entityManager"></param> /// <param name="ariMeshMat"></param> /// <param name="aniScriptSheet"></param> /// <param name="aniBasePos"></param> /// <returns></returns> public static Entity CreateEntity(int _i, EntityManager _entityManager, ref MeshMatList _meshMatList, ref AniScriptSheet _aniScriptSheet, ref AniBasePos _aniBasePos ) { var archetype = _entityManager.CreateArchetype(ComponentTypes.CharaComponentType); var entity = _entityManager.CreateEntity(archetype); //ComponentDataのセット var posL = 0; //Define.Instance.GetMapSize() / 2; var posH = 0; //Define.Instance.GetMapSize() / 2; // //Tag // entityManager.SetComponentData(entity, new CharaTag); //必要なキャラのみインプットをつける if (_i < Define.Instance.Common.PlayerNum) { _entityManager.AddComponent(entity, ComponentType.Create <PadInput>()); } //ID _entityManager.SetComponentData(entity, new CharaId { familyId = 0, myId = _i, }); // //位置 // _entityManager.SetComponentData(entity, new Position // { // Value = new float3(UnityEngine.Random.Range(posL, posH), UnityEngine.Random.Range(posL, posH), 0) // }); //位置 _entityManager.SetComponentData(entity, new CharaMove { position = new Vector3Int(UnityEngine.Random.Range(posL, posH), UnityEngine.Random.Range(posL, posH), 0), delta = Vector3Int.zero }); //モーション _entityManager.SetComponentData(entity, new CharaMotion { }); //位置 _entityManager.SetComponentData(entity, new CharaMuki { muki = EnumMuki.Right, // dashMuki = EnumMuki.None, }); // //行動 // _entityManager.SetComponentData(entity, new CharaBehave // { // behaveType = 0, // angle = (int)UnityEngine.Random.Range(0, 11), // endTime = (Time.realtimeSinceStartup + 0.5f + UnityEngine.Random.value) // }); //見た目 _entityManager.SetComponentData(entity, new CharaLook { isLeft = 0, isBack = 0 }); //SharedComponentDataのセット _entityManager.AddSharedComponentData(entity, _meshMatList); _entityManager.AddSharedComponentData(entity, _aniScriptSheet); _entityManager.AddSharedComponentData(entity, _aniBasePos); return(entity); }