Beispiel #1
0
    // set the facing of the player and the current talker
    private void SetDefaultFacing(Dialogue.DialogueData.DialoguePoint dialoguePoint)
    {
        if (null == dialoguePoint ||                         // we can't do anything without a dialogue point
            dialoguePoint.actions.ContainsFacingActions() || // if this step has facing actions, then don't do anything here
            IsDuringGameplay())                              // if this is a speech bubble conversation during gameplay, we're not gonna set facing
        {
            return;
        }

        GameObject caller = GlobalUtils.FindCharacter(dialoguePoint.caller);

        if (null == caller)         // if we can't find the character to use
        {
            return;
        }

        GameObject player = PlayerManager.LocalPlayerGameObject();

        if (null == player)         // if we have no player we don't know who to look at
        {
            return;
        }

        if (caller != player)
        {
            FacingAction.OrientFacing(caller, player);
        }
    }
Beispiel #2
0
    // perform any initialization on dialogue participants
    static private void EnterParticipantsToDialogue()
    {
        if (null != activeDialogue.dialoguePoints)
        {
            for (int dialogue = 0; dialogue < activeDialogue.dialoguePoints.Count; ++dialogue)             // go through all dialogue conversation points
            {
                if (null != activeDialogue.dialoguePoints[dialogue])
                {
                    GameObject caller = GlobalUtils.FindCharacter(activeDialogue.dialoguePoints[dialogue].caller);
                    if (null != caller)
                    {
                        CharacterComponent charComp = caller.GetComponent <CharacterComponent>();
                        if (null != charComp)
                        {
                            AnimationSequence.SetAnimationEnterState(charComp);                             // start the dialogue enter animation

                            if (null != charComp.TargetingComponent)
                            {
                                charComp.TargetingComponent.SetMovementTarget(Vector3.zero, true);                 // stop the character movement
                                charComp.TargetingComponent.SetAttackTarget(null);                                 // stop the character attacking
                            }
                        }
                        //_interaction.SwitchCharacterTeam(caller.GetComponent<NPCStatsComponent>()); // stop an enemy from being targetable
                    }
                }
            }
        }
    }
Beispiel #3
0
    public override void Execute()
    {
        GameObject characterGameObject = GlobalUtils.FindCharacter(characterToUse);

        if (null != characterGameObject)
        {
            FusionAudio.PostEvent(soundToPlay, characterGameObject, true);
        }
        else
        {
            FusionAudio.PostEvent(soundToPlay);
        }
    }
Beispiel #4
0
    static public void OrientFacing(CharacterModel orient, CharacterModel lookat)
    {
        GameObject characterToOrientGameObject = GlobalUtils.FindCharacter(orient);

        if (null != characterToOrientGameObject)
        {
            GameObject characterToLookAtGameObject = GlobalUtils.FindCharacter(lookat);
            if (null != characterToLookAtGameObject)
            {
                OrientFacing(characterToOrientGameObject, characterToLookAtGameObject);
            }
        }
    }
Beispiel #5
0
 // play all the tracks
 public override void Execute()
 {
     for (int track = 0; track < animations.Count; ++track)
     {
         GameObject characterToUse = GlobalUtils.FindCharacter(animations[track].characterToUse);
         if (null != characterToUse)
         {
             CharacterComponent charTarget = characterToUse.GetComponent <CharacterComponent>();
             if (null != charTarget)
             {
                 SetAnimationState(animations[track].animationToPlay, charTarget, animations[track].doLoop);
             }
         }
     }
 }
Beispiel #6
0
 public void AdvanceChatBubbles(Dialogue.DialogueData.DialoguePoint conversation)
 {
     if (null != conversation)
     {
         GameObject caller = GlobalUtils.FindCharacter(conversation.caller);
         if (null != caller)
         {
             ShowChatBubble showChat = caller.GetComponent <ShowChatBubble>();
             if (null != showChat)
             {
                 showChat.Show(StringUtils.ReplaceTokens(conversation.call));
             }
         }
     }
 }
Beispiel #7
0
 // get all the participants in the conversation
 static public void GetAllInteractionParticipants(ref List <GameObject> outParticipants, List <Dialogue.DialogueData.DialoguePoint> dialoguePoints)
 {
     if (null != dialoguePoints)
     {
         for (int dialogue = 0; dialogue < dialoguePoints.Count; ++dialogue)
         {
             if (null != dialoguePoints[dialogue])
             {
                 GameObject caller = GlobalUtils.FindCharacter(dialoguePoints[dialogue].caller);
                 if (null != caller && !outParticipants.Contains(caller))
                 {
                     outParticipants.Add(caller);
                 }
             }
         }
     }
 }
Beispiel #8
0
    // set the horizontal position of the bubble tail
    private void PositionBubbleTailHorizontally(CharacterModel callerInput, Vector3 latestBehaviorPosition, Quaternion latestBehaviorRotation)
    {
        GameObject caller = GlobalUtils.FindCharacter(callerInput);

        if (null != caller && null != UICamera.mainCamera)
        {
            Vector3 screenPoint = WorldToScreenPoint(caller.transform.position, latestBehaviorPosition, latestBehaviorRotation);

            Vector3 worldPoint = UICamera.mainCamera.ScreenToWorldPoint(screenPoint);
            worldPoint.z = 0f;

            const float Padding           = 0.75f;
            float       mainBubbleXExtent = (_uiLabelDialogueBody.localSize.x * 0.5f) * Padding;

            PositionSpeechBubbleTailHorizontally(worldPoint, mainBubbleXExtent);
            PositionThoughtBubbleTailHorizontally(worldPoint, mainBubbleXExtent);
        }
    }
Beispiel #9
0
 // does the dialogue use the participant
 static public bool UsesParticipant(List <Dialogue.DialogueData.DialoguePoint> dialoguePoints, GameObject participant)
 {
     if (null != dialoguePoints)
     {
         for (int dialogue = 0; dialogue < dialoguePoints.Count; ++dialogue)
         {
             if (null != dialoguePoints[dialogue])
             {
                 GameObject caller = GlobalUtils.FindCharacter(dialoguePoints[dialogue].caller);
                 if (null != caller && participant == caller)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #10
0
 static private void TriggerEndAnimations()
 {
     if (null != activeDialogue.dialoguePoints)
     {
         for (int dialogue = 0; dialogue < activeDialogue.dialoguePoints.Count; ++dialogue)
         {
             if (null != activeDialogue.dialoguePoints[dialogue])
             {
                 GameObject participant = GlobalUtils.FindCharacter(activeDialogue.dialoguePoints[dialogue].caller);
                 if (null != participant)
                 {
                     //CharacterComponent charTarget = participant.GetComponent<CharacterComponent>();
                     //if (null != charTarget && eCharacterState.Dialogue == charTarget.State)
                     //{
                     //AnimationSequence.SetAnimationExitState(charTarget);
                     //charTarget.State = eCharacterState.Idle;
                     //}
                 }
             }
         }
     }
 }
Beispiel #11
0
    // set the horizontal position of the bubble
    private void PositionBubbleHorizontally(CharacterModel callerInput, Vector3 latestBehaviorPosition, Quaternion latestBehaviorRotation)
    {
        GameObject caller = GlobalUtils.FindCharacter(callerInput);

        if (null != caller && null != UICamera.mainCamera)
        {
            Vector3 screenPoint = WorldToScreenPoint(caller.transform.position, latestBehaviorPosition, latestBehaviorRotation);

            const float HorizontalShift = 250f;             // how much we move the bubble by, based on it being in the left/right third
            if (IsPointInLeftThirdOfScreenWidth(screenPoint))
            {
                bubbleContainer.transform.localPosition = new Vector3(-HorizontalShift, 0f, 0f);
            }
            else if (IsPointInRightThirdOfScreenWidth(screenPoint))
            {
                bubbleContainer.transform.localPosition = new Vector3(HorizontalShift, 0f, 0f);
            }
            else             // point must be in the center of the screen
            {
                bubbleContainer.transform.localPosition = Vector3.zero;
            }
        }
    }
Beispiel #12
0
    // turn on the type of camera we need for this conversation step
    static public void SetUpNewCamera(Dialogue.DialogueData.DialoguePointCamera conversation, CharacterModel inputCaller, List <Dialogue.DialogueData.DialoguePoint> dialoguePoints)
    {
        if (null == conversation.camera)
        {
            return;
        }

        CameraLerp cameraLerp = (null != conversation.cameraLerpOverride) ? conversation.cameraLerpOverride : GlobalDialogueData.Instance.defaultDialogueLerp;

        System.Type cameraType = conversation.camera.GetType();
        if (typeof(GameCameraParams) == cameraType)
        {
            if (null != Camera.main)
            {
                CameraBase cameraComponent = Camera.main.GetComponent <CameraBase>();

                GameCameraParams gameCameraParams = (GameCameraParams)conversation.camera;
                switch (conversation.targets)
                {
                case Dialogue.DialogueData.DialoguePointCamera.CameraTargets.localPlayer:
                    if (gameCameraParams.gameCamera)
                    {
                        cameraComponent.EnterFixedOffsetGameCamera(cameraLerp);
                    }
                    else
                    {
                        PlayerController controller = PlayerManager.LocalPlayerController();
                        if (null != controller)
                        {
                            List <GameObject> target = new List <GameObject>();
                            target.Add(controller.gameObject);
                            cameraComponent.EnterInteractionCamera(ref target, ref gameCameraParams, cameraLerp);
                        }
                    }
                    break;

                case Dialogue.DialogueData.DialoguePointCamera.CameraTargets.all:
                    List <GameObject> targets = new List <GameObject>();
                    Interaction.GetAllInteractionParticipants(ref targets, dialoguePoints);
                    if (targets.Count > 0)
                    {
                        cameraComponent.EnterInteractionCamera(ref targets, ref gameCameraParams, cameraLerp);
                    }
                    break;

                case Dialogue.DialogueData.DialoguePointCamera.CameraTargets.caller:
                    GameObject caller = GlobalUtils.FindCharacter(inputCaller);
                    if (null != caller)
                    {
                        if (inputCaller.isPlayer && gameCameraParams.gameCamera)
                        {
                            cameraComponent.EnterFixedOffsetGameCamera(cameraLerp);
                        }
                        else
                        {
                            List <GameObject> target = new List <GameObject>();
                            target.Add(caller);
                            cameraComponent.EnterInteractionCamera(ref target, ref gameCameraParams, cameraLerp);
                        }
                    }
                    break;

                default: break;
                }
            }
        }
        else if (typeof(CinematicCameraParams) == cameraType)
        {
            if (null != conversation.cinematic)
            {
                if (conversation.IsCinematicAPrefabRequiringInstantiation())
                {
                    GameObject cinematicObject = (GameObject)GameObject.Instantiate(conversation.cinematic);
                    if (null != cinematicObject && cinematicObject.activeInHierarchy)
                    {
                        Cinematic.Play(cinematicObject.GetComponent <Cinematic>(), PlayerManager.LocalPlayerGameObject());
                    }
                }
                else
                {
                    Cinematic.Play(conversation.cinematic.GetComponent <Cinematic>(), PlayerManager.LocalPlayerGameObject());
                }
            }
        }
    }