Exemple #1
0
    public async void DeleteCurrentAnchor()
    {
        if (aRTapHandler.objectToPlace != null)
        {
            Log.debug("Trying to discard anchor");
            if (anchorLerper.hasAnchorSelected)
            {
                Log.debug("Anchor has been lerped");
                anchorLerper.PrepareToDelete();
            }
            Log.debug("Destroying");
            Destroy(aRTapHandler.objectToPlace);
            Log.debug("Setting text");
            anchorInfoText.GetComponentInParent <FadeText>().SetText($"Anchor creation canceled");
            return;
        }
        Log.debug("Trying to delete existing anchor");
        AnchorProperties anchorToDeleteProperties = aRTapHandler.currentSelectedAnchor.GetComponent <AnchorProperties>();

        anchorInfoText.text = $"Deleting anchor:\n{anchorToDeleteProperties.anchorLabel}...";
        Log.debug($"Try to Delete CloudSpatialAnchor: {currentCloudSpatialAnchor.Identifier} ");
        await spatialAnchorManager.DeleteAnchorAsync(currentCloudSpatialAnchor);

        Log.debug($"CloudSpatialAnchor is Deleted: {currentCloudSpatialAnchor.Identifier}");
        anchorInfoText.GetComponentInParent <FadeText>().SetText($"Anchor deleted \nLabel: {anchorToDeleteProperties.anchorLabel}");
        Destroy(anchorToDeleteProperties.button);
        FindObjectOfType <AnchorButtonPopulator>().RemoveAnchorFromDictionary(anchorToDeleteProperties.anchorID);
        await anchorConverter.ResetSession();

        anchorConverter.FindAnchorsByLocation();
    }
Exemple #2
0
    private void setCanvasCamera(Camera creatureCam)
    {
        Canvas canvas = MainText.GetComponentInParent <Canvas>();

        canvas.renderMode    = RenderMode.ScreenSpaceCamera;
        canvas.worldCamera   = creatureCam;
        canvas.planeDistance = .5f;
    }
Exemple #3
0
    public async Task CreateCloudAnchor(CloudSpatialAnchor cloudAnchor, AnchorProperties anchorProperties)
    {
        anchorProperties.dateSecondsString = $"{(Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds}";
        UpdateAnchorProperties(cloudAnchor, anchorProperties);
        if (cloudAnchor == null)
        {
            Log.debug("Cloud anchor is null");
            return;
        }
        tutorialManager.gameObject.SetActive(true);

        anchorInfoText.GetComponentInParent <FadeText>().ShowText();
        while (!spatialAnchorManager.IsReadyForCreate)
        {
            progressBar.SetActive(true);
            Log.debug($"Not enough environmental data : {spatialAnchorManager.SessionStatus.RecommendedForCreateProgress}");
            anchorInfoText.text = $"Look around to gather more data";
            progressBar.GetComponent <Slider>().value = spatialAnchorManager.SessionStatus.RecommendedForCreateProgress;
            await Task.Delay(333);
        }
        tutorialManager.gameObject.SetActive(false);

        try
        {
            Log.debug("Trying to create cloud anchor");
            anchorInfoText.text = $"Creating anchor...";
            progressBar.SetActive(false);
            await spatialAnchorManager.CreateAnchorAsync(cloudAnchor);

            anchorInfoText.GetComponentInParent <FadeText>().SetText("Anchor created!");
        }
        catch (Exception ex)
        {
            Log.debug(ex.Message);
            anchorInfoText.GetComponentInParent <FadeText>().SetText("Oops there was problem created anchor!");
        }
    }
Exemple #4
0
    //Gets the int to be read out to the user
    public void ReadBalance()
    {
        nRS = FindObjectOfType <NumberReaderScript>();
        string temp = playerCoins.text;

        temp = Regex.Replace(temp, "Coins: ", "");

        playerCoins.GetComponentInParent <Button>().Select();

        int i = int.Parse(temp);

        nRS.SetNumber(i);

        nRS.ReadNumber();
    }
 public void OnClick(bool right)
 {
     currentGoals.text += GameManager.cursors[Client.instance.myId].username + ": ";
     if (right)
     {
         currentGoals.text += goal2.text + "\n";
     }
     else
     {
         currentGoals.text += goal1.text + "\n";
     }
     goal1.GetComponentInParent <Button>().gameObject.SetActive(false);
     goal2.GetComponentInParent <Button>().gameObject.SetActive(false);
     // Initialize Next UI
     // Talk to Evan if we should seperate the 2 UI Canvas
 }
Exemple #6
0
        /// <summary>
        /// Get the best fit size for this TMP_Text Component.
        /// </summary>
        /// <param name="text">The TMP_Text Component to get the best fit size of.</param>
        /// <param name="newStrings">List of strings which will be used in resizing calculations to ensure it is visible in this Text Component.</param>
        /// <returns>Returns the font size the Text has been set to.</returns>
        private static float GetBestFitSize(TMP_Text text, List <string> newStrings)
        {
            var smallestFontSize = 0f;
            var currentText      = text.text;

            if (newStrings == null)
            {
                newStrings = new List <string> {
                    currentText
                };
            }
            if (!newStrings.Contains(currentText))
            {
                newStrings.Add(currentText);
            }
            var bestFitBehaviour = text.GetComponentInParent <BestFit>();

            foreach (var s in newStrings)
            {
                text.text             = s;
                text.enableAutoSizing = true;
                text.fontSizeMin      = bestFitBehaviour ? bestFitBehaviour.MinFontSize : 1f;
                text.fontSizeMax      = bestFitBehaviour ? bestFitBehaviour.MaxFontSize : 1000f;
                //Set to max possible to start all text at an equal point.
                text.fontSize = text.fontSizeMax;
                //Force the text mesh to be updated.
                text.Rebuild(CanvasUpdate.PreRender);
                //Disable BestFit on Component.
                text.enableAutoSizing = false;
                var newSize = text.fontSize;
                //NewSizeRescale is used to scale down newSize if rect used for text is bigger than rect for the GameObject.
                var newSizeRescale = RescaleFontSize(text, 1f);
                //Multiply newSize by newSizeScale and round down to the nearest int.
                newSize *= newSizeRescale;
                //If newSize is smaller than the current smallestFontSize or if smallestFontSize has not been set, set smallestFontSize to equal newSize.
                if (newSize < smallestFontSize || Mathf.Approximately(smallestFontSize, 0))
                {
                    smallestFontSize = newSize;
                }
            }
            //Reset the text to display what it was previously.
            text.text = currentText;
            return(Mathf.Min(smallestFontSize, bestFitBehaviour ? bestFitBehaviour.MaxFontSize : 300));
        }
        private void SetText(TMP_Text textComp)
        {
            text = textComp;
            text.enableWordWrapping = true;

            text.fontSizeMax      = text.fontSize;
            text.enableAutoSizing = true;

            if (text.margin.x < 10 && text.margin.z < 10)
            {
                text.margin = new Vector4(10, text.margin.y, 10, text.margin.w);
            }

            if (text.GetComponentInParent <TMP_InputField>() != null)
            {
                setRTL = true;
            }

            GameContext.Instance.MessageDirector.RegisterBundlesListener(CheckRTL);
        }
Exemple #8
0
    //Input for the wheel scene
    void Update()
    {
        if (GestureInputManager.CurrentInput != InputAction.Null)
        {
            string type = GestureInputManager.CurrentInput.ToString();

            Debug.Log(type);

            //Waits until the result text has been changed
            if (text.text != "")
            {
                if (type == "SwipeUp")
                {
                    sR.ClearSummary();

                    //If summary isn't null the player is not in the tutorial
                    if (summary != null)
                    {
                        if (balance.text != "0")
                        {
                            sS.BoardScene();
                        }

                        else
                        {
                            sS.MenuScene();
                        }
                    }

                    else
                    {
                        if (completed.activeSelf)
                        {
                            sS.MenuScene();
                        }

                        else
                        {
                            wheel.SetActive(false);
                            completed.SetActive(true);
                        }
                    }
                }

                else if (type == "SwipeDown")
                {
                    sS.MenuScene();
                }

                //Show the round summary
                else if (type == "DoubleClick")
                {
                    if (wheel.activeSelf && summary != null)
                    {
                        wheel.SetActive(false);
                        summary.SetActive(true);
                    }
                }

                //Play the balance
                else if (type == "Click" && wheel.activeSelf && !source.isPlaying && !nums.isPlaying)
                {
                    balance.GetComponentInParent <Button>().onClick.Invoke();
                }
            }
        }
    }
    //All the gestures for the betting panel
    public void Gestures(string type)
    {
        //Confirms bet
        if (type == "DoubleClick")
        {
            if (balance.text != "0")
            {
                if (source == null)
                {
                    bGI = FindObjectOfType <BoardGestureInput>();
                    bGI.SetFirst();
                    confirm.onClick.Invoke();
                }

                else
                {
                    if (amount.text == "100")
                    {
                        bGI = FindObjectOfType <BoardGestureInput>();
                        bGI.SetFirst();
                        confirm.onClick.Invoke();
                    }

                    else
                    {
                        if (!narrator.isPlaying)
                        {
                            source.Play();
                        }
                    }
                }
            }
        }

        //Plays balance
        else if (type == "Click")
        {
            if (!narrator.isPlaying && !amountReader.isPlaying)
            {
                balance.GetComponentInParent <Button>().onClick.Invoke();
            }
        }

        //Changes amount
        else if (type.Contains("Swipe"))
        {
            if (bPT == null)
            {
                bPT = gameObject.GetComponent <BetPanelTimer>();
            }

            bPT.CallTimer();

            string temp = Regex.Replace(balance.text, "[^.0-9]", "");

            int am = int.Parse(amount.text);

            int bal = int.Parse(temp);

            if (type.Contains("Up"))
            {
                if (am + 100 <= bal)
                {
                    am += 100;
                }

                else
                {
                    am = bal;
                }

                amount.text = am.ToString();
            }

            else if (type.Contains("Down"))
            {
                if (am - 100 >= 10)
                {
                    am -= 100;
                }

                else
                {
                    am = 10;
                }

                amount.text = am.ToString();
            }

            else if (type.Contains("Left"))
            {
                if (am - 10 >= 10)
                {
                    am         -= 10;
                    amount.text = am.ToString();
                }
            }

            else if (type.Contains("Right"))
            {
                if (am + 10 <= bal)
                {
                    am         += 10;
                    amount.text = am.ToString();
                }
            }
        }
    }