Ejemplo n.º 1
0
        public DialogController(GameState gm, SpriteBatch sb, DialogModel dm, string cityName, ContentManager cm)
        {
            gameState = gm;
            spriteBatch = sb;
            Dialog = dm;
            contentManager = cm;

            names = new Queue<String>();
            lines = new Queue<String>();
            colors = new Dictionary<String,Color>();
            faces = new Dictionary<String,Texture2D>();
            cutscenes = new Dictionary<String, Texture2D>();
            startStopCues = new Dictionary<String, String>();
            Parse();
            speaker = "";
            speech = cityName;
            color = Color.Black;
            screen = new DialogView(sb);
            stopCue = "";
        }
Ejemplo n.º 2
0
        public void Update(GameTime gameTime, bool stayInDialogue)
        {
            KeyboardState ks = Keyboard.GetState();
            // If player wants to see introduction dialogue again
            if (ks.IsKeyDown(Keys.I))
            {
                if (currentState != State.inDialog)
                    start = false;
            }

            if (!start)
            {
                start = true;
                DialogModel dm = new DialogModel("Introduction");
                dm.LoadContent(game.Content);
                SelectedCity.DialogControl = new DialogController(gameState, spriteBatch, dm, "Tutorial", game.Content);
                SelectedCity.DialogControl.Initialize();
                SelectedCity.DialogControl.LoadContent(game.Content);
                currentState = State.inDialog;
            }
            else if (!stayInDialogue)
            {
                currentState = State.inMap;
            }
            switch (currentState)
            {
                /// code for inDialog
                case State.inDialog:
                    if (SelectedCity.DialogControl.Finished)
                    {
                        if (SelectedCity.State == DataTypes.WorldData.CityState.Cleared || SelectedCity.Data.PlayLevel == "NoLevel")
                        {
                            currentState = State.inMap;
                            if (SelectedCity.Data.PlayLevel == "NoLevel")
                            {
                                if (SelectedCity.State != DataTypes.WorldData.CityState.Cleared && SelectedCity.Name == "Milan")
                                {
                                    LevelUnlock.Play();
                                    SelectedCity.State = DataTypes.WorldData.CityState.Cleared; // For Milan
                                    foreach (Models.City c in Cities)
                                    {
                                        if (c.Data.ID == SelectedCity.Data.Unlock1 || c.Data.ID == SelectedCity.Data.Unlock2 ||
                                            c.Data.ID == SelectedCity.Data.Unlock3) c.State = DataTypes.WorldData.CityState.NewlyUnlocked;
                                    }
                                }
                            }
                        }
                        else if (SelectedCity.DialogControl.Dialog.DialogFileName == "Introduction" || SelectedCity.DialogControl.Dialog == SelectedCity.successDialogue)
                        {
                            currentState = State.inMap;
                        }
                        else
                        {
                            MediaPlayer.Stop();
                            gameState.SelectedLevel = SelectedCity.Data.PlayLevel;
                            // Console.WriteLine(gameState.SelectedLevel);
                            gameState.CurrentScreen = DataTypes.Screens.PlayLevel;
                            currentState = State.inGame;
                        }
                    }
                    else
                    {
                        if (!gameState.Input.Cancel)
                        {
                            SelectedCity.DialogControl.Update(gameTime);
                        }
                        else
                        {
                            currentState = State.inMap;
                        }
                    }
                    break;

                /// code for inGame
                case State.inGame:
                    if (gameState.Score > SelectedCity.Data.ScoreReq && gameState.Combo > SelectedCity.Data.ComboReq)
                    {
                        SelectedCity.State = DataTypes.WorldData.CityState.Cleared;
                        LevelUnlock.Play();
                        foreach (Models.City c in SelectedCity.Unlocked)
                        {
                            if (c != null)
                            {
                                // Console.WriteLine("here at city" + c.Data.Name);
                                c.State = DataTypes.WorldData.CityState.NewlyUnlocked;
                            }
                        }
                        if (SelectedCity.Data.BigSix)
                        {
                            this.big_Six++;
                            if (big_Six >= 4)
                            {
                                foreach (Models.City c in Cities)
                                {
                                    if (c.Data.ID == 15) c.State = DataTypes.WorldData.CityState.NewlyUnlocked;
                                }
                            }
                            // City with ID 14 doesn't exist anymore (flight of bumblebee was not arranged)
                            else if (big_Six == 6)
                            {
                                foreach (Models.City c in Cities)
                                {
                                    if (c.Data.ID == 14) c.State = DataTypes.WorldData.CityState.NewlyUnlocked;
                                }
                            }

                        }
                        DialogModel dm = SelectedCity.successDialogue;
                        dm.LoadContent(game.Content);
                        SelectedCity.DialogControl = new DialogController(gameState, spriteBatch, dm, "(Success!)", game.Content);
                        SelectedCity.DialogControl.Initialize();
                        SelectedCity.DialogControl.LoadContent(game.Content);
                        currentState = State.inDialog;
                    }
                    else
                    {
                        SelectedCity.State = DataTypes.WorldData.CityState.Unlocked;
                        currentState = State.inMap;
                    }

                    gameState.SaveRequested = true;

                    break;

                default: //inMap
                    foreach (Models.City city in Cities)
                    {
                        // TODO: remove magic constant!
                        if (Vector2.Distance(city.AbsolutePosition, gameState.Input.Position) < 20.0f)
                        {
                            SelectedCity = city;
                            break;
                        }
                    }
                    if (SelectedCity != LastCity)
                        MapMove.Play();
                    LastCity = SelectedCity;

                    if (gameState.Input.Confirm && SelectedCity.NotLocked)
                    {
                        DialogModel toLoad = null;
                        switch (SelectedCity.State)
                        {
                            case DataTypes.WorldData.CityState.Cleared:
                                toLoad = SelectedCity.clearedDialogue;
                                break;
                            case DataTypes.WorldData.CityState.NewlyUnlocked:
                                toLoad = SelectedCity.newlyUnlockedDialogue;
                                break;
                            case DataTypes.WorldData.CityState.Unlocked:
                                toLoad = SelectedCity.unlockedDialogue;
                                break;
                            default: //if the node is locked, though this shouldn't be reachable
                                break;
                        }
                        if (toLoad != null)
                        {
                            EnterCity.Play();
                            toLoad.LoadContent(game.Content);
                            SelectedCity.DialogControl = new DialogController(gameState, spriteBatch, toLoad, SelectedCity.Name,game.Content);
                            SelectedCity.DialogControl.Initialize();
                            SelectedCity.DialogControl.LoadContent(game.Content); // MOVE TO NODE'S
                        }
                        currentState = State.inDialog;
                    }
                    break;
            }
        }