This commit is contained in:
dddushesss 2022-02-05 22:15:01 +03:00
parent 6f1f5911cd
commit 53ffc3a8f6
32 changed files with 155 additions and 638 deletions

View File

@ -17,7 +17,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &4726489279989878082 --- !u!224 &4726489279989878082
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1706,7 +1706,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 4572196853266583038} - component: {fileID: 4572196853266583038}
- component: {fileID: 4105327572543419563} - component: {fileID: 4105327572543419563}
- component: {fileID: 5011141071925245406}
- component: {fileID: 1900872271281143359} - component: {fileID: 1900872271281143359}
- component: {fileID: 5890376687783205851} - component: {fileID: 5890376687783205851}
m_Layer: 0 m_Layer: 0
@ -1768,20 +1767,6 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &5011141071925245406
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3762867976042010436}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
m_Name:
m_EditorClassIdentifier:
barCanvas: {fileID: 0}
aimCanvas: {fileID: 0}
--- !u!136 &1900872271281143359 --- !u!136 &1900872271281143359
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -2933,7 +2933,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 7150739129758644021} - component: {fileID: 7150739129758644021}
- component: {fileID: -4568693640035559416} - component: {fileID: -4568693640035559416}
- component: {fileID: 8989822822968797088}
- component: {fileID: 8911891366586862002} - component: {fileID: 8911891366586862002}
- component: {fileID: 3288245434296440335} - component: {fileID: 3288245434296440335}
m_Layer: 0 m_Layer: 0
@ -2995,20 +2994,6 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &8989822822968797088
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7527582019267571087}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
m_Name:
m_EditorClassIdentifier:
barCanvas: {fileID: 0}
aimCanvas: {fileID: 0}
--- !u!136 &8911891366586862002 --- !u!136 &8911891366586862002
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -312,7 +312,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 73672630868547665} - component: {fileID: 73672630868547665}
- component: {fileID: -4047225411828250527} - component: {fileID: -4047225411828250527}
- component: {fileID: 8353965929846142445}
- component: {fileID: 1571523103774403885} - component: {fileID: 1571523103774403885}
- component: {fileID: 8290923392032443996} - component: {fileID: 8290923392032443996}
m_Layer: 0 m_Layer: 0
@ -374,20 +373,6 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &8353965929846142445
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 742650227762578155}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
m_Name:
m_EditorClassIdentifier:
barCanvas: {fileID: 0}
aimCanvas: {fileID: 0}
--- !u!136 &1571523103774403885 --- !u!136 &1571523103774403885
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -3438,7 +3438,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 8075972121593568698} - component: {fileID: 8075972121593568698}
- component: {fileID: -1510388322638865353} - component: {fileID: -1510388322638865353}
- component: {fileID: 7120083236827966330}
- component: {fileID: 2198464067484123790} - component: {fileID: 2198464067484123790}
- component: {fileID: 5657146932405139005} - component: {fileID: 5657146932405139005}
m_Layer: 0 m_Layer: 0
@ -3500,20 +3499,6 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &7120083236827966330
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8887939040951305984}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
m_Name:
m_EditorClassIdentifier:
barCanvas: {fileID: 0}
aimCanvas: {fileID: 0}
--- !u!136 &2198464067484123790 --- !u!136 &2198464067484123790
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -97,7 +97,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 609351601165668828} - component: {fileID: 609351601165668828}
- component: {fileID: -1148229131982139879} - component: {fileID: -1148229131982139879}
- component: {fileID: 7312803781132825500}
- component: {fileID: 6373024555497604353} - component: {fileID: 6373024555497604353}
- component: {fileID: 3412540945423151583} - component: {fileID: 3412540945423151583}
m_Layer: 0 m_Layer: 0
@ -159,20 +158,6 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &7312803781132825500
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 233917392663333734}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
m_Name:
m_EditorClassIdentifier:
barCanvas: {fileID: 0}
aimCanvas: {fileID: 0}
--- !u!136 &6373024555497604353 --- !u!136 &6373024555497604353
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -14,6 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_units: _units:
- isPlayer: 0 - isPlayer: 0
isAI: 1
spawnPos: spawnPos:
x: 19 x: 19
z: 4 z: 4
@ -23,7 +24,8 @@ MonoBehaviour:
maxMana: 1000 maxMana: 1000
maxHP: 100 maxHP: 100
inventoryCapacity: 4 inventoryCapacity: 4
- isPlayer: 1 - isPlayer: 0
isAI: 1
spawnPos: spawnPos:
x: 3 x: 3
z: 4 z: 4
@ -33,7 +35,8 @@ MonoBehaviour:
maxMana: 1000 maxMana: 1000
maxHP: 100 maxHP: 100
inventoryCapacity: 4 inventoryCapacity: 4
- isPlayer: 0 - isPlayer: 1
isAI: 0
spawnPos: spawnPos:
x: -1 x: -1
z: 42 z: 42
@ -44,6 +47,7 @@ MonoBehaviour:
maxHP: 100 maxHP: 100
inventoryCapacity: 4 inventoryCapacity: 4
- isPlayer: 0 - isPlayer: 0
isAI: 1
spawnPos: spawnPos:
x: -17 x: -17
z: 40 z: 40

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: cde640b28d28d9d44884fde46fe58fbf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,179 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &573487771985128269
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7336257010221584373}
- component: {fileID: 2261832089206299311}
- component: {fileID: 3682028664096015806}
m_Layer: 0
m_Name: Layer1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7336257010221584373
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 573487771985128269}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 6325281106960576957}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1839735485 &2261832089206299311
Tilemap:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 573487771985128269}
m_Enabled: 1
m_Tiles: {}
m_AnimatedTiles: {}
m_TileAssetArray: []
m_TileSpriteArray: []
m_TileMatrixArray: []
m_TileColorArray: []
m_TileObjectToInstantiateArray: []
m_AnimationFrameRate: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Origin: {x: 0, y: 0, z: 0}
m_Size: {x: 0, y: 0, z: 1}
m_TileAnchor: {x: 0, y: 0, z: 0}
m_TileOrientation: 0
m_TileOrientationMatrix:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
--- !u!483693784 &3682028664096015806
TilemapRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 573487771985128269}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 0
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_ChunkSize: {x: 32, y: 32, z: 32}
m_ChunkCullingBounds: {x: 0, y: 0, z: 0}
m_MaxChunkCount: 16
m_MaxFrameAge: 16
m_SortOrder: 0
m_Mode: 0
m_DetectChunkCullingBounds: 0
m_MaskInteraction: 0
--- !u!1 &5709523213856216068
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6325281106960576957}
- component: {fileID: 4694445811689797251}
m_Layer: 31
m_Name: New Palette
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6325281106960576957
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5709523213856216068}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 7336257010221584373}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!156049354 &4694445811689797251
Grid:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5709523213856216068}
m_Enabled: 1
m_CellSize: {x: 1, y: 1, z: 0}
m_CellGap: {x: 0, y: 0, z: 0}
m_CellLayout: 1
m_CellSwizzle: 0
--- !u!114 &1048497982843186255
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 12395, guid: 0000000000000000e000000000000000, type: 0}
m_Name: Palette Settings
m_EditorClassIdentifier:
cellSizing: 0
m_TransparencySortMode: 2
m_TransparencySortAxis: {x: 0, y: 0, z: 1}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 6129d4bf5c9ee654394c0733076e9b2e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -124,13 +124,15 @@ namespace AI
var item = GetNearestItem(agent); var item = GetNearestItem(agent);
if (((item.dist > 0 && item.dist <= _data.DistaceToCollectBonus) || if (((item.dist > 0 && item.dist <= _data.DistaceToCollectBonus) ||
agent.Unit.Mana <= agent.Unit.Data.maxMana * _data.ManaPercentToCollectBonus) && agent.Unit.Mana <= agent.Unit.Data.maxMana * _data.ManaPercentToCollectBonus) &&
agent.Unit.Inventory.Count < agent.Unit.InventoryCapacity) (item.hex.Item.Type == ItemType.DEFENCE
? agent.Unit.InventoryDefence.Count
: agent.Unit.Inventory.Count) < agent.Unit.InventoryCapacity / 2)
{ {
SetBehaviour(BotState.CollectingBonus, agent); SetBehaviour(BotState.CollectingBonus, agent);
return BotState.CollectingBonus; return BotState.CollectingBonus;
} }
var protect = agent.Unit.Inventory.Where(x => x is Bonus { BonusType: BonusType.Defence }).ToList(); var protect = agent.Unit.InventoryDefence.Where(x => x is Bonus { BonusType: BonusType.Defence }).ToList();
if (protect.Count > 0 && agent.Unit.Hp <= agent.Unit.Data.maxHP * _data.PercentToUseProtectBonus && if (protect.Count > 0 && agent.Unit.Hp <= agent.Unit.Data.maxHP * _data.PercentToUseProtectBonus &&
agent.Unit.DefenceBonus == 0) agent.Unit.DefenceBonus == 0)
{ {

View File

@ -3,7 +3,7 @@ using Runtime.Controller;
namespace Controller namespace Controller
{ {
public class Controllers : IExecute, IInitialization, ILateExecute, ICleanup public class Controllers : IExecute, IInitialization, ILateExecute, ICleanup, IFixedExecute, IAwake
{ {
private readonly List<IInitialization> _initializeControllers; private readonly List<IInitialization> _initializeControllers;
private readonly List<IExecute> _executeControllers; private readonly List<IExecute> _executeControllers;

View File

@ -39,7 +39,7 @@ namespace Controller
hexGrid.OnGridLoaded += () => unitFactory.SpawnList(data.UnitData.Units); hexGrid.OnGridLoaded += () => unitFactory.SpawnList(data.UnitData.Units);
hexGrid.OnHexPainted += paintedController.SetHexColors; hexGrid.OnHexPainted += paintedController.SetHexColors;
hexGrid.OnHexPainted += paintedController.CheckDeathOrDestroy;
hexGrid.SpawnField(); hexGrid.SpawnField();
} }

View File

@ -28,6 +28,7 @@ namespace Data
public struct UnitInfo public struct UnitInfo
{ {
public bool isPlayer; public bool isPlayer;
public bool isAI;
public HexCoordinates spawnPos; public HexCoordinates spawnPos;
public GameObject unitPrefa; public GameObject unitPrefa;
public UnitColor color; public UnitColor color;

View File

@ -13,7 +13,6 @@ namespace HexFiled
public event Action<HexCell> OnHexPainted; public event Action<HexCell> OnHexPainted;
[SerializeField] private HexCell[] neighbors; [SerializeField] private HexCell[] neighbors;
[SerializeField] private Item _item; [SerializeField] private Item _item;
private UnitColor _color; private UnitColor _color;
@ -24,8 +23,9 @@ namespace HexFiled
public Item Item public Item Item
{ {
get => _item; get => _item;
set => _item = _item == null ? value : null; set => _item = value;
} }
private GameObject _building; private GameObject _building;
public GameObject Building public GameObject Building
@ -44,9 +44,10 @@ namespace HexFiled
{ {
_renderer = GetComponent<MeshRenderer>(); _renderer = GetComponent<MeshRenderer>();
_color = UnitColor.Grey; _color = UnitColor.Grey;
if (!HexManager.CellByColor.ContainsKey(_color)) if (!HexManager.CellByColor.ContainsKey(_color))
{ {
HexManager.CellByColor.Add(_color, new List<HexCell>(){this}); HexManager.CellByColor.Add(_color, new List<HexCell>() { this });
} }
else else
{ {
@ -72,28 +73,50 @@ namespace HexFiled
cell.neighbors[(int)direction.Back()] = this; cell.neighbors[(int)direction.Back()] = this;
} }
public void PaintHex(UnitColor color) public void PaintHex(UnitColor color, bool isSetting = false)
{ {
if (color == _color) return; if (color == _color) return;
if (!HexManager.CellByColor.ContainsKey(color)) if (!HexManager.CellByColor.ContainsKey(color))
{ {
HexManager.CellByColor.Add(color, new List<HexCell>(){this}); HexManager.CellByColor.Add(color, new List<HexCell>() { this });
} }
_renderer.material.mainTexture = HexGrid.Colors[color].Texture; _renderer.material.mainTexture = HexGrid.Colors[color].Texture;
var previousColor = _color;
HexManager.CellByColor[previousColor].Remove(this); HexManager.CellByColor[_color].Remove(this);
_color = color; _color = color;
HexManager.CellByColor[_color].Add(this); HexManager.CellByColor[_color].Add(this);
if (!isSetting)
OnHexPainted?.Invoke(this); OnHexPainted?.Invoke(this);
if(color == UnitColor.Grey) return;
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXCellCapturePrefab, transform.position + new Vector3(0,0.1f,0)); if (_building != null)
{
Destroy(_building);
}
HexManager.UnitCurrentCell
.Where(cells
=> HexManager.CellByColor[cells.Key].Count < 3
|| (cells.Value.cell == this && cells.Value.unit.Color != Color))
.Select(cells => cells.Value.unit)
.ToList().ForEach(x => x.Death());
if (color == UnitColor.Grey)
{
if (_item != null)
{
_item.Despawn();
}
return;
}
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXCellCapturePrefab,
transform.position + new Vector3(0, 0.1f, 0));
MusicController.Instance.AddAudioSource(vfx); MusicController.Instance.AddAudioSource(vfx);
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures, vfx); MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures, vfx);
} }
} }
} }

