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

View File

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

View File

@ -74,11 +74,6 @@ public class CaptureController : MonoBehaviour
} }
/*else
{
TileManagment.SetCharTilesState(_playerState);
//Debug.Log("for " + gameObject.name);
}*/
} }
private void CaptureStartTile() private void CaptureStartTile()
@ -103,7 +98,7 @@ public class CaptureController : MonoBehaviour
private void CaptureTile(TileInfo tile) private void CaptureTile(TileInfo tile)
{ {
TileManagment.ChangeTileOwner(tile, _playerState); TileManagment.ChangeTileOwner(tile, _playerState.ownerIndex);
_playerState.SetNewState(CharacterState.Idle); _playerState.SetNewState(CharacterState.Idle);
if (capVFX != null) if (capVFX != null)
{ {

View File

@ -36,40 +36,6 @@ public class DeathChecker : MonoBehaviour
InvokeRepeating("Checker", 1f, updateTime); 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) private void SetupLastDeathTimes(List<PlayerState> players)
{ {
foreach (var player in 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) public void MakeDead(PlayerState player)
{ {
@ -88,8 +101,6 @@ public class DeathChecker : MonoBehaviour
OnPlayerDeath?.Invoke(player); OnPlayerDeath?.Invoke(player);
PlayerDeadActions(player); PlayerDeadActions(player);
//Debug.Log("make dead " + player.name);
} }
public void MakeDeadPermanent(PlayerState player) public void MakeDeadPermanent(PlayerState player)
@ -155,8 +166,9 @@ public class DeathChecker : MonoBehaviour
private void PlayerDeadActions(PlayerState player) private void PlayerDeadActions(PlayerState player)
{ {
List<TileInfo> playerTiles = TileManagment.GetCharacterTiles(player); List<TileInfo> playerTiles = TileManagment.GetCharacterTiles(player);
TileManagment.SetEasyCaptureForAll(playerTiles);
player.SetDead(); player.SetDead();
TileManagment.SetLockState(playerTiles);
//Debug.Log("player " + player.name + " dead"); //Debug.Log("player " + player.name + " dead");
if (deathParticles) if (deathParticles)
@ -174,7 +186,7 @@ public class DeathChecker : MonoBehaviour
{ {
TileManagment.RemoveLockState(playerTiles); TileManagment.RemoveLockState(playerTiles);
player.SetAlive(resTile.tilePosition); player.SetAlive(resTile.tilePosition);
//TileManagment.SetCharTilesState(player); TileManagment.SetCharTilesState(player);
if (resParticles) if (resParticles)
{ {
Instantiate(resParticles, player.transform.position, deathParticles.transform.rotation); 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 List<List<TileInfo>> charTiles = new List<List<TileInfo>>();
public static Action OnInitialized; public static Action OnInitialized;
public static Action<PlayerState> OnAnyTileCaptured; public static Action OnAnyTileCaptured;
public static List<Material> tileMaterialsStatic; public static List<Material> tileMaterialsStatic;
@ -83,9 +83,8 @@ public class TileManagment : MonoBehaviour
tile.GetComponent<Renderer>().material = tileMaterialsStatic[(int)tile.tileOwnerIndex]; 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; TileOwner oldOwner = tile.tileOwnerIndex;
tile.tileOwnerIndex = newOwner; tile.tileOwnerIndex = newOwner;
tile.GetComponent<Renderer>().material = tileMaterialsStatic[(int)tile.tileOwnerIndex]; tile.GetComponent<Renderer>().material = tileMaterialsStatic[(int)tile.tileOwnerIndex];
@ -94,14 +93,14 @@ public class TileManagment : MonoBehaviour
charTiles[(int)oldOwner].Remove(tile); charTiles[(int)oldOwner].Remove(tile);
SetTilesCapState(newOwner, oldOwner, levelTiles, GameManager.players); 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) public static void SetTilesCapState(TileOwner ownerNew, TileOwner owerOld, List<TileInfo> allTiles, List<PlayerState> players)
{ {
CheckSurroundedTiles(allTiles, ownerNew, owerOld); CheckSurroundedTiles(allTiles, ownerNew, owerOld);
//SetAllCharTilesStates(players); SetAllCharTilesStates(players);
} }
public static void AssignBuildingToTile(TileInfo tile, GameObject building) public static void AssignBuildingToTile(TileInfo tile, GameObject building)
@ -248,24 +247,13 @@ public class TileManagment : MonoBehaviour
return playerTiles; return playerTiles;
} }
public static void SetLockState(List<TileInfo> tiles) public static void SetEasyCaptureForAll(List<TileInfo> tiles)
{ {
foreach (TileInfo tile in tiles) foreach (TileInfo tile in tiles)
{ {
tile.isLocked = true; tile.isLocked = true;
tile.easyCapForAll = 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) public static void RemoveLockState(List<TileInfo> tiles)
@ -273,10 +261,20 @@ public class TileManagment : MonoBehaviour
foreach (TileInfo tile in tiles) foreach (TileInfo tile in tiles)
{ {
tile.isLocked = false; 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) public static TileInfo GetClosestOtherTile(TileInfo currentTile, TileOwner owner,/* float capRadius,*/ Vector3 startPoint)
{ {
var neutralTiles = charTiles[(int)TileOwner.Neutral]; var neutralTiles = charTiles[(int)TileOwner.Neutral];
@ -353,7 +351,6 @@ public class TileManagment : MonoBehaviour
public static void SetCharTilesState(PlayerState player) public static void SetCharTilesState(PlayerState player)
{ {
//Debug.Log("set chartiles state");
List<TileInfo> allPlayerTiles = charTiles[(int)player.ownerIndex]; List<TileInfo> allPlayerTiles = charTiles[(int)player.ownerIndex];
foreach (TileInfo tile in allPlayerTiles) foreach (TileInfo tile in allPlayerTiles)
{ {
@ -361,13 +358,10 @@ public class TileManagment : MonoBehaviour
} }
List<TileInfo> playerConnectedTiles = GetConnectedTiles(levelTiles, player.ownerIndex, player.currentTile); List<TileInfo> playerConnectedTiles = GetConnectedTiles(levelTiles, player.ownerIndex, player.currentTile);
foreach (TileInfo tile in playerConnectedTiles) foreach (TileInfo tile in playerConnectedTiles)
{
if (!tile.isLocked)
{ {
tile.easyCapForAll = false; tile.easyCapForAll = false;
} }
} }
}
public static void SetAllCharTilesStates(List<PlayerState> players) public static void SetAllCharTilesStates(List<PlayerState> players)
{ {
@ -447,15 +441,18 @@ public class TileManagment : MonoBehaviour
connectedTiles.Add(tile); connectedTiles.Add(tile);
var adjacentTiles = GetOwnerAdjacentTiles(tile, tile.tileOwnerIndex); var adjacentTiles = GetAllAdjacentTiles(tile);
foreach (TileInfo newTile in adjacentTiles) foreach (TileInfo newTile in adjacentTiles)
{
if (newTile.tileOwnerIndex == tile.tileOwnerIndex)
{ {
q.Enqueue(newTile); q.Enqueue(newTile);
} }
}
iterations++; iterations++;
} }
//Debug.Log("there are " + connectedTiles.Count + " near the " + ownerIndex);
return connectedTiles; return connectedTiles;
} }

File diff suppressed because one or more lines are too long