attack distance. unit hit
This commit is contained in:
parent
2b5b4029f0
commit
c342edbea9
@ -1615,6 +1615,8 @@ GameObject:
|
||||
- component: {fileID: 4572196853266583038}
|
||||
- component: {fileID: 4105327572543419563}
|
||||
- component: {fileID: 5011141071925245406}
|
||||
- component: {fileID: 1900872271281143359}
|
||||
- component: {fileID: 5890376687783205851}
|
||||
m_Layer: 0
|
||||
m_Name: Ariost
|
||||
m_TagString: Untagged
|
||||
@ -1687,6 +1689,36 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
charBarCanvas: {fileID: 268172662505640299}
|
||||
--- !u!136 &1900872271281143359
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3762867976042010436}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.4395566
|
||||
m_Height: 2.058372
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 1.0294466, z: -0.0604434}
|
||||
--- !u!54 &5890376687783205851
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3762867976042010436}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &3785454847173043879
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2935,6 +2935,8 @@ GameObject:
|
||||
- component: {fileID: 7150739129758644021}
|
||||
- component: {fileID: -4568693640035559416}
|
||||
- component: {fileID: 8989822822968797088}
|
||||
- component: {fileID: 8911891366586862002}
|
||||
- component: {fileID: 3288245434296440335}
|
||||
m_Layer: 0
|
||||
m_Name: Asvald
|
||||
m_TagString: Untagged
|
||||
@ -3008,6 +3010,36 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
charBarCanvas: {fileID: 5591725933991455353}
|
||||
--- !u!136 &8911891366586862002
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7527582019267571087}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.5280086
|
||||
m_Height: 2.234182
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0.9057262, z: 0.02800858}
|
||||
--- !u!54 &3288245434296440335
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7527582019267571087}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &7550162364350684268
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -313,6 +313,8 @@ GameObject:
|
||||
- component: {fileID: 73672630868547665}
|
||||
- component: {fileID: -4047225411828250527}
|
||||
- component: {fileID: 8353965929846142445}
|
||||
- component: {fileID: 1571523103774403885}
|
||||
- component: {fileID: 8290923392032443996}
|
||||
m_Layer: 0
|
||||
m_Name: Emir
|
||||
m_TagString: Untagged
|
||||
@ -386,6 +388,36 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
charBarCanvas: {fileID: 9197595637317142914}
|
||||
--- !u!136 &1571523103774403885
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 742650227762578155}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.4395566
|
||||
m_Height: 2.058372
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 1.0294466, z: -0.0604434}
|
||||
--- !u!54 &8290923392032443996
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 742650227762578155}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &792258801834930952
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3818,18 +3850,18 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: dec5dd0d644d5c548a53563e65837162, type: 3}
|
||||
--- !u!224 &7764648799730394358 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 5156761560679623958, guid: dec5dd0d644d5c548a53563e65837162,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 3193594884886186464}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &9197595637317142914 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6049883652435591266, guid: dec5dd0d644d5c548a53563e65837162,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 3193594884886186464}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!224 &7764648799730394358 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 5156761560679623958, guid: dec5dd0d644d5c548a53563e65837162,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 3193594884886186464}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &7193426573827869494
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3440,6 +3440,8 @@ GameObject:
|
||||
- component: {fileID: 8075972121593568698}
|
||||
- component: {fileID: -1510388322638865353}
|
||||
- component: {fileID: 7120083236827966330}
|
||||
- component: {fileID: 2198464067484123790}
|
||||
- component: {fileID: 5657146932405139005}
|
||||
m_Layer: 0
|
||||
m_Name: Mats
|
||||
m_TagString: Untagged
|
||||
@ -3513,6 +3515,36 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
charBarCanvas: {fileID: 8614863231585036848}
|
||||
--- !u!136 &2198464067484123790
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8887939040951305984}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.4395566
|
||||
m_Height: 2.058372
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 1.0294466, z: -0.0604434}
|
||||
--- !u!54 &5657146932405139005
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8887939040951305984}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &8928538182418462435
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3893,15 +3925,15 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: dec5dd0d644d5c548a53563e65837162, type: 3}
|
||||
--- !u!1 &8614863231585036848 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6049883652435591266, guid: dec5dd0d644d5c548a53563e65837162,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 2628876604355308114}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!224 &7200088151662806852 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 5156761560679623958, guid: dec5dd0d644d5c548a53563e65837162,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 2628876604355308114}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &8614863231585036848 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6049883652435591266, guid: dec5dd0d644d5c548a53563e65837162,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 2628876604355308114}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
@ -98,6 +98,8 @@ GameObject:
|
||||
- component: {fileID: 609351601165668828}
|
||||
- component: {fileID: -1148229131982139879}
|
||||
- component: {fileID: 7312803781132825500}
|
||||
- component: {fileID: 6373024555497604353}
|
||||
- component: {fileID: 3412540945423151583}
|
||||
m_Layer: 0
|
||||
m_Name: Ragnar
|
||||
m_TagString: Untagged
|
||||
@ -149,7 +151,7 @@ Animator:
|
||||
m_GameObject: {fileID: 233917392663333734}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000, guid: 6c6726efa8f26a44c89dbcc255bf46f9, type: 2}
|
||||
m_Controller: {fileID: 9100000, guid: 9e1a6090cd4d65d4599676c24fcb5cff, type: 2}
|
||||
m_CullingMode: 0
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
@ -171,6 +173,36 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
charBarCanvas: {fileID: 7624052504724712865}
|
||||
--- !u!136 &6373024555497604353
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 233917392663333734}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.4395566
|
||||
m_Height: 2.058372
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 1.0294466, z: -0.0604434}
|
||||
--- !u!54 &3412540945423151583
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 233917392663333734}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &256650191767157381
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -12,6 +12,7 @@ GameObject:
|
||||
- component: {fileID: 7219588875864790975}
|
||||
- component: {fileID: 7219588875865804323}
|
||||
- component: {fileID: 7219588875878423961}
|
||||
- component: {fileID: 6099487056254604312}
|
||||
m_Layer: 0
|
||||
m_Name: Laser
|
||||
m_TagString: Untagged
|
||||
@ -4834,6 +4835,20 @@ AudioSource:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 0
|
||||
--- !u!136 &6099487056254604312
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7219588875883387333}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.5445045
|
||||
m_Height: 1.089009
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 3.586327e-17, z: -0.02872634}
|
||||
--- !u!1 &7219588875883396939
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -5222,7 +5237,7 @@ ParticleSystem:
|
||||
m_RotationOrder: 4
|
||||
startRotationX:
|
||||
serializedVersion: 2
|
||||
minMaxState: 0
|
||||
minMaxState: 3
|
||||
scalar: 1
|
||||
minScalar: 0
|
||||
maxCurve:
|
||||
@ -5275,7 +5290,7 @@ ParticleSystem:
|
||||
m_RotationOrder: 4
|
||||
startRotationY:
|
||||
serializedVersion: 2
|
||||
minMaxState: 0
|
||||
minMaxState: 3
|
||||
scalar: 1
|
||||
minScalar: 0
|
||||
maxCurve:
|
||||
@ -9860,7 +9875,7 @@ ParticleSystem:
|
||||
m_RotationOrder: 0
|
||||
startSizeY:
|
||||
serializedVersion: 2
|
||||
minMaxState: 0
|
||||
minMaxState: 3
|
||||
scalar: 1
|
||||
minScalar: 1
|
||||
maxCurve:
|
||||
@ -9913,7 +9928,7 @@ ParticleSystem:
|
||||
m_RotationOrder: 4
|
||||
startSizeZ:
|
||||
serializedVersion: 2
|
||||
minMaxState: 0
|
||||
minMaxState: 3
|
||||
scalar: 1
|
||||
minScalar: 1
|
||||
maxCurve:
|
||||
|
@ -14396,6 +14396,8 @@ GameObject:
|
||||
- component: {fileID: 4746165193703840883}
|
||||
- component: {fileID: 4746165193722172489}
|
||||
- component: {fileID: 4746165193724002145}
|
||||
- component: {fileID: 1047993054701375893}
|
||||
- component: {fileID: 7831311356765102851}
|
||||
m_Layer: 0
|
||||
m_Name: StandartAttack
|
||||
m_TagString: Untagged
|
||||
@ -19133,6 +19135,32 @@ ParticleSystemRenderer:
|
||||
m_Mesh2: {fileID: 0}
|
||||
m_Mesh3: {fileID: 0}
|
||||
m_MaskInteraction: 0
|
||||
--- !u!136 &1047993054701375893
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4746165193704193263}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.5
|
||||
m_Height: 1
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7831311356765102851
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4746165193704193263}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f35bf8471b73bda40bb1eb4c020d64e6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &6794842974925477961
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -7,7 +7,7 @@ namespace Chars
|
||||
{
|
||||
public class Enemy : IUnit
|
||||
{
|
||||
private GameObject _playerPrefab;
|
||||
private GameObject _enemyPrefab;
|
||||
private HexCoordinates _spawnPos;
|
||||
private UnitColor _color;
|
||||
private HexCell _cell;
|
||||
@ -18,13 +18,16 @@ namespace Chars
|
||||
private bool _isBusy;
|
||||
private Animator _animator;
|
||||
private AnimLength _animLength;
|
||||
private CharBar _charBar;
|
||||
private float _mana;
|
||||
private float _hp;
|
||||
|
||||
public UnitView EnemyView => _unitView;
|
||||
public bool IsBusy => _isBusy;
|
||||
|
||||
public Enemy(EnemyInfo enemyInfo, HexGrid grid)
|
||||
{
|
||||
_playerPrefab = enemyInfo.playerPrefab;
|
||||
_enemyPrefab = enemyInfo.playerPrefab;
|
||||
_spawnPos = enemyInfo.spawnPos;
|
||||
_color = enemyInfo.color;
|
||||
_grid = grid;
|
||||
@ -62,12 +65,18 @@ namespace Chars
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCanvas()
|
||||
{
|
||||
_charBar.ManaBar.fillAmount = _mana / 100;
|
||||
_charBar.HealthBar.fillAmount = _hp / 100;
|
||||
}
|
||||
|
||||
public void Spawn()
|
||||
{
|
||||
if(!_isAlive)
|
||||
{
|
||||
_cell = _grid.GetCellFromCoord(_spawnPos);
|
||||
_instance = Object.Instantiate(_playerPrefab, _cell.transform.parent);
|
||||
_instance = Object.Instantiate(_enemyPrefab, _cell.transform.parent);
|
||||
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||
_cell.PaintHex(_color);
|
||||
for (int i = 0; i < 6; i++)
|
||||
@ -78,10 +87,15 @@ namespace Chars
|
||||
_isAlive = true;
|
||||
_unitView = _instance.GetComponent<UnitView>();
|
||||
_animator = _instance.GetComponent<Animator>();
|
||||
_charBar = _instance.GetComponent<CharBar>();
|
||||
SetAnimLength();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUpActions()
|
||||
{
|
||||
_unitView.OnHit += Damage;
|
||||
}
|
||||
public void Death()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
@ -95,7 +109,8 @@ namespace Chars
|
||||
|
||||
public void Damage(float dmg)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
_hp -= dmg;
|
||||
UpdateCanvas();
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ namespace Chars
|
||||
private float _hp;
|
||||
private float _mana;
|
||||
private Weapon _weapon;
|
||||
private Vector3 _direction;
|
||||
private Vector2 _direction;
|
||||
private CharBar _charBar;
|
||||
|
||||
public bool IsBusy => _isBusy;
|
||||
@ -119,8 +119,11 @@ namespace Chars
|
||||
private void Attacking()
|
||||
{
|
||||
var ball = Object.Instantiate(_weapon.objectToThrow,
|
||||
_instance.transform.position + new Vector3(0, 2), Quaternion.identity);
|
||||
ball.transform.DOMove(new Vector3(_direction.x * 100,2, _direction.y * 100), _weapon.speed)
|
||||
_instance.transform.position + new Vector3(0, 0), Quaternion.identity);
|
||||
ball.transform.DOMove(
|
||||
new Vector3(_direction.normalized.x,
|
||||
0, _direction.normalized.y) * _weapon.disnatce * _hexGrid.HexDistance + _instance.transform.position,
|
||||
_weapon.speed)
|
||||
.SetEase(Ease.Linear)
|
||||
.OnComplete(() => Object.Destroy(ball));
|
||||
}
|
||||
@ -152,7 +155,7 @@ namespace Chars
|
||||
|
||||
public void Aim(Vector2 direction)
|
||||
{
|
||||
_unitView.transform.LookAt(new Vector3(direction.x,0, direction.y) + _unitView.transform.position);
|
||||
_unitView.transform.LookAt(new Vector3(direction.x, 0, direction.y) + _unitView.transform.position);
|
||||
_direction = direction;
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,12 @@ namespace HexFiled
|
||||
private HexCell[] _cells;
|
||||
private Canvas _gridCanvas;
|
||||
private GameObject _baseGameObject;
|
||||
private Dictionary<UnitColor, CellColor> _colors;
|
||||
private float _hexDistance;
|
||||
|
||||
public float HexDistance => _hexDistance;
|
||||
public Action<HexCell> OnHexPainted;
|
||||
public Action OnGridLoaded;
|
||||
private Dictionary<UnitColor, CellColor> _colors;
|
||||
|
||||
public HexGrid(FieldData fieldData)
|
||||
{
|
||||
@ -82,19 +85,26 @@ namespace HexFiled
|
||||
else
|
||||
{
|
||||
cell.SetNeighbor(HexDirection.SW, _cells[i - _width]);
|
||||
if (_hexDistance == 0f)
|
||||
{
|
||||
_hexDistance = Vector3.Distance(cell.transform.position,
|
||||
cell.GetNeighbor(HexDirection.SW).transform.position);
|
||||
}
|
||||
|
||||
if (x < _width - 1)
|
||||
{
|
||||
cell.SetNeighbor(HexDirection.SE, _cells[i - _width + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
TMP_Text label = Object.Instantiate(_cellLabelPrefab, _gridCanvas.transform, false);
|
||||
label.rectTransform.anchoredPosition =
|
||||
new Vector2(position.x, position.z);
|
||||
label.text = cell.coordinates.ToStringOnSeparateLines();
|
||||
#endif
|
||||
}
|
||||
// #if UNITY_EDITOR
|
||||
// TMP_Text label = Object.Instantiate(_cellLabelPrefab, _gridCanvas.transform, false);
|
||||
// label.rectTransform.anchoredPosition =
|
||||
// new Vector2(position.x, position.z);
|
||||
// label.text = cell.coordinates.ToStringOnSeparateLines();
|
||||
// #endif
|
||||
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using DefaultNamespace.Weapons;
|
||||
using UnityEngine;
|
||||
|
||||
public class UnitView : MonoBehaviour
|
||||
@ -6,6 +7,7 @@ public class UnitView : MonoBehaviour
|
||||
public Action OnStep;
|
||||
public Action OnAttackEnd;
|
||||
public Action OnAttack;
|
||||
public Action<float> OnHit;
|
||||
public GameObject charBarCanvas;
|
||||
|
||||
private void Step()
|
||||
@ -22,4 +24,16 @@ public class UnitView : MonoBehaviour
|
||||
{
|
||||
OnAttack?.Invoke();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
WeaponView weaponView = other.GetComponent<WeaponView>();
|
||||
if (weaponView != null)
|
||||
{
|
||||
OnHit?.Invoke(weaponView.Weapon.damage);
|
||||
Destroy(other);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
17
Assets/WeaponView.cs
Normal file
17
Assets/WeaponView.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DefaultNamespace.Weapons;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponView : MonoBehaviour
|
||||
{
|
||||
private Weapon _weapon;
|
||||
|
||||
public Weapon Weapon => _weapon;
|
||||
|
||||
public void SetWeapon(Weapon weapon)
|
||||
{
|
||||
_weapon = weapon;
|
||||
}
|
||||
|
||||
}
|
11
Assets/WeaponView.cs.meta
Normal file
11
Assets/WeaponView.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f35bf8471b73bda40bb1eb4c020d64e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user