Revert "some bugs"

This reverts commit 2fecae89c6d9b6d7a9eee4e271d88342ec2e31ee.
This commit is contained in:
mamontow 2021-08-31 22:39:13 +03:00
parent 2fecae89c6
commit ceb2ff5351
7 changed files with 107 additions and 442 deletions

View File

@ -1419,7 +1419,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 2
tileOwnerIndex: 0
easyCaptureFor:
checkedFor:
isBorderTile: 0
@ -2209,7 +2209,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 2
tileOwnerIndex: 0
easyCaptureFor:
checkedFor:
isBorderTile: 0
@ -11121,7 +11121,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 0
tileOwnerIndex: 2
easyCaptureFor:
checkedFor:
isBorderTile: 0
@ -11464,7 +11464,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 2
tileOwnerIndex: 0
easyCaptureFor:
checkedFor:
isBorderTile: 0
@ -12578,7 +12578,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 0
tileOwnerIndex: 2
easyCaptureFor:
checkedFor:
isBorderTile: 0
@ -13377,7 +13377,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102420987}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7bdb1f3013038a142b6409f33a96c7b4, type: 3}
m_Name:
@ -14054,7 +14054,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 0
tileOwnerIndex: 2
easyCaptureFor:
checkedFor:
isBorderTile: 0
@ -18874,7 +18874,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5182c2cb5eef6d849b560f764c4a0ed6, type: 3}
m_Name:
m_EditorClassIdentifier:
startHealth: 50
startHealth: 120
currentHealth: 0
playerImpactVFX: {fileID: 2957420090356197408, guid: 5d1244f7b80cadd428a70173a01ce889,
type: 3}
@ -23031,8 +23031,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4b3c4882af86905429c1c42aabf068c1, type: 3}
m_Name:
m_EditorClassIdentifier:
neutralCaptureTime: 0.2
enemyCaptureTime: 0.3
neutralCaptureTime: 1
enemyCaptureTime: 2
capVFX: {fileID: 442387583353148024, guid: 53959bc898e9a644daad0282881d596a, type: 3}
--- !u!114 &1801060025
MonoBehaviour:
@ -23085,7 +23085,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5182c2cb5eef6d849b560f764c4a0ed6, type: 3}
m_Name:
m_EditorClassIdentifier:
startHealth: 350
startHealth: 120
currentHealth: 0
playerImpactVFX: {fileID: 2957420090356197408, guid: 5d1244f7b80cadd428a70173a01ce889,
type: 3}
@ -24086,7 +24086,7 @@ MonoBehaviour:
canBeAttacked: 1
canBuildHere: 1
buildingOnTile: {fileID: 0}
tileOwnerIndex: 0
tileOwnerIndex: 2
easyCaptureFor:
checkedFor:
isBorderTile: 0

View File

@ -96,8 +96,7 @@ public class AI_BotController : MonoBehaviour
private void StartPatrolBehaviour() //looking for available tiles, calculating path and set patrol state
{
//calculate path
leftInput = Vector2.zero;
//calculate path
TileInfo currentTile = _playerState.currentTile;
TileInfo targetPathTile = TileManagment.GetClosestOtherTile(currentTile, _playerState.ownerIndex, _startBotPoint);
//Debug.Log(targetPathTile);
@ -130,7 +129,7 @@ public class AI_BotController : MonoBehaviour
private void CheckBotState()
{
//Debug.Log("CheckState");
Debug.Log("CheckState");
BotState newBotState;
if (IsEnemyEnabledForAttack())

View File

@ -49,11 +49,11 @@ public class CaptureController : MonoBehaviour
private void TryToCaptureTile()
{
TileInfo tile = _playerState.currentTile;
if (_playerState.ownerIndex != tile.tileOwnerIndex)
{
{
_playerState.SetNewState(CharacterState.Capture);
if (tile.easyCaptureFor.Contains(_playerState.ownerIndex) || tile.easyCapForAll)
{
CaptureTile(tile);
@ -69,16 +69,11 @@ public class CaptureController : MonoBehaviour
{
_currentCoroutine = Capturing(tile, enemyCaptureTime);
StartCoroutine(_currentCoroutine);
}
}
}
}
/*else
{
TileManagment.SetCharTilesState(_playerState);
//Debug.Log("for " + gameObject.name);
}*/
}
private void CaptureStartTile()
@ -103,7 +98,7 @@ public class CaptureController : MonoBehaviour
private void CaptureTile(TileInfo tile)
{
TileManagment.ChangeTileOwner(tile, _playerState);
TileManagment.ChangeTileOwner(tile, _playerState.ownerIndex);
_playerState.SetNewState(CharacterState.Idle);
if (capVFX != null)
{

View File

@ -36,40 +36,6 @@ public class DeathChecker : MonoBehaviour
InvokeRepeating("Checker", 1f, updateTime);
}
private void CheckPlayersDeath(PlayerState capPlayer)
{
List<PlayerState> thisIterationDeadPlayers = new List<PlayerState>();
foreach (var player in capPlayer.enemies)
{
if (!GameManager.activePlayers.Contains(player))
{
continue;
}
var playerTile = player.currentTile;
var myAdjacentTiles = TileManagment.GetOwnerAdjacentTiles(playerTile, player.ownerIndex);
int canStandTiles = 0;
foreach (var tile in myAdjacentTiles)
{
if (tile.canMove)
{
canStandTiles++;
}
}
if (canStandTiles == 0)
{
thisIterationDeadPlayers.Add(player);
}
Debug.Log("Found " + canStandTiles + " canStand tiles in " + myAdjacentTiles.Count + " adjacent player tiles for " + player.name);
}
foreach (var player in thisIterationDeadPlayers)
{
Debug.Log("make dead " + player.name + "via checker");
MakeDead(player);
}
}
private void SetupLastDeathTimes(List<PlayerState> players)
{
foreach (var player in players)
@ -78,7 +44,54 @@ public class DeathChecker : MonoBehaviour
}
}
private void CheckPlayersDeath()
{
List<PlayerState> thisIterationDeadPlayers = new List<PlayerState>();
foreach (var player in GameManager.activePlayers)
{
var playerTile = player.currentTile;
var myAdjacentTiles = TileManagment.GetOwnerAdjacentTiles(playerTile, 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);
}
/*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);
}
}*/
}
foreach (var player in thisIterationDeadPlayers)
{
MakeDead(player);
}
}
public void MakeDead(PlayerState player)
{
@ -88,8 +101,6 @@ public class DeathChecker : MonoBehaviour
OnPlayerDeath?.Invoke(player);
PlayerDeadActions(player);
//Debug.Log("make dead " + player.name);
}
public void MakeDeadPermanent(PlayerState player)
@ -155,8 +166,9 @@ public class DeathChecker : MonoBehaviour
private void PlayerDeadActions(PlayerState player)
{
List<TileInfo> playerTiles = TileManagment.GetCharacterTiles(player);
TileManagment.SetEasyCaptureForAll(playerTiles);
player.SetDead();
TileManagment.SetLockState(playerTiles);
//Debug.Log("player " + player.name + " dead");
if (deathParticles)
@ -174,7 +186,7 @@ public class DeathChecker : MonoBehaviour
{
TileManagment.RemoveLockState(playerTiles);
player.SetAlive(resTile.tilePosition);
//TileManagment.SetCharTilesState(player);
TileManagment.SetCharTilesState(player);
if (resParticles)
{
Instantiate(resParticles, player.transform.position, deathParticles.transform.rotation);

View File

@ -12,7 +12,7 @@ public class TileManagment : MonoBehaviour
public static List<List<TileInfo>> charTiles = new List<List<TileInfo>>();
public static Action OnInitialized;
public static Action<PlayerState> OnAnyTileCaptured;
public static Action OnAnyTileCaptured;
public static List<Material> tileMaterialsStatic;
@ -83,9 +83,8 @@ public class TileManagment : MonoBehaviour
tile.GetComponent<Renderer>().material = tileMaterialsStatic[(int)tile.tileOwnerIndex];
}
public static void ChangeTileOwner(TileInfo tile, PlayerState newPlayer)
public static void ChangeTileOwner(TileInfo tile, TileOwner newOwner)
{
TileOwner newOwner = newPlayer.ownerIndex;
TileOwner oldOwner = tile.tileOwnerIndex;
tile.tileOwnerIndex = newOwner;
tile.GetComponent<Renderer>().material = tileMaterialsStatic[(int)tile.tileOwnerIndex];
@ -94,14 +93,14 @@ public class TileManagment : MonoBehaviour
charTiles[(int)oldOwner].Remove(tile);
SetTilesCapState(newOwner, oldOwner, levelTiles, GameManager.players);
OnAnyTileCaptured?.Invoke(newPlayer);
OnAnyTileCaptured?.Invoke();
}
public static void SetTilesCapState(TileOwner ownerNew, TileOwner owerOld, List<TileInfo> allTiles, List<PlayerState> players)
{
CheckSurroundedTiles(allTiles, ownerNew, owerOld);
//SetAllCharTilesStates(players);
SetAllCharTilesStates(players);
}
public static void AssignBuildingToTile(TileInfo tile, GameObject building)
@ -248,24 +247,13 @@ public class TileManagment : MonoBehaviour
return playerTiles;
}
public static void SetLockState(List<TileInfo> tiles)
public static void SetEasyCaptureForAll(List<TileInfo> tiles)
{
foreach (TileInfo tile in tiles)
{
tile.isLocked = true;
tile.easyCapForAll = true;
}
Debug.Log("easycapForAll");
}
public static void SetEasyCaptureForAll(PlayerState player)
{
List<TileInfo> tiles = charTiles[(int)player.ownerIndex];
foreach (TileInfo tile in tiles)
{
tile.isLocked = true;
tile.easyCapForAll = true;
}
}
public static void RemoveLockState(List<TileInfo> tiles)
@ -273,9 +261,19 @@ public class TileManagment : MonoBehaviour
foreach (TileInfo tile in tiles)
{
tile.isLocked = false;
tile.easyCapForAll = false;
}
}
}
/*public static TileInfo GetClosestOwnerTile(TileInfo startTile, TileOwner owner, float searchRadius)
{
var ownerTiles = charTiles[(int)owner];
TileInfo closestTile = ownerTiles[0];
foreach (TileInfo tile in ownerTiles)
{
//if ()
}
return closestTile;
}*/
public static TileInfo GetClosestOtherTile(TileInfo currentTile, TileOwner owner,/* float capRadius,*/ Vector3 startPoint)
{
@ -353,7 +351,6 @@ public class TileManagment : MonoBehaviour
public static void SetCharTilesState(PlayerState player)
{
//Debug.Log("set chartiles state");
List<TileInfo> allPlayerTiles = charTiles[(int)player.ownerIndex];
foreach (TileInfo tile in allPlayerTiles)
{
@ -362,10 +359,7 @@ public class TileManagment : MonoBehaviour
List<TileInfo> playerConnectedTiles = GetConnectedTiles(levelTiles, player.ownerIndex, player.currentTile);
foreach (TileInfo tile in playerConnectedTiles)
{
if (!tile.isLocked)
{
tile.easyCapForAll = false;
}
tile.easyCapForAll = false;
}
}
@ -447,15 +441,18 @@ public class TileManagment : MonoBehaviour
connectedTiles.Add(tile);
var adjacentTiles = GetOwnerAdjacentTiles(tile, tile.tileOwnerIndex);
var adjacentTiles = GetAllAdjacentTiles(tile);
foreach (TileInfo newTile in adjacentTiles)
{
q.Enqueue(newTile);
if (newTile.tileOwnerIndex == tile.tileOwnerIndex)
{
q.Enqueue(newTile);
}
}
iterations++;
}
//Debug.Log("there are " + connectedTiles.Count + " near the " + ownerIndex);
return connectedTiles;
}

View File

@ -94,6 +94,6 @@ public class TileMovement : MonoBehaviour
{
//Debug.Log("finish movement");
_playerState.currentTile = currentTile;
_playerState.SetNewState(CharacterState.Idle);
_playerState.SetNewState(CharacterState.Idle);
}
}

File diff suppressed because one or more lines are too long