Modified cap system
This commit is contained in:
parent
4413cd7d06
commit
3553af9210
@ -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}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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.easyCapForAll)
|
||||
{
|
||||
CaptureTile(tile);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tile.tileOwnerIndex == TileOwner.Neutral)
|
||||
{
|
||||
@ -65,11 +69,7 @@ public class CaptureController : MonoBehaviour
|
||||
{
|
||||
_currentCoroutine = Capturing(tile, enemyCaptureTime);
|
||||
StartCoroutine(_currentCoroutine);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureTile(tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class DeathChecker : MonoBehaviour
|
||||
private List<float> lastDeathTime = new List<float>();
|
||||
|
||||
private float updateTime = 1f;
|
||||
private int spawnSafezone = 2;
|
||||
private int spawnSafezone = 1;
|
||||
|
||||
|
||||
public static Action<PlayerState> OnPlayerDeath;
|
||||
@ -166,7 +166,7 @@ public class DeathChecker : MonoBehaviour
|
||||
private void PlayerDeadActions(PlayerState player)
|
||||
{
|
||||
List<TileInfo> playerTiles = TileManagment.GetCharacterTiles(player);
|
||||
TileManagment.SetEasyCaptureForPlayers(playerTiles, player.enemies);
|
||||
TileManagment.SetEasyCaptureForAll(playerTiles);
|
||||
|
||||
player.SetDead();
|
||||
//Debug.Log("player " + player.name + " dead");
|
||||
@ -184,15 +184,9 @@ 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.RemoveLockState(playerTiles);
|
||||
player.SetAlive(resTile.tilePosition);
|
||||
|
||||
TileManagment.SetCharTilesState(player);
|
||||
if (resParticles)
|
||||
{
|
||||
Instantiate(resParticles, player.transform.position, deathParticles.transform.rotation);
|
||||
|
@ -18,6 +18,7 @@ public class TileInfo : MonoBehaviour
|
||||
|
||||
|
||||
public bool isBorderTile = false;
|
||||
public bool easyCapForAll = false;
|
||||
public bool isChecked = false;
|
||||
public bool isLocked = false;
|
||||
|
||||
|
@ -92,10 +92,15 @@ public class TileManagment : MonoBehaviour
|
||||
charTiles[(int)newOwner].Add(tile);
|
||||
charTiles[(int)oldOwner].Remove(tile);
|
||||
|
||||
SetTilesCapState(newOwner, oldOwner, levelTiles, GameManager.players);
|
||||
OnAnyTileCaptured?.Invoke();
|
||||
|
||||
CheckSurroundedTiles(levelTiles, newOwner, oldOwner);
|
||||
}
|
||||
|
||||
public static void SetTilesCapState(TileOwner ownerNew, TileOwner owerOld, List<TileInfo> allTiles, List<PlayerState> players)
|
||||
{
|
||||
CheckSurroundedTiles(allTiles, ownerNew, owerOld);
|
||||
SetAllCharTilesStates(players);
|
||||
}
|
||||
|
||||
public static void AssignBuildingToTile(TileInfo tile, GameObject building)
|
||||
@ -242,27 +247,19 @@ public class TileManagment : MonoBehaviour
|
||||
return playerTiles;
|
||||
}
|
||||
|
||||
public static void SetEasyCaptureForPlayers(List<TileInfo> tiles, List<PlayerState> enemies)
|
||||
{
|
||||
if (enemies.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public static void SetEasyCaptureForAll(List<TileInfo> tiles)
|
||||
{
|
||||
foreach (TileInfo tile in tiles)
|
||||
{
|
||||
tile.isLocked = true;
|
||||
foreach (var enemy in enemies)
|
||||
{
|
||||
tile.easyCaptureFor.Add(enemy.ownerIndex);
|
||||
}
|
||||
tile.easyCapForAll = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveEasyCaptureForTiles(List<TileInfo> tiles)
|
||||
public static void RemoveLockState(List<TileInfo> tiles)
|
||||
{
|
||||
foreach (TileInfo tile in tiles)
|
||||
{
|
||||
tile.easyCaptureFor.Clear();
|
||||
{
|
||||
tile.isLocked = false;
|
||||
}
|
||||
}
|
||||
@ -352,6 +349,28 @@ public class TileManagment : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public static void SetCharTilesState(PlayerState player)
|
||||
{
|
||||
List<TileInfo> allPlayerTiles = charTiles[(int)player.ownerIndex];
|
||||
foreach (TileInfo tile in allPlayerTiles)
|
||||
{
|
||||
tile.easyCapForAll = true;
|
||||
}
|
||||
List<TileInfo> playerConnectedTiles = GetConnectedTiles(levelTiles, player.ownerIndex, player.currentTile);
|
||||
foreach (TileInfo tile in playerConnectedTiles)
|
||||
{
|
||||
tile.easyCapForAll = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetAllCharTilesStates(List<PlayerState> players)
|
||||
{
|
||||
foreach (var player in players)
|
||||
{
|
||||
SetCharTilesState(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckIfSurroundedByOwner(List<TileInfo> tiles, TileOwner ownerIndex, TileInfo startTile)
|
||||
{
|
||||
List<TileInfo> connectedTiles = new List<TileInfo>();
|
||||
@ -400,6 +419,91 @@ public class TileManagment : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public static List<TileInfo> GetConnectedTiles(List<TileInfo> allTiles, TileOwner ownerIndex, TileInfo startTile)
|
||||
{
|
||||
List<TileInfo> connectedTiles = new List<TileInfo>();
|
||||
var q = new Queue<TileInfo>(allTiles.Count);
|
||||
q.Enqueue(startTile);
|
||||
int iterations = 0;
|
||||
|
||||
while (q.Count > 0)
|
||||
{
|
||||
var tile = q.Dequeue();
|
||||
if (q.Count > allTiles.Count)
|
||||
{
|
||||
throw new Exception("The algorithm is probably looping. Queue size: " + q.Count);
|
||||
}
|
||||
|
||||
if (connectedTiles.Contains(tile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
connectedTiles.Add(tile);
|
||||
|
||||
var adjacentTiles = GetAllAdjacentTiles(tile);
|
||||
|
||||
foreach (TileInfo newTile in adjacentTiles)
|
||||
{
|
||||
if (newTile.tileOwnerIndex == tile.tileOwnerIndex)
|
||||
{
|
||||
q.Enqueue(newTile);
|
||||
}
|
||||
}
|
||||
iterations++;
|
||||
}
|
||||
|
||||
return connectedTiles;
|
||||
}
|
||||
|
||||
/*public static void CheckIfSurroundedByOwner(List<TileInfo> tiles, TileOwner ownerIndex, TileInfo startTile)
|
||||
{
|
||||
List<TileInfo> connectedTiles = new List<TileInfo>();
|
||||
var q = new Queue<TileInfo>(tiles.Count);
|
||||
q.Enqueue(startTile);
|
||||
int iterations = 0;
|
||||
|
||||
while (q.Count > 0)
|
||||
{
|
||||
var tile = q.Dequeue();
|
||||
if (q.Count > tiles.Count)
|
||||
{
|
||||
throw new Exception("The algorithm is probably looping. Queue size: " + q.Count);
|
||||
}
|
||||
|
||||
if (tile.isBorderTile) //we are in a wrong area
|
||||
{
|
||||
connectedTiles.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (connectedTiles.Contains(tile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
connectedTiles.Add(tile);
|
||||
tile.checkedFor.Add(ownerIndex);
|
||||
//Debug.Log("Checked");
|
||||
var adjacentTiles = GetOtherTiles(tile, ownerIndex);
|
||||
|
||||
foreach (TileInfo newTile in adjacentTiles)
|
||||
{
|
||||
q.Enqueue(newTile);
|
||||
}
|
||||
|
||||
iterations++;
|
||||
}
|
||||
|
||||
foreach (TileInfo tile in connectedTiles)
|
||||
{
|
||||
if (!tile.isLocked)
|
||||
{
|
||||
tile.easyCaptureFor.Add(ownerIndex);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private Vector3[] GetBasicDirections(int directionsAmount)
|
||||
{
|
||||
Vector3[] tempArr = new Vector3[directionsAmount];
|
||||
|
File diff suppressed because one or more lines are too long
@ -127,7 +127,7 @@ PlayerSettings:
|
||||
16:10: 1
|
||||
16:9: 1
|
||||
Others: 1
|
||||
bundleVersion: 0.16
|
||||
bundleVersion: 0.17
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user