using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using System; using System.Collections.Generic; using System.Text; namespace Sprint2_actual { class MouseController : IController { private ICommand upperLeftQuadLCommand; private ICommand upperRightQuadLCommand; private ICommand lowerLeftQuadLCommand; private ICommand lowerRightQuadLCommand; private ICommand RCommand; private ICommand prevPress; private int Height { get; set; } private int Width { get; set; } public MouseController() { prevPress = upperLeftQuadLCommand; } public void RegisterCommand(int comtype, ICommand command) { if(comtype == 1) { upperLeftQuadLCommand = command; } else if (comtype == 2) { upperRightQuadLCommand = command; } else if (comtype == 3) { lowerLeftQuadLCommand = command; } else if (comtype == 4) { lowerRightQuadLCommand = command; } else { RCommand = command; } } public void RegisterScreenSize(int width, int height) { Height = height; Width = width; } public void Update() { MouseState m = Mouse.GetState(); if(m.LeftButton == ButtonState.Pressed) { if(m.X Width / 2 && m.Y < Height / 2 && prevPress != upperRightQuadLCommand) { upperRightQuadLCommand.Execute(); prevPress = upperRightQuadLCommand; } else if (m.X < Width / 2 && m.Y > Height / 2 && prevPress != lowerLeftQuadLCommand) { lowerLeftQuadLCommand.Execute(); prevPress = lowerLeftQuadLCommand; } else if (m.X > Width / 2 && m.Y > Height / 2 && prevPress != lowerRightQuadLCommand) { lowerRightQuadLCommand.Execute(); prevPress = lowerRightQuadLCommand; } } if(m.RightButton == ButtonState.Pressed) { RCommand.Execute(); } } } }