View File

@ -37,11 +37,8 @@ namespace HexFiled
{ {
_fieldData = fieldData; _fieldData = fieldData;
_baseGameObject = new GameObject("HexGrid"); _baseGameObject = new GameObject("HexGrid");
_colors = new Dictionary<UnitColor, CellColor>(fieldData.colors.Count); _colors = fieldData.colors.ToDictionary(x => x.UnitColor, x => x);
foreach (var color in fieldData.colors)
{
_colors.Add(color.UnitColor, color);
}
_gridCanvas = Object.Instantiate(fieldData.CoordinatesCanvas, _baseGameObject.transform) _gridCanvas = Object.Instantiate(fieldData.CoordinatesCanvas, _baseGameObject.transform)
.GetComponent<Canvas>(); .GetComponent<Canvas>();
@ -85,7 +82,7 @@ namespace HexFiled
position.z = z * (HexMetrics.outerRadius * 1.5f); position.z = z * (HexMetrics.outerRadius * 1.5f);
var cellGO = Object.Instantiate(_fieldData.cellPrefab); var cellGO = Object.Instantiate(_fieldData.cellPrefab);
HexCell cell = _cells[i] = cellGO.GetComponent<HexCell>(); HexCell cell = _cells[i] = cellGO.GetComponent<HexCell>();
cell.PaintHex(UnitColor.Grey); cell.PaintHex(UnitColor.Grey, true);
cell.transform.SetParent(_baseGameObject.transform, false); cell.transform.SetParent(_baseGameObject.transform, false);
cell.transform.localPosition = position; cell.transform.localPosition = position;
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z); cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);

