Beispiel #1
0
        override public void Skip()
        {
            if (charToMove)
            {
                if (charToMove is NPC)
                {
                    NPC npcToMove = (NPC)charToMove;
                    npcToMove.FollowReset();
                }

                if (doStop)
                {
                    charToMove.EndPath();
                }
                else if (movePath)
                {
                    if (movePath.pathType == AC_PathType.ForwardOnly)
                    {
                        // Place at end
                        int i = movePath.nodes.Count - 1;
                        charToMove.transform.position = movePath.nodes [i];
                        if (i > 0)
                        {
                            charToMove.SetLookDirection(movePath.nodes[i] - movePath.nodes[i - 1], true);
                        }
                        return;
                    }

                    if (doTeleport)
                    {
                        charToMove.transform.position = movePath.transform.position;

                        // Set rotation if there is more than one node
                        if (movePath.nodes.Count > 1)
                        {
                            charToMove.SetLookDirection(movePath.nodes[1] - movePath.nodes[0], true);
                        }
                    }

                    if (!isPlayer)
                    {
                        charToMove.SetPath(movePath);
                    }
                }
            }
        }
Beispiel #2
0
        override public void Skip()
        {
            if (charToMove && marker)
            {
                charToMove.EndPath();

                if (charToMove is NPC)
                {
                    NPC npcToMove = (NPC)charToMove;
                    npcToMove.FollowReset();
                }

                Vector3[] pointArray;
                Vector3   targetPosition = marker.transform.position;

                if (KickStarter.settingsManager.ActInScreenSpace())
                {
                    targetPosition = AdvGame.GetScreenNavMesh(targetPosition);
                }

                if (pathFind && KickStarter.navigationManager)
                {
                    pointArray = KickStarter.navigationManager.navigationEngine.GetPointsArray(charToMove.transform.position, targetPosition);
                }
                else
                {
                    List <Vector3> pointList = new List <Vector3>();
                    pointList.Add(targetPosition);
                    pointArray = pointList.ToArray();
                }

                int i = pointArray.Length - 1;

                if (i > 0)
                {
                    charToMove.SetLookDirection(pointArray[i] - pointArray[i - 1], true);
                }
                else
                {
                    charToMove.SetLookDirection(pointArray[i] - charToMove.transform.position, true);
                }

                charToMove.Teleport(pointArray [i]);
            }
        }
Beispiel #3
0
        override public float Run()
        {
            if (npcToMove)
            {
                if (followType == FollowType.StopFollowing)
                {
                    npcToMove.FollowReset();
                    return(0f);
                }

                if (followPlayer || charToFollow != (Char)npcToMove)
                {
                    npcToMove.FollowAssign(charToFollow, followPlayer, updateFrequency, followDistance, followDistanceMax);
                }
            }

            return(0f);
        }
Beispiel #4
0
        override public float Run()
        {
            UpgradeSelf();

            if (movePath && movePath.GetComponent <Char>())
            {
                Debug.LogWarning("Can't follow a Path attached to a Character!");
                return(0f);
            }

            if (!isRunning)
            {
                isRunning = true;

                if (charToMove)
                {
                    if (charToMove is NPC)
                    {
                        NPC npcToMove = (NPC)charToMove;
                        npcToMove.FollowReset();
                    }

                    if (movePathMethod == MovePathMethod.StopMoving)
                    {
                        charToMove.EndPath();
                    }
                    else if (movePathMethod == MovePathMethod.MoveOnNewPath)
                    {
                        if (movePath)
                        {
                            if (doTeleport)
                            {
                                charToMove.Teleport(movePath.transform.position);

                                // Set rotation if there is more than one node
                                if (movePath.nodes.Count > 1)
                                {
                                    charToMove.SetLookDirection(movePath.nodes[1] - movePath.nodes[0], true);
                                }
                            }

                            if (isPlayer && movePath.pathType != AC_PathType.ForwardOnly)
                            {
                                Debug.LogWarning("Cannot move player along a non-forward only path, as this will create an indefinite cutscene.");
                            }
                            else
                            {
                                if (willWait && movePath.pathType != AC_PathType.ForwardOnly)
                                {
                                    willWait = false;
                                    Debug.LogWarning("Cannot pause while character moves along a non-forward only path, as this will create an indefinite cutscene.");
                                }

                                charToMove.SetPath(movePath);

                                if (willWait)
                                {
                                    return(defaultPauseTime);
                                }
                            }
                        }
                    }
                    else if (movePathMethod == MovePathMethod.ResumeLastSetPath)
                    {
                        charToMove.ResumeLastPath();
                    }
                }

                return(0f);
            }
            else
            {
                if (charToMove.GetPath() != movePath)
                {
                    isRunning = false;
                    return(0f);
                }
                else
                {
                    return(defaultPauseTime);
                }
            }
        }
Beispiel #5
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                if (charToMove && marker)
                {
                    Paths path = charToMove.GetComponent <Paths>();
                    if (path == null)
                    {
                        Debug.LogWarning("Cannot move a character with no Paths component");
                    }
                    else
                    {
                        if (charToMove is NPC)
                        {
                            NPC npcToMove = (NPC)charToMove;
                            npcToMove.FollowReset();
                        }

                        path.pathType  = AC_PathType.ForwardOnly;
                        path.pathSpeed = speed;
                        path.affectY   = true;

                        Vector3[] pointArray;
                        Vector3   targetPosition = marker.transform.position;

                        if (KickStarter.settingsManager.ActInScreenSpace())
                        {
                            targetPosition = AdvGame.GetScreenNavMesh(targetPosition);
                        }

                        if (pathFind && KickStarter.navigationManager)
                        {
                            pointArray = KickStarter.navigationManager.navigationEngine.GetPointsArray(charToMove, charToMove.transform.position, targetPosition);
                        }
                        else
                        {
                            List <Vector3> pointList = new List <Vector3>();
                            pointList.Add(targetPosition);
                            pointArray = pointList.ToArray();
                        }

                        if (speed == PathSpeed.Walk)
                        {
                            charToMove.MoveAlongPoints(pointArray, false);
                        }
                        else
                        {
                            charToMove.MoveAlongPoints(pointArray, true);
                        }

                        if (charToMove.activePath)
                        {
                            if (!pathFind && doFloat)
                            {
                                charToMove.activePath.affectY = true;
                            }
                            else
                            {
                                charToMove.activePath.affectY = false;
                            }
                        }

                        if (willWait)
                        {
                            return(defaultPauseTime);
                        }
                    }
                }

                return(0f);
            }
            else
            {
                if (!charToMove.IsPathfinding())
                {
                    isRunning = false;
                    return(0f);
                }
                else
                {
                    return(defaultPauseTime);
                }
            }
        }