Improved AI. Added attack energy, implemented attack mechanic.
This commit is contained in:
parent
9f0458ce3d
commit
3bacc3c516
340
Assets/Prefabs_NEW/UI/UI_AttackEnergy.prefab
Normal file
340
Assets/Prefabs_NEW/UI/UI_AttackEnergy.prefab
Normal file
@ -0,0 +1,340 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8903131178090680177
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8903131178090680178}
|
||||
- component: {fileID: 8903131178090680180}
|
||||
- component: {fileID: 8903131178090680179}
|
||||
m_Layer: 0
|
||||
m_Name: Slider
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8903131178090680178
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178090680177}
|
||||
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: 8903131178422816012}
|
||||
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_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 150, y: 6}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8903131178090680180
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178090680177}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8903131178090680179
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178090680177}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.02352941, g: 0.8416887, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 3a005f0b85cb35a4b80f78f133592569, type: 3}
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 0
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &8903131178351670492
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8903131178351670493}
|
||||
- component: {fileID: 7660888748284326884}
|
||||
m_Layer: 0
|
||||
m_Name: UI_AttackEnergy
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8903131178351670493
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178351670492}
|
||||
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: 8903131179114995249}
|
||||
- {fileID: 8903131178422816012}
|
||||
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_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &7660888748284326884
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178351670492}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 891957198d6ac824b834b2240d628d99, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_progressSlider: {fileID: 8903131178090680179}
|
||||
--- !u!1 &8903131178422816011
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8903131178422816012}
|
||||
- component: {fileID: 8903131178422816014}
|
||||
- component: {fileID: 8903131178422816013}
|
||||
m_Layer: 0
|
||||
m_Name: Bar
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8903131178422816012
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178422816011}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
|
||||
m_Children:
|
||||
- {fileID: 8903131178090680178}
|
||||
m_Father: {fileID: 8903131178351670493}
|
||||
m_RootOrder: 1
|
||||
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_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 150, y: 6}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8903131178422816014
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178422816011}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8903131178422816013
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131178422816011}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.745283, g: 0, b: 0, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 3a005f0b85cb35a4b80f78f133592569, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &8903131179114995248
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8903131179114995249}
|
||||
- component: {fileID: 8903131179114995251}
|
||||
- component: {fileID: 8903131179114995250}
|
||||
m_Layer: 0
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8903131179114995249
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131179114995248}
|
||||
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: 8903131178351670493}
|
||||
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_AnchoredPosition: {x: 0, y: 0.51}
|
||||
m_SizeDelta: {x: 200, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8903131179114995251
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131179114995248}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8903131179114995250
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8903131179114995248}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: '
|
||||
|
||||
'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 0161d805a3764c089bef00bfe00793f5, type: 2}
|
||||
m_sharedMaterial: {fileID: 2147374, guid: 0161d805a3764c089bef00bfe00793f5, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 0.39
|
||||
m_fontSizeBase: 0.39
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
7
Assets/Prefabs_NEW/UI/UI_AttackEnergy.prefab.meta
Normal file
7
Assets/Prefabs_NEW/UI/UI_AttackEnergy.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38920eb0e54d3704a8051d8884b5b76a
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -35,7 +35,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 150, y: 10}
|
||||
m_SizeDelta: {x: 150, y: 6}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6574093770988502000
|
||||
CanvasRenderer:
|
||||
@ -84,7 +84,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6574093771786895449}
|
||||
- component: {fileID: 962935407416420353}
|
||||
- component: {fileID: 5396834544230483808}
|
||||
m_Layer: 0
|
||||
m_Name: UI_Health
|
||||
m_TagString: Untagged
|
||||
@ -113,7 +113,7 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &962935407416420353
|
||||
--- !u!114 &5396834544230483808
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -122,7 +122,7 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 6574093771786895448}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cebe8e1376b6b2c47a1679181730a908, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 891957198d6ac824b834b2240d628d99, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_progressSlider: {fileID: 6574093770988502007}
|
||||
@ -162,7 +162,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 150, y: 10}
|
||||
m_SizeDelta: {x: 150, y: 6}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6574093771858033034
|
||||
CanvasRenderer:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,9 +22,7 @@ public class AI_Input : MonoBehaviour
|
||||
private PlayerState _playerState;
|
||||
private TileMovement _tileMovement;
|
||||
private PlayerActionManager _actionManager;
|
||||
private CaptureController _captureController;
|
||||
|
||||
private IEnumerator _attackCoroutine;
|
||||
private Attack _attack;
|
||||
|
||||
private Vector3 _startBotPoint;
|
||||
|
||||
@ -33,38 +31,28 @@ public class AI_Input : MonoBehaviour
|
||||
_playerState = GetComponent<PlayerState>();
|
||||
_tileMovement = GetComponent<TileMovement>();
|
||||
_actionManager = GetComponent<PlayerActionManager>();
|
||||
_captureController = GetComponent<CaptureController>();
|
||||
_attack = GetComponent<Attack>();
|
||||
|
||||
_actionManager.OnActionSuccess += BackToPatrol;
|
||||
_actionManager.OnActionSuccess += StartPatrolBehaviour;
|
||||
_actionManager.OnActionStart += OnActionStart;
|
||||
|
||||
_tileMovement.OnStartMovement += StopJoystick;
|
||||
_playerState.OnInitializied += StartPatrolBehaviour;
|
||||
_playerState.OnInitializied += ActivateAI;
|
||||
|
||||
OnCurrentPathFinished += StartPatrolBehaviour;
|
||||
|
||||
_playerState.OnDeath += StopAllActions;
|
||||
|
||||
_attack.OnEnergyLow += StartPatrolBehaviour;
|
||||
|
||||
_startBotPoint = transform.position;
|
||||
//Debug.Log(_startBotPoint);
|
||||
|
||||
}
|
||||
|
||||
/*private void SetNewTarget(TileInfo tile, float capTime)
|
||||
{
|
||||
StartPatrolBehaviour();
|
||||
}*/
|
||||
|
||||
private void StopAllActions()
|
||||
{
|
||||
botState = BotState.Patrol;
|
||||
StopAllCoroutines();
|
||||
//CancelInvoke();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator CheckBotState(float updateTime)
|
||||
@ -78,23 +66,23 @@ public class AI_Input : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
/*private void OnEnable()
|
||||
{
|
||||
//Debug.Log("bot " + gameObject.name + " started");
|
||||
//InvokeRepeating("CheckState", UnityEngine.Random.Range(0.5f, 1f), updateBehaviourIn); //to make not the same start
|
||||
Debug.Log("enable");
|
||||
//StartPatrolBehaviour();
|
||||
StartCoroutine(CheckBotState(updateBehaviourIn));
|
||||
}
|
||||
} */
|
||||
|
||||
private void OnActionStart(ActionType arg1, CharacterState arg2)
|
||||
{
|
||||
_currentEnemy = null;
|
||||
}
|
||||
|
||||
private void BackToPatrol()
|
||||
private void ActivateAI()
|
||||
{
|
||||
Debug.Log("back to patrol");
|
||||
StartPatrolBehaviour();
|
||||
//StartCoroutine(CheckBotState(updateBehaviourIn));
|
||||
StartCoroutine(CheckBotState(updateBehaviourIn));
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +91,7 @@ public class AI_Input : MonoBehaviour
|
||||
leftInput = Vector2.zero;
|
||||
}
|
||||
|
||||
private void MoveTo(TileInfo tile)
|
||||
private void MoveToNearTile(TileInfo tile)
|
||||
{
|
||||
if (_currentFollowingPath.Count > 0)
|
||||
{
|
||||
@ -116,7 +104,6 @@ public class AI_Input : MonoBehaviour
|
||||
//Debug.Log("start Patrol");
|
||||
_currentEnemy = null;
|
||||
botState = BotState.Patrol;
|
||||
//TileInfo targetTile = TileManagment.GetRandomOtherTile(_playerState.ownerIndex);
|
||||
TileInfo targetTile = TileManagment.GetNearestOtherTile(_playerState.currentTile, _playerState.ownerIndex, neutralCapDistance, _startBotPoint);
|
||||
var startTile = _playerState.currentTile;
|
||||
_currentFollowingPath = Pathfinding.FindPath(startTile, targetTile, TileManagment.levelTiles, TileManagment.tileOffset);
|
||||
@ -125,15 +112,12 @@ public class AI_Input : MonoBehaviour
|
||||
StartPatrolBehaviour();
|
||||
return;
|
||||
}
|
||||
//MoveTo(_currentFollowingPath[1]);
|
||||
}
|
||||
|
||||
private void CheckState(/*ActionType newType, CharacterState newState*/)
|
||||
private void CheckState()
|
||||
{
|
||||
//Debug.Log("Check state");
|
||||
/*if (botState.currentState == CharacterState.Dead)
|
||||
return;*/
|
||||
if (botState != BotState.Attack)
|
||||
Debug.Log("Check state");
|
||||
if (botState != BotState.Attack && _attack.IsReady())
|
||||
{
|
||||
foreach (PlayerState enemy in _playerState.enemies)
|
||||
{
|
||||
@ -150,7 +134,7 @@ public class AI_Input : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
if (botState == BotState.Patrol)
|
||||
if (botState == BotState.Patrol && _attack.IsReady())
|
||||
{
|
||||
foreach (PlayerState enemy in _playerState.enemies)
|
||||
{
|
||||
@ -210,8 +194,6 @@ public class AI_Input : MonoBehaviour
|
||||
//Debug.Log("startAttack");
|
||||
leftInput = Vector2.zero;
|
||||
_currentFollowingPath.Clear();
|
||||
//_attackCoroutine = TryToAttack(0.2f);
|
||||
//StartCoroutine(_attackCoroutine);
|
||||
_actionManager.AttackEnemyOnTile(_currentEnemy.currentTile);
|
||||
}
|
||||
}
|
||||
@ -229,7 +211,6 @@ public class AI_Input : MonoBehaviour
|
||||
}
|
||||
}
|
||||
TileInfo currentPos = TileManagment.GetTile(transform.position);
|
||||
//Debug.Log(adjacentTarget);
|
||||
RecalculatePath(currentPos, adjacentTarget);
|
||||
if (_currentFollowingPath == null)
|
||||
{
|
||||
@ -262,14 +243,13 @@ public class AI_Input : MonoBehaviour
|
||||
if (!endTile.canMove)
|
||||
{
|
||||
endTile = TileManagment.GetNearestOtherTile(_playerState.currentTile, _playerState.ownerIndex, neutralCapDistance, _startBotPoint);
|
||||
//endTile = TileManagment.GetRandomOtherTile(_playerState.ownerIndex);
|
||||
//Debug.Log("changed target");
|
||||
|
||||
}
|
||||
var currentTile = _playerState.currentTile;
|
||||
_currentFollowingPath.Clear();
|
||||
_currentFollowingPath = Pathfinding.FindPath(currentTile, endTile, TileManagment.levelTiles, TileManagment.tileOffset);
|
||||
MoveTo(_currentFollowingPath[1]);
|
||||
//Debug.Log("moving");
|
||||
MoveToNearTile(_currentFollowingPath[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -288,15 +268,6 @@ public class AI_Input : MonoBehaviour
|
||||
//StopAllCoroutines();
|
||||
}
|
||||
|
||||
private IEnumerator TryToAttack(float attackCoolDown)
|
||||
{
|
||||
_actionManager.AttackEnemyOnTile(_currentEnemy.currentTile);
|
||||
yield return new WaitForSeconds(attackCoolDown);
|
||||
BackToPatrol();
|
||||
StopCoroutine(_attackCoroutine);
|
||||
_attackCoroutine = null;
|
||||
//StopAllCoroutines();
|
||||
}
|
||||
|
||||
public enum BotState
|
||||
{
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -6,12 +7,41 @@ public class Attack : PlayerAction
|
||||
{
|
||||
public GameObject standartAttackPref;
|
||||
public GameObject standartAttackGroundImpact;
|
||||
|
||||
public float maxAttackEnergy = 3f;
|
||||
public float attackResetTime = 3f;
|
||||
public float attackCost = 1f;
|
||||
|
||||
public UI_Quantity UI_Energy;
|
||||
|
||||
private float attackEnergy;
|
||||
private float _silenceTime = 2f;
|
||||
private float _lastAttackTime = 0f;
|
||||
private bool _isReady = true;
|
||||
private bool _isCharging = true;
|
||||
|
||||
public Action OnEnergyLow;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
attackEnergy = maxAttackEnergy;
|
||||
_isCharging = false;
|
||||
_isReady = true;
|
||||
UI_Energy.UpdateBar(attackEnergy, maxAttackEnergy);
|
||||
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
CheckAttackAllowance();
|
||||
}
|
||||
public override bool IsActionAllowed(TileInfo targetTile, PlayerState playerState)
|
||||
{
|
||||
if (!targetTile)
|
||||
return false;
|
||||
bool permission = base.IsActionAllowed(targetTile, playerState);
|
||||
permission = permission && targetTile.canBeAttacked;
|
||||
permission = permission && targetTile.canBeAttacked && _isReady;
|
||||
return permission;
|
||||
}
|
||||
|
||||
@ -28,5 +58,68 @@ public class Attack : PlayerAction
|
||||
currentProjectile.SetinitialParams(projOwner, direction, TileManagment.tileOffset);
|
||||
|
||||
Instantiate(standartAttackGroundImpact, startPosition, standartAttackGroundImpact.transform.rotation);
|
||||
|
||||
_lastAttackTime = Time.time;
|
||||
_isCharging = false;
|
||||
ReduceAttackEnergy();
|
||||
UI_Energy.UpdateBar(attackEnergy, maxAttackEnergy);
|
||||
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
private void ReduceAttackEnergy()
|
||||
{
|
||||
attackEnergy-=attackCost;
|
||||
|
||||
if (attackEnergy < attackCost)
|
||||
{
|
||||
_isReady = false;
|
||||
OnEnergyLow?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckAttackAllowance()
|
||||
{
|
||||
if (Time.time > _lastAttackTime + _silenceTime)
|
||||
{
|
||||
if (!_isCharging && attackEnergy < maxAttackEnergy)
|
||||
{
|
||||
StartCoroutine(FillAttackEnergy(attackResetTime));
|
||||
}
|
||||
}
|
||||
|
||||
_isReady = attackEnergy > attackCost;
|
||||
}
|
||||
|
||||
private IEnumerator FillAttackEnergy(float fillTime)
|
||||
{
|
||||
//Debug.Log(attackEnergy);
|
||||
|
||||
_isCharging = true;
|
||||
float timer = 0f;
|
||||
float currentAttackEnergy = attackEnergy;
|
||||
while (timer < fillTime)
|
||||
{
|
||||
float fillProgress = timer / fillTime;
|
||||
timer += Time.fixedDeltaTime;
|
||||
attackEnergy = currentAttackEnergy + fillProgress * attackCost;
|
||||
UI_Energy.UpdateBar(attackEnergy, maxAttackEnergy);
|
||||
|
||||
if (attackEnergy > maxAttackEnergy)
|
||||
{
|
||||
attackEnergy = maxAttackEnergy;
|
||||
UI_Energy.UpdateBar(attackEnergy, maxAttackEnergy);
|
||||
break;
|
||||
}
|
||||
|
||||
yield return new WaitForFixedUpdate();
|
||||
}
|
||||
_isCharging = false;
|
||||
//Debug.Log(attackEnergy);
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _isReady;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class CaptureController : MonoBehaviour
|
||||
_playerState.OnInitializied += CaptureStartTile;
|
||||
_playerState.OnCaptureAllow += TryToCaptureTile;
|
||||
_playerState.OnCaptureForbid += StopCapturingTile;
|
||||
_playerState.OnDeath += StopCapturingTile;
|
||||
|
||||
OnCaptureEnd += CaptureTile;
|
||||
}
|
||||
@ -55,6 +56,8 @@ public class CaptureController : MonoBehaviour
|
||||
|
||||
private void TryToCaptureTile()
|
||||
{
|
||||
if (_playerState.currentState == CharacterState.Dead)
|
||||
return;
|
||||
TileInfo tile = _playerState.currentTile;
|
||||
//Debug.Log("Try to capture " + tile.name);
|
||||
if(_ownerIndex != tile.tileOwnerIndex)
|
||||
|
@ -9,7 +9,7 @@ public class HealthController : MonoBehaviour
|
||||
public float currentHealth;
|
||||
|
||||
[SerializeField]
|
||||
private UI_Health healthUI;
|
||||
private UI_Quantity healthUI;
|
||||
|
||||
public GameObject playerImpactVFX, groundImpactVFX;
|
||||
|
||||
@ -17,7 +17,7 @@ public class HealthController : MonoBehaviour
|
||||
private void OnEnable()
|
||||
{
|
||||
currentHealth = startHealth;
|
||||
healthUI.UpdateHealthBar(currentHealth, startHealth);
|
||||
healthUI.UpdateBar(currentHealth, startHealth);
|
||||
}
|
||||
|
||||
public void TakeDamage(float amount)
|
||||
@ -25,7 +25,7 @@ public class HealthController : MonoBehaviour
|
||||
if (currentHealth < 0)
|
||||
return;
|
||||
currentHealth -= amount;
|
||||
healthUI.UpdateHealthBar(currentHealth, startHealth);
|
||||
healthUI.UpdateBar(currentHealth, startHealth);
|
||||
Instantiate(playerImpactVFX, transform.position, playerImpactVFX.transform.rotation);
|
||||
Instantiate(groundImpactVFX, transform.position, groundImpactVFX.transform.rotation);
|
||||
if (currentHealth <= 0)
|
||||
|
@ -110,6 +110,10 @@ public class PlayerActionManager : MonoBehaviour
|
||||
|
||||
private void DoAction(PlayerAction action)
|
||||
{
|
||||
if (!action.IsActionAllowed(_target, _playerState))
|
||||
{
|
||||
return;
|
||||
}
|
||||
OnActionStart?.Invoke(action.actionType, CharacterState.Action);
|
||||
transform.LookAt(_target.tilePosition);
|
||||
action.StartActionOperations(_target);
|
||||
|
@ -111,7 +111,6 @@ public class PlayerDeathController : MonoBehaviour
|
||||
alivePlayers.Add(player);
|
||||
deadPlayers.Remove(player);
|
||||
PlayerResActions(player);
|
||||
//player.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void PlayerDeadActions(PlayerState player)
|
||||
@ -120,17 +119,18 @@ public class PlayerDeathController : MonoBehaviour
|
||||
{
|
||||
Instantiate(deathParticles, player.transform.position, deathParticles.transform.rotation);
|
||||
}
|
||||
|
||||
player.currentTile.canMove = true;
|
||||
player.SetNewState(ActionType.Attack, CharacterState.Dead);
|
||||
player.OnDeathActions();
|
||||
|
||||
List<TileInfo> playerTiles = TileManagment.charTiles[(int)player.ownerIndex];
|
||||
TileInfo currentTile = TileManagment.GetTile(player.transform.position);
|
||||
currentTile.canMove = true;
|
||||
//TileInfo currentTile = TileManagment.GetTile(player.transform.position);
|
||||
|
||||
foreach (TileInfo tile in playerTiles)
|
||||
{
|
||||
foreach (var enemy in player.enemies)
|
||||
{
|
||||
tile.easyCaptureFor.Add(enemy.ownerIndex);
|
||||
tile.isLocked = true;
|
||||
}
|
||||
}
|
||||
player.gameObject.SetActive(false);
|
||||
@ -145,16 +145,14 @@ public class PlayerDeathController : MonoBehaviour
|
||||
foreach (TileInfo tile in playerTiles)
|
||||
{
|
||||
tile.easyCaptureFor.Clear();
|
||||
tile.isLocked = false;
|
||||
}
|
||||
|
||||
player.gameObject.SetActive(true);
|
||||
player.SetNewState(ActionType.Attack, CharacterState.Idle);
|
||||
player.currentTile = GetAvailableResPos(player, playerTiles);
|
||||
player.transform.position = player.currentTile.tilePosition;
|
||||
player.transform.position = GetAvailableResPos(player, playerTiles);
|
||||
player.SetStartParams();
|
||||
player.currentTile.canMove = false;
|
||||
//player.transform.position = TileManagment.GetRandomOtherTile(player.ownerIndex).tilePosition;
|
||||
|
||||
//player.SetStartParams();
|
||||
//Debug.Log("player " + player.name + " res");
|
||||
|
||||
if (resParticles)
|
||||
@ -163,7 +161,7 @@ public class PlayerDeathController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private TileInfo GetAvailableResPos(PlayerState player, List<TileInfo> playerTiles)
|
||||
private Vector3 GetAvailableResPos(PlayerState player, List<TileInfo> playerTiles)
|
||||
{
|
||||
foreach (TileInfo tile in playerTiles)
|
||||
{
|
||||
@ -172,12 +170,12 @@ public class PlayerDeathController : MonoBehaviour
|
||||
var myNeighbourTiles = TileManagment.GetAllAdjacentTiles(tile, player.ownerIndex);
|
||||
if (myNeighbourTiles.Count >= spawnSafezone)
|
||||
{
|
||||
return tile;
|
||||
return tile.tilePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
Debug.Log("nowhere to spawn");
|
||||
return null;
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
public void OnKillBtnClick(int playerIndex)
|
||||
|
@ -86,10 +86,10 @@ public class PlayerState : MonoBehaviour
|
||||
else
|
||||
{
|
||||
CaptureState(false);
|
||||
/*if (newState == CharacterState.Dead)
|
||||
if (newState == CharacterState.Dead)
|
||||
{
|
||||
OnDeath?.Invoke();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
currentState = newState;
|
||||
OnCharStateChanged?.Invoke(newState, newAction);
|
||||
@ -105,8 +105,6 @@ public class PlayerState : MonoBehaviour
|
||||
public void SetStartParams()
|
||||
{
|
||||
currentTile = TileManagment.GetTile(transform.position);
|
||||
//currentState = CharacterState.Idle;
|
||||
//currentAction = ActionType.Attack;
|
||||
SetNewState(ActionType.Attack, CharacterState.Idle);
|
||||
SetEnemies();
|
||||
OnInitializied?.Invoke();
|
||||
@ -117,10 +115,6 @@ public class PlayerState : MonoBehaviour
|
||||
return (currentTile.tileOwnerIndex == ownerIndex) && (currentState == CharacterState.Idle);
|
||||
}
|
||||
|
||||
public void OnDeathActions()
|
||||
{
|
||||
OnDeath?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public enum CharacterState
|
||||
|
@ -9,6 +9,7 @@ public class TileInfo : MonoBehaviour
|
||||
public bool canMove = true;
|
||||
public bool canBeAttacked = true;
|
||||
public bool canBuildHere = true;
|
||||
public bool isLocked = false;
|
||||
|
||||
public GameObject buildingOnTile;
|
||||
|
||||
|
@ -54,10 +54,6 @@ public class TileManagment : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//Debug.Log("We have "+ levelTiles.Count + " tiles on this level");
|
||||
//Debug.Log("Tiles offset "+ _tilesOffset +" units");
|
||||
//Debug.Log(GetTile(new Vector3(0f, 0f, 0f), new Vector3(-0.9f, 0f, 1.7f), 1));
|
||||
//pathTiles = Pathfinding.FindPath(levelTiles[0].GetComponent<PathNode>(), levelTiles[106].GetComponent<PathNode>(), tileOffset);
|
||||
if (tileMaterials.Count == 0)
|
||||
{
|
||||
Debug.LogError("You need to set tile materials to TileManagment");
|
||||
@ -72,16 +68,16 @@ public class TileManagment : MonoBehaviour
|
||||
tile.GetComponent<Renderer>().material = tileMaterials[(int)tile.tileOwnerIndex];
|
||||
}
|
||||
|
||||
public void ChangeTileOwner(TileInfo tile, TileOwner ownerIndex)
|
||||
public void ChangeTileOwner(TileInfo tile, TileOwner newOwner)
|
||||
{
|
||||
TileOwner oldOwner = tile.tileOwnerIndex;
|
||||
tile.tileOwnerIndex = ownerIndex;
|
||||
tile.tileOwnerIndex = newOwner;
|
||||
tile.GetComponent<Renderer>().material = tileMaterials[(int)tile.tileOwnerIndex];
|
||||
|
||||
charTiles[(int)ownerIndex].Add(tile);
|
||||
charTiles[(int)newOwner].Add(tile);
|
||||
charTiles[(int)oldOwner].Remove(tile);
|
||||
|
||||
CheckSurroundedTiles(levelTiles, ownerIndex, tile);
|
||||
CheckSurroundedTiles(levelTiles, newOwner, oldOwner);
|
||||
|
||||
OnAnyTileCaptured?.Invoke();
|
||||
|
||||
@ -238,41 +234,39 @@ public class TileManagment : MonoBehaviour
|
||||
return tempArr;
|
||||
}
|
||||
|
||||
public static void CheckSurroundedTiles(List<TileInfo> tiles, TileOwner ownerIndex, TileInfo capTile)
|
||||
public static void CheckSurroundedTiles(List<TileInfo> tiles, TileOwner newOwner, TileOwner oldOwner)
|
||||
{
|
||||
List<TileOwner> checkPlayers = new List<TileOwner>();
|
||||
checkPlayers.Add(oldOwner);
|
||||
checkPlayers.Add(newOwner);
|
||||
|
||||
foreach (var player in checkPlayers)
|
||||
{
|
||||
//List<TileOwner> checkingOwners = new List<TileOwner>();
|
||||
//checkingOwners.Add(capTile.tileOwnerIndex);
|
||||
//checkingOwners.Add(ownerIndex);
|
||||
//Debug.Log(checkingOwners[0]);
|
||||
//Debug.Log(checkingOwners[1]);
|
||||
foreach (TileInfo tile in levelTiles)
|
||||
{
|
||||
tile.checkedFor.Remove(ownerIndex);
|
||||
tile.easyCaptureFor.Remove(ownerIndex);
|
||||
/*foreach (TileOwner owner in checkingOwners)
|
||||
|
||||
tile.checkedFor.Remove(newOwner);
|
||||
if (!tile.isLocked)
|
||||
{
|
||||
tile.checkedFor.Remove(owner);
|
||||
tile.easyCaptureFor.Remove(owner);
|
||||
} */
|
||||
tile.easyCaptureFor.Remove(newOwner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var player in checkPlayers)
|
||||
{
|
||||
foreach (TileInfo tile in levelTiles)
|
||||
{
|
||||
if (!tile.isBorderTile)
|
||||
{
|
||||
if ((!tile.checkedFor.Contains(ownerIndex)) && (tile.tileOwnerIndex != ownerIndex))
|
||||
if ((!tile.checkedFor.Contains(player)) && (tile.tileOwnerIndex != player))
|
||||
{
|
||||
CheckIfSurroundedByOwner(tiles, ownerIndex, tile);
|
||||
CheckIfSurroundedByOwner(tiles, player, tile);
|
||||
}
|
||||
/*foreach (TileOwner owner in checkingOwners)
|
||||
{
|
||||
if ((!tile.checkedFor.Contains(owner)) && (tile.tileOwnerIndex != owner))
|
||||
{
|
||||
CheckIfSurroundedByOwner(tiles, owner, tile);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -316,10 +310,13 @@ public class TileManagment : MonoBehaviour
|
||||
}
|
||||
|
||||
foreach (TileInfo tile in connectedTiles)
|
||||
{
|
||||
if(!tile.isLocked)
|
||||
{
|
||||
tile.easyCaptureFor.Add(ownerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* public static void SetSurroundedTiles(List<TileInfo> tiles, TileOwner ownerIndex, TileInfo startTile)
|
||||
{
|
||||
List<TileInfo> surroundedTiles = new List<TileInfo>();
|
||||
|
27
Assets/Scripts/UI_Quantity.cs
Normal file
27
Assets/Scripts/UI_Quantity.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UI_Quantity : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Image _progressSlider;
|
||||
|
||||
private Transform _mainCam;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_mainCam = Camera.main.transform;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
transform.forward = _mainCam.forward;
|
||||
}
|
||||
|
||||
public void UpdateBar(float currentQuantity, float maxQuantity)
|
||||
{
|
||||
_progressSlider.fillAmount = currentQuantity / maxQuantity;
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI_Quantity.cs.meta
Normal file
11
Assets/Scripts/UI_Quantity.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 891957198d6ac824b834b2240d628d99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user