Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            if (!alreadydone)
            {
                alreadydone = true;
                Rigidbody      rigRollerball = rollerball.GetComponent <Rigidbody>();
                ballProperties ballProp      = rollerball.GetComponent <ballProperties>();
                ballProp.hp -= damage;
                rigRollerball.AddForce(-transform.forward * forcespeed, ForceMode.Impulse);
                GameObject go = Instantiate(hitcount, rollerball.transform.position, Quaternion.FromToRotation(Vector3.forward, rollerball.transform.position));
                go.transform.GetChild(0).GetComponent <Text>().text = "" + damage;
                Destroy(go, 1.14f);
                Destroy(Instantiate(hiteffect, rollerball.transform.position, Quaternion.FromToRotation(Vector3.forward, rollerball.transform.position)) as GameObject, 1.3f);

                if (ballProp.hp <= 0)
                {
                    finish.SetActive(true);
                    rigRollerball.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
                    Destroy(Instantiate(deatheffect, rollerball.transform.position, Quaternion.FromToRotation(Vector3.forward, rollerball.transform.position)) as GameObject, 1.3f);
                    ballProp.hpText.text = "0";
                    Destroy(rollerball);
                }
                else
                {
                    return;
                }
            }
        }
    }
Example #2
0
    void Start()
    {
        Application.targetFrameRate = 60;
        QualitySettings.vSyncCount  = 0;
        Time.timeScale = 1;
        t         = 0.0f;
        StartTime = 0.0f;
        FinishCanvas.SetActive(false);
        count = 0;
        ballProperties ballprop = rollerball.GetComponent <ballProperties>();

        foreach (Transform i in rollerball.transform)
        {
            count++;
        }
        toplar = new GameObject[count];
        count  = 0;
        foreach (Transform i in rollerball.transform)
        {
            toplar[count] = i.gameObject;
            count++;
        }
        for (int i = 0; i < toplar.Length; i++)
        {
            if (toplar[i].name == PlayerPrefs.GetString("s_usesball"))
            {
                toplar[i].SetActive(true);
                switch (i)
                {
                case 0:
                    ballprop.hp = 15;
                    break;

                case 1:
                    ballprop.hp = 21;
                    break;

                case 2:
                    ballprop.hp = 32;
                    break;

                case 3:
                    ballprop.hp = 48;
                    break;

                case 4:
                    ballprop.hp = 62;
                    break;
                }
            }
            else
            {
                toplar[i].SetActive(false);
            }
        }
    }