Example #1
0
 public StoryPrompt(StoryPrompt copy)
 {
     this.Name = copy.Name;
     this.Prompt = copy.Prompt;
     this.NarratorOnly = copy.NarratorOnly;
     this.PrefabToSpawn = copy.PrefabToSpawn;
     this.Choices = copy.Choices;
 }
Example #2
0
 public StoryPrompt(StoryPrompt copy)
 {
     this.Name          = copy.Name;
     this.Prompt        = copy.Prompt;
     this.NarratorOnly  = copy.NarratorOnly;
     this.PrefabToSpawn = copy.PrefabToSpawn;
     this.Choices       = copy.Choices;
 }
Example #3
0
    public void ChoiceSelected(StoryChoice choice)
    {
        DeactivateActive();
        StoryPrompt targetPrompt = story.LookupPrompt(choice.TargetPrompt);

        activePrompt = targetPrompt;
        ActivateActive();
    }
Example #4
0
	public void LoadFromPrompt(StoryPrompt prompt)
	{
		cg.alpha = 1f;
		Sprite s = LoadSprite(prompt.ImageName);
		if(s == null) {
			throw new System.Exception("Sprite not found for prompt " + prompt.Name);
		}
		img.sprite = s;
	}
Example #5
0
    IEnumerator DoPrompt(StoryPrompt prompt)
    {
        onPromptStart.Invoke();
        CreateChoices(prompt);
        if (prompt.ImageName != null)
        {
            imgPrompt.LoadFromPrompt(prompt);
        }
        else
        {
            imgPrompt.DisableImg();
        }

        if (prompt.AudioName != null)
        {
            prompt.PlayAudio();
        }

        if (prompt.NarratorOnly)
        {
            fateAwaits.SetActive(true);
        }
        else
        {
            fateAwaits.SetActive(false);
            string PromptText = prompt.Prompt;
            float  duration   = PromptText.Length * TimePerLetter;

            int promptLength = 0;
            Prompting = true;
            bool exit = false;
            while (promptLength < PromptText.Length - 1)
            {
                promptField.text = PromptText.Substring(0, promptLength);
                promptLength++;
                float t = 0f;
                while (t < TimePerLetter)
                {
                    t   += Time.deltaTime;
                    exit = Input.GetKeyDown(KeyCode.Space);
                    if (exit)
                    {
                        break;
                    }
                    yield return(null);
                }
                if (exit)
                {
                    break;
                }
            }
            promptField.text = PromptText;
        }
        Prompting = false;
        onPromptEnd.Invoke();
    }
Example #6
0
    public void LoadFromPrompt(StoryPrompt prompt)
    {
        cg.alpha = 1f;
        Sprite s = LoadSprite(prompt.ImageName);

        if (s == null)
        {
            throw new System.Exception("Sprite not found for prompt " + prompt.Name);
        }
        img.sprite = s;
    }
Example #7
0
	IEnumerator DoPrompt(StoryPrompt prompt)
	{
		
		onPromptStart.Invoke();
		CreateChoices(prompt);
		if(prompt.ImageName != null)
		{
			imgPrompt.LoadFromPrompt(prompt);
		}
		else
		{
			imgPrompt.DisableImg();
		}

        if(prompt.AudioName != null)
        {
            prompt.PlayAudio();
        }

		if(prompt.NarratorOnly) 
		{
			fateAwaits.SetActive(true);
		}
		else
		{
			fateAwaits.SetActive(false);
			string PromptText = prompt.Prompt;
			float duration = PromptText.Length * TimePerLetter;

			int promptLength = 0;
            Prompting = true;
            bool exit = false;
			while(promptLength < PromptText.Length - 1)
			{
				promptField.text = PromptText.Substring(0, promptLength);
				promptLength++;
                float t = 0f;
                while (t < TimePerLetter)
                {
                    t += Time.deltaTime;
                    exit = Input.GetKeyDown(KeyCode.Space);
                    if (exit)
                        break;
                    yield return null;
                }
                if (exit)
                    break;
            }
			promptField.text = PromptText;
		}
        Prompting = false;
		onPromptEnd.Invoke();
	}
Example #8
0
    public void ActivateActive()
    {
        if (activePrompt.Name == "cluePage")
        {
            print(cycleCount);
            int clue1Index = cycleCount * 2;
            int clue2Index = cycleCount * 2 + 1;
            if (clue1Index >= this.story.Clues.Count)
            {
                string allClues = "You're so close, but all clues have been discovered:\n\n";
                for (int i = 0; i < this.story.Clues.Count; i++)
                {
                    allClues += (this.story.Clues[i] + "\n");
                    allClues += "\n";
                }
                activePrompt.Prompt = allClues;
            }
            else
            {
                if (promptCopy == "")
                {
                    promptCopy = activePrompt.Prompt;
                }
                string clue1 = this.story.Clues[clue1Index];
                string clue2 = this.story.Clues[clue2Index];
                print(clue1);
                print(clue2);
                activePrompt.Prompt = string.Format(promptCopy, "\n" + clue1);
                this.prompter.MakePrompt(activePrompt);
                StoryPrompt copy = new StoryPrompt(activePrompt);
                copy.Prompt = string.Format(promptCopy, "\n" + clue2);
                consoleReceiver.SendPrompt(copy);
                cycleCount++;
                return;
            }
        }


        if (activePrompt.Name == "Narrator Intro")
        {
            lastWordsPanel.gameObject.SetActive(true);
            prompter.canvasGroup.alpha = 0f;
        }
        if (activePrompt.FormatIsDeathWord == true)
        {
            activePrompt.Prompt = string.Format(activePrompt.Prompt, lastWords);
        }
        this.prompter.MakePrompt(activePrompt);
        consoleReceiver.SendPrompt(activePrompt);
    }
Example #9
0
	void CreateChoices(StoryPrompt prompt)
	{
		prompterChoices = new List<PrompterChoice>();
		foreach(Transform choice in choiceRoot) 
		{
			Destroy(choice.gameObject);
		}
		foreach(StoryChoice choice in prompt.Choices)
		{
			GameObject prompterPrefabInstance = Instantiate(PrompterChoicePrefab);
			prompterPrefabInstance.transform.SetParent(choiceRoot,false);
			PrompterChoice pc = prompterPrefabInstance.GetComponent<PrompterChoice>();
			pc.AssignStoryChoice(choice);
			prompterChoices.Add(pc);
		}
	}
Example #10
0
 void CreateChoices(StoryPrompt prompt)
 {
     prompterChoices = new List <PrompterChoice>();
     foreach (Transform choice in choiceRoot)
     {
         Destroy(choice.gameObject);
     }
     foreach (StoryChoice choice in prompt.Choices)
     {
         GameObject prompterPrefabInstance = Instantiate(PrompterChoicePrefab);
         prompterPrefabInstance.transform.SetParent(choiceRoot, false);
         PrompterChoice pc = prompterPrefabInstance.GetComponent <PrompterChoice>();
         pc.AssignStoryChoice(choice);
         prompterChoices.Add(pc);
     }
 }
Example #11
0
	void AirConsole_instance_onConnect(int device_id)
	{
		if(begun) 
		{
			return;
		}
		loadScreen.SetActive(false);
		begun = true;
		string json = File.ReadAllText(StoryPath);
		this.story = Deserialize(typeof(Story), json) as Story;
        this.story.ShuffleClues();
		StoryPrompt firstPrompt = this.story.LookupPrompt(story.FirstPromptName);
		activePrompt = firstPrompt;
		this.prompter.MakePrompt(firstPrompt);
		consoleReceiver.SendPrompt(firstPrompt);
		ActivateActive();
	}
Example #12
0
    void AirConsole_instance_onConnect(int device_id)
    {
        if (begun)
        {
            return;
        }
        loadScreen.SetActive(false);
        begun = true;
        string json = File.ReadAllText(StoryPath);

        this.story = Deserialize(typeof(Story), json) as Story;
        this.story.ShuffleClues();
        StoryPrompt firstPrompt = this.story.LookupPrompt(story.FirstPromptName);

        activePrompt = firstPrompt;
        this.prompter.MakePrompt(firstPrompt);
        consoleReceiver.SendPrompt(firstPrompt);
        ActivateActive();
    }
Example #13
0
	public void ChoiceSelected(StoryChoice choice)
	{
		DeactivateActive();
		StoryPrompt targetPrompt = story.LookupPrompt(choice.TargetPrompt);
		activePrompt = targetPrompt;
		ActivateActive();
	}
Example #14
0
 public void MakePrompt(StoryPrompt prompt)
 {
     StopCoroutine("DoPrompt");
     StartCoroutine(DoPrompt(prompt));
 }
Example #15
0
	public void SendPrompt(StoryPrompt aPrompt) {
		print(aPrompt.Serialize());
		AirConsole.instance.Broadcast(aPrompt.Serialize());
	}
Example #16
0
	public void MakePrompt(StoryPrompt prompt)
	{
        StopCoroutine("DoPrompt");
		StartCoroutine(DoPrompt(prompt));
	}
Example #17
0
	public void ActivateActive()
    {
        if (activePrompt.Name == "cluePage")
        {
			print(cycleCount);
            int clue1Index = cycleCount * 2;
            int clue2Index = cycleCount * 2 + 1;
            if (clue1Index >= this.story.Clues.Count)
            {
                string allClues = "You're so close, but all clues have been discovered:\n\n";
                for (int i = 0; i < this.story.Clues.Count; i++)
                {
                    allClues += (this.story.Clues[i] + "\n");
                    allClues += "\n";
                }
                activePrompt.Prompt = allClues;
            }
            else
            {
				if(promptCopy == "")
				{
					promptCopy = activePrompt.Prompt;
				}
				string clue1 = this.story.Clues[clue1Index];
				string clue2 = this.story.Clues[clue2Index];
				print(clue1);
				print(clue2);
                activePrompt.Prompt = string.Format(promptCopy, "\n" + clue1);
                this.prompter.MakePrompt(activePrompt);
                StoryPrompt copy = new StoryPrompt(activePrompt);
				copy.Prompt = string.Format(promptCopy, "\n" + clue2);
                consoleReceiver.SendPrompt(copy);
                cycleCount++;
                return;
            }
        }


        if (activePrompt.Name == "Narrator Intro")
		{
			lastWordsPanel.gameObject.SetActive(true);
			prompter.canvasGroup.alpha = 0f;
		}
		if(activePrompt.FormatIsDeathWord == true)
		{
			activePrompt.Prompt = string.Format(activePrompt.Prompt, lastWords);
		}
        this.prompter.MakePrompt(activePrompt);
        consoleReceiver.SendPrompt(activePrompt);
    }
Example #18
0
 public void SendPrompt(StoryPrompt aPrompt)
 {
     print(aPrompt.Serialize());
     AirConsole.instance.Broadcast(aPrompt.Serialize());
 }