void Start() { pathGenerator = (PathGenerator)GameObject.FindObjectOfType(typeof(PathGenerator)); mouseInputHandler = (MouseInputHandler)GameObject.FindObjectOfType(typeof(MouseInputHandler)); mouseInputHandler.OnRightClick += new MouseClickHandler(mouseInputHandler_OnRightClick); }
protected override void Initialize() { textureHandler = new TextureHandler(); base.Initialize(); currentScene = new Scene(this); mouseInputHandler = new MouseInputHandler(this); }
void Start() { pathGenerator = (PathGenerator)GameObject.FindObjectOfType( typeof( PathGenerator ) ); mouseInputHandler = (MouseInputHandler)GameObject.FindObjectOfType( typeof( MouseInputHandler ) ); mouseInputHandler.OnRightClick += new MouseClickHandler( mouseInputHandler_OnRightClick ); }
void Awake() { MouseInputHandler input = GetComponent <MouseInputHandler>(); //input.OnPress += OnPressed; //input.OnRelease += OnReleased; body = transform.FindChild(Constants.TransformBodyName); StartCoroutine(PointGun()); }
public MouseInputBehaviour(Game game, SpriteBatch spriteBatch, INotificationWindow notificationBox, Board board, TurnManager turnManager, MouseInputHandler mouseInputHandler, int screenWidth, int screenHeight) { _SpriteBatch = spriteBatch; _Game = game; this.turnManager = turnManager; this.screenWidth = screenWidth; this.screenHeight = screenHeight; this.notificationBox = notificationBox; this._Board = board; mouseInputHandler.LeftMouseClick += handleMouseClick; }
public void RegisterEvents(MouseInputHandler mouseInput) { foreach (BaseScreen screen in _screens) { screen.RegisterEvents(mouseInput); } foreach (Component component in _components) { component.RegisterEvents(mouseInput); } }
protected override void Initialize() { base.Initialize(); var mersenneTwister = new MersenneTwister(); var loader = new LevelLoader(); var firstLevel = new Level(loader.Load("Content/first"), mersenneTwister); var view = new GameView(new Point(Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight), new Point(64, 64), firstLevel); _controller = new Controller(firstLevel, view); var input = new MouseInputHandler(_controller, view); input.Swap += _controller.SwapAnimals; }
public InputManager(Game game) : base(game) { mouseEvents = new EventQueue <MouseEventData>(); keyEvents = new EventQueue <KeyEventData>(); touchEvents = new EventQueue <TouchEventData>(); gamePadEvents = new EventQueue <GamePadEventData>(); mouseInput = new MouseInputHandler(mouseEvents); touchInput = new TouchInputHandler(touchEvents); components = new List <IUpdateable> { new KeyboardComponent(keyEvents, game.Window), mouseInput, touchInput, new GamePadComponent(gamePadEvents) }; }
public void Init(MouseInputHandler mouseInput) { _baseScreen.RegisterEvents(mouseInput); GameWorld = new WorldGenerator(33, 33, 1, WorldSeed).Generate().Build(); Hero = new Hero(Assets.GetSpecies("hero")); new HeroAi(Hero); Hero.NewActionSetEvent += _replayCaptureManager.AddReplayEvent; GameWorld.AddCreature(GameWorld.GetRandomEmptyPoint(0), 0, Hero); for (int i = 0; i < 10; i++) { Monster monster = new Monster(Assets.GetSpecies("troll")); new MonsterAi(monster); GameWorld.AddCreature(GameWorld.GetRandomEmptyPoint(0), 0, monster); } GameWorld.ComputeFov(Hero.X, Hero.Y, Hero.Depth, 12, Helpers.FovType.Shadowcast); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { this.IsMouseVisible = true; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); var random = new Random(); var board = new Board(BoardWidth, BoardHeight, random); var playerList = new[] { new Player("Ian", startingMoney, Color.Red), new Player("Ryan", startingMoney, Color.Blue), new Player("Stefan", startingMoney, Color.Yellow), new Player("Jeremy", startingMoney, Color.Green) }.ToList(); var turnManager = new TurnManager(board, playerList); notificationBox = null; var mouseInputHandler = new MouseInputHandler(this); var mouseInputBehaviour = new MouseInputBehaviour(this, spriteBatch, notificationBox, board, turnManager, mouseInputHandler, ScreenWidth, ScreenHeight); var moneyView = new MoneyView(this, turnManager, spriteBatch, playerList); //var turnIndicatorView = new TurnIndicatorView(this, spriteBatch, turnManager, BoardWidth, BoardHeight); //for(int i = 0; i < BoardWidth; i++) { // board.Cells[i, 0].Owner = playerList[0]; //} var boardView = new BoardView(this, board, spriteBatch, ScreenWidth, ScreenHeight); Components.Add(boardView); base.Initialize(); }
public void SetMouseInputHandler(MouseInputHandler onMouseEvent) { _onMouseEvent = onMouseEvent; }
private void Awake() { instance = this; }
public GameScene(IScene scene) : base(scene) { var gameElementFactory = new BasicGameElementFactory(); IGameObject gameObject = new BasicGameObject("Mario") .AddComponent <Transform>(new Transform(gameElementFactory.MakeComponent())) .AddComponent <Text>(new Text(gameElementFactory.MakeComponent(), "Terminus")) .AddComponent <Sprite>(new Sprite(gameElementFactory.MakeComponent(), "MarioSprite", 1)) as IGameObject; var mouseInputHandler = new MouseInputHandler(gameElementFactory.MakeComponent()); EventAggregator.SubsribeEvent(mouseInputHandler); var mouseWhatever = new MouseState().ScrollWheelValue; mouseInputHandler.AddEventListener(mouseState => true, (mouseState, dependencies) => { var camera = GameObjects.First(go => go.Name == "Camera").GetComponent <Camera>(); dependencies.GetComponent <Transform>().Position = new Vector3(camera.ScreenToWorld(mouseState.Position.ToVector2()), 0); dependencies.GetComponent <Text>().TextContent = "Current mouse pos in screen space \nx: " + mouseState.X + "\ny: " + mouseState.Y; dependencies.GetComponent <Text>().TextContent += "\nCurrent camera pos in world space \nx: " + camera.Dependencies.GetComponent <Transform>().Position.X + "\ny: " + camera.Dependencies.GetComponent <Transform>().Position.Y + "\nCurrent mouse pos in world space \nx: " + dependencies.GetComponent <Transform>().Position.X + "\ny: " + dependencies.GetComponent <Transform>().Position.Y; var scale = (mouseWhatever - mouseState.ScrollWheelValue) * 0.001f; if (Math.Abs(scale) > 0.001f) { mouseWhatever = mouseState.ScrollWheelValue; camera.Dependencies.GetComponent <Transform>().Scale += new Vector3(scale, scale, 0); } } ); gameObject.AddComponent <MouseInputHandler>(mouseInputHandler); GameObjects.Add(gameObject); gameObject = new BasicGameObject("InvertedMario") .AddComponent <Transform>(new Transform(gameElementFactory.MakeComponent(), new Vector3(50, 200, 0), new Vector3(0.5f, 1f, 1f))) .AddComponent <Sprite>(new Sprite(gameElementFactory.MakeComponent(), "InvertedMarioSprite")) as IGameObject; var keyboardInputHandler = new KeyboardInputHandler(gameElementFactory.MakeComponent()); EventAggregator.SubsribeEvent(keyboardInputHandler); keyboardInputHandler.AddEventListener( keyboardState => keyboardState.IsKeyDown(Keys.W), (keyboardState, components) => components.GetComponent <Transform>().Position += new Vector3(0, -2, 0)); keyboardInputHandler.AddEventListener( keyboardState => keyboardState.IsKeyDown(Keys.S), (keyboardState, components) => components.GetComponent <Transform>().Position += new Vector3(0, 2, 0)); keyboardInputHandler.AddEventListener( keyboardState => keyboardState.IsKeyDown(Keys.A), (keyboardState, components) => components.GetComponent <Transform>().Position += new Vector3(-2, 0, 0)); keyboardInputHandler.AddEventListener( keyboardState => keyboardState.IsKeyDown(Keys.D), (keyboardState, components) => components.GetComponent <Transform>().Position += new Vector3(2, 0, 0)); keyboardInputHandler.AddEventListener( keyboardState => keyboardState.IsKeyDown(Keys.Space), (keyboardState, components) => components.GetComponent <Transform>().Rotation *= Matrix.CreateFromYawPitchRoll(0, 0, MathHelper.PiOver4 / 10)); gameObject.AddComponent <KeyboardInputHandler>(keyboardInputHandler); gameObject.GetComponent <Transform>().Rotation = Matrix.CreateFromYawPitchRoll(0, 0, MathHelper.PiOver4); GameObjects.Add(gameObject); var invertedMario = gameObject; gameObject = new BasicGameObject("RedMario") .AddComponent <Transform>(new Transform(gameElementFactory.MakeComponent(), new Vector3(200, 0, 0))) .AddComponent <Sprite>(new Sprite(gameElementFactory.MakeComponent(), "RedMarioSprite", 2)) as IGameObject; //gameObject.AddComponent<Transform>(new Transform(new Vector3(100, 0, 0), new Vector3(1, 2, 1), Matrix.CreateFromYawPitchRoll(0, 0, -MathHelper.PiOver2)));gameObject.AddComponent<Transform>(new Transform_ Transform_ ()S)_ Transform_< AddComponent();addcompob GameObjects.Add(gameObject); gameObject.GetComponent <Transform>().SetTransformParent(invertedMario.GetComponent <Transform>()); }
void Start() { input = MouseInputHandler.instance; }
public void RegisterEvents(MouseInputHandler mouseInput) { mouseInput.OnMouseMove += OnMouseMove; mouseInput.OnMouseDown += OnMouseDown; mouseInput.OnMouseReleased += OnMouseReleased; }
private void Update() { MouseInputHandler?.Invoke(); KeyboardInputHandler?.Invoke(); }