Game-Design / Sprint3_actual / MouseController.cs
MouseController.cs
Raw
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Text;

namespace Sprint3_actual
{
    class MouseController : IController
    {
        private ICommand prevRoom;
        private ICommand nextRoom;

        private MouseState oldState;

        public void RegisterCommand(int comtype, ICommand command)
        {
            if(comtype == 1)
            {
                prevRoom = command;
            }
            else if (comtype == 2)
            {
                nextRoom = command;
            }
        }

        public void Update()
        {
            MouseState m = Mouse.GetState();
            if (m != oldState)
            {
                if(m.LeftButton == ButtonState.Pressed)
                {
                    prevRoom.Execute();

                }
                if(m.RightButton == ButtonState.Pressed)
                {
                    nextRoom.Execute();
                }
            }

            oldState = m;
        }
    }
}