diff --git a/Assets/Animation/Character/TestController.controller b/Assets/Animation/Character/TestController.controller index 77d45ee2..3e37b2ad 100644 --- a/Assets/Animation/Character/TestController.controller +++ b/Assets/Animation/Character/TestController.controller @@ -215,31 +215,31 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: BackToIdle m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Build m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: TreeAttack m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Move m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -492,7 +492,7 @@ AnimatorState: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: Movement - m_Speed: 2 + m_Speed: 3 m_CycleOffset: 0 m_Transitions: - {fileID: 354894258193955894} diff --git a/Assets/Scenes/Level_1.unity b/Assets/Scenes/Level_1.unity index 2051c392..07f45601 100644 --- a/Assets/Scenes/Level_1.unity +++ b/Assets/Scenes/Level_1.unity @@ -18857,7 +18857,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f701310aaea215a4d9e0c8646d3e1ecd, type: 3} m_Name: m_EditorClassIdentifier: - nextTileMoveTime: 1 + nextTileMoveTime: 0.7 moveDistance: 1 moveVFX: {fileID: 2040783568} --- !u!114 &1503763734 @@ -18926,7 +18926,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 754e9bf36b6ab0b40a8b71c58aa34b04, type: 3} m_Name: m_EditorClassIdentifier: - isAIActive: 0 + isAIActive: 1 botState: 0 leftInput: {x: 0, y: 0} rightInput: {x: 0, y: 0} @@ -22869,7 +22869,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f701310aaea215a4d9e0c8646d3e1ecd, type: 3} m_Name: m_EditorClassIdentifier: - nextTileMoveTime: 1 + nextTileMoveTime: 0.7 moveDistance: 1 moveVFX: {fileID: 1307683756} --- !u!114 &1801060024 @@ -22884,8 +22884,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4b3c4882af86905429c1c42aabf068c1, type: 3} m_Name: m_EditorClassIdentifier: - neutralCaptureTime: 1 - enemyCaptureTime: 2 + neutralCaptureTime: 0.2 + enemyCaptureTime: 0.4 capVFX: {fileID: 442387583353148024, guid: 53959bc898e9a644daad0282881d596a, type: 3} --- !u!114 &1801060025 MonoBehaviour: @@ -22938,7 +22938,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5182c2cb5eef6d849b560f764c4a0ed6, type: 3} m_Name: m_EditorClassIdentifier: - startHealth: 120 + startHealth: 10000 currentHealth: 0 playerImpactVFX: {fileID: 2957420090356197408, guid: 5d1244f7b80cadd428a70173a01ce889, type: 3} @@ -24850,8 +24850,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1923264931} - m_LocalRotation: {x: 0.029971035, y: -0.000000004076362, z: 0.0000000075761575, - w: 0.9995508} + m_LocalRotation: {x: 0.029971035, y: 0.000000004076362, z: -0.000000007576159, w: 0.9995508} m_LocalPosition: {x: 0, y: 0.87083435, z: -14.50833} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] @@ -25539,7 +25538,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1946816075} - m_LocalRotation: {x: 0.5257311, y: -0.000000007318311, z: 0.000000004522964, w: 0.85065085} + m_LocalRotation: {x: 0.5257311, y: 0.0000000073183117, z: -0.0000000045229647, w: 0.85065085} m_LocalPosition: {x: 0, y: 13, z: -6.5} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: diff --git a/Assets/Scripts/AI/AI_BotController.cs b/Assets/Scripts/AI/AI_BotController.cs index 53a844b4..cbbd83ba 100644 --- a/Assets/Scripts/AI/AI_BotController.cs +++ b/Assets/Scripts/AI/AI_BotController.cs @@ -31,6 +31,9 @@ public class AI_BotController : MonoBehaviour private bool isAttackedOnce = false; + private int _maxTriesToCalculatePath = 15; + private int _triesToCalculatePath = 15; + private void Awake() { _playerState = GetComponent(); @@ -99,14 +102,24 @@ public class AI_BotController : MonoBehaviour //calculate path TileInfo currentTile = _playerState.currentTile; TileInfo targetPathTile = TileManagment.GetClosestOtherTile(currentTile, _playerState.ownerIndex, _startBotPoint); + _triesToCalculatePath++; //Debug.Log(targetPathTile); - if (!RecalculatePath(currentTile, targetPathTile)) + if (!RecalculatePath(currentTile, targetPathTile) && _triesToCalculatePath < _maxTriesToCalculatePath) { StartPatrolBehaviour(); - botState = BotState.Patrol; return; } - botState = BotState.Patrol; + else + { + targetPathTile = TileManagment.GetRandomOtherTile(_playerState.ownerIndex); + RecalculatePath(currentTile, targetPathTile); + } + if (_currentFollowingPath.Count > 0) + { + botState = BotState.Patrol; + _triesToCalculatePath = 0; + } + } private void SetInitialBotParams() @@ -317,7 +330,7 @@ public class AI_BotController : MonoBehaviour } if (RecalculatePath(currentTile, endTile)) { - TileInfo nextPathTile = _currentFollowingPath[1]; + TileInfo nextPathTile = _currentFollowingPath[1]; Move(nextPathTile); } } diff --git a/Assets/Scripts/CaptureController.cs b/Assets/Scripts/CaptureController.cs index bd1ef2ca..76a5b16b 100644 --- a/Assets/Scripts/CaptureController.cs +++ b/Assets/Scripts/CaptureController.cs @@ -54,7 +54,11 @@ public class CaptureController : MonoBehaviour { _playerState.SetNewState(CharacterState.Capture); - if (!tile.easyCaptureFor.Contains(_playerState.ownerIndex)) + if (tile.easyCaptureFor.Contains(_playerState.ownerIndex) || tile.isLocked) + { + CaptureTile(tile); + } + else { if (tile.tileOwnerIndex == TileOwner.Neutral) { @@ -67,10 +71,6 @@ public class CaptureController : MonoBehaviour StartCoroutine(_currentCoroutine); } } - else - { - CaptureTile(tile); - } } @@ -98,7 +98,7 @@ public class CaptureController : MonoBehaviour private void CaptureTile(TileInfo tile) { - TileManagment.ChangeTileOwner(tile, _playerState.ownerIndex); + TileManagment.ChangeTileOwner(tile, _playerState); _playerState.SetNewState(CharacterState.Idle); if (capVFX != null) { diff --git a/Assets/Scripts/Global/DeathChecker.cs b/Assets/Scripts/Global/DeathChecker.cs index 8d75d9f4..bdd187e3 100644 --- a/Assets/Scripts/Global/DeathChecker.cs +++ b/Assets/Scripts/Global/DeathChecker.cs @@ -15,7 +15,7 @@ public class DeathChecker : MonoBehaviour private List lastDeathTime = new List(); private float updateTime = 1f; - private int spawnSafezone = 2; + private int spawnSafezone = 1; public static Action OnPlayerDeath; @@ -36,55 +36,36 @@ public class DeathChecker : MonoBehaviour InvokeRepeating("Checker", 1f, updateTime); } - private void SetupLastDeathTimes(List players) - { - foreach (var player in players) - { - lastDeathTime.Add(0f); - } - } - - private void CheckPlayersDeath() + private void CheckPlayersDeath(PlayerState agressor) { List thisIterationDeadPlayers = new List(); - foreach (var player in GameManager.activePlayers) + foreach (var player in agressor.enemies) { - var playerTile = player.currentTile; + if (!GameManager.activePlayers.Contains(player) + || Vector3.Distance(agressor.transform.position, player.transform.position)>1.5f*TileManagment.tileOffset) + { + continue; + } + TileInfo playerTile = player.currentTile; + if (player.currentTile.canMove) + { + playerTile = player.targetMoveTile; + } var myAdjacentTiles = TileManagment.GetOwnerAdjacentTiles(playerTile, player.ownerIndex); - int cantStandTilesCounter = 0; - int tileCounter = 0; + int canStandTiles = 0; foreach (var tile in myAdjacentTiles) { - tileCounter++; - if (!tile.canMove) + if (tile.canMove) { - cantStandTilesCounter++; + canStandTiles++; } - } - if (cantStandTilesCounter >= myAdjacentTiles.Count) + if (canStandTiles > 0) { - thisIterationDeadPlayers.Add(player); + continue; } - /*if (playerTile.tileOwnerIndex != player.ownerIndex) - { - - int cantStandTilesCounter = 0; - int tileCounter = 0; - foreach (var tile in myAdjacentTiles) - { - tileCounter++; - if (!tile.canMove) - { - cantStandTilesCounter++; - } - - } - if (cantStandTilesCounter >= myAdjacentTiles.Count) - { - thisIterationDeadPlayers.Add(player); - } - }*/ + thisIterationDeadPlayers.Add(player); + Debug.Log("Found " + canStandTiles + " canStand tiles in " + myAdjacentTiles.Count + " adjacent"); } foreach (var player in thisIterationDeadPlayers) @@ -93,6 +74,15 @@ public class DeathChecker : MonoBehaviour } } + private void SetupLastDeathTimes(List players) + { + foreach (var player in players) + { + lastDeathTime.Add(0f); + } + } + + public void MakeDead(PlayerState player) { int playerIndex = GameManager.players.IndexOf(player); @@ -166,10 +156,10 @@ public class DeathChecker : MonoBehaviour private void PlayerDeadActions(PlayerState player) { List playerTiles = TileManagment.GetCharacterTiles(player); - TileManagment.SetEasyCaptureForPlayers(playerTiles, player.enemies); + TileManagment.LockTiles(playerTiles, true); player.SetDead(); - //Debug.Log("player " + player.name + " dead"); + Debug.Log("player " + player.name + " dead"); if (deathParticles) { @@ -184,12 +174,7 @@ public class DeathChecker : MonoBehaviour TileInfo resTile = GetAvailableResTile(player, playerTiles); if (resTile) { - TileManagment.RemoveEasyCaptureForTiles(playerTiles); - - foreach (var enemy in player.enemies) - { - TileManagment.CheckIfSurroundedByOwner(TileManagment.levelTiles, enemy.ownerIndex, playerTiles[0]); - } + TileManagment.LockTiles(playerTiles, false); player.SetAlive(resTile.tilePosition); diff --git a/Assets/Scripts/TileInfo.cs b/Assets/Scripts/TileInfo.cs index 0af148b3..3670b742 100644 --- a/Assets/Scripts/TileInfo.cs +++ b/Assets/Scripts/TileInfo.cs @@ -18,7 +18,6 @@ public class TileInfo : MonoBehaviour public bool isBorderTile = false; - public bool isChecked = false; public bool isLocked = false; #region Pathfinding values diff --git a/Assets/Scripts/TileManagment.cs b/Assets/Scripts/TileManagment.cs index c895260d..caeb2ded 100644 --- a/Assets/Scripts/TileManagment.cs +++ b/Assets/Scripts/TileManagment.cs @@ -12,7 +12,7 @@ public class TileManagment : MonoBehaviour public static List> charTiles = new List>(); public static Action OnInitialized; - public static Action OnAnyTileCaptured; + public static Action OnAnyTileCaptured; public static List tileMaterialsStatic; @@ -28,7 +28,8 @@ public class TileManagment : MonoBehaviour private void Awake() { - InitTileManager(); + InitTileManager(); + Debug.Log("tile offset is " + tileOffset + " points"); } private void InitTileManager() @@ -83,8 +84,10 @@ public class TileManagment : MonoBehaviour tile.GetComponent().material = tileMaterialsStatic[(int)tile.tileOwnerIndex]; } - public static void ChangeTileOwner(TileInfo tile, TileOwner newOwner) + public static void ChangeTileOwner(TileInfo tile, PlayerState newPlayer) { + tile.isLocked = false; + TileOwner newOwner = newPlayer.ownerIndex; TileOwner oldOwner = tile.tileOwnerIndex; tile.tileOwnerIndex = newOwner; tile.GetComponent().material = tileMaterialsStatic[(int)tile.tileOwnerIndex]; @@ -92,7 +95,7 @@ public class TileManagment : MonoBehaviour charTiles[(int)newOwner].Add(tile); charTiles[(int)oldOwner].Remove(tile); - OnAnyTileCaptured?.Invoke(); + OnAnyTileCaptured?.Invoke(newPlayer); CheckSurroundedTiles(levelTiles, newOwner, oldOwner); @@ -242,30 +245,24 @@ public class TileManagment : MonoBehaviour return playerTiles; } - public static void SetEasyCaptureForPlayers(List tiles, List enemies) + public static void LockTiles(List tiles, bool lockState) { - if (enemies.Count <= 0) - { - return; - } foreach (TileInfo tile in tiles) { - tile.isLocked = true; - foreach (var enemy in enemies) - { - tile.easyCaptureFor.Add(enemy.ownerIndex); - } + tile.isLocked = lockState; } } - public static void RemoveEasyCaptureForTiles(List tiles) + + + /*public static void RemoveEasyCaptureForTiles(List tiles) { foreach (TileInfo tile in tiles) { tile.easyCaptureFor.Clear(); tile.isLocked = false; } - } + }*/ /*public static TileInfo GetClosestOwnerTile(TileInfo startTile, TileOwner owner, float searchRadius) { @@ -323,13 +320,8 @@ public class TileManagment : MonoBehaviour { tile.checkedFor.Clear(); foreach (var owner in checkPlayers) - { - //tile.checkedFor.Remove(newOwner); - if (!tile.isLocked) - { - tile.easyCaptureFor.Remove(owner); - //tile.easyCaptureFor.Clear(); - } + { + tile.easyCaptureFor.Remove(owner); } @@ -393,10 +385,7 @@ public class TileManagment : MonoBehaviour foreach (TileInfo tile in connectedTiles) { - if (!tile.isLocked) - { - tile.easyCaptureFor.Add(ownerIndex); - } + tile.easyCaptureFor.Add(ownerIndex); } }