View File

@ -56,7 +56,7 @@ namespace HexFiled
public static void PaintHexList(List<HexCell> field, UnitColor color, float time) public static void PaintHexList(List<HexCell> field, UnitColor color, float time)
{ {
List<Action<UnitColor>> actions = new List<Action<UnitColor>>(); List<Action<UnitColor, bool>> actions = new List<Action<UnitColor, bool>>();
field.ForEach(x => actions.Add(x.PaintHex)); field.ForEach(x => actions.Add(x.PaintHex));
@ -70,7 +70,7 @@ namespace HexFiled
cells.AddRange(field); cells.AddRange(field);
cells.ForEach(x => x.PaintHex(color)); cells.ForEach(x => x.PaintHex(color, true));
} }
} }
} }

View File

@ -1,220 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5177366465263722279
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5177366465263722277}
- component: {fileID: 5177366465263722276}
m_Layer: 0
m_Name: Directional Light Left
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5177366465263722277
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5177366465263722279}
m_LocalRotation: {x: 0.38302222, y: 0.38302222, z: -0.17860618, w: 0.82139385}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5177366466773781006}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: 50, z: 0}
--- !u!108 &5177366465263722276
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5177366465263722279}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 0.7
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 0.408
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &5177366465427951230
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5177366465427951228}
- component: {fileID: 5177366465427951231}
m_Layer: 0
m_Name: Directional Light Right
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5177366465427951228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5177366465427951230}
m_LocalRotation: {x: 0.32139382, y: 0.32139382, z: -0.8830222, w: 0.11697779}
m_LocalPosition: {x: 35.65, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5177366466773781006}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 140, y: 140, z: 0}
--- !u!108 &5177366465427951231
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5177366465427951230}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 0.6
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 0
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &5177366466773781009
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5177366466773781006}
m_Layer: 0
m_Name: Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5177366466773781006
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5177366466773781009}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -14.18, y: 11.79, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 5177366465263722277}
- {fileID: 5177366465427951228}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: a7fb19d4a93bce94bba24aacfe92a572
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +1,7 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Units; using Units;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
namespace HexFiled namespace HexFiled
@ -17,80 +16,42 @@ namespace HexFiled
} }
public void CheckDeathOrDestroy(HexCell cell)
{
HexManager.UnitCurrentCell
.Where(cells
=> HexManager.CellByColor[cells.Key].Count < 3
|| (cells.Value.cell == cell && cells.Value.unit.Color != cell.Color))
.Select(cells => cells.Value.unit)
.ToList().ForEach(x => x.Death());
if (cell.Building != null)
{
Object.Destroy(cell.Building);
}
if (cell.Item != null)
{
cell.Item.Despawn();
}
}
public void SetHexColors(HexCell cell) public void SetHexColors(HexCell cell)
{ {
_cell = cell; _cell = cell;
var hexByColorDict = DifferentHexByColor(cell.GetListNeighbours()); var hexByColorDict = Enum.GetValues(typeof(UnitColor)).Cast<UnitColor>().ToDictionary(color => color,
foreach (var item in hexByColorDict) color => cell.GetListNeighbours().Where(x => x != null && x.Color == color).ToList());
cell.GetListNeighbours().Where(x => x != null && x.Color != cell.Color).ToList().ForEach(neighbour =>
{ {
if (item.Key == cell.Color && item.Value.Count >= 2 && item.Value.Count < 6 && if (hexByColorDict.TryGetValue(neighbour.Color, out var value) &&
HexManager.UnitCurrentCell.ContainsKey(cell.Color)) value.Count >= 2 && value.Count < 6)
{ {
cell.GetListNeighbours().ForEach(x => value.ForEach(x =>
{
if (x != null && x.Color != cell.Color)
{ {
var path = Round(x, null); var path = Round(x, null);
if (!path.hasPath) if (!path.hasPath)
{
HexManager.PaintHexList(path.field, cell.Color, 0.05f); HexManager.PaintHexList(path.field, cell.Color, 0.05f);
} }
}); });
} }
if (item.Value.Count >= 2 && item.Key != UnitColor.Grey && item.Key != cell.Color)
if (neighbour.Color != UnitColor.Grey
&& HexManager.UnitCurrentCell.TryGetValue(neighbour.Color, out var unit)
&& hexByColorDict.TryGetValue(neighbour.Color, out var cells)
&& cells.Count >= 2 && cells.Count < 5
&& !HasPath(neighbour, unit.cell, out var path))
{ {
item.Value.ForEach(neighbour => HexManager.PaintHexList(path, UnitColor.Grey);
{
if (HexManager.UnitCurrentCell.TryGetValue(item.Key, out var unitCel) &&
!HasPath(neighbour, unitCel.cell, out var path).hasPath)
{
HexManager.PaintHexList(path.field, UnitColor.Grey);
} }
}); });
} }
}
}
private Dictionary<UnitColor, List<HexCell>> DifferentHexByColor(List<HexCell> cellsList)
{
Dictionary<UnitColor, List<HexCell>> resultDict = new Dictionary<UnitColor, List<HexCell>>();
cellsList.ForEach(cell =>
{
if (cell != null && resultDict.ContainsKey(cell.Color))
{
resultDict[cell.Color].Add(cell);
}
else if (cell != null)
{
resultDict.Add(cell.Color, new List<HexCell> { cell });
}
});
return resultDict;
}
private (bool hasPath, List<HexCell> field) Round(HexCell start, HexCell end) private (bool hasPath, List<HexCell> field) Round(HexCell start, HexCell end)
{ {
if (start == null || start.Color == _cell.Color) if (start == null || start.Color == _cell.Color)
@ -153,13 +114,13 @@ namespace HexFiled
return (false, closedList); return (false, closedList);
} }
private ( bool hasPath, List<HexCell> field ) HasPath(HexCell start, HexCell end, private bool HasPath(HexCell start, HexCell end,
out ( bool hasPath, List<HexCell> field ) value) out List<HexCell> value)
{ {
if (start.Color == _cell.Color || end.Color == _cell.Color) if (start.Color == _cell.Color || end.Color == _cell.Color)
{ {
value = (true, null); value = null;
return (true, null); return true;
} }
List<HexCell> closedList = new List<HexCell>(); List<HexCell> closedList = new List<HexCell>();
@ -170,13 +131,12 @@ namespace HexFiled
closedList.Add(currentCell); closedList.Add(currentCell);
while (stackIterators.Count >= 0) while (stackIterators.Count >= 0)
{ {
if (currentCell == end) if (currentCell == end)
{ {
value = (true, null); value = null;
return (true, null); return true;
} }
List<HexCell> openList = currentCell.GetListNeighbours() List<HexCell> openList = currentCell.GetListNeighbours()
@ -195,8 +155,8 @@ namespace HexFiled
{ {
if (stackIterators.Count == 0) if (stackIterators.Count == 0)
{ {
value = (false, closedList); value = closedList;
return (false, closedList); return false;
} }
currentCell = stackIterators.Pop(); currentCell = stackIterators.Pop();
@ -204,13 +164,13 @@ namespace HexFiled
if (currentCell.GetListNeighbours().Contains(end)) if (currentCell.GetListNeighbours().Contains(end))
{ {
value = (true, null); value = null;
return (true, null); return true;
} }
} }
value = (false, closedList); value = closedList;
return (false, closedList); return false;
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace DefaultNamespace
{ {
public class HexMapEditor : MonoBehaviour public class HexMapEditor : MonoBehaviour
{ {
[SerializeField] private List<CellColor> cellColors;
[SerializeField] private GameObject hexPrefab; [SerializeField] private GameObject hexPrefab;
[SerializeField] private GameObject labelPrefab; [SerializeField] private GameObject labelPrefab;
@ -26,7 +26,7 @@ namespace DefaultNamespace
Destroy(fieldBaseGameObject); Destroy(fieldBaseGameObject);
} }
hexGrid = new HexGrid(x, y, hexPrefab, cellColors, labelPrefab);
WriteToBinaryFile("HexField", hexGrid); WriteToBinaryFile("HexField", hexGrid);
fieldBaseGameObject = hexGrid.SpawnField(); fieldBaseGameObject = hexGrid.SpawnField();
} }

View File

@ -9,11 +9,12 @@ namespace Items
public class Building : Item public class Building : Item
{ {
[SerializeField] private GameObject buildingPrefab; [SerializeField] private GameObject buildingPrefab;
private Action _action;
public void Invoke(Action action) public void Invoke(Action action)
{ {
OnItemUsed += action; _action = action;
OnItemUsed += _action;
} }
@ -26,7 +27,7 @@ namespace Items
cell.Building = obj; cell.Building = obj;
OnItemUsed.Invoke(); OnItemUsed.Invoke();
OnItemUsed = null; OnItemUsed = _action;
} }
} }
} }

View File

@ -2,6 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using DefaultNamespace; using DefaultNamespace;
using HexFiled; using HexFiled;
using Items.ItemViews;
using Units; using Units;
using UnityEngine; using UnityEngine;
using Object = UnityEngine.Object; using Object = UnityEngine.Object;
@ -29,13 +30,10 @@ namespace Items
{ {
private GameObject _instance; private GameObject _instance;
[SerializeField] private Sprite icon; [SerializeField] private Sprite icon;
[SerializeField] private bool isInvokeOnPickUp = false;
[SerializeField] private ItemType type; [SerializeField] private ItemType type;
public ItemType Type => type; public ItemType Type => type;
public bool IsInvokeOnPickUp => isInvokeOnPickUp;
public Sprite Icon => icon; public Sprite Icon => icon;
protected Unit Unit; protected Unit Unit;
@ -62,7 +60,7 @@ namespace Items
public void Despawn() public void Despawn()
{ {
Object.Destroy(_instance); Destroy(_instance.gameObject);
} }
public void Dispose() public void Dispose()

View File

@ -1,9 +1,7 @@
using System; using DG.Tweening;
using DG.Tweening;
using Units;
using UnityEngine; using UnityEngine;
namespace Items namespace Items.ItemViews
{ {
public class ItemView : MonoBehaviour public class ItemView : MonoBehaviour
{ {
@ -13,15 +11,11 @@ namespace Items
public Item Item => _item; public Item Item => _item;
private void Start()
{
pickedUp = false;
itemName = _item.name;
}
public void SetUp(Item item) public void SetUp(Item item)
{ {
_item = item; _item = item;
pickedUp = false;
itemName = _item.name;
Rotate(); Rotate();
} }
@ -32,10 +26,16 @@ namespace Items
private void Rotate() private void Rotate()
{ {
transform.DORotate(transform.rotation.eulerAngles + new Vector3(0, 10, 0), 0.1f) transform.DORotate(transform.rotation.eulerAngles + new Vector3(0, 10, 0), 0.1f)
.SetEase(Ease.InQuad) .SetEase(Ease.InQuad)
.SetLoops(-1, LoopType.Incremental); .SetLoops(-1, LoopType.Incremental)
.OnUpdate(() =>
{
if (pickedUp)
{
Destroy(gameObject);
}
});
} }
} }
} }

View File

@ -43,6 +43,10 @@ namespace DefaultNamespace
{ {
StartCoroutine(Timer(actions, time, param)); StartCoroutine(Timer(actions, time, param));
} }
public void StartTimer<T>(List<Action<T, bool>> actions, float time, T param)
{
StartCoroutine(Timer(actions, time, param));
}
IEnumerator Timer(Action action, float time) IEnumerator Timer(Action action, float time)
{ {
@ -64,5 +68,13 @@ namespace DefaultNamespace
action?.Invoke(param); action?.Invoke(param);
} }
} }
IEnumerator Timer<T>(List<Action<T, bool>> actions, float time, T param)
{
foreach (var action in actions)
{
yield return new WaitForSeconds(time);
action?.Invoke(param, true);
}
}
} }
} }

View File

@ -104,15 +104,16 @@ namespace Units
public void Retreet(HexDirection dir) public void Retreet(HexDirection dir)
{ {
if (!_isCapturing) return; if (!_isCapturing) return;
var openList = _cell.GetListNeighbours().Where(x => x.Color == _data.color).ToList(); var openList = _cell.GetListNeighbours().Where(x => x != null && x.Color == _data.color).ToList();
if (openList.Contains(_cell.GetNeighbor(dir))) if (!openList.Contains(_cell.GetNeighbor(dir)))
{ {
return;
}
_isBusy = false; _isBusy = false;
_isHardToCapture = false; _isHardToCapture = false;
_unitView.StopHardCapture(); _unitView.StopHardCapture();
Move(dir); Move(dir);
} }
}
public void Move(HexDirection direction) public void Move(HexDirection direction)
{ {
@ -210,19 +211,24 @@ namespace Units
if (!_isAlive) if (!_isAlive)
{ {
_cell = _hexGrid.GetCellFromCoord(hexCoordinates); _cell = _hexGrid.GetCellFromCoord(hexCoordinates);
_cell.PaintHex(_data.color); _cell.PaintHex(_data.color, true);
_cell.GetListNeighbours().ForEach(x => x?.PaintHex(Color)); _cell.GetListNeighbours().ForEach(x =>
{
x?.PaintHex(Color, true);
});
_inventory = new List<Item>(); _inventory = new List<Item>();
_inventoryDefence = new List<Item>(); _inventoryDefence = new List<Item>();
HexManager.UnitCurrentCell.Add(_data.color, (_cell, this)); HexManager.UnitCurrentCell.Add(_data.color, (_cell, this));
_instance = Object.Instantiate(_data.unitPrefa, _cell.transform.parent); _instance = Object.Instantiate(_data.unitPrefa, _cell.transform.parent);
_instance.transform.localPosition = _cell.transform.localPosition; _instance.transform.localPosition = _cell.transform.localPosition;
_isAlive = true; _isAlive = true;
_animator = _instance.GetComponent<Animator>(); _animator = _instance.GetComponent<Animator>();
_unitView = _instance.GetComponent<UnitView>(); _unitView = _instance.AddComponent<UnitView>();
_unitView.SetUp(_weapon, RegenMana, _data.manaRegen, CaptureHex, _unitView.SetUp(_weapon, RegenMana, _data.manaRegen, CaptureHex,
@ -461,7 +467,7 @@ namespace Units
return; return;
} }
SetUpBonus(0, 0, BonusType.Defence);
_hp -= dmg; _hp -= dmg;
UpdateBarCanvas(); UpdateBarCanvas();

View File

@ -70,10 +70,12 @@ namespace Chars
var enemy = new Unit(unitInfo, var enemy = new Unit(unitInfo,
_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid); _data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid);
if (unitInfo.isAI)
{
AIAgent agent = new AIAgent(unitInfo, enemy); AIAgent agent = new AIAgent(unitInfo, enemy);
enemy.OnPlayerSpawned += x => _controllers.Add(agent); enemy.OnPlayerSpawned += x => _controllers.Add(agent);
enemy.OnDeath += x => { _controllers.Remove(agent); }; enemy.OnDeath += x => { _controllers.Remove(agent); };
}
enemy.Spawn(unitInfo.spawnPos); enemy.Spawn(unitInfo.spawnPos);

View File

@ -6,6 +6,7 @@ using DefaultNamespace;
using DG.Tweening; using DG.Tweening;
using HexFiled; using HexFiled;
using Items; using Items;
using Items.ItemViews;
using Units; using Units;
using UnityEngine; using UnityEngine;
using Weapons; using Weapons;

View File

@ -15,6 +15,7 @@ public class DynamicJoystick : Joystick
private Vector2 starPos; private Vector2 starPos;
[SerializeField] private float moveThreshold = 1; [SerializeField] private float moveThreshold = 1;
[SerializeField] private float returnDuration = 0.5f;
protected override void Start() protected override void Start()
{ {
@ -26,6 +27,7 @@ public class DynamicJoystick : Joystick
public override void OnPointerDown(PointerEventData eventData) public override void OnPointerDown(PointerEventData eventData)
{ {
background.DOComplete();
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position); background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
FadeJoystick(true); FadeJoystick(true);
base.OnPointerDown(eventData); base.OnPointerDown(eventData);
@ -34,7 +36,8 @@ public class DynamicJoystick : Joystick
public override void OnPointerUp(PointerEventData eventData) public override void OnPointerUp(PointerEventData eventData)
{ {
FadeJoystick(false); FadeJoystick(false);
background.anchoredPosition = starPos; background.DOAnchorPos(starPos, returnDuration);
base.OnPointerUp(eventData); base.OnPointerUp(eventData);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long