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