Esempio n. 1
0
 public void Awake()
 {
     if (singleton == null)
     {
         singleton = this;
         return;
     }
     Destroy(this);
 }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject);
    }
Esempio n. 3
0
    void OnCollisionEnter(Collision other)
    {
        //Tell the TestScript to stop rotating
        testScript ts = GameObject.Find("Sphere").GetComponent <testScript>();

        ts.stopRotation();

        //Tell the Timer script to stop counting
        Timer timer = GameObject.Find("Plane").GetComponent <Timer>();

        timer.stopTimer();
        ballHit = true;
        print("Ball hit the board");
        print(string.Format("Ball Hit situation is {0}:", ballHit));
        GameObject  smashed     = Instantiate(smashedBullet, transform.position, Quaternion.identity) as GameObject;
        GameControl gameControl = GameObject.Find("Board").GetComponent <GameControl>();

        Destroy(this.gameObject);
        smashed.name = "smashed";
        gameControl.collisionHappenedDoSth();
    }
Esempio n. 4
0
    void detectZoneMatch()
    {
        Debug.Log("rotation situation @ detectZoneMatch is : " + timeToRotate);
        testScript test          = GameObject.Find("Sphere").GetComponent <testScript>();
        Vector3    testPosition  = test.transform.position;
        float      newAngle      = angle(testPosition, Vector3.zero);
        float      originalAngle = angle(test.originalPosition, Vector2.zero);
        float      deltaAngle    = newAngle - originalAngle;

        if (deltaAngle < 0)
        {
            deltaAngle += 360;
        }

        Vector3 smashedPosition  = GameObject.Find("smashed").transform.position;
        float   smashedAngle     = angle(smashedPosition, Vector3.zero);
        float   getOriginalAngle = smashedAngle - deltaAngle;

        if (getOriginalAngle < 0)
        {
            getOriginalAngle += 360;
        }
        int newZone = (int)(getOriginalAngle / 360 * 12) + 1;

        Debug.Log(string.Format("newAngle: {0} originalAngle: {1} deltaAngle: {2} smashedAngle: {3}",
                                newAngle, originalAngle, deltaAngle, smashedAngle));
        Debug.Log("zone was:" + newZone);
        if (newZone == number)
        {
            speed = speed + 2;
            //audioSource.Play();
        }
        else
        {
            wrongAnswer++;
            wrongShot.text = ("Wrong shots: " + wrongAnswer.ToString());
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        if (timeToReset)
        {
            timeRemaining = 6;
            timeIsUp      = false;
            timeToFreeze  = false;
            timeToReset   = false;
            return;
        }
        if (timeToFreeze)
        {
            return;
        }
        //Tell the TestScript to stop rotating if timer goes to zero
        testScript ts = GameObject.Find("Sphere").GetComponent <testScript>();
        //Tell the board in GameControl to stop rotating if timer goes to zero
        GameControl gc = GameObject.Find("Board").GetComponent <GameControl>();

        //print the time remaining with 2 digits only
        timer.text = timeRemaining.ToString("f2");

        if (timeRemaining >= minTime)
        {
            startTimer();
        }
        else if (timeRemaining <= 0 && !timeIsUp)
        {
            print("time is up");
            timeIsUp          = true;
            gc.wrongAnswer   += 1;
            gc.wrongShot.text = gc.wrongAnswer.ToString();
            gc.timeIsUp();
            ts.stopRotation();
        }
    }
Esempio n. 6
0
 private void Awake()
 {
     main = this;
 }