Advertisement
diegographics

Untitled

Mar 10th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.83 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4.  
  5. [System.Serializable]
  6. public class Buttons
  7. {
  8.     public string ButtonName;
  9.     public int ButtonID;
  10.     public ButtonType ButtonAction;
  11.     [System.Serializable]
  12.     public enum ButtonType
  13.     {
  14.         Hold,
  15.         Up,
  16.         Down
  17.     }
  18.     public Buttons(string name, int id)
  19.     {
  20.         ButtonName = name;
  21.         ButtonID = id;
  22.     }
  23.     public Buttons()
  24.     {
  25.     }
  26. }
  27.  
  28. public class ControllerDemo : MonoBehaviour {
  29.    
  30.     public Buttons[] xBox360;
  31.  
  32.     // Use this for initialization
  33.     void Start ()
  34.     {
  35.  
  36.     }
  37.  
  38.     void Update () {
  39.  
  40.  
  41.  
  42.         // ---AXIS---
  43.         // Right Trigger (RT) Left Trigger (LT)
  44.         if (Input.GetAxis("TriggerLeft") != 0)
  45.         {
  46.             Debug.Log("Left: " + Input.GetAxis("TriggerLeft"));
  47.         }
  48.         if (Input.GetAxis("TriggerRight") != 0)
  49.         {
  50.             Debug.Log("Right:" + Input.GetAxis("TriggerRight"));
  51.         }
  52.        
  53.         //Left Stick
  54.         if (Input.GetAxis("Horizontal") != 0)
  55.         {
  56.             Debug.Log("Horizontal: " + Input.GetAxis("Horizontal"));
  57.         }
  58.         if (Input.GetAxis("Vertical") != 0)
  59.         {
  60.             Debug.Log("Vertical: " + Input.GetAxis("Vertical"));
  61.         }
  62.         if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) // Both
  63.         {
  64.  
  65.         }
  66.  
  67.         // Right Stick
  68.         if (Input.GetAxis("Horizontal2") != 0)
  69.         {
  70.             Debug.Log("Horizontal2: " + Input.GetAxis("Horizontal2"));
  71.         }
  72.         if (Input.GetAxis("Vertical2") != 0)
  73.         {
  74.             Debug.Log("Vertical2: " + Input.GetAxis("Vertical2"));
  75.         }
  76.         if (Input.GetAxis("Horizontal2") != 0 || Input.GetAxis("Vertical2") != 0) // Both
  77.         {
  78.  
  79.         }
  80.  
  81.         // D-Pad
  82.         if (Input.GetAxis("Horizontal3") != 0)
  83.         {
  84.             Debug.Log("Horizontal3: " + Input.GetAxis("Horizontal3"));
  85.         }
  86.         if (Input.GetAxis("Vertical3") != 0)
  87.         {
  88.             Debug.Log("Vertical3: " + Input.GetAxis("Vertical3"));
  89.         }
  90.         if (Input.GetAxis("Horizontal3") != 0 || Input.GetAxis("Vertical3") != 0) // Both
  91.         {
  92.  
  93.         }
  94.  
  95.         //---Buttons---
  96.  
  97.         // Button: A
  98.         if (Input.GetButton("A"))
  99.         {
  100.            
  101.         }
  102.         if (Input.GetButtonDown("A"))
  103.         {
  104.  
  105.         }
  106.         if (Input.GetButtonUp("A"))
  107.         {
  108.  
  109.         }
  110.  
  111.         // Button: B
  112.         if (Input.GetButton("B"))
  113.         {
  114.            
  115.         }
  116.         if (Input.GetButtonDown("B"))
  117.         {
  118.            
  119.         }
  120.         if (Input.GetButtonUp("B"))
  121.         {
  122.            
  123.         }
  124.  
  125.         // Button: X
  126.         if (Input.GetButton("X"))
  127.         {
  128.            
  129.         }
  130.         if (Input.GetButtonDown("X"))
  131.         {
  132.            
  133.         }
  134.         if (Input.GetButtonUp("X"))
  135.         {
  136.            
  137.         }
  138.  
  139.         // Button: Y
  140.         if (Input.GetButton("Y"))
  141.         {
  142.            
  143.         }
  144.         if (Input.GetButtonDown("Y"))
  145.         {
  146.            
  147.         }
  148.         if (Input.GetButtonUp("Y"))
  149.         {
  150.            
  151.         }
  152.  
  153.         // Button: LB
  154.         if (Input.GetButton("LB"))
  155.         {
  156.            
  157.         }
  158.         if (Input.GetButtonDown("LB"))
  159.         {
  160.            
  161.         }
  162.         if (Input.GetButtonUp("LB"))
  163.         {
  164.            
  165.         }
  166.  
  167.         // Button: RB
  168.         if (Input.GetButton("RB"))
  169.         {
  170.            
  171.         }
  172.         if (Input.GetButtonDown("RB"))
  173.         {
  174.            
  175.         }
  176.         if (Input.GetButtonUp("RB"))
  177.         {
  178.            
  179.         }
  180.  
  181.         // Button: LAP
  182.         if (Input.GetButton("LAP"))
  183.         {
  184.            
  185.         }
  186.         if (Input.GetButtonDown("LAP"))
  187.         {
  188.            
  189.         }
  190.         if (Input.GetButtonUp("LAP"))
  191.         {
  192.            
  193.         }
  194.  
  195.         // Button: RAP
  196.         if (Input.GetButton("RAP"))
  197.         {
  198.            
  199.         }
  200.         if (Input.GetButtonDown("RAP"))
  201.         {
  202.            
  203.         }
  204.         if (Input.GetButtonUp("RAP"))
  205.         {
  206.            
  207.         }
  208.  
  209.         // Button: Back
  210.         if (Input.GetButton("Back"))
  211.         {
  212.            
  213.         }
  214.         if (Input.GetButtonDown("Back"))
  215.         {
  216.            
  217.         }
  218.         if (Input.GetButtonUp("Back"))
  219.         {
  220.            
  221.         }
  222.  
  223.         // Button: Start
  224.         if (Input.GetButton("Start"))
  225.         {
  226.            
  227.         }
  228.         if (Input.GetButtonDown("Start"))
  229.         {
  230.            
  231.         }
  232.         if (Input.GetButtonUp("Start"))
  233.         {
  234.            
  235.         }
  236.     }
  237.  
  238.  
  239.  
  240.     // Button Constructor
  241.  
  242.     void pushButton(){
  243.     for(int i=0; i < xBox360.Length; i++)
  244.         {
  245.             if (xBox360[i].ButtonName == "A")
  246.             {
  247.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  248.                 {
  249.  
  250.                 }
  251.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  252.                 {
  253.  
  254.                 }
  255.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  256.                 {
  257.  
  258.                 }
  259.             }
  260.  
  261.             if (xBox360[i].ButtonName == "B")
  262.             {
  263.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  264.                 {
  265.  
  266.                 }
  267.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  268.                 {
  269.  
  270.                 }
  271.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  272.                 {
  273.  
  274.                 }
  275.             }
  276.  
  277.             if (xBox360[i].ButtonName == "X")
  278.             {
  279.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  280.                 {
  281.  
  282.                 }
  283.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  284.                 {
  285.  
  286.                 }
  287.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  288.                 {
  289.  
  290.                 }
  291.             }
  292.  
  293.             if (xBox360[i].ButtonName == "Y")
  294.             {
  295.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  296.                 {
  297.  
  298.                 }
  299.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  300.                 {
  301.  
  302.                 }
  303.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  304.                 {
  305.  
  306.                 }
  307.             }
  308.  
  309.             if (xBox360[i].ButtonName == "LB")
  310.             {
  311.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  312.                 {
  313.  
  314.                 }
  315.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  316.                 {
  317.  
  318.                 }
  319.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  320.                 {
  321.  
  322.                 }
  323.             }
  324.  
  325.             if (xBox360[i].ButtonName == "RB")
  326.             {
  327.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  328.                 {
  329.  
  330.                 }
  331.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  332.                 {
  333.  
  334.                 }
  335.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  336.                 {
  337.  
  338.                 }
  339.             }
  340.  
  341.             if (xBox360[i].ButtonName == "Start")
  342.             {
  343.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  344.                 {
  345.  
  346.                 }
  347.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  348.                 {
  349.  
  350.                 }
  351.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  352.                 {
  353.  
  354.                 }
  355.             }
  356.  
  357.             if (xBox360[i].ButtonName == "Back")
  358.             {
  359.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
  360.                 {
  361.  
  362.                 }
  363.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
  364.                 {
  365.  
  366.                 }
  367.                 if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
  368.                 {
  369.  
  370.                 }
  371.             }
  372.            
  373.         }
  374.     }
  375.  
  376.  
  377.     // Helpers
  378.     public static float floatToDegree(float v, float h)
  379.     {
  380.         return Mathf.Atan2(v, h) * 180 / Mathf.PI;
  381.     }
  382.  
  383.     public static int getDegreeCircle(float winkel, int n)
  384.     {
  385.         if (winkel < 0) winkel += 360;
  386.         float verschiebung = 360 / (float)(2 * n);
  387.         for (int i = 0; i < n; i++)
  388.         {
  389.             float start_winkel = 360 * i / (float)n;
  390.             float end_winkel = 360 * (i + 1) / (float)n;
  391.             //Verschiebung
  392.             start_winkel -= verschiebung;
  393.             end_winkel -= verschiebung;
  394.             if (start_winkel < 0) start_winkel += 360;
  395.             if (end_winkel < 0) end_winkel += 360;
  396.             if (winkel < end_winkel && winkel >= start_winkel)
  397.                 return i;
  398.         }
  399.         return 0;
  400.     }
  401. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement