Beispiel #1
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                if (runtimeFaceObject == null && (faceType == CharFaceType.Body || (faceType == CharFaceType.Head && !stopLooking)))
                {
                    return(0f);
                }

                if (runtimeCharToMove)
                {
                    if (faceType == CharFaceType.Body)
                    {
                        if (!isInstant && runtimeCharToMove.IsMovingAlongPath())
                        {
                            runtimeCharToMove.EndPath();
                        }

                        if (lookUpDown && isPlayer && KickStarter.settingsManager.IsInFirstPerson())
                        {
                            Player player = (Player)runtimeCharToMove;
                            player.SetTilt(runtimeFaceObject.transform.position, isInstant);
                        }

                        runtimeCharToMove.SetLookDirection(GetLookVector(KickStarter.settingsManager), isInstant);
                    }
                    else if (faceType == CharFaceType.Head)
                    {
                        if (stopLooking)
                        {
                            runtimeCharToMove.ClearHeadTurnTarget(isInstant, HeadFacing.Manual);
                        }
                        else
                        {
                            Vector3 offset = Vector3.zero;

                            Hotspot faceObjectHotspot = runtimeFaceObject.GetComponent <Hotspot>();
                            Char    faceObjectChar    = runtimeFaceObject.GetComponent <Char>();

                            if (lookAtHead && faceObjectChar != null)
                            {
                                Transform neckBone = faceObjectChar.neckBone;
                                if (neckBone != null)
                                {
                                    runtimeFaceObject = neckBone.gameObject;
                                }
                                else
                                {
                                    ACDebug.Log("Cannot look at " + faceObjectChar.name + "'s head as their 'Neck bone' has not been defined.", faceObjectChar);
                                }
                            }
                            else if (faceObjectHotspot != null)
                            {
                                if (faceObjectHotspot.centrePoint != null)
                                {
                                    runtimeFaceObject = faceObjectHotspot.centrePoint.gameObject;
                                }
                                else
                                {
                                    offset = faceObjectHotspot.GetIconPosition(true);
                                }
                            }

                            runtimeCharToMove.SetHeadTurnTarget(runtimeFaceObject.transform, offset, isInstant);
                        }
                    }

                    if (isInstant)
                    {
                        return(0f);
                    }
                    else
                    {
                        if (willWait)
                        {
                            return(defaultPauseTime);
                        }
                        else
                        {
                            return(0f);
                        }
                    }
                }

                return(0f);
            }
            else
            {
                if (faceType == CharFaceType.Head && runtimeCharToMove.IsMovingHead())
                {
                    return(defaultPauseTime);
                }
                else if (faceType == CharFaceType.Body && runtimeCharToMove.IsTurning())
                {
                    return(defaultPauseTime);
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }
        }
Beispiel #2
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                if (faceObject == null && (faceType == CharFaceType.Body || (faceType == CharFaceType.Head && !stopLooking)))
                {
                    return(0f);
                }

                if (charToMove)
                {
                    if (faceType == CharFaceType.Body)
                    {
                        if (lookUpDown && isPlayer && KickStarter.settingsManager.IsInFirstPerson())
                        {
                            Player player = (Player)charToMove;
                            player.SetTilt(faceObject.transform.position, isInstant);
                        }

                        charToMove.SetLookDirection(GetLookVector(KickStarter.settingsManager), isInstant);
                    }
                    else if (faceType == CharFaceType.Head)
                    {
                        if (stopLooking)
                        {
                            charToMove.ClearHeadTurnTarget(HeadFacing.Manual, isInstant);
                        }
                        else
                        {
                            Vector3 lookAtPosition = faceObject.transform.position;

                            if (faceObject.GetComponent <Hotspot>())
                            {
                                lookAtPosition = faceObject.GetComponent <Hotspot>().GetIconPosition();
                            }

                            charToMove.SetHeadTurnTarget(lookAtPosition, isInstant);
                        }
                    }

                    if (isInstant)
                    {
                        return(0f);
                    }
                    else
                    {
                        if (faceType == CharFaceType.Body)
                        {
                            charToMove.EndPath();
                        }

                        if (willWait)
                        {
                            return(defaultPauseTime);
                        }
                        else
                        {
                            return(0f);
                        }
                    }
                }

                return(0f);
            }
            else
            {
                if (faceType == CharFaceType.Head && charToMove.IsMovingHead())
                {
                    return(defaultPauseTime);
                }
                else if (faceType == CharFaceType.Body && charToMove.IsTurning())
                {
                    return(defaultPauseTime);
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }
        }