Пример #1
0
    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);
    }
Пример #2
0
    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;
        }
    }
Пример #3
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);
    }