public void Fire(WebSocket webSocket)
    {
        //They shouldnt be able to pick up multiple trash items at once
        if (heldItem != null)
        {
            return;
        }

        // Bit shift the index of the layer (9) to get a bit mask
        // Only casts on layer 9 (targets)
        int layerMask = 1 << 9;

        RaycastHit hit;
        // Does the ray intersect any objects on layer 9
        var Ray = camera.ScreenPointToRay(cursorPosition.position);

        if (Physics.Raycast(Ray, out hit, 300.0f, layerMask))
        {
            // Get the target info component
            TargetParent targetWeHit = hit.collider.gameObject.GetComponent <TargetParent>();
            // Send message with target stuff
            TargetInfoMessage msg = new TargetInfoMessage();
            heldItem              = targetWeHit;
            msg.targetName        = targetWeHit.targetInfo.targetName;
            msg.targetDescription = targetWeHit.targetInfo.targetDescription;
            msg.type              = "targetInfo";
            msg.userID            = userID;
            targetWeHit.DoHit(this);
            webSocket.Send(JsonUtility.ToJson(msg));
        }
    }
 public void Release(WebSocket webSocket)
 {
     if (heldItem != null)
     {
         heldItem.DoYeet();
         heldItem.heldBy = null;
         heldItem        = null;
         //Upon yeet, play our sound
         soundMaker.PlayRandomBubble();
     }
 }
示例#3
0
    public void AnswerCreation(List <string> categories, string correctAnswers, int stepIncrease)
    {
        this.stepIncrease = stepIncrease;
        int itemCount = 0;

        ToggleBackdrop(true);
        List <string> items = GetListOfItems(categories, correctAnswers);
        GameObject    TargetParent;

        foreach (string item in items)
        {
            List <Item> itemsSplitted = DataManager.GetItemsByNameAndCategories(categories, item);
            GameObject  answerButton  = Instantiate(answerPrefab);
            string      textButton    = "";
            int         countNewLine  = 1;
            itemCount++;

            foreach (Item itemSplit in itemsSplitted)
            {
                answerButton.name = itemSplit.name;
                string text = itemSplit.text;
                text        = PastLevelOne ? "• " + itemSplit.shorttext : itemSplit.text;
                textButton += text;
                if (countNewLine < itemsSplitted.Count)
                {
                    textButton = textButton + "\r\n";
                    countNewLine++;
                }
            }
            answerButton.GetComponentsInChildren <Text>()[1].text             = itemCount.ToString();
            answerButton.GetComponentInChildren <Text>().text                 = textButton;
            answerButton.GetComponentInChildren <Text>().resizeTextForBestFit = PastLevelOne;
            answerButton.GetComponentInChildren <Text>().alignment            = PastLevelOne ? TextAnchor.MiddleLeft : TextAnchor.MiddleCenter;

            string TargetParentString = "Panel" + itemCount;
            TargetParent = GameObject.Find(TargetParentString);
            RectTransform TargetParentRect = TargetParent.GetComponent <RectTransform>();

            RectTransform anwserTextRect = answerButton.GetComponent <RectTransform>();
            anwserTextRect.transform.SetParent(TargetParentRect.transform);
            anwserTextRect.position   = TargetParentRect.position;
            anwserTextRect.sizeDelta  = TargetParentRect.rect.size;
            anwserTextRect.localScale = new Vector3(1, 1, 0);
        }
        RewardsController.instance.SetFinalScore();
        coroutine = TimerForAnswer("Selection");
        StartCoroutine(coroutine);
    }
示例#4
0
    public void AnswerCreation(Classes category, int stepIncrease)
    {
        List <Item> items       = DataManager.GetItemsForClass(category.name);
        List <Item> listOfItems = new List <Item>();

        this.stepIncrease = stepIncrease;
        int itemCount = 0;

        ToggleBackdrop(true);

        GameObject TargetParent;

        foreach (Item item in items)
        {
            listOfItems.Add(item);
            itemCount++;

            GameObject answerButton = Instantiate(answerPrefab);
            answerButton.name = item.name;
            answerButton.GetComponentInChildren <Text>().text     = item.text;
            answerButton.GetComponentsInChildren <Text>()[1].text = itemCount.ToString();

            string TargetParentString = "Panel" + itemCount;
            TargetParent = GameObject.Find(TargetParentString);
            RectTransform TargetParentRect = TargetParent.GetComponent <RectTransform>();

            RectTransform anwserTextRect = answerButton.GetComponent <RectTransform>();
            anwserTextRect.transform.SetParent(TargetParentRect.transform);
            anwserTextRect.position   = TargetParentRect.position;
            anwserTextRect.sizeDelta  = TargetParentRect.rect.size;
            anwserTextRect.localScale = new Vector3(1, 1, 0);
        }
        RewardsController.instance.SetFinalScore();
        coroutine = TimerForAnswer("Selection");
        StartCoroutine(coroutine);
    }
示例#5
0
    public void AnswerCreation(Steps step, List <string> parameters1, List <int> parameters2, int stepIncrease)
    {
        ToggleBackdrop(true);

        int itemCount = 0;

        GameObject TargetParent;
        string     stepTypeQuestion = step.type;
        Hashtable  ht = new Hashtable();

        if (stepTypeQuestion == "param")
        {
            ht = CreateExclude(parameters1);
            int prodInsertPriceCount = 0;
            foreach (string product in parameters1)
            {
                int price = parameters2 != null && parameters2.Count >= 1 ? parameters2[prodInsertPriceCount] : 0;
                GetExclude(ht, product).Add(price);
                ht[product] = GetExclude(ht, product);
                prodInsertPriceCount++;
            }
        }
        List <Question> questions = step.questions;

        this.stepIncrease = stepIncrease;
        ShuffleMe(questions);
        foreach (Question item in questions)
        {
            itemCount++;
            int countNewLine = 1;

            GameObject answerButton = Instantiate(answerPrefab);
            answerButton.name = "question_" + item.id;
            answerButton.GetComponentsInChildren <Text>()[1].text = itemCount.ToString();
            if (stepTypeQuestion == "text")
            {
                answerButton.GetComponentInChildren <Text>().text = item.text;
            }
            else if (stepTypeQuestion == "param")
            {
                string questionTot = "";
                int    prodCount   = 0;
                //Debrief's question on product prices
                foreach (string product in parameters1)
                {
                    int price = parameters2 != null && parameters2.Count >= 1 ? parameters2[prodCount] : 0;
                    if (item.id != 1)
                    {
                        int rndNumber = GiveMeANumber(1, 10, GetExclude(ht, product));
                        if (price == rndNumber)
                        {
                            Debug.LogWarning("not working");
                        }
                        price = rndNumber;
                        GetExclude(ht, product).Add(price);
                        ht[product] = GetExclude(ht, product);
                    }
                    questionTot += PastLevelOne ? "• " + string.Format(item.text, product.ToLower(), price) : string.Format(item.text, product.ToLower(), price);
                    if (countNewLine < parameters1.Count)
                    {
                        questionTot = questionTot + "\r\n";
                        countNewLine++;
                    }
                    prodCount++;
                }
                answerButton.GetComponentInChildren <Text>().text = questionTot;
                answerButton.GetComponentInChildren <Text>().resizeTextForBestFit = PastLevelOne;
                answerButton.GetComponentInChildren <Text>().alignment            = PastLevelOne ? TextAnchor.MiddleLeft : TextAnchor.MiddleCenter;
            }


            string TargetParentString = "Panel" + itemCount;
            TargetParent = GameObject.Find(TargetParentString);
            RectTransform TargetParentRect = TargetParent.GetComponent <RectTransform>();

            RectTransform anwserTextRect = answerButton.GetComponent <RectTransform>();
            anwserTextRect.transform.SetParent(TargetParentRect.transform);
            anwserTextRect.position   = TargetParentRect.position;
            anwserTextRect.sizeDelta  = TargetParentRect.rect.size;
            anwserTextRect.localScale = new Vector3(1, 1, 0);
        }
        PlayerPrefs.SetString("CorrectQuestion", "question_1");
        RewardsController.instance.SetFinalScore();
        coroutine = TimerForAnswer("Selection");
        StartCoroutine(coroutine);
    }