Convert joystick to HexDirection.cs, player move

This commit is contained in:
dddushesss 2021-12-15 18:41:43 +03:00
parent 2453c7082f
commit 6b656a6486
12 changed files with 151 additions and 450 deletions

View File

@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 2346010271288414183}
- component: {fileID: 2346010271288414182}
- component: {fileID: 2346010271288414169}
- component: {fileID: 4385872142190176059}
m_Layer: 5
m_Name: GameCanvas
m_TagString: Untagged
@ -101,6 +102,20 @@ MonoBehaviour:
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &4385872142190176059
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2346010271288414168}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2019082adca55bd4c8ae55c9a0543ae6, type: 3}
m_Name:
m_EditorClassIdentifier:
moveJoystick: {fileID: 5903238893732464856}
attackJoystick: {fileID: 5903238893920995264}
--- !u!1001 &2346010270301780417
PrefabInstance:
m_ObjectHideFlags: 0
@ -226,7 +241,7 @@ PrefabInstance:
- target: {fileID: 8170153791668043269, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Name
value: AtackJoystick
value: AttackJoystick
objectReference: {fileID: 0}
- target: {fileID: 8170153791961219456, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
@ -278,6 +293,18 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 2346010270301780417}
m_PrefabAsset: {fileID: 0}
--- !u!114 &5903238893920995264 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8170153791668043265, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
m_PrefabInstance: {fileID: 2346010270301780417}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a47f546fc70ec8428172694e78e4288, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &2346010270651823833
PrefabInstance:
m_ObjectHideFlags: 0
@ -428,3 +455,15 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 2346010270651823833}
m_PrefabAsset: {fileID: 0}
--- !u!114 &5903238893732464856 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8170153791668043265, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
m_PrefabInstance: {fileID: 2346010270651823833}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a47f546fc70ec8428172694e78e4288, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -12,8 +12,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2d46325a4e4e45338d7e9733fb8d6013, type: 3}
m_Name: PlayerData
m_EditorClassIdentifier:
SpawnPos:
x: 2
z: 2
PlayerPrefab: {fileID: 7527582019267571087, guid: f102085e8bc4cad4992d43b84dee1055,
spawnPos:
x: 0
z: 0
playerPrefab: {fileID: 7527582019267571087, guid: f102085e8bc4cad4992d43b84dee1055,
type: 3}
joystickView: {fileID: 4385872142190176059, guid: 4df6913b39f4979429158c344680d83f,
type: 3}

View File

@ -123,12 +123,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!224 &614690929 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
m_PrefabInstance: {fileID: 1167446855}
m_PrefabAsset: {fileID: 0}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
@ -305,321 +299,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 30, y: 0, z: 0}
--- !u!1001 &1167446855
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2126832994}
m_Modifications:
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMin.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.x
value: 400
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -400
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043269, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Name
value: AtackJoystick
objectReference: {fileID: 0}
- target: {fileID: 8170153791961219456, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.x
value: 50
objectReference: {fileID: 0}
- target: {fileID: 8170153791961219456, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.y
value: 50
objectReference: {fileID: 0}
- target: {fileID: 8170153791961219459, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: d291abfba78d1da41807b9080554b675,
type: 3}
- target: {fileID: 8170153792821263252, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 4db2952f6e3f0bc43889874a9299ff0e,
type: 3}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.x
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.y
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 222
objectReference: {fileID: 0}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 140
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0d230cc8be529a542a08cb878ab14b18, type: 3}
--- !u!1001 &1355422815
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2126832994}
m_Modifications:
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.x
value: 400
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8170153791668043269, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_Name
value: Movement Joystick
objectReference: {fileID: 0}
- target: {fileID: 8170153791961219456, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.x
value: 50
objectReference: {fileID: 0}
- target: {fileID: 8170153791961219456, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.y
value: 50
objectReference: {fileID: 0}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.x
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_SizeDelta.y
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8170153792821263258, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 118.9
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0d230cc8be529a542a08cb878ab14b18, type: 3}
--- !u!1 &1750604535
GameObject:
m_ObjectHideFlags: 0
@ -684,7 +363,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1854206697
GameObject:
@ -730,110 +409,3 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &2047218564 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18,
type: 3}
m_PrefabInstance: {fileID: 1355422815}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2126832990
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2126832994}
- component: {fileID: 2126832993}
- component: {fileID: 2126832992}
- component: {fileID: 2126832991}
m_Layer: 5
m_Name: GameCanvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2126832991
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126832990}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &2126832992
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126832990}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &2126832993
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126832990}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 963194227}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &2126832994
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126832990}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 2047218564}
- {fileID: 614690929}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}

