Example #1
0
        public void Reset(GameEngine gameEngine, MainCharacter mainCharacter, ContentManager content)
        {
            if (Interviewees.Count == MaxInterviewees)
            {
                GState = LocationState.ConfirmedReturn;
            }
            else
            {
                GState = LocationState.Normal;
            }
            content.Unload();

            MainCharacter   = mainCharacter;
            Content         = content;
            IsTransitioning = false;
            Point WindowSize = Game1.GetWindowSize();

            // Load Characters
            String CharPath = Path.Combine(Content.RootDirectory, "characters.txt");
            String CharJSON = File.ReadAllText(CharPath);

            CharList = JsonSerializer.Deserialize <AllCharacters>(CharJSON);

            // Load Case Info
            String CasePath = Path.Combine(Content.RootDirectory, "case" + MainCharacter.CurrentCase + ".txt");
            String CaseJSON = File.ReadAllText(CasePath);
            Case   Case     = JsonSerializer.Deserialize <Case>(CaseJSON);

            // Visual Elements
            Background = new Background(content, BGImagePath);
            CharPics   = new Dictionary <string, ClickableTexture>();
            Greetings  = new Dictionary <string, string>();

            Notebook     = Content.Load <Texture2D>("notebook_icon");
            NotebookRect = new Rectangle(WindowSize.X - 100, 20, 70, 70);
            MapIcon      = Content.Load <Texture2D>("map-icon");
            MapIconRect  = new Rectangle(WindowSize.X - 200, 20, 70, 70);

            Arial      = content.Load <SpriteFont>("Fonts/Arial");
            SpeechMenu = null;

            int     NumSuspects = Case.Suspects.Count;
            Vector2 CharPos     = new Vector2(WindowSize.X / 6, WindowSize.Y / 3); // may want to customize position at a given location later

            foreach (string Suspect in Case.Suspects)
            {
                Greetings[Suspect] = CharList.AllChars[Suspect].Greetings[0];
                Texture2D CharTexture = Content.Load <Texture2D>(CharList.AllChars[Suspect].ImagePath);
                CharPics[Suspect] = new ClickableTexture(CharTexture, CharPos);
                CharPos.X        += 0.75f * WindowSize.X / NumSuspects;
            }
            IntervieweeListRect = new Rectangle(WindowSize.X / 4, 2 * WindowSize.Y / 3, WindowSize.X / 2, WindowSize.Y / 4);

            TextOffset = new Vector2(0, Arial.MeasureString("A").Y);

            MouseState     = Mouse.GetState();
            PrevMouseState = MouseState;
        }
Example #2
0
        private void MouseClicked(MouseState mouseState)
        {
            Point     MouseClick     = new Point(mouseState.X, mouseState.Y);
            Rectangle MouseClickRect = new Rectangle(MouseClick, new Point(10, 10));

            switch (GState)
            {
            // If nothing selected, check whether location was selected
            case LocationState.Normal:
                foreach (string CharName in CharPics.Keys)
                {
                    if (MouseClickRect.Intersects(CharPics[CharName].Rect))
                    {
                        GState             = LocationState.ClickedPerson;
                        SpeechMenu         = new SpeechMenu(Greetings[CharName], CharPics[CharName].Rect, Content, Arial);
                        SelectedPersonName = CharName;
                    }
                }
                if (MouseClickRect.Intersects(NotebookRect))
                {
                    GState = LocationState.ToNotebook;
                }
                if (MouseClickRect.Intersects(MapIconRect))
                {
                    GState = LocationState.ClickedReturn;
                    string query = "Are you sure you're done exploring for now?";
                    ConfirmMenu = new ConfirmMenu(query, Content, Arial);
                }
                break;

            case LocationState.ClickedPerson:
                if (SpeechMenu.IsCancelling(MouseClickRect))
                {
                    GState     = LocationState.Normal;
                    SpeechMenu = null;
                }
                else if (SpeechMenu.IsConfirming(MouseClickRect))
                {
                    GState = LocationState.ConfirmedPerson;
                    Interviewees.Add(SelectedPersonName);
                    SpeechMenu = null;
                }
                break;

            case LocationState.ClickedReturn:
                if (ConfirmMenu.IsCancelling(MouseClickRect))
                {
                    GState      = LocationState.Normal;
                    ConfirmMenu = null;
                }
                else if (ConfirmMenu.IsConfirming(MouseClickRect))
                {
                    GState      = LocationState.ConfirmedReturn;
                    ConfirmMenu = null;
                }
                break;

            default:
                break;
            }
        }