Example #1
0
    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);
    }
Example #2
0
    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);
    }
Example #3
0
    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);
            }
        }