View File

@ -4,7 +4,7 @@ namespace Chars
{
public class Enemy : IUnit
{
public void Move(HexCoordinates coordinates)
public void Move(HexDirection direction)
{
throw new System.NotImplementedException();
}

View File

@ -4,7 +4,7 @@ namespace Chars
{
public interface IUnit
{
public void Move(HexCoordinates coordinates);
public void Move(HexDirection direction);
public void Spawn();
public void Death();
}

View File

@ -13,18 +13,25 @@ namespace Chars
private HexCell _cell;
private HexGrid _hexGrid;
public GameObject Playerinstance => _instance;
public Player(PlayerData playerData, HexGrid hexGrid)
{
_curentPosition = playerData.SpawnPos;
prefab = playerData.PlayerPrefab;
_curentPosition = playerData.spawnPos;
prefab = playerData.playerPrefab;
_isAlive = false;
_hexGrid = hexGrid;
}
public void Move(HexCoordinates coordinates)
public void Move(HexDirection direction)
{
throw new System.NotImplementedException();
if (_cell.GetNeighbor(direction))
{
_cell = _cell.GetNeighbor(direction);
_instance.transform.Translate(_cell.transform.position);
}
}
public void Spawn()

View File

@ -1,19 +1,68 @@
using Runtime.Controller;
using System;
using Data;
using HexFiled;
using Runtime.Controller;
using UnityEditor.Callbacks;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Chars
{
public class PlayerControl : IExecute
{
private Player _player;
private FloatingJoystick _moveJoystick;
private FloatingJoystick _attackJoystick;
public PlayerControl(Player player)
public PlayerControl(Player player, PlayerData playerData)
{
_player = player;
var joyView = Object.Instantiate(playerData.joystickView);
_moveJoystick = joyView.MoveJoystick;
_attackJoystick = joyView.AttackJoystick;
}
public void Execute()
{
if (_moveJoystick.Direction != Vector2.zero)
{
_player.Move(VectorToDirection(_moveJoystick.Direction.normalized));
}
}
private static HexDirection VectorToDirection(Vector2 dir)
{
if (dir.x >= 0 && dir.y <= 1 && dir.x <= 1 && dir.y >= 0.5)
{
return HexDirection.NE;
}
if (Math.Abs(dir.x - 1f) < 0.2 && dir.y <= 0.5 && dir.y >= -0.5)
{
return HexDirection.E;
}
if (dir.x <= 1 && dir.y <= -0.5 && dir.x >= 0 && dir.y >= -1)
{
return HexDirection.SE;
}
if (dir.x <= 0 && dir.y >= -1 && dir.x >= -1 && dir.y <= -0.5)
{
return HexDirection.SW;
}
if (Math.Abs(dir.x - (-1f)) < 0.2 && dir.y >= -0.5 && dir.y <= 0.5)
{
return HexDirection.W;
}
if (dir.x >= -1 && dir.y >= 0.5 && dir.x <= 0 && dir.y <= 1)
{
return HexDirection.NW;
}
return HexDirection.NULL;
}
}
}

View File

@ -0,0 +1,17 @@
using UnityEngine;
namespace Chars
{
public class PlayerControlView : MonoBehaviour
{
[SerializeField] private FloatingJoystick moveJoystick;
[SerializeField] private FloatingJoystick attackJoystick;
public FloatingJoystick MoveJoystick => moveJoystick;
public FloatingJoystick AttackJoystick => attackJoystick;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2019082adca55bd4c8ae55c9a0543ae6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -20,6 +20,9 @@ namespace Controller
var unitFactory = new UnitFactory(units);
hexGrid.OnGridLoaded += unitFactory.Spawn;
PlayerControl playerControl = new PlayerControl(player, data.PlayerData);
controllers.Add(playerControl);
}
private void DoSomething(HexCell cell)

View File

@ -1,4 +1,5 @@
using HexFiled;
using Chars;
using HexFiled;
using UnityEngine;
namespace Data
@ -6,8 +7,8 @@ namespace Data
[CreateAssetMenu(fileName = "PlayerData", menuName = "Data/PlayerData", order = 0)]
public class PlayerData : ScriptableObject
{
public HexCoordinates SpawnPos;
public GameObject PlayerPrefab;
public FloatingJoystick Joystick;
public HexCoordinates spawnPos;
public GameObject playerPrefab;
public PlayerControlView joystickView;
}
}

View File

@ -1,7 +1,7 @@
namespace HexFiled
{
public enum HexDirection {
NE, E, SE, SW, W, NW
NE, E, SE, SW, W, NW, NULL
}
public static class HexDirectionExtensions