Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityCoder.Utils;
  5.  
  6. namespace GameOver.HouseEditor
  7. {
  8.     public enum ETypeInput
  9.     {
  10.         Mouse,
  11.         Keyboard,
  12.         GamePad
  13.     }
  14.  
  15.     public class InputManager : Singleton<InputManager>
  16.     {
  17.         private delegate float InputHandler();
  18.         private InputHandler _horizontal;
  19.         private InputHandler _vertical;
  20.         private InputHandler _zoom;
  21.  
  22.         private ETypeInput _typeInput;
  23.         public ETypeInput TypeInput
  24.         {
  25.             get { return _typeInput; }
  26.             set {SetTypeInput(value);}
  27.         }
  28.  
  29.         public float Horizontal()
  30.         {
  31.             return _horizontal();
  32.         }
  33.  
  34.         public float Vertical()
  35.         {
  36.             return _vertical();
  37.         }
  38.  
  39.         public float Zoom()
  40.         {
  41.             return _zoom();
  42.         }
  43.  
  44.         private void Start()
  45.         {
  46.             SetTypeInput(ETypeInput.Mouse);
  47.         }
  48.  
  49.         private void SetTypeInput(ETypeInput typeInput)
  50.         {
  51.             _typeInput = typeInput;
  52.             switch(_typeInput)
  53.             {
  54.                 case ETypeInput.Keyboard:
  55.                     break;
  56.                 case ETypeInput.Mouse:
  57.                     _horizontal = HorizontalMouse;
  58.                     _vertical = VerticalMouse;
  59.                     _zoom = ZoomMouse;
  60.                     break;
  61.                 case ETypeInput.GamePad:
  62.                     break;
  63.             }
  64.         }
  65.  
  66.  
  67.         private float HorizontalMouse()
  68.         {
  69.             return Input.GetAxisRaw("Mouse X");
  70.         }
  71.         private float VerticalMouse()
  72.         {
  73.             return Input.GetAxisRaw("Mouse Y");
  74.         }
  75.         private float ZoomMouse()
  76.         {
  77.             return Input.GetAxisRaw("Horizontal");
  78.         }
  79.  
  80.  
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement