public (List <Vector2Int>, List <GameObject>) findGoalsDiamond( List <GameObject> targets ) { List <Vector2Int> goalList = new List <Vector2Int>(); List <GameObject> objectList = new List <GameObject>(); foreach (GameObject targetObject in targets) { List <Vector2Int> allTargetPos = new List <Vector2Int>(); allTargetPos.Add(targetObject.GetComponent <FighterClass>().pos); allTargetPos.AddRange(targetObject.GetComponent <FighterClass>().extra_pos); foreach (Vector2Int targetPos in allTargetPos) { for (int row = -MaxRange; row <= MaxRange + character.GetComponent <GridObject>().TileSize.x; row++) { for (int col = -MaxRange + Mathf.Abs(row); col <= MaxRange - Mathf.Abs(row); col++) { if (Mathf.Abs(row) + Mathf.Abs(col) >= MinRange) { Vector2Int goal = targetPos + new Vector2Int(row, col); if (BattleMapProcesses.isThisOnTheGrid(goal) && !goalList.Contains(goal)) { goalList.Add(goal); objectList.Add(targetObject); } } } } } } return(goalList, objectList); }
private ZapBlockScript findOtherZapBlock(Vector2Int posDif) { Vector2Int new_pos = pos + posDif; if (BattleMapProcesses.isThisOnTheGrid(new_pos)) { GameObject target_block = ContainingGrid[new_pos.x, new_pos.y]; return(target_block.GetComponent <ZapBlockScript>()); } return(null); }
public virtual bool PushObjectCheck(int HorChange, int VerChange, float Speed, int pushStrength, bool overridePushability = false) { foreach (PushObjectTriggerInfo pushObjectTrigger in PushObjectTriggers) { if (pushObjectTrigger.Left && HorChange < 0 || pushObjectTrigger.Right && HorChange > 0 || pushObjectTrigger.Down && VerChange < 0 || pushObjectTrigger.Up && VerChange > 0) { if (CombatExecutor.CutsceneDataManager.TriggerATrigger(pushObjectTrigger.Label)) { GameDataTracker.combatExecutor.AddCutsceneToQueue(Resources.Load <DialogueContainer>(pushObjectTrigger.CutscenePath), name, gameObject); } } } if (pushStrength < 0) { return(false); } if (!Pushable && !overridePushability) { return(false); } Vector2Int EndPos = new Vector2Int(pos.x + HorChange, pos.y + VerChange); List <Vector2Int> potentialGridOccupations = PotentialGridOccupation(EndPos); foreach (Vector2Int potentialGridOccupation in potentialGridOccupations) { if (!BattleMapProcesses.isThisOnTheGrid(potentialGridOccupation)) { return(false); } if (!BattleMapProcesses.CanIMoveToTile(potentialGridOccupation, this)) { return(false); } if (CombatExecutor.gridHeight[pos.x, pos.y] < CombatExecutor.gridHeight[potentialGridOccupation.x, potentialGridOccupation.y]) { return(false); } } if (BattleMapProcesses.isTileEmpty(potentialGridOccupations, gameObject)) { return(true); } if (AttemptPush(potentialGridOccupations, HorChange, VerChange, Speed, pushStrength)) { return(true); } return(false); }
public bool AttemptPush(List <Vector2Int> pushTargets, int HorChange, int VerChange, float Speed, int pushStrength) { List <FighterClass> charactersToPush = new List <FighterClass>(); List <CombatObject> objectsToPush = new List <CombatObject>(); foreach (Vector2Int pushTarget in pushTargets) { if (!BattleMapProcesses.isThisOnTheGrid(pushTarget)) { return(false); } if (CombatExecutor.characterGrid[pushTarget.x, pushTarget.y] != null) { FighterClass characterToPush = CombatExecutor.characterGrid[pushTarget.x, pushTarget.y].GetComponent <FighterClass>(); if (!CombatExecutor.characterGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>().PushObjectCheck(HorChange, VerChange, Speed, pushStrength - 1)) { return(false); } if (!charactersToPush.Contains(characterToPush)) { objectsToPush.Add(characterToPush); } } if (CombatExecutor.objectGrid[pushTarget.x, pushTarget.y] != null) { if (!CombatExecutor.objectGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>().Passable) { CombatObject objectToPush = CombatExecutor.objectGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>(); if (!CombatExecutor.objectGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>().PushObjectCheck(HorChange, VerChange, Speed, pushStrength - 1)) { return(false); } if (!objectsToPush.Contains(objectToPush)) { objectsToPush.Add(objectToPush); } } } } foreach (CombatObject characterToPush in charactersToPush) { characterToPush.MoveCharacterExecute(new Vector2Int(characterToPush.pos.x + HorChange, characterToPush.pos.y + VerChange), Speed, Speed, CombatExecutor.characterGrid); } foreach (CombatObject objectToPush in objectsToPush) { objectToPush.MoveCharacterExecute(new Vector2Int(objectToPush.pos.x + HorChange, objectToPush.pos.y + VerChange), Speed, Speed, CombatExecutor.objectGrid); } return(true); }
public (List <Vector2Int>, List <GameObject>) findGoalsX( List <GameObject> targets ) { List <Vector2Int> goalList = new List <Vector2Int>(); List <GameObject> objectList = new List <GameObject>(); foreach (GameObject targetObject in targets) { List <Vector2Int> allTargetPos = new List <Vector2Int>(); allTargetPos.Add(targetObject.GetComponent <FighterClass>().pos); allTargetPos.AddRange(targetObject.GetComponent <FighterClass>().extra_pos); foreach (Vector2Int targetPos in allTargetPos) { for (int idx = MinRange; idx <= MaxRange; idx++) { Vector2Int newGoalVector; newGoalVector = targetPos + new Vector2Int(idx, idx); if (BattleMapProcesses.isThisOnTheGrid(newGoalVector) && !goalList.Contains(newGoalVector)) { goalList.Add(newGoalVector); objectList.Add(targetObject); } newGoalVector = targetPos + new Vector2Int(-idx, -idx); if (BattleMapProcesses.isThisOnTheGrid(newGoalVector) && !goalList.Contains(newGoalVector)) { goalList.Add(newGoalVector); objectList.Add(targetObject); } newGoalVector = targetPos + new Vector2Int(-idx, idx); if (BattleMapProcesses.isThisOnTheGrid(newGoalVector) && !goalList.Contains(newGoalVector)) { goalList.Add(newGoalVector); objectList.Add(targetObject); } newGoalVector = targetPos + new Vector2Int(idx, -idx); if (BattleMapProcesses.isThisOnTheGrid(newGoalVector) && !goalList.Contains(newGoalVector)) { goalList.Add(newGoalVector); objectList.Add(targetObject); } } } } return(goalList, objectList); }
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); }
public virtual void MoveCharacter(int HorChange, int VerChange) { Vector2Int EndPos = new Vector2Int(pos.x + HorChange, pos.y + VerChange); List <Vector2Int> potentialGridOccupations = PotentialGridOccupation(EndPos); if (HorChange > 0) { gameObject.GetComponent <SpriteFlipper>().setFacingRight(); } if (HorChange < 0) { gameObject.GetComponent <SpriteFlipper>().setFacingLeft(); } foreach (Vector2Int potentialGridOccupation in potentialGridOccupations) { if (!BattleMapProcesses.isThisOnTheGrid(EndPos)) { return; } if (!BattleMapProcesses.CanIMoveToTile(EndPos, this)) { return; } } if (BattleMapProcesses.isTileEmpty(potentialGridOccupations, gameObject)) { MoveCharacterExecute(EndPos, WalkSpeed, JumpSpeed, CombatExecutor.characterGrid); return; } if (AttemptPush(potentialGridOccupations, HorChange, VerChange, WalkSpeed, PushStrength)) { MoveCharacterExecute(EndPos, WalkSpeed, JumpSpeed, CombatExecutor.characterGrid); return; } }
public override bool Update() { if (cutscenePhase == 0) { cutscene.Activate(); cutscenePhase++; } if (cutscenePhase == 1) { bool done = cutscene.Update(); if (done) { cutscene = null; cutscenePhase++; } } if (cutscenePhase == 2) { bool rollAllowed = false; if (BattleMapProcesses.isThisOnTheGrid(EndPos)) { List <Vector2Int> potentialGridOccupations = source.PotentialGridOccupation(EndPos); bool landingEmpty = BattleMapProcesses.isTileEmpty(potentialGridOccupations, source.gameObject); if (landingEmpty && BattleMapProcesses.CanIMoveToTile(EndPos, source)) { rollAllowed = true; } } if (rollAllowed) { MoveToLocation moveTo = ScriptableObject.CreateInstance <MoveToLocation>(); moveTo.endPosition = GridManager.GridToPosition(EndPos, source.TileSize); moveTo.parent = parent; moveTo.speed = source.WalkSpeed; cutscene = moveTo; source.RemoveObjectFromGrid(); source.AddObjectToGrid(EndPos); } else { parent.GetComponent <SpriteFlipper>().flip(); JumpToLocation jumpTo = ScriptableObject.CreateInstance <JumpToLocation>(); jumpTo.endPosition = GridManager.GridToPosition(source.pos, source.TileSize); jumpTo.parent = parent; jumpTo.heightOverHighestCharacter = 0.5f; jumpTo.speed = source.JumpSpeed; cutscene = jumpTo; if (BattleMapProcesses.isThisOnTheGrid(EndPos)) { if (characterGrid[EndPos.x, EndPos.y] != null) { target = characterGrid[EndPos.x, EndPos.y].GetComponent <FighterClass>(); if (target.objectID <= 10) { target.postBufferAttackEffect(source.Power, FighterClass.attackType.Normal, FighterClass.statusEffects.None, FighterClass.attackLocation.Ground, parent); } } } } cutscene.Activate(); cutscenePhase++; } if (cutscenePhase == 3) { if (cutscene.Update()) { cutscene = null; cutscenePhase++; return(true); } } //jumpToTwo.endPosition = new Vector3(EndPos.y * blockOffset.x, gridHeight[(int)EndPos.x, (int)EndPos.y] * blockOffset.z + 0, EndPos.x * blockOffset.y); return(false); }
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); } }