Пример #1
0
    IEnumerator LoadData()
    {
        dealSound.Play();
        myturn = true;

        progress.SetActive(true);

        ProgressBarToolkit.CircularProgressBar2D script = (ProgressBarToolkit.CircularProgressBar2D)progress.GetComponent <ProgressBarToolkit.CircularProgressBar2D>();;
        script.Init(3);

        float  time1 = Time.time;
        string path;

        path = "https://i1hm3pvto9.execute-api.us-east-1.amazonaws.com/prod/test";

        WWW www1 = new WWW(path);

        yield return(www1);

        var           str        = Json.Deserialize(www1.text) as Dictionary <string, object>;
        List <object> dataObject = str["results"] as List <object>;

        for (int i = 0; i < 4; i++)
        {
            cardData[i] = dataObject[i] as Dictionary <string, object>;
        }

        float time2    = Time.time;
        float timeDiff = time2 - time1;

        if (timeDiff < 3)
        {
            yield return(new WaitForSeconds(3 - timeDiff));
        }
        progress.SetActive(false);
    }
Пример #2
0
    IEnumerator SelfChoose()
    {
        myturn = true;
        timer.GetComponent <RectTransform>().anchoredPosition = new Vector2(-30f, -300f);
        timer.SetActive(true);

        ProgressBarToolkit.CircularProgressBar2D script = (ProgressBarToolkit.CircularProgressBar2D)timer.GetComponent <ProgressBarToolkit.CircularProgressBar2D>();;
        script.Init(turnTime);

        float time1 = Time.time;

        while (myturn && (Time.time - time1) < turnTime)
        {
            yield return(null);
        }
        myturn = false;

        int i;

        for (i = 0; i < bench.Count(); i++)
        {
            if (cards[bench.Get(i)].picture.tag == "Focus")
            {
                break;
            }
        }
        if (i == bench.Count())
        {
            i = 0;
        }

        cardSound.Play();

        GameObject obj = cards[bench.Get(i)].picture;

        obj.tag = "Untagged";


        GameObject priceTag = Instantiate(tagModel, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        priceTag.name                    = "PriceTag";
        priceTag.transform.parent        = obj.transform;
        priceTag.transform.localPosition = new Vector3(screenWidthUnit / 8.0f / 0.4f, screenWidthUnit / 8.0f * 1.4f / 0.4f, 0);
        priceTag.transform.localScale    = new Vector3(0.05f, 0.05f, 0.05f);
        priceTag.GetComponent <Renderer> ().sortingOrder = 100;
        priceTag.GetComponent <TextMesh> ().text         = "<color=#ff0000ff>$" + cards[bench.Get(i)].price.ToString() + "</color>";

        link = Instantiate(linkModel, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
        link.transform.parent        = obj.transform;
        link.transform.localPosition = new Vector3(screenWidthUnit / 8.0f / 0.4f - 0.32f, screenWidthUnit / 8.0f * 1.4f / 0.4f - 0.9f, 0);
        link.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
        link.GetComponent <Renderer> ().sortingOrder = 1;

        link.AddComponent <BoxCollider2D>();
        link.AddComponent <LinkBehavior2>();

        self.sum = self.sum + cards [bench.Get(i)].price;

        selfPrice.GetComponentInChildren <Text>().text = "$" + self.sum.ToString();

        self.AddNode(bench.Get(i));
        bench.RemoveNode(i);


        Vector3 destination = new Vector3(screenWidthUnit / 4.0f * (self.Count() + 0.5f) - screenWidthUnit / 2.0f, -0.28f * screenHeightUnit, 0);

        StartCoroutine(Fade(obj, destination, 0.375f));

        timer.SetActive(false);
    }
Пример #3
0
    IEnumerator OpponentChoose(float x)
    {
        timer.GetComponent <RectTransform>().anchoredPosition = new Vector2(-30f, 300f);
        timer.SetActive(true);

        ProgressBarToolkit.CircularProgressBar2D script = (ProgressBarToolkit.CircularProgressBar2D)timer.GetComponent <ProgressBarToolkit.CircularProgressBar2D>();;
        script.Init(turnTime);

        yield return(new WaitForSeconds(Random.value * (x - 1f) + 1f));

        timer.SetActive(false);

        float[] factor = new float[bench.Count()];
        float   sum    = 0;
        int     i;

        for (i = 0; i < bench.Count(); i++)
        {
            sum = sum + cards[bench.Get(i)].price;
        }
        factor[0] = cards[bench.Get(0)].price / sum;

        for (i = 1; i < bench.Count(); i++)
        {
            factor[i] = factor[i - 1] + cards[bench.Get(i)].price / sum;
        }

        factor [i - 1] = 1;
        float random = Random.value;

        for (i = 0; i < bench.Count(); i++)
        {
            if (random <= factor[i])
            {
                Debug.Log(i.ToString());
                break;
            }
        }

        cardSound.Play();
        GameObject obj = cards[bench.Get(i)].picture;

        GameObject priceTag = Instantiate(tagModel, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        priceTag.name                    = "PriceTag";
        priceTag.transform.parent        = obj.transform;
        priceTag.transform.localPosition = new Vector3(screenWidthUnit / 8.0f / 0.4f, screenWidthUnit / 8.0f * 1.4f / 0.4f, 0);
        priceTag.transform.localScale    = new Vector3(0.05f, 0.05f, 0.05f);
        priceTag.GetComponent <Renderer> ().sortingOrder = 100;
        priceTag.GetComponent <TextMesh> ().text         = "<color=#ff0000ff>$" + cards[bench.Get(i)].price.ToString() + "</color>";

        link = Instantiate(linkModel, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
        link.transform.parent        = obj.transform;
        link.transform.localPosition = new Vector3(screenWidthUnit / 8.0f / 0.4f - 0.32f, screenWidthUnit / 8.0f * 1.4f / 0.4f - 0.9f, 0);
        link.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
        link.GetComponent <Renderer> ().sortingOrder = 1;

        link.AddComponent <BoxCollider2D>();
        link.AddComponent <LinkBehavior2>();

        opponent.sum = opponent.sum + cards [bench.Get(i)].price;
        opponentPrice.GetComponentInChildren <Text>().text = "$" + opponent.sum.ToString();

        opponent.AddNode(bench.Get(i));
        bench.RemoveNode(i);

        Vector3 destination = new Vector3(screenWidthUnit / 4.0f * (opponent.Count() + 0.5f) - screenWidthUnit / 2.0f, 0.28f * screenHeightUnit, 0);

        StartCoroutine(Fade(obj, destination, 0.375f));

        Debug.Log(i.ToString());
    }