public virtual void MoveCharacterExecute(Vector2Int EndPos, float walkSpeed, float jumpSpeed, GameObject[,] grid) { if (CombatExecutor.gridHeight[EndPos.x, EndPos.y] != CombatExecutor.gridHeight[pos.x, pos.y]) { JumpToLocation JumpTo = ScriptableObject.CreateInstance <JumpToLocation>(); JumpTo.endPosition = GridManager.GridToPosition(EndPos, TileSize); JumpTo.parent = gameObject; JumpTo.heightOverHighestCharacter = 1; JumpTo.speed = jumpSpeed; LastMoveSpeed = jumpSpeed; JumpTo.Activate(); move = JumpTo; } else { MoveToLocation WalkTo = ScriptableObject.CreateInstance <MoveToLocation>(); WalkTo.endPosition = GridManager.GridToPosition(EndPos, TileSize); WalkTo.parent = gameObject; WalkTo.speed = walkSpeed; LastMoveSpeed = walkSpeed; WalkTo.Activate(); move = WalkTo; } MoveObject(EndPos); }
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); }
IEnumerator Parabola(NavMeshAgent agent, float height, float duration) { travelingMeshLink = true; OffMeshLinkData data = agent.currentOffMeshLinkData; Vector3 startPos = agent.transform.position; Vector3 endPos = data.endPos + Vector3.up * agent.baseOffset; JumpToLocation JumpTo = ScriptableObject.CreateInstance <JumpToLocation>(); JumpTo.endPosition = endPos; JumpTo.parent = gameObject; JumpTo.heightOverHighestCharacter = 1; JumpTo.speed = duration; JumpTo.Activate(); while (!JumpTo.Update()) { yield return(0); } agent.CompleteOffMeshLink(); travelingMeshLink = false; }
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); } }