Ejemplo n.º 1
0
        public virtual void OnCacheConversations()
        {
            //HELPER VARABLES
            string file = Server.SecurePath("~/dialogtemplates/{0}.xml", this.ModelId);

            if (File.Exists(file))
            {
                using (DialogReader reader = DialogReader.Open(file))
                {
                    while (reader.Read())
                    {
                        if (reader.HasInformation)
                        {
                            //Always uppercase (invariant for globalisation issues)
                            string name = reader.Name.ToUpperInvariant();
                            if (name == "GOSSIP")
                            {
                                //Gossip is a base function of ours
                                _Gossip = reader.Value;
                            }
                            else
                            {
                                //Parse to all child registered functions
                                for (int i = 0; i < state.RegisteredNpcFunctions.Count; i++)
                                {
                                    state.RegisteredNpcFunctions[i].OnCacheDialogInfo(this, reader.Name, reader.Value);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
    private void Awake()
    {
        dialogsReader = FindObjectOfType <DialogReader>();
        source        = GetComponent <AudioSource>();
        source.clip   = ringingSound;

        LevelData levelData = LevelManager.Instance.LevelData;

        ringingTimings = new Queue <float>();
        List <float> sortingList = new List <float>();

        foreach (float f in levelData.PhoneRingTimings)
        {
            sortingList.Add(f);
        }
        sortingList.Sort();
        foreach (float f in sortingList)
        {
            ringingTimings.Enqueue(f);
        }

        ringingRoutine = null;

        GetNextTiming();
    }
Ejemplo n.º 3
0
    void InitPuzzle(string command)
    {
        string[] parsedText = DialogReader.ParseBrackets(command);
        Debug.Log("parsed: " + parsedText[0] + "," + parsedText[1]);
        switch (parsedText[0].Trim().ToLower())
        {
        case "thoughtspiral":
            Debug.Log("hasspiral");
            Debug.Log("1:" + parsedText[1]);
            EndPart();
            ThoughtSpiralPuzzle.Initialize(parsedText[1], WinnableScores());
            puzzling = true;
            //_playerController.busy = true;
            _playerController.playerMoving = false;
            _playerController.busy         = true;
            break;

        case "passwordinput":
            Debug.Log("entering password input");
            inputInAction                  = true;
            PasswordInput.activated        = true;
            PasswordInput.inputEnabled     = true;
            _playerController.playerMoving = false;
            _playerController.busy         = true;
            break;

        default:
            Debug.Log("puzzle not found");
            break;
        }
    }
Ejemplo n.º 4
0
    void ReformatText(string fullText)      //ugly, edit later
    {
        string[] parsedText = DialogReader.ParseBrackets(fullText);
        if (parsedText[0].Equals(""))
        {
            fullSpanText.enabled   = true;
            speakerTextbox.enabled = false;
            if (speakerBackground != null)
            {
                speakerBackground.SetActive(false);
            }
            fullSpanText.text = parsedText[1];
            currTextUsed      = fullSpanText;
        }
        else
        {
            speakerTextbox.enabled = true;
            speakerTextbox.text    = parsedText[0];
            if (speakerBackground != null)
            {
                speakerBackground.SetActive(true);
            }

            fullSpanText.enabled = true;
            fullSpanText.text    = parsedText[1];
            currTextUsed         = fullSpanText;
        }
    }
Ejemplo n.º 5
0
 public void Begin(DialogReader DR)
 {
     started = true;
     dr      = DR;
     Debug.Log("is dr null in Begin: " + (dr == null));
     skipBar.SetActive(true);
     Debug.Log("began");
 }
Ejemplo n.º 6
0
    private void Start()
    {
        XmlDocument XMLDoc = new XmlDocument();

        XMLDoc.LoadXml(Settings.XMLFile.text);
        _dialogReader = new DialogReader(XMLDoc);
        Write();
    }
Ejemplo n.º 7
0
 void TerminateScene()
 {
     dialogEnded = true;
     dr.Terminate();
     dr = null;
     EndPart();
     Debug.Log("scene terminated");
     Debug.Log(dr == null);
 }
Ejemplo n.º 8
0
 public void Update()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         DialogReader.InitScenario("MetalMilitia");
         DialogueBuffer.PushFirst();
     }
     if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         DialogReader.InitScenario("Scenario5");
         DialogueBuffer.PushFirst();
     }
 }
Ejemplo n.º 9
0
        public override void Update(float gameTime, MainSprite main)
        {
            //talking to dogs
            KeyboardState keyboardState = Keyboard.GetState();

            if (data.Equals("Dave"))
            {
                Console.WriteLine("You reached the exit");
                if (oldState.IsKeyUp(Keys.Enter) && keyboardState.IsKeyDown(Keys.Enter))
                {
                    //lock the character's animation and allow the dialog box to be drawn
                    drawDialog  = true;
                    main.locked = true;
                    dialogReader.nextLine();

                    //reset the dialog reader and unlock character animation once we've reached the end of the dialog
                    if (dialogReader.isDialogDone())
                    {
                        main.locked  = false;
                        drawDialog   = false;
                        dialogReader = new DialogReader();
                        dialogReader.getDialog(@"C:\Users\ember\source\repos\firstrate\Content\TestDialog.txt");
                    }
                }
            }

            if (drawDialog)
            {
                currentDialog = dialogReader.typeLine(animationTimer);
            }

            //check if they are at the exit
            if (data.Equals("Exit"))
            {
                // isDone = true;
                Console.WriteLine("You reached the exit"); //never reaching this point -- have to remember how data is set
            }


            //dog animation
            animationTimer += gameTime;
            if (animationTimer > 450)
            {
                daveAnimation.Update();
                animationTimer = 0;
            }

            oldState = keyboardState;
        }
Ejemplo n.º 10
0
    void initDR()
    {
        if (dr != null)
        {
            dr.Terminate();
        }

        if (dialogFileName == null)
        {
            GetSceneName();
            dialogFileName = Utility.sceneToFile[currScene];
        }

        string dialogPath = Utility.PrefixFile(dialogFileName.Trim());

        if (!dialogPath.EndsWith(".txt"))
        {
            dialogPath += ".txt";
        }

        if (scoreFileName == null)
        {
            scoreFileName = "scores.txt";
        }
        string scorePath = Utility.PrefixFile(scoreFileName.Trim());

        if (!scorePath.EndsWith(".txt"))
        {
            scorePath += ".txt";
        }

        dr = new DialogReader(dialogPath, scorePath);
        if (DialogReader.variables.Count == 0 || DialogReader.varNames.Count == 0)
        {
            dr.GetInitValues();
        }
        // if (dr.variables.Count == 0 || dr.varNames.Count == 0){
        //  dr.GetInitValues();
        // }
        Debug.Log("dr initialized");
    }
Ejemplo n.º 11
0
 void Correct()
 {
     print("CORRECT");
     DialogReader.InitScenario("Code");
     text.text = "De code is 1337";
 }
Ejemplo n.º 12
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            answerBox.SetData(new Color[] { Color.LemonChiffon });

            //singleton!!!
            if (dialogReader == null)
            {
                dialogReader  = new DialogReader();
                currentDialog = dialogReader.getDialog
                                    (@"C:\Users\ember\source\repos\Aljourney\Aljourney\Dialogs\IntroDialog.txt");
            }

            /*get mouse click to progress dialog box
             * where dialogCounter is the current position in the array of dialogs
             * currentDialog is the array of dialogs retrieved from the file
             * currentLine is the line we are going to type to the screen*/
            if (dialogCounter == 0)
            {
                currentLine = currentDialog[dialogCounter];
                dialogCounter++;
            }
            MouseState mouseState = Mouse.GetState();

            if (mouseState.LeftButton == ButtonState.Pressed && !oldMouseState.Equals(mouseState))
            {
                mouseClicks++;
                if (mouseClicks % 2 == 1)
                {
                    textCounter = currentLine.Length;
                    typedLine   = "";
                    foreach (char c in currentLine)
                    {
                        typedLine += c;
                    }
                }
                else
                {
                    if (dialogCounter < currentDialog.Count)
                    {
                        currentLine = currentDialog[dialogCounter];
                        textCounter = 0;
                        typedLine   = "";
                    }
                    dialogCounter++;
                }
            }
            oldMouseState = mouseState;

            //time Rho's animation
            rhoTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (rhoTimer > 250)
            {
                animateRho.Update();
                animateXCharacter.Update();
                animateYCharacter.Update();
                rhoTimer = 0;
            }

            textTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (textTimer > 100)
            {
                if (textCounter < currentLine.Length)
                {
                    typedLine += currentLine[textCounter];
                }
                if (textCounter <= currentLine.Length)
                {
                    textCounter++;
                }
                if (textCounter == currentLine.Length)
                {
                    mouseClicks++;
                }
                textTimer = 0;
            }
            base.Update(gameTime);
        }
 public void Unregister()
 {
     DialogReader.Unregister(this);
 }
 public void Register()
 {
     DialogReader.Register(this);
 }
 private void Awake()
 {
     dialogReader = FindObjectOfType <DialogReader>();
 }
Ejemplo n.º 16
0
 public void changeScoresss()
 {
     DialogReader.variables["smood"] += 40;
     DialogReader.WriteScores(DialogReader.varNames, DialogReader.variables);
 }
Ejemplo n.º 17
0
        /// <summary>Executes the program. First prompts for the character name.
        /// Next, it starts a reader for dialog and narration and prints those
        /// with some formatting. After that, it initializes room one, then
        /// parses the user input</summary>
        private static void Main(string[] args)
        {
            Console.WriteLine("What is your name?");
            var user = new Human(Console.ReadLine());

            var narration = new StreamReader("Narration.txt");

            DialogReader.PrintDialog("Dialogue.txt");

            //format, then prints some lines of narration
            PrintLines(2);
            var counter = 0;

            while (counter < 7)
            {
                Console.WriteLine(narration.ReadLine());
                counter++;
            }

            /*Sets up each room and the user's location in each*/
            Room one, two, three, four, five;
            var  room = new[]
            {
                (five = new Room(5, user)), (four = new Room(4, user)),
                (three = new Room(3, user)), (two = new Room(2, user)),
                (one = new Room(1, user))
            };

            var location = new[]
            {
                five.GetUserLocation(), four.GetUserLocation(),
                three.GetUserLocation(), two.GetUserLocation(),
                one.GetUserLocation()
            };
            /*End setup*/

            //sets up room one
            var roomIndex = 4;

            user.SetLocation(location[roomIndex]);
            MapReader.PrintMap("RoomOneMap.txt", room[roomIndex], user);

            //For my purposes to keep track of movement
            Console.WriteLine(user.GetLocation().GetX());
            Console.WriteLine(user.GetLocation().GetY());
            while (!End())
            {
                //if it hits an exit, goes to the next room, sets the new starting location,
                //and prints the map, adding a couple lines of space
                if (InputReader.StartReading(Console.ReadLine(), user, room[roomIndex]))
                {
                    roomIndex--;
                    user.SetLocation(location[roomIndex]);
                    MapReader.PrintMap(room[roomIndex].GetFileName(), room[roomIndex], user);
                    user.Hitpoints += 2;
                    user.SetStamina(user.GetStamina());
                    PrintLines(2);
                }

                Console.WriteLine(user.GetLocation().GetX());
                Console.WriteLine(user.GetLocation().GetY());
            }

            EndGame();
        }