public virtual void displayRange() { CombatExecutor ce = GameDataTracker.combatExecutor; GameObject[,] blockGrid = CombatExecutor.blockGrid; Vector2Int mapShape = CombatExecutor.mapShape; if (rangeIndicator != null) { List <GameObject> characterTarget = new List <GameObject>(); characterTarget.Add(character); List <Vector2Int> possibleTargets; if (targetShape == TargetShape.Square) { possibleTargets = findGoalsSquare( characterTarget ).Item1; } else if (targetShape == TargetShape.Diamond) { possibleTargets = findGoalsDiamond( characterTarget ).Item1; } else if (targetShape == TargetShape.Cross) { possibleTargets = findGoalsCross( characterTarget ).Item1; } else if (targetShape == TargetShape.X) { possibleTargets = findGoalsX( characterTarget ).Item1; } else { possibleTargets = new List <Vector2Int>(); } foreach (Vector2 possibleTarget in possibleTargets) { GameObject newProjector = new GameObject("Projector"); DecalProjector projector = newProjector.AddComponent <DecalProjector>(); projector.material = rangeIndicator; newProjector.transform.localRotation = Quaternion.Euler(90, 0, 0); newProjector.transform.position = blockGrid[(int)possibleTarget.x, (int)possibleTarget.y].transform.position; decalProjectors.Add(newProjector); } } }
public virtual void GetRoute(CombatExecutor combatExecutor) { AStar router = ScriptableObject.CreateInstance <AStar>(); //Get Move moveTemplate move = GetMove(); if (move.targetType != moveTemplate.TargetType.None) { //Get Goals List <GameObject> possibleTargets = combatExecutor.getTargets(move.targetType); if (combatExecutor.Clip.GetComponent <FighterClass>().Dead) { possibleTargets.Remove(combatExecutor.Clip); } if (combatExecutor.Partner != null) { if (combatExecutor.Partner.GetComponent <FighterClass>().Dead) { possibleTargets.Remove(combatExecutor.Partner); } } List <Vector2Int> goalPos = new List <Vector2Int>(); List <GameObject> goalObjects = new List <GameObject>(); move.character = gameObject; (goalPos, goalObjects) = move.findGoals(possibleTargets); (Vector2Int newPos, FighterClass.CharacterPosition moveType, bool atGoal) = router.GetNextTile( this, pos, goalPos ); if (atGoal) { List <GameObject> selectedTargets = new List <GameObject>(); selectedTargets.Add(goalObjects[router.finalGoalIdx]); move.Activate(selectedTargets); } else { MoveCharacter((newPos.x - pos.x), (newPos.y - pos.y)); } } else { move.character = gameObject; move.Activate(new List <GameObject>()); } }
public override bool Activate() { combatData = GameDataTracker.combatExecutor; blockOffset = CombatExecutor.blockOffset; gridHeight = CombatExecutor.gridHeight; characterGrid = CombatExecutor.characterGrid; source = parent.GetComponent <FighterClass>(); EndPos = BattleMapProcesses.findNearestTileFullyFitsObject(source.TileSize, target.pos); source.RemoveObjectFromGrid(); JumpToLocation jumpTo = ScriptableObject.CreateInstance <JumpToLocation>(); jumpTo.endPosition = GridManager.GridToPosition(EndPos, source.TileSize); jumpTo.parent = parent; jumpTo.heightOverHighestCharacter = 2.5f; jumpTo.speed = source.JumpSpeed; cutscene = jumpTo; return(true); }
private bool checkIfExpand(Vector2Int from, Vector2Int to) { List <Vector2Int> potentialTiles = characterInfo.PotentialGridOccupation(to); if (!BattleMapProcesses.isThisListOnGrid(potentialTiles)) { return(false); } if (!CombatExecutor.LevelFloor(to, characterInfo.TileSize)) { return(false); } if (!(routeMap[(int)to.x, (int)to.y] is null)) { return(false); } if (!BattleMapProcesses.isTileEmpty(potentialTiles, characterInfo.gameObject)) { return(false); } BlockTemplate blockInfo = CombatExecutor.blockGrid[(int)to.x, (int)to.y].GetComponent <BlockTemplate>(); if (!((characterInfo.CanWalk && blockInfo.Walkable) || (characterInfo.CanFly && blockInfo.Flyable) || (characterInfo.CanSwim && blockInfo.Swimable))) { return(false); } int heightDifference = CombatExecutor.gridHeight[(int)to.x, (int)to.y] - CombatExecutor.gridHeight[(int)from.x, (int)from.y]; if (heightDifference > characterInfo.MaxJumpHeight) { return(false); } return(true); }
override public bool Activate() { targetObjects = CombatExecutor.GetAllObjectExcept(targetPos); return(true); }
public override bool Update() { if (cutscenePhase == 0) { cutscene.Activate(); cutscenePhase++; source.animator.SetTrigger("CrateAttack"); } if (cutscenePhase == 1) { bool done = cutscene.Update(); if (done) { cutscene = null; cutscenePhase++; } } if (cutscenePhase == 2) { List <Vector2Int> potentialGridOccupations = source.PotentialGridOccupation(EndPos); bool landingEmpty = BattleMapProcesses.isTileEmpty(potentialGridOccupations, source.gameObject); if (landingEmpty) { source.Stun(1); source.LightWeight(1); parent.transform.position = GridManager.GridToPosition(EndPos, source.TileSize); } else { if (BattleMapProcesses.doesObjectOverlapTargets(potentialGridOccupations, target)) { target.postBufferAttackEffect(source.Power, FighterClass.attackType.Normal, FighterClass.statusEffects.None, FighterClass.attackLocation.Ground, parent); } } if (!landingEmpty || !CombatExecutor.LevelFloor(EndPos, source.TileSize)) { List <Vector2Int> possibleLocations; if (!landingEmpty) { possibleLocations = BattleMapProcesses.FindNearestTileNoCharacter(EndPos, 3, source.gameObject); source.animator.SetTrigger("Land"); } else { possibleLocations = BattleMapProcesses.FindNearestTileNoCharacter(EndPos, 1, source.gameObject); } int locationIndex = Random.Range(0, possibleLocations.Count); EndPos = possibleLocations[locationIndex]; JumpToLocation jumpTo = ScriptableObject.CreateInstance <JumpToLocation>(); jumpTo.parent = parent; jumpTo.speed = source.JumpSpeed * 1.5f; jumpTo.heightOverHighestCharacter = 1; jumpTo.endPosition = GridManager.GridToPosition(EndPos, source.TileSize); jumpTo.Activate(); cutscene = jumpTo; } source.AddObjectToGrid(EndPos); cutscenePhase++; } if (cutscenePhase == 3) { if (!(cutscene is null)) { bool done = cutscene.Update(); if (done) { cutscene = null; cutscenePhase++; return(true); } } else { return(true); } }