Beispiel #1
0
    int GetInputTypeAsInt(inputType input)
    {
        switch (input)
        {
        case inputType.tap:
            return(0);

        case inputType.swipeLeft:
            return(1);

        case inputType.swipeRight:
            return(2);

        case inputType.swipeDown:
            return(3);

        case inputType.swipeUp:
            return(4);

        case inputType.up:
            return(5);

        default:
            return(0);
        }
    }
Beispiel #2
0
    inputType controlsUsed(inputType controls)
    {
        if (controls == inputType.ios)
        {
            print("iOS controls enabled");
        }
        else if (controls == inputType.osx)
        {
            print("OSX controls enabled");
        }
        else if (controls == inputType.pc)
        {
            print("PC controls enabled");
        }
        else if (controls == inputType.android)
        {
            print("Droid controls enabled");
        }
        else if (controls == inputType.iCade)
        {
            print("iCade controls enabled");
        }
        else if (controls == inputType.oculous)
        {
            print("Oculous controls enabled");
        }
        else
        {
        }

        return(controls);
    }
        public CreateWholeFrame(string Name, inputType type)
        {
            Label label = new Label()
            {
                Content  = Name,
                FontSize = 14,
                Padding  = new System.Windows.Thickness(2),
            };

            if (type == inputType.Password)
            {
                box = new PasswordBox()
                {
                    MaxHeight = 20, MaxLength = 150, MinWidth = 100
                };
                (box as PasswordBox).PasswordChar = '*';
            }
            else
            {
                box = new TextBox()
                {
                    MaxHeight = 20, MaxLength = 150, MinWidth = 100
                };
            }
            dock.AddChild(label, Dock.Left);
            dock.AddChild(box, Dock.Left);
            Content = dock;
            Margin  = new Thickness(5);
        }
    // Update is called once per frame
    void Update()
    {
        inputType input = inputFunc();

        // Debug.Log(input.X + ", " + input.Y);
        if (input.attack && !isAttacking)
        {
            StartCoroutine(currentAttack());
        }
        else if (input.block && !isAttacking)
        {
            StartCoroutine(block());
        }

        Vector3 direction = new Vector3(-input.Y, 0, -input.X);

        //Debug.Log(direction);
        if (direction != Vector3.zero && !changingmodes)
        {
            Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up);
            transform.rotation = rotation;
            rb.AddForce(Quaternion.Euler(0, -90, 0) * direction * speed * 10);
        }
        anim.SetFloat("Speed", rb.velocity.magnitude);
    }
Beispiel #5
0
    /*
     *      Func: AddAction
     *      Desc: Registers a function callback when an action (eg swipe) is performed on an object.
     *      Args:
     *              inpObj:     GameObject:	The object that we are registering the action for
     *              inpType:    inputType:	The action type we are watching for (tap/swipe/hold)
     *              enabled:    bool:		Whether or not the action is currently enabled
     *              outFunc:	Function:	The function to run when the action is performed
     *              outArgs:	Arguments:  The arguments to run with the function when an action is performed
     *              ... outArgs can continue indefinitely, as many args as you want can be given...
     *      Outs:
     *              Int: -1 on Error, >0 is list index in registeredActions, the public list registry
     *      Example Use(s):
     *
     *              //Add action to grid for tapping to build a building, pass in touch pos to addBuilding func, it starts enabled
     *              AddAction(this.gameobject, inputType.tap, true, this.addBuilding, touchEndPos)
     *
     *              //Add action to building for when user presses and holds on it, it starts disabled
     *              AddAction(this.GameObject, inputType.pressHold, false, this.showDetails)
     */
    public int AddAction(GameObject inpObj, inputType inpType, bool enabled, System.Action outFunc, object[] outArgs = null)
    {
        LogAction(string.Format("Adding '{0}' action to '{1}' with func '{3}' and args '{4}' in '{2}' state...", inpType, inpObj.name, enabled, outFunc.Method, outArgs));

        //Create action data for action
        actionData newActionData = new actionData();

        //Return -1 (fail) if addActionData fails, as this validates the input data
        if (!(newActionData.addActionData(inpObj, inpType, enabled, outFunc, outArgs)))
        {
            LogAction("Error adding actionData to newActionData var.");
            return(-1);
        }
        ;

        //Register the action in our action list
        if (actionCount >= 4094)
        {
            print("AddAction: Error: Action List Full!");
        }
        ;
        registeredActions[actionCount] = newActionData;
        actionCount++;

        //Return index in list to caller func
        return(actionCount - 1);
    }
Beispiel #6
0
        public InputMessageBox(inputType inputType = inputType.Default)
        {
            InitializeComponent();

            InputViewModel = new InputMessageBoxViewModel(inputType);

            DataContext = InputViewModel;
        }
    ///////////////////////////////////////////////////////////////////////////
    //                             INPUT TYPE METHODS                        //
    ///////////////////////////////////////////////////////////////////////////
    private inputType leftStick()
    {
        inputType toRet = new inputType();

        toRet.X      = Input.GetAxis("P1-H");
        toRet.Y      = Input.GetAxis("P1-V");
        toRet.attack = Input.GetAxis("P1-A") > 0.5;
        toRet.block  = Input.GetAxis("P1-B") == 1;
        return(toRet);
    }
    private inputType rightStick2()
    {
        inputType toRet = new inputType();

        toRet.X      = Input.GetAxis("P4-H");
        toRet.Y      = Input.GetAxis("P4-V");
        toRet.attack = Input.GetAxis("P4-A") > 0.5;
        toRet.block  = Input.GetAxis("P4-B") == 1;
        return(toRet);
    }
Beispiel #9
0
        public InputMessageBoxViewModel(inputType inputType = inputType.Default)
        {
            Properties = new InputMessageBoxProperties();

            OkButtonClickCommand = new OkButtonClickCommand(this);

            switch (inputType)
            {
            case inputType.Default:
            {
                Properties.ButtonWidth      = 75;
                Properties.CancelButtonText = "Cancelar";
                Properties.Height           = 108;
                Properties.Width            = 430;
                Properties.Message          = "Informe um valor...";
                Properties.OkButtonText     = "Ok";
                Properties.Title            = string.Format("InputMessageBox");
                break;
            }

            case inputType.AdicionarConteudo:
            {
                Properties.ButtonWidth       = 75;
                Properties.CancelButtonText  = "Cancelar";
                Properties.Height            = 108;
                Properties.Message           = "Digite o nome do conteudo a ser pesquisado...";
                Properties.ValidationMessage = "Digite o nome do conteudo a ser pesquisado.";
                Properties.OkButtonText      = "Pesquisar";
                Properties.Title             = string.Format("Pesquisar - {0}", Settings.Default.AppName);
                Properties.Width             = 430;
                break;
            }

            case inputType.SemResultados:
            {
                Properties.ButtonWidth       = 75;
                Properties.CancelButtonText  = "Cancelar";
                Properties.Height            = 108;
                Properties.Message           = "Não foram encontrados resultados para este nome, informe um novo nome.";
                Properties.ValidationMessage = "Digite o nome do conteudo a ser pesquisado.";
                Properties.OkButtonText      = "Pesquisar";
                Properties.Title             = string.Format("Pesquisar - {0}", Settings.Default.AppName);
                Properties.Width             = 430;
                break;
            }

            default:
                break;
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("This takes a single argument of the input PCB filename");
                return;
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("Could not find input file: " + args[0]);
                return;
            }


            if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "translate.csv")))
            {
                Console.WriteLine("Could not find translate.csv file, make sure it's in the executing directory.");
                return;
            }

            inputFileName = args[0];
            var inputFileExtention = Path.GetExtension(inputFileName).ToUpper();

            if (inputFileExtention == ".CSPCBDOC")
            {
                inputFileType = inputType.CS;
            }
            else if (inputFileExtention == ".PCBDOC")
            {
                inputFileType = inputType.AD;
            }
            else
            {
                Console.WriteLine("Unknown input file extention");
                return;
            }

            ReadTranslationList();

            PCBDOC_InputFile  = new CompoundFile(inputFileName, CFSUpdateMode.ReadOnly, CFSConfiguration.Default);
            PCBDOC_OutputFile = new CompoundFile();

            LoadNewPCBFile();
            PCBDOC_OutputFile.Save(GetNewFileName());


            Console.WriteLine("Translation complete.");
        }
Beispiel #11
0
        //Sets rotation angles based on input type
        protected void CheckRotation(inputType inputControl, ref Vector3 eulerAngles)
        {
            switch (inputControl)
            {
            case inputType.WASD:
                eulerAngles.x += -Input.GetAxis("Mouse Y") * 359f * cursorSensitivity;
                eulerAngles.y += Input.GetAxis("Mouse X") * 359f * cursorSensitivity;
                break;

            case inputType.Xbox:
                eulerAngles.x += Input.GetAxis("XRightVertical") * 359f * cursorSensitivity;
                eulerAngles.y += Input.GetAxis("XRightHorizontal") * 359f * cursorSensitivity;
                break;
            }
        }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        tipo = (inputType)dropMenu.GetComponent <Dropdown>().value;

        switch (tipo)
        {
        case inputType.TipoR:

            field1PH.GetComponentInChildren <Text>().text = "rd...";
            field2PH.GetComponentInChildren <Text>().text = "rt...";
            field3PH.GetComponentInChildren <Text>().text = "rs...";
            break;

        case inputType.TipoI:

            field1PH.GetComponentInChildren <Text>().text = "rd...";
            field2PH.GetComponentInChildren <Text>().text = "rt...";
            field3PH.GetComponentInChildren <Text>().text = "Imm...";
            break;

        case inputType.LW:

            field1PH.GetComponentInChildren <Text>().text = "rd...";
            field2PH.GetComponentInChildren <Text>().text = "Imm...";
            field3PH.GetComponentInChildren <Text>().text = "rs...";
            break;

        case inputType.SW:

            field1PH.GetComponentInChildren <Text>().text = "rd...";
            field2PH.GetComponentInChildren <Text>().text = "Imm...";
            field3PH.GetComponentInChildren <Text>().text = "rs...";
            break;

        case inputType.nop:

            field1PH.GetComponentInChildren <Text>().text = "null";
            field2PH.GetComponentInChildren <Text>().text = "null";
            field3PH.GetComponentInChildren <Text>().text = "null";
            break;
        }
    }
Beispiel #13
0
    public IncomingObject(int typeOfInput, GameObject newPrefab, Sprite mainInteractionSprite, float start, float end, float arriveBeat, float beatsHeld, int indexNum)
    {
//		expected = GetInputType( typeOfInput );

        inputRangeIsForHead = true;

        startInput = start;
        endInput   = end;

        arrivalBeat = arriveBeat;

        beatsToHold = beatsHeld;

        endHold = beatsHeld + arrivalBeat;

        prefab     = newPrefab;
        mainSprite = mainInteractionSprite;

        index = indexNum;

        isBeingHeld = false;

        if (beatsToHold > 1)
        {
            held = true;

            firstInput  = inputType.tap;
            secondInput = GetInputType(typeOfInput);

            if (secondInput == inputType.tap)
            {
                secondInput = inputType.up;
            }
        }
        else
        {
            held       = false;
            firstInput = GetInputType(typeOfInput);
        }

        expected = firstInput;
    }
Beispiel #14
0
        //Sets direction based on input type
        protected void CheckMovement(inputType inputControl, ref Vector3 deltaPosition)
        {
            switch (inputControl)
            {
            case inputType.WASD:
                if (Input.GetKey(forwardInput))
                {
                    isMoving       = true;
                    deltaPosition += transform.forward;
                }
                if (Input.GetKey(backwardInput))
                {
                    isMoving       = true;
                    deltaPosition += -transform.forward;
                }
                if (Input.GetKey(rightInput))
                {
                    isMoving       = true;
                    deltaPosition += transform.right;
                }
                if (Input.GetKey(leftInput))
                {
                    isMoving       = true;
                    deltaPosition += -transform.right;
                }
                break;

            case inputType.Xbox:

                float moveHorizontal = Input.GetAxis("Horizontal");
                float moveVertical   = Input.GetAxis("Vertical");
                if (Mathf.Abs(moveHorizontal) > 0 || Mathf.Abs(moveVertical) > 0)
                {
                    isMoving       = true;
                    deltaPosition += new Vector3(moveHorizontal, 0, moveVertical);
                }
                break;
            }
        }
Beispiel #15
0
        //Validated values constructor-ish method
        public bool addActionData(GameObject iObj, inputType iInpType, bool iEnabled, System.Action iFunc, object[] iFuncArgs = null)
        {
            //Validate data
            if (iObj == null)
            {
                return(false);
            }
            ;
            if (((int)iInpType) > 5 || ((int)iInpType) < 0)
            {
                return(false);
            }
            ;
            if (iFunc == null)
            {
                return(false);
            }
            ;

            //Set validated values
            obj = iObj; inpType = iInpType; enabled = iEnabled; func = iFunc; funcArgs = iFuncArgs;
            return(true);
        }
Beispiel #16
0
 public inputObject(inputType type, KeyCode refKey)
 {
     iType        = type;
     referenceKey = refKey;
 }
Beispiel #17
0
 public inputObject(inputType type, GameObject refObj)
 {
     iType           = type;
     referenceObject = refObj;
 }
Beispiel #18
0
    void EndOfInput()
    {
        float endBeat = metronome.currentPartialBeats;

        float beatsHeld = endBeat - beatOfInput;

        inputType swipe = DetermineSwipe(Input.mousePosition);
//		Debug.Log (" swipe : " + swipe);
        int interactionType = GetInputTypeAsInt(swipe);

        if (readPlayerInput)
        {
            //set sprite
            int    swipeInt  = GetInputTypeAsInt(swipe);
            Sprite newSprite = instantiate.GetSprite(swipeInt);
            //destroy user created object
            ShowFeedback feedbackScript = (ShowFeedback )userCreatedObject.GetComponent(typeof(ShowFeedback));
            feedbackScript.SetSprite(newSprite);
            feedbackScript.TimeDestruction();


            float normalizedEndBeat   = GetClosestHalfBeat(endBeat);
            float normalizedStartBeat = GetClosestHalfBeat(beatOfInput);

            string saveData = "";
            saveData += normalizedStartBeat + ",";
            saveData += normalizedEndBeat + ",";
            saveData += interactionType.ToString() + ",";

            //if previous input does not overlap with current input
            if (normalizedStartBeat > previousEndBeat)
            {
                //record data
                GameData.dataControl.SavePerformanceStats(saveData);
                previousEndBeat = normalizedEndBeat;
            }
        }
        if (!readPlayerInput)
        {
            Debug.Log(" received : " + swipe + ", expected : " + currentObject.expected);

            if (WithinInputRange())
            {
//				Debug.Log (" received : " + swipe + ", expected : " + currentObject.expected );
                if (currentObject.expected == swipe)
                {
                    if (swipe != inputType.tap && swipe != inputType.up)
                    {
                        Debug.Log(swipe + " at " + metronome.currentPartialBeats);
                    }

                    Debug.Log("ATTEMPTING TO DESTROY");
                    currentObject.feedbackScript.ShowSuccess();
                }

                else if (currentObject.expected == inputType.tap && !currentObject.isBeingHeld)

                {
                    currentObject.feedbackScript.ShowSuccess();
                }
            }
            //if held object is let go early
            else if (currentObject.held && currentObject.isBeingHeld)
            {
                currentObject.feedbackScript.UnsuccessfulHoldContinuesToDestruction();
            }

            currentObject.isBeingHeld = false;
        }
    }
Beispiel #19
0
		public inputObject( inputType type, GameObject refObj) {
			iType = type;
			referenceObject = refObj;
		}		
Beispiel #20
0
 /// <summary>
 /// Constructor
 /// Args:
 ///     - inputType _type : assigns the type of the slot
 ///     - slotType _subtype : assigns the subtype of the slot
 /// </summary>
 public Slot(inputType _type, slotType _subtype)
 {
     type    = _type;
     subtype = _subtype;
 }
Beispiel #21
0
 //Default constructor, no data validation.
 public actionData(GameObject iObj, inputType iInpType, bool iEnabled, System.Action iFunc, object[] iFuncArgs = null)
 {
     //Set unvalidated values
     obj = iObj; inpType = iInpType; enabled = iEnabled; func = iFunc; funcArgs = iFuncArgs;
 }
Beispiel #22
0
 public RegularLanguage(inputType type)
 {
     this.type = type;
 }
Beispiel #23
0
 public RegularLanguage(string input, inputType type)
 {
     this.input = input;
     this.type  = type;
 }
Beispiel #24
0
		public inputObject( inputType type, KeyCode refKey) {
			iType = type;
			referenceKey = refKey;
		}	
    //		Gets Touch Type (Tap, Swipe(Dir), HeldPress)
    //	0 = Tap, 1 = Held Press, 2 = LeftSwipe, 3 = Right Swipe, 4 = UpSwipe, 5 = DownSwipe
    private int GetTouchType(Vector2 startPos, Vector2 endPos, float holdTime)
    {
        //Variables for function
        inputType resultingType = inputType.tap;                //Value to return to caller
        float     minSwipeDist  = 30f;                          //Minimum distance in pixelCoords for a swipe to be counted
        float     minSwipeTime  = 0.1f;                         //Minimum time a touch must be held for a swipe to count
        float     minHoldTime   = 0.75f;                        //Minimum time (s) a touch must be held for to be considered a held press

        //Check for tap
        if (holdTime < minSwipeTime)
        {
            resultingType = inputType.tap;
            return((int)resultingType);
        }
        ;

        //Check for held press
        if (holdTime >= minHoldTime)
        {
            resultingType = inputType.pressHold;
            return((int)resultingType);
        }
        ;

        //	Check for swipe
        if (holdTime >= minSwipeTime && holdTime < minHoldTime)
        {
            // Check for Horizontal Swipe Distance
            bool  xDirRight = false;                    //Bool for L/R
            float xDiff     = 0.0f;                     //Swipe Distance
            if (startPos.x >= endPos.x)
            {
                xDirRight = false;
                xDiff     = startPos.x - endPos.x;
            }
            else
            {
                xDirRight = true;
                xDiff     = endPos.x - startPos.x;
            };

            // Check for Vertical Swipe Distance
            bool  yDirUp = false;                       //Bool for Up/Down
            float yDiff  = 0.0f;                        //Swipe Distance
            if (startPos.y >= endPos.y)
            {
                yDirUp = false;
                yDiff  = startPos.y - endPos.y;
            }
            else
            {
                yDirUp = true;
                yDiff  = endPos.y - startPos.y;
            };

            //	Check if either were big enough to be considered a swipe
            // Check left/right first, then up/down, a swipe cannot be both, so if & else if
            if (xDiff >= minSwipeDist)
            {
                //Set swipe left/right values
                if (xDirRight)
                {
                    resultingType = inputType.swipeRight;
                }
                else
                {
                    resultingType = inputType.swipeLeft;
                };
            }
            else if (yDiff >= minSwipeDist)
            {
                //Set swipe uo/down values
                if (yDirUp)
                {
                    resultingType = inputType.swipeUp;
                }
                else
                {
                    resultingType = inputType.swipeDown;
                };
            }
            else
            {
                //Is not a swipe, or a touchHoldPress, just a tap, so set type
                resultingType = inputType.tap;
            };
        }
        ;

        //Return the type
        return((int)resultingType);
    }