Пример #1
0
    private void Start()
    {
        if (GameObject.Find("DontDestroy") == null)
        {
            ISC = Instantiate(ISCObj).GetComponent <InterSceneController>();
        }
        else
        {
            ISC = GameObject.Find("DontDestroy").GetComponent <InterSceneController>();
        }

        ISC.diffDrop = GameObject.Find("Dropdown").GetComponent <Dropdown>();

        newTour.onClick.AddListener(NewTournament);
        startTour.onClick.AddListener(StartTournament);
        drop.onValueChanged.AddListener(delegate { ValChang(drop); });

        SnewTour.onClick.AddListener(SNewTournament);
        SstartTour.onClick.AddListener(SStartTournament);
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        Transform spawnt;

        for (int i = 0; i < spawn.transform.childCount; i++)
        {
            spawnt = spawn.transform.GetChild(i).GetComponent <Transform>();

            switch (spawnt.name)
            {
            case "Black":
            {
                for (int j = 0; j < balls.Count; j++)
                {
                    //Debug.Log(balls[j].transform.name);

                    if (string.Equals(balls[j].transform.name, spawnt.name))
                    {
                        b = balls[j];
                    }
                }

                if (b != null)
                {
                    b.GetComponent <Rigidbody>().drag          = drag;
                    b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                    b.GetComponent <SphereCollider>().material = pmaterial;

                    ballsClon.Add(Instantiate(b, spawnt));
                    ballsClon.Last <GameObject>().AddComponent <Trigger>();
                }
                else
                {
                    Debug.Log("Ni ma");
                }
                break;
            }

            case "Blue":
            {
                for (int j = 0; j < balls.Count; j++)
                {
                    if (string.Equals(balls[j].transform.name, spawnt.name))
                    {
                        b = balls[j];
                    }
                }

                if (b != null)
                {
                    b.GetComponent <Rigidbody>().drag          = drag;
                    b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                    b.GetComponent <SphereCollider>().material = pmaterial;

                    ballsClon.Add(Instantiate(b, spawnt));
                    ballsClon.Last <GameObject>().AddComponent <Trigger>();
                }
                else
                {
                    Debug.Log("Ni ma");
                }
                break;
            }

            case "Yellow":
            {
                for (int j = 0; j < balls.Count; j++)
                {
                    if (string.Equals(balls[j].transform.name, spawnt.name))
                    {
                        b = balls[j];
                    }
                }

                if (b != null)
                {
                    b.GetComponent <Rigidbody>().drag          = drag;
                    b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                    b.GetComponent <SphereCollider>().material = pmaterial;

                    ballsClon.Add(Instantiate(b, spawnt));
                    ballsClon.Last <GameObject>().AddComponent <Trigger>();
                }
                else
                {
                    Debug.Log("Ni ma");
                }
                break;
            }

            case "Pink":
            {
                for (int j = 0; j < balls.Count; j++)
                {
                    if (string.Equals(balls[j].transform.name, spawnt.name))
                    {
                        b = balls[j];
                    }
                }

                if (b != null)
                {
                    b.GetComponent <Rigidbody>().drag          = drag;
                    b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                    b.GetComponent <SphereCollider>().material = pmaterial;

                    ballsClon.Add(Instantiate(b, spawnt));
                    ballsClon.Last <GameObject>().AddComponent <Trigger>();
                }
                else
                {
                    Debug.Log("Ni ma");
                }
                break;
            }

            case "Green":
            {
                for (int j = 0; j < balls.Count; j++)
                {
                    if (string.Equals(balls[j].transform.name, spawnt.name))
                    {
                        b = balls[j];
                    }
                }

                if (b != null)
                {
                    b.GetComponent <Rigidbody>().drag          = drag;
                    b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                    b.GetComponent <SphereCollider>().material = pmaterial;

                    ballsClon.Add(Instantiate(b, spawnt));
                    ballsClon.Last <GameObject>().AddComponent <Trigger>();
                }
                else
                {
                    Debug.Log("Ni ma");
                }
                break;
            }

            case "Brown":
            {
                for (int j = 0; j < balls.Count; j++)
                {
                    if (string.Equals(balls[j].transform.name, spawnt.name))
                    {
                        b = balls[j];
                    }
                }

                if (b != null)
                {
                    b.GetComponent <Rigidbody>().drag          = drag;
                    b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                    b.GetComponent <SphereCollider>().material = pmaterial;

                    ballsClon.Add(Instantiate(b, spawnt));
                    ballsClon.Last <GameObject>().AddComponent <Trigger>();
                }
                else
                {
                    Debug.Log("Ni ma");
                }
                break;
            }

            default:
            {
                if (spawnt.name != "White")
                {
                    for (int j = 0; j < balls.Count; j++)
                    {
                        if (string.Equals(balls[j].transform.name, "Red"))
                        {
                            b = balls[j];
                        }
                    }

                    if (b != null)
                    {
                        b.GetComponent <Rigidbody>().drag          = drag;
                        b.GetComponent <Rigidbody>().angularDrag   = angdrag;
                        b.GetComponent <SphereCollider>().material = pmaterial;

                        ballsClon.Add(Instantiate(b, spawnt));
                        ballsClon.Last <GameObject>().AddComponent <Trigger>();
                    }
                    else
                    {
                        Debug.Log("Ni ma");
                    }
                }
                break;
            }
            }
        }

        foreach (GameObject b in ballsClon)
        {
            b.transform.tag        = "Ball";
            b.transform.localScale = new Vector3(8, 8, 8);
            b.AddComponent <SphereCollider>();
            b.GetComponent <SphereCollider>().radius   *= 2;
            b.GetComponent <SphereCollider>().isTrigger = true;
        }

        ISC = GameObject.Find("DontDestroy").GetComponent <InterSceneController>();
        switch (ISC.difficulty)
        {
        case 0:
        {
            stupidity = 10;
            break;
        }

        case 1:
        {
            stupidity = 6;
            break;
        }

        case 2:
        {
            stupidity = 4;
            break;
        }

        case 3:
        {
            stupidity = 2;
            break;
        }

        case 4:
        {
            stupidity = 0;
            break;
        }
        }

        foul = true;
    }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        int       i = 0;
        Transform spawnt;

        foreach (GameObject b in balls)
        {
            i++;

            spawnt = spawn.transform.Find(i.ToString()).GetComponent <Transform>();

            b.transform.position = new Vector3(0, 0, 0);
            b.GetComponent <Rigidbody>().drag          = drag;
            b.GetComponent <Rigidbody>().angularDrag   = angdrag;
            b.GetComponent <SphereCollider>().material = pmaterial;


            ballsClon.Add(Instantiate(b, spawnt));
            ballsClon[i - 1].AddComponent <Trigger>();
            ballsClon[i - 1].GetComponent <Rigidbody>().maxAngularVelocity = 200;
            ballsClon[i - 1].transform.localScale = new Vector3(8, 8, 8);
            ballsClon[i - 1].transform.tag        = "Ball";

            ballsClon[i - 1].AddComponent <SphereCollider>();
            ballsClon[i - 1].GetComponent <SphereCollider>().radius   *= 2;
            ballsClon[i - 1].GetComponent <SphereCollider>().isTrigger = true;
        }

        ISC = GameObject.Find("DontDestroy").GetComponent <InterSceneController>();
        switch (ISC.difficulty)
        {
        case 0:
        {
            stupidity = 10;
            break;
        }

        case 1:
        {
            stupidity = 6;
            break;
        }

        case 2:
        {
            stupidity = 4;
            break;
        }

        case 3:
        {
            stupidity = 2;
            break;
        }

        case 4:
        {
            stupidity = 0;
            break;
        }
        }
    }