Example #1
0
	private void Start ()
	{
		if (GameObject.FindWithTag (Tags.persistentEngine))
		{
			if (GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>())
			{
				stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
			}
			
			if (GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>())
			{
				options = stateHandler.GetComponent <Options>();
			}
		}
	}
Example #2
0
    void Start()
    {
        if (GameObject.FindWithTag(Tags.persistentEngine))
        {
            if (GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>())
            {
                stateHandler = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>();
            }

            if (GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>())
            {
                runtimeInventory = stateHandler.GetComponent <RuntimeInventory>();
            }
        }

        if (GameObject.FindWithTag(Tags.player) && GameObject.FindWithTag(Tags.player).GetComponent <Player>())
        {
            player = GameObject.FindWithTag(Tags.player).GetComponent <Player>();
        }
    }
Example #3
0
    override public float Run()
    {
        dialog       = GameObject.FindWithTag(Tags.gameEngine).GetComponent <Dialog>();
        stateHandler = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>();
        options      = stateHandler.GetComponent <Options>();

        if (dialog && stateHandler && options)
        {
            if (!isRunning)
            {
                isRunning = true;

                string _text     = messageText;
                string _language = "";

                if (options.optionsData.language > 0)
                {
                    // Not in original language, so pull translation in from Speech Manager
                    if (!speechManager)
                    {
                        speechManager = AdvGame.GetReferences().speechManager;
                    }

                    if (speechManager.GetLineByID(lineID) != null && speechManager.GetLineByID(lineID).translationText.Count > (options.optionsData.language - 1))
                    {
                        _text     = speechManager.GetLineByID(lineID).translationText [options.optionsData.language - 1];
                        _language = speechManager.languages[options.optionsData.language];
                    }
                }

                if (_text != "")
                {
                    dialog.KillDialog();

                    if (isBackground)
                    {
                        stateHandler.gameState = GameState.Normal;
                    }
                    else
                    {
                        stateHandler.gameState = GameState.Cutscene;
                    }

                    if (isPlayer)
                    {
                        speaker = GameObject.FindWithTag(Tags.player).GetComponent <Player>();
                    }

                    if (speaker)
                    {
                        dialog.StartDialog(speaker, _text, lineID, _language);

                        if (headClip || mouthClip)
                        {
                            AdvGame.CleanUnusedClips(speaker.GetComponent <Animation>());

                            if (headClip)
                            {
                                AdvGame.PlayAnimClip(speaker.GetComponent <Animation>(), (int)AnimLayer.Head, headClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, speaker.neckBone);
                            }

                            if (mouthClip)
                            {
                                AdvGame.PlayAnimClip(speaker.GetComponent <Animation>(), (int)AnimLayer.Mouth, mouthClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, speaker.neckBone);
                            }
                        }
                    }
                    else
                    {
                        dialog.StartDialog(_text);
                    }

                    if (!isBackground)
                    {
                        return(defaultPauseTime);
                    }
                }

                return(0f);
            }
            else
            {
                if (!dialog.isMessageAlive)
                {
                    isRunning = false;
                    stateHandler.gameState = GameState.Cutscene;
                    return(0f);
                }
                else
                {
                    return(defaultPauseTime);
                }
            }
        }

        return(0f);
    }