//Get free tile for a one tile character public BattleTileScript GetFreeBattleTile(WalkingSideType walkingSide) { List <BattleTileScript> emptyBattleTiles = new List <BattleTileScript>(); emptyBattleTiles = BattleTiles.Where(r => r.BattleTileState == BattleTileStateType.Empty && (r.WalkingSide == walkingSide || walkingSide == WalkingSideType.Both)).ToList(); int battletileCount = emptyBattleTiles.Count; return(emptyBattleTiles[Random.Range(0, battletileCount)]); }
public List <BattleTileScript> GetBattleTiles(List <Vector2Int> pos, WalkingSideType walkingSide) { List <BattleTileScript> res = new List <BattleTileScript>(); foreach (Vector2Int item in pos) { res.Add(GetBattleTile(item, walkingSide)); } return(res); }
public CharacterBaseInfoClass(string name, CharacterSelectionType characterSelection, List <ControllerType> playerController, CharacterNameType characterName, WalkingSideType walkingSide, AttackType charAttackType, BaseCharType bCharType) { Name = name; CharacterSelection = characterSelection; PlayerController = playerController; CharacterName = characterName; WalkingSide = walkingSide; CharAttackType = charAttackType; BCharType = bCharType; }
//Setup tile info public void SetupTileFromBattleTileInfo(BattleTileInfo info) { BattleTileState = info.BattleTileState; WalkingSide = info.WalkingSide; if (info.HasEffect) { foreach (var item in info.Effects) { } } //BattleTileT = info.BattleTileT; /*if (BattleTileT == BattleTileType.Portal) * { * PortalInfo = new PortalInfoClass(this, info.Portal, info.IDPortal); * GridManagerScript.Instance.Portals.Add(PortalInfo); * }*/ }
//Get free tile for a more than one tile character public BattleTileScript GetFreeBattleTile(WalkingSideType walkingSide, List <Vector2Int> occupiedTiles) { List <BattleTileScript> emptyBattleTiles = new List <BattleTileScript>(); emptyBattleTiles = BattleTiles.Where(r => r.BattleTileState == BattleTileStateType.Empty && (r.WalkingSide == walkingSide || walkingSide == WalkingSideType.Both)).ToList(); bool areOccupiedTileFree = true; BattleTileScript emptyTile = null; while (emptyBattleTiles.Count > 0) { emptyTile = emptyBattleTiles[Random.Range(0, emptyBattleTiles.Count)]; emptyBattleTiles.Remove(emptyTile); areOccupiedTileFree = true; foreach (Vector2Int item in occupiedTiles) { BattleTileScript tileToCheck = BattleTiles.Where(r => r.Pos == emptyTile.Pos + item).FirstOrDefault(); if (tileToCheck == null) { areOccupiedTileFree = false; break; } else { if (tileToCheck.BattleTileState != BattleTileStateType.Empty) { areOccupiedTileFree = false; break; } } } if (areOccupiedTileFree) { return(emptyTile); } } return(null); }
public void SpawnPowerUpAtRandomPointOnSide(ScriptableObjectItemPowerUps powerUp, WalkingSideType side) { SpawnPowerUpAtGridPos(powerUp, GridManagerScript.Instance.GetFreeBattleTile(side).Pos); }
//Checking if the given positions are part of the desired movent area public bool AreBattleTilesInControllerArea(List <Vector2Int> oldPos, List <Vector2Int> newPos, WalkingSideType walkingSide) { bool AreInControlledArea = false; foreach (Vector2Int item in newPos) { AreInControlledArea = BattleTiles.Where(r => r.Pos == item && (r.WalkingSide == walkingSide || walkingSide == WalkingSideType.Both) && (r._BattleTileState == BattleTileStateType.Empty || (r._BattleTileState == BattleTileStateType.Occupied && oldPos.Contains(item)))).ToList().Count > 0 ? true : false; if (!AreInControlledArea) { break; } } return(AreInControlledArea); }
public BattleTileScript GetRandomFreeAdjacentTile(Vector2Int originPos, int withinRadius = 1, bool circularRadius = false, WalkingSideType side = WalkingSideType.Both) { BattleTileScript[] freeAdjTiles = GetFreeTilesAdjacentTo(originPos, withinRadius, circularRadius, side); if (freeAdjTiles != null) { return(freeAdjTiles[Random.Range(0, freeAdjTiles.Length)]); } else { return(null); } }
public BattleTileScript[] GetFreeTilesAdjacentTo(Vector2Int originPos, int withinRadius = 1, bool circularRadius = false, WalkingSideType side = WalkingSideType.Both) { List <BattleTileScript> adjFreeTiles = new List <BattleTileScript>(); foreach (BattleTileScript tile in GetTilesAdjacentTo(originPos, withinRadius, circularRadius, side)) { if (tile._BattleTileState == BattleTileStateType.Empty) { adjFreeTiles.Add(tile); } } if (adjFreeTiles.Count == 0) { return(null); } else { return(adjFreeTiles.ToArray()); } }
public BattleTileScript[] GetTilesAdjacentTo(Vector2Int originPos, int withinRadius = 1, bool circularRadius = false, WalkingSideType side = WalkingSideType.Both) { BattleTileScript originTile = BattleTiles.Where(r => r.Pos == originPos).FirstOrDefault(); if (originTile == null) { return(null); } Vector2Int curTilePos = new Vector2Int(); BattleTileScript curTile = null; List <BattleTileScript> adjTiles = new List <BattleTileScript>(); //WalkingSideType side = BattleTiles.Where(r => r.Pos == originPos).First().WalkingSide; for (int x = -withinRadius; x <= withinRadius; x++) { for (int y = -withinRadius; y <= withinRadius; y++) { curTilePos = new Vector2Int(x, y) + originPos; curTile = side != WalkingSideType.Both ? GetBattleTile(curTilePos, side) : BattleTiles.Where(r => r.Pos == originPos).FirstOrDefault(); if (curTile != null && curTilePos != originPos && (circularRadius ? Vector2Int.Distance(curTilePos, originPos) - 0.5f < withinRadius : true)) { adjTiles.Add(curTile); } } } if (adjTiles.Count == 0) { return(null); } else { return(adjTiles.ToArray()); } }
//Get BattleTileScript of the tile public BattleTileScript GetBattleTile(Vector2Int pos, WalkingSideType walkingSide)//isEnemyOrPlayer = true/Player false/Enemy { return(BattleTiles.Where(r => r.Pos == pos && (r.WalkingSide == walkingSide || walkingSide == WalkingSideType.Both)).FirstOrDefault()); }