diff --git a/Assets/Animation/CoolAnimation.controller b/Assets/Animation/CoolAnimation.controller index e71b68f..39f7138 100644 --- a/Assets/Animation/CoolAnimation.controller +++ b/Assets/Animation/CoolAnimation.controller @@ -364,31 +364,31 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Death m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Put m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Action m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Direction m_Type: 3 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -525,7 +525,7 @@ AnimatorStateMachine: m_Position: {x: 600, y: 300, z: 0} - serializedVersion: 1 m_State: {fileID: 2719619372482766879} - m_Position: {x: 400, y: 400, z: 0} + m_Position: {x: 470, y: 360, z: 0} - serializedVersion: 1 m_State: {fileID: -9122630403755595834} m_Position: {x: 700, y: 400, z: 0} diff --git a/Assets/Prefab/character.prefab b/Assets/Prefab/character.prefab index 2e1036d..6419608 100644 --- a/Assets/Prefab/character.prefab +++ b/Assets/Prefab/character.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 1991111706524250881} - component: {fileID: 3842974436686933763} - component: {fileID: 3345964830931367101} + - component: {fileID: -8915626750319151747} m_Layer: 5 m_Name: character m_TagString: Untagged @@ -119,3 +120,15 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 +--- !u!114 &-8915626750319151747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4224658953871280930} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c3edf77b2c5735244852d35bb471ed04, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefab/panel.prefab b/Assets/Prefab/panel.prefab index 8d9cc16..c2c9a69 100644 --- a/Assets/Prefab/panel.prefab +++ b/Assets/Prefab/panel.prefab @@ -35,8 +35,8 @@ RectTransform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 1, y: 1} m_Pivot: {x: 0, y: 0} diff --git a/Assets/Scenes/game-demo.unity b/Assets/Scenes/game-demo.unity index 31aac37..a439a02 100644 --- a/Assets/Scenes/game-demo.unity +++ b/Assets/Scenes/game-demo.unity @@ -213,6 +213,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tileObject: {fileID: 4445064752271836034, guid: e5e948cfa5bc30e4ea21e23f816fbf64, type: 3} + characterObject: {fileID: 4224658953871280930, guid: 8adffb436bc09d7488091b3cfb87471f, type: 3} turnText: {fileID: 956752251} --- !u!1 &477515213 GameObject: diff --git a/Assets/Src/game/charMove.cs b/Assets/Src/game/charMove.cs index 075d7cd..6232c9e 100644 --- a/Assets/Src/game/charMove.cs +++ b/Assets/Src/game/charMove.cs @@ -4,6 +4,10 @@ public class charMove : MonoBehaviour { + int xDiff; + int yDiff; + SpriteRenderer m_image; + Animator animator; // Start is called before the first frame update void Start() { @@ -16,8 +20,42 @@ void Update() } - public void SetView() + void LateUpdate() { + m_image.size = new Vector2(1,1); + } + + public void Set(Sprite texture,RuntimeAnimatorController controller,int xDiff,int yDiff) + { + m_image = GetComponent(); + animator = GetComponent(); + this.xDiff = xDiff; + this.yDiff = yDiff; + m_image.sprite = texture; + animator.runtimeAnimatorController = controller; + } + + public void Act(string command) + { + switch (command.Trim()) + { + case "wu": + animator.SetTrigger("Walk"); + animator.SetInteger("Direction",12); + break; + case "wr": + animator.SetTrigger("Walk"); + animator.SetInteger("Direction",3); + break; + case "wd": + animator.SetTrigger("Walk"); + animator.SetInteger("Direction",6); + break; + case "wl": + animator.SetTrigger("Walk"); + animator.SetInteger("Direction",9); + break; + } } } diff --git a/Assets/Src/game/tileImg.cs b/Assets/Src/game/tileImg.cs index 6efc3a4..fc40447 100644 --- a/Assets/Src/game/tileImg.cs +++ b/Assets/Src/game/tileImg.cs @@ -42,7 +42,6 @@ public void ImgChange(string type) else { m_image.sprite = texture[0]; - m_image.size = new Vector2(1,1); } break; case "block": @@ -53,7 +52,6 @@ public void ImgChange(string type) else { m_image.sprite = texture[1]; - m_image.size = new Vector2(1,1); } break; case "item": @@ -64,7 +62,6 @@ public void ImgChange(string type) else { m_image.sprite = texture[2]; - m_image.size = new Vector2(1,1); } break; } diff --git a/Assets/Src/game/viewManager.cs b/Assets/Src/game/viewManager.cs index c779eef..3b7994e 100644 --- a/Assets/Src/game/viewManager.cs +++ b/Assets/Src/game/viewManager.cs @@ -8,12 +8,16 @@ public class viewManager : MonoBehaviour { public GameObject tileObject = null; + public GameObject characterObject = null; public Text turnText = null; GameObject[,] viewObjList; GameObject cool; GameObject hot; + charMove coolSrc; + charMove hotSrc; + Sprite[] texture; RuntimeAnimatorController[] animators = null; @@ -29,7 +33,7 @@ void Update() } - public void Act(int[,] diff) + public void Act(int[,] diff,string command) { if (diff == null) return; @@ -41,11 +45,17 @@ public void Act(int[,] diff) if (diff[a,2] == 2) type = "block"; if (diff[a,2] == 4) { - //coolの移動関数を呼ぶ + //coolの移動モーション関数を呼ぶ + coolSrc.Act(command); + cool.transform.SetParent(viewObjList[diff[a,0],diff[a,1]].transform); + cool.transform.localPosition = new Vector3(0,0,0); } if (diff[a,2] == 5) { - //hotの移動関数を呼ぶ + //hotの移動モーション関数を呼ぶ + hotSrc.Act(command); + hot.transform.SetParent(viewObjList[diff[a,0],diff[a,1]].transform); + hot.transform.localPosition = new Vector3(0,0,0); } viewObjList[diff[a,0],diff[a,1]].GetComponent().ImgChange(type); @@ -133,5 +143,18 @@ void ShowMap(int[,] map) } //cool,hotを生成しposの位置のオブジェクトの子にする + cool = Instantiate(characterObject); + cool.transform.SetParent(viewObjList[coolPos[0],coolPos[1]].transform); + cool.transform.localScale = new Vector3(1,1,0); + cool.transform.localPosition = new Vector3(0,0,0); + coolSrc = cool.GetComponent(); + coolSrc.Set(texture[3],animators[1],xSize,ySize); + + hot = Instantiate(characterObject); + hot.transform.SetParent(viewObjList[hotPos[0],hotPos[1]].transform); + hot.transform.localScale = new Vector3(1,1,0); + hot.transform.localPosition = new Vector3(0,0,0); + hotSrc = hot.GetComponent(); + hotSrc.Set(texture[4],animators[2],xSize,ySize); } } diff --git a/Assets/Src/global/GameManager.cs b/Assets/Src/global/GameManager.cs index bfbdaef..617afdd 100644 --- a/Assets/Src/global/GameManager.cs +++ b/Assets/Src/global/GameManager.cs @@ -197,6 +197,7 @@ async Task Action(bool isCool) returnData = mapManager.ActChar(team,recieve); recieve = await cool.Send(string.Join("",returnData)); returnData = mapManager.ActChar(team,recieve); + viewManager.Act(mapManager.getDifference(),recieve); recieve = await cool.Send(string.Join("",returnData)); if (recieve == "#\r\n") Debug.Log("OK"); break; @@ -206,13 +207,13 @@ async Task Action(bool isCool) returnData = mapManager.ActChar(team,recieve); recieve = await hot.Send(string.Join("",returnData)); returnData = mapManager.ActChar(team,recieve); + viewManager.Act(mapManager.getDifference(),recieve); recieve = await hot.Send(string.Join("",returnData)); if (recieve == "#\r\n") Debug.Log("OK"); break; } await Task.Delay(500); - viewManager.Act(mapManager.getDifference()); turn = mapManager.getTurn(); viewManager.SetTurn(turn); diff --git a/Assets/Texture/cool/cool.png.meta b/Assets/Texture/cool/cool.png.meta index 363699e..522f411 100644 --- a/Assets/Texture/cool/cool.png.meta +++ b/Assets/Texture/cool/cool.png.meta @@ -45,8 +45,8 @@ TextureImporter: spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} + alignment: 6 + spritePivot: {x: 0, y: 0} spritePixelsToUnits: 100 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 @@ -132,7 +132,7 @@ TextureImporter: physicsShape: [] bones: [] spriteID: 5e97eb03825dee720800000000000000 - internalID: 0 + internalID: 1537655665 vertices: [] indices: edges: [] diff --git a/Assets/Texture/hot/hot.png.meta b/Assets/Texture/hot/hot.png.meta index 424bfaf..b6ac039 100644 --- a/Assets/Texture/hot/hot.png.meta +++ b/Assets/Texture/hot/hot.png.meta @@ -45,8 +45,8 @@ TextureImporter: spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} + alignment: 6 + spritePivot: {x: 0, y: 0} spritePixelsToUnits: 100 spriteBorder: {x: 2, y: 2, z: 2, w: 2} spriteGenerateFallbackPhysicsShape: 1