public void AddError(GameObject errorObject)
    {
        AppError appError    = null;
        AppError appNewError = GetNewAppError(errorObject);
        int      position    = FindPositionOfGameObjectError(errorObject);

        if (position == -1)
        {
            appError = appNewError;
            errors.Add(appError);
            if (errors.Count == 1)
            {
                if (OnErrorChanged != null)
                {
                    OnErrorChanged.Invoke(appError.errorName);
                }
            }
        }
        else
        {
            appError = errors[position];
            bool updated = UpdateError(appError, appNewError);
            if (updated && position == 0)
            {
                if (OnErrorChanged != null)
                {
                    OnErrorChanged.Invoke(appError.errorName);
                }
            }
        }
        Error = true;
    }
Beispiel #2
0
    public void CallEvents()
    {
        switch (m_type.ToLower())
        {
        case "int":
        case "integer":
            m_intEvent.Invoke(GetIntValue()); break;

        case "float":
        case "real":
            m_floatEvent.Invoke(GetFloatValue()); break;

        case "string":
        case "text":
            m_stringEvent.Invoke(GetStringValue()); break;

        case "bool":
        case "boolean":
            m_boolEvent.Invoke(GetBoolValue()); break;

        default: break;
        }

        m_optionEvent.Invoke(this);
    }
Beispiel #3
0
        private void DeeplinkOnReceived(string deeplink)
        {
            Debug.Log("Received Deeplink: " + deeplink);
            var unEscapedDeeplink = WWW.UnEscapeURL(deeplink);

            deepLinkReceived.Invoke(unEscapedDeeplink);
        }
Beispiel #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == Constants.TagPlayer)
     {
         OnPlayerEnter.Invoke(TextToDisplay);
     }
 }
Beispiel #5
0
    void EndMovement()
    {
        Debug.Log("End Movement");
        isMoving = false;

        //Create the gesture from the position list
        Point[] pointArray = new Point[positionsList.Count];
        for (int i = 0; i < positionsList.Count; i++)
        {
            Vector2 screenPoint = Camera.main.WorldToScreenPoint(positionsList[i]);
            pointArray[i] = new Point(screenPoint.x, screenPoint.y, 0);
        }

        Gesture newGesture = new Gesture(pointArray);

        if (creationMode)
        {
            newGesture.Name = newGestureName;
            traningSet.Add(newGesture);

            string fileName = Application.persistentDataPath + "/" + newGestureName + ".xml";
            GestureIO.WriteGesture(pointArray, newGestureName, fileName);
        }
        else
        {
            Result result = PointCloudRecognizer.Classify(newGesture, traningSet.ToArray());
            Debug.Log(result.GestureClass + result.Score);

            if (result.Score > recognitionThreshold)
            {
                OnRecognized.Invoke(result.GestureClass);
            }
        }
    }
Beispiel #6
0
 private void Update()
 {
     if (_inputField.isFocused && Input.GetKeyDown("return"))
     {
         _onSubmit.Invoke(_inputField.text);
     }
 }
    //fonction qui termine le mouvement et essaie de reconnaître ou créer le glyphe donné par le joueur
    void endMove()
    {
        //on termine le mouvement
        inMotion = false;

        //creer un tableau qui a la grandeur du tableau de points créé en start+update
        Point[] pointsArray = new Point[positionList.Count];

        //pour chaque point de la liste de positions
        for (int i = 0; i < positionList.Count; i++)
        {
            //le point dans l'ecran devient la position en i traduite du monde vers l'ecran
            Vector2 screenPoint = Camera.main.WorldToScreenPoint(positionList[i]);

            //on ne veut garder que le x et y de ce point pour la reconnaissance
            pointsArray[i] = new Point(screenPoint.x, screenPoint.y, 0);
        }

        //le mouvement donné = aux points décrits dans la boucle ci-haut
        Gesture newGesture = new Gesture(pointsArray);

        //si on est en mode de creation de glyphe
        if (creationMode)
        {
            //le nom du glyph devient celui choisi dans la console
            newGesture.Name = newGestureName;
            //rajouter ce glyph à la liste de glyphes connus
            trainingSet.Add(newGesture);

            //créer un fichier xml qui aura le nom indiqué et qui contiendra la liste de points
            string fileName = Application.dataPath + "/gestures/" + newGestureName + ".xml";
            GestureIO.WriteGesture(pointsArray, newGestureName, fileName);
        }

        //si on n'est pas en mode creatif
        else
        {
            //besoin de >1 pour faire le calcul, sinon crash (on peut pas calculer le chemin entre 2 points s'il n'y a pas 2 points!)
            if (pointsArray.Length > 1)
            {
                //Provient du code PDollar
                //fonction Classify de PointCloudRecognizer -> retourne la class du glyphe qui match le plus entre la gesture du joueur et celles dans la liste
                //transferer la liste en array avec toArray()
                Result result = PointCloudRecognizer.Classify(newGesture, trainingSet.ToArray());

                //si le score de notre resultat est acceptable
                if (result.Score > recognitionThreshold)
                {
                    //invoquer la fonction implémentée dans l'inspecteur de Unity
                    OnRecognized.Invoke(result.GestureClass);
                }
            }
        }

        //detruit le tracé apres 3s
        Destroy(trailClone, 3f);
        //enlève le parent du tracé
        trailClone.transform.parent = null;
    }
Beispiel #8
0
        private void OnLanguageChanged(int langId)
        {
            string locText = localizedText.GetLocalizedText((SystemLanguage)langId);

            if (label != null)
            {
                label.text = locText;
            }
            onLocalizedText.Invoke(locText);
        }
Beispiel #9
0
        public void SetCount(int value)
        {
            _init = true;

            if (value != _count)
            {
                _count = value;
                if (_count > maxValue)
                {
                    _count = minValue;
                }
                if (_count < minValue)
                {
                    _count = maxValue;
                }

                onCounterStringChanged.Invoke(_count.ToString());
                onCountChanged.Invoke(_count);
            }
        }
Beispiel #10
0
    public void UpdateTextAndSize()
    {
        var rgbColour = new Color(KWData.colorR, KWData.colorG, KWData.colorB);
        var hexColour = ColorUtility.ToHtmlStringRGB(rgbColour);

        // Add the Sprite to the display if the index is higher than 0
        textfield.text  = KWData.spriteIndex > 0 ? "<color=#" + hexColour + ">" + "<sprite name=\"Custom_" + KWData.spriteIndex + "\" tint></color>" : "";
        textfield.text += (string.IsNullOrWhiteSpace(KWData.label)) ? "custom" : KWData.label;

        // Update keyword format full text
        textUpdate.Invoke(textfield.text);
    }
Beispiel #11
0
        protected string ExecuteCommandInternal(string commandString)
        {
            // notify any listeners that a command was entered
            OnCommandEntered.Invoke(commandString);

            // add the new command to the history and ensure the length remains below the maximum
            CommandHistory.Add(commandString);
            while (CommandHistory.Count > MaxHistory)
            {
                CommandHistory.RemoveAt(0);
            }

            // update the history index
            HistoryIndex = CommandHistory.Count - 1;

            // tokenise the command string
            List <string> tokens = TokeniseString(commandString);

            // early out if there was no data
            if (tokens.Count == 0)
            {
                return("[Error] Tried to execute a blank command.");
            }

            // extract the command
            string commandId = tokens[0].ToLower();

            tokens.RemoveAt(0);

            // does the command exist?
            if (AlternateCommandNames.ContainsKey(commandId))
            {
                CommandInterface command = Commands[AlternateCommandNames[commandId]];

                if (command.IsAvailable)
                {
                    return(command.Execute(tokens));
                }
            }

            return("[Error] The command \'" + commandId + "\' could not be found.");
        }
Beispiel #12
0
    public void SendContent()
    {
        switch (contentType)
        {
        case ParseTarget.Int:
            IntEvent.Invoke(int.Parse(buttonText.text));
            break;

        case ParseTarget.Float:
            FloatEvent.Invoke(float.Parse(buttonText.text));
            break;

        case ParseTarget.String:
            StringEvent.Invoke(buttonText.text);
            break;

        default:
            break;
        }
    }
Beispiel #13
0
        private void OnLoginFailure(PlayFabError error)
        {
            isLoggedIn = false;
            error.GenerateErrorReport();
            string errorMessage = string.Empty;

            switch (error.Error)
            {
            // Recognize and handle the error
            case PlayFabErrorCode.InvalidTitleId:
                // Handle invalid title id error
                errorMessage = "User already logged in";
                break;

            case PlayFabErrorCode.AccountNotFound:
                // Handle account not found error
                errorMessage = "Email address not found, Do you need to register for an account?";
                break;

            case PlayFabErrorCode.InvalidEmailOrPassword:
                // Handle invalid email or password error
                errorMessage = "Email address or Password is incorrect";
                break;

            case PlayFabErrorCode.RequestViewConstraintParamsNotAllowed:
                // Handle not allowed view params error
                errorMessage = "Invalid login parameters";
                break;

            default:
                // Handle unexpected error
                break;
            }
            // Show error message
            onLoginFail.Invoke(errorMessage);
            if (onSOLoginFail != null)
            {
                onSOLoginFail.Raise(errorMessage);
            }
        }
 public void Dispatch(string stringValue)
 {
     m_stringEvent.Invoke(stringValue);
 }
 public void OnEventRaised(string message)
 {
     response.Invoke(message);
 }
Beispiel #16
0
 private void DeeplinkOnReceived(string arg0)
 {
     Debug.Log("Received Deeplink: " + arg0);
     deepLinkReceived.Invoke(arg0);
 }
Beispiel #17
0
 protected override void Callback(string value)
 {
     _response.Invoke(value);
 }
Beispiel #18
0
 public virtual void OnEventRaised(string s1)
 {
     Response.Invoke(s1);
 }
 public void OnEventRaised(string payload)
 {
     response.Invoke(payload);
 }
 private void SceneLoaderScriptableOnLoadPercentage(float obj)
 {
     OnPercentage.Invoke(obj * multiplier);
     OnPercentageFormat.Invoke(string.Format(percentageFormat, obj * multiplier));
 }
Beispiel #21
0
    void UpdateTick(TrackedDevicePose_t[] devicePoses)
    {
        //If this is the first measurement, find and initialize the controller references
        if (CurMeasurementCount == 0)
        {
            // Get Controller ids for left/right hand
            var leftId = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
            if (leftId == OpenVR.k_unTrackedDeviceIndexInvalid)
            {
                FloorFixStatus.Invoke("No left controller found.");
                FloorFixEnded.Invoke();
                CurState = State.Inactive;
                return;
            }
            var rightId = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.RightHand);
            if (rightId == OpenVR.k_unTrackedDeviceIndexInvalid)
            {
                FloorFixStatus.Invoke("No right controller found.");
                FloorFixEnded.Invoke();
                CurState = State.Inactive;
                return;
            }
            // Get poses
            TrackedDevicePose_t leftPose  = devicePoses[leftId];
            TrackedDevicePose_t rightPose = devicePoses[rightId];
            if (!leftPose.bPoseIsValid || !leftPose.bDeviceIsConnected || leftPose.eTrackingResult != ETrackingResult.Running_OK)
            {
                FloorFixStatus.Invoke("Left controller tracking problems.");
                FloorFixEnded.Invoke();
                CurState = State.Inactive;
                return;
            }
            else if (!rightPose.bPoseIsValid || !rightPose.bDeviceIsConnected || rightPose.eTrackingResult != ETrackingResult.Running_OK)
            {
                FloorFixStatus.Invoke("Right controller tracking problems.");
                FloorFixEnded.Invoke();
                CurState = State.Inactive;
                return;
            }
            else
            {
                // The controller with the lowest y-pos is the floor fix reference
                if (leftPose.mDeviceToAbsoluteTracking.m7 < rightPose.mDeviceToAbsoluteTracking.m7)
                {
                    ReferenceController = leftId;
                }
                else
                {
                    ReferenceController = rightId;
                }

                var m = devicePoses[ReferenceController].mDeviceToAbsoluteTracking;
                TempOffsetY = (double)m.m7;

                TempRoll = Math.Atan2(m.m4, m.m5);
                //Causes if to go to else statement on the next run
                CurMeasurementCount = 1;
            }
        }
        else //Not the first measurement. Start Calculating the offset
        {
            CurMeasurementCount++;
            var m = devicePoses[ReferenceController].mDeviceToAbsoluteTracking;

            double rollDiff = Math.Atan2(m.m4, m.m5) - TempRoll;
            if (rollDiff > Math.PI)
            {
                rollDiff -= 2.0 * Math.PI;
            }
            else if (rollDiff < -Math.PI)
            {
                rollDiff += 2.0 * Math.PI;
            }
            TempRoll += rollDiff / (double)CurMeasurementCount;
            if (TempRoll > Math.PI)
            {
                TempRoll -= 2.0 * Math.PI;
            }
            else if (TempRoll < -Math.PI)
            {
                TempRoll += 2.0 * Math.PI;
            }

            if (CurMeasurementCount >= 25)
            {
                float FloorOffset; //The Calculated Floor Offset
                if (Math.Abs(TempRoll) <= Math.PI / 2)
                {
                    FloorOffset = (float)(TempOffsetY - ControllerUpOffsetCorrection);
                }
                else
                {
                    FloorOffset = (float)(TempOffsetY - ControllerDownOffsetCorrection);
                }



                AddOffsetToCenter(FloorOffset);
                FloorFixStatus.Invoke("Fixed Floor: " + FloorOffset);
                FloorFixEnded.Invoke();
                CurState = State.Inactive;
            }
        }
    }
 public void RaiseDragonSelectedEvent()
 {
     DragonSelectedEvent.Invoke(Dragon.id);
 }
Beispiel #23
0
 public void Instruct(string instruction)
 {
     instructionListeners.Invoke(instruction);
 }
 public void OnEventRaised(string value)
 {
     StringResponce.Invoke(value);
 }
    // Update is called once per frame
    void Update()
    {
        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(inputSource), button, out bool isPressed, inputThreshold);
        //Start Movement
        if (!isMoving && isPressed)
        {
            StartMovement();
        }
        //End Movement
        else if (isMoving && !isPressed)
        {
            EndMovement();
        }
        //Update Movement
        else if (isMoving && isPressed)
        {
            UpdateMovement();
        }

        void StartMovement()
        {
            isMoving = true;
            positionList.Clear();
            var position = movementSource.position;

            positionList.Add(position);
            if (debugCubePrefab)
            {
                Destroy(Instantiate(debugCubePrefab, position, Quaternion.identity), 2);
            }
        }

        void EndMovement()
        {
            isMoving = false;
            //Create the gesture from the pos list
            Point[] pointArray = new Point[positionList.Count];
            for (int i = 0; i < positionList.Count; i++)
            {
                Vector2 screenPoint = Camera.main.WorldToScreenPoint(positionList[i]);
                pointArray[i] = new Point(screenPoint.x, screenPoint.y, 0);
            }
            Gesture newGesture = new Gesture(pointArray);

            if (creationMode)
            {
                newGesture.Name = newGestureName;
                trainingSet.Add(newGesture);

                string fileName = Application.persistentDataPath + "/" + newGestureName + ".xml";
                GestureIO.WriteGesture(pointArray, newGestureName, fileName);
            }
            else
            {
                Result result = PointCloudRecognizer.Classify(newGesture, trainingSet.ToArray());
                Debug.Log(result.GestureClass + ": " + result.Score);
                if (result.Score > recognitionThreshold)
                {
                    onRecognize?.Invoke(result.GestureClass);
                }
            }
        }

        void UpdateMovement()
        {
            Vector3 lastPosition = positionList[positionList.Count - 1];

            if (Vector3.Distance(movementSource.position, lastPosition) > newPositionThresholdDistance)
            {
                positionList.Add(movementSource.position);
                if (debugCubePrefab)
                {
                    Destroy(Instantiate(debugCubePrefab, movementSource.position, Quaternion.identity), 2);
                }
            }
        }
    }