// Update is called once per frame
    void Update()
    {
        if (numbersInstantiated && instantiatedCoinNumberOne == null && instantiatedCoinNumberTwo == null && instantiatedCoinNumberThree == null)
        {
            numbersInstantiated = false;
        }
        if (!goHome && !numbersInstantiated && !currentStates.GetSingleStarPowerPressed() && Mathf.Abs(Mathf.Abs((circleObject.transform.rotation.eulerAngles.z) - (360 - (incrementalAngle * 5)))) < 4f)
        {
            instantiatedCoinNumberOne = (GameObject)Instantiate(coinNumberOne, new Vector3(targetX, targetY, -6), Quaternion.identity);
            PowerButtonHandler.increaseCoinNumber();
            instantiatedCoinNumberTwo = (GameObject)Instantiate(coinNumberZero, new Vector3(targetX, targetY, -6), Quaternion.Euler(new Vector3(0, 0, -22.5f)));
            PowerButtonHandler.increaseCoinNumber();
            instantiatedCoinNumberThree = (GameObject)Instantiate(coinNumberZero, new Vector3(targetX, targetY, -6), Quaternion.Euler(new Vector3(0, 0, -45)));
            PowerButtonHandler.increaseCoinNumber();
            if (GameObject.Find("Single Star Coin Holder") != null)
            {
                coinNumberParent = GameObject.Find("Single Star Coin Holder");
            }
            else
            {
                coinNumberParent = new GameObject();
                coinNumberParent.transform.position = new Vector3(targetX, transform.position.y, transform.position.z);
                coinNumberParent.name = "Single Star Coin Holder";
            }
            instantiatedCoinNumberOne.transform.parent   = coinNumberParent.transform;
            instantiatedCoinNumberTwo.transform.parent   = coinNumberParent.transform;
            instantiatedCoinNumberThree.transform.parent = coinNumberParent.transform;

            instantiatedCoinNumberOne.name   = "Power Coin One";
            instantiatedCoinNumberTwo.name   = "Power Coin Two";
            instantiatedCoinNumberThree.name = "Power Coin Three";

            instantiatedCoinNumberOne.GetComponent <PowerCoinNumberMovementController> ().SetAttachedButton(gameObject);
            instantiatedCoinNumberTwo.GetComponent <PowerCoinNumberMovementController> ().SetAttachedButton(gameObject);
            instantiatedCoinNumberThree.GetComponent <PowerCoinNumberMovementController> ().SetAttachedButton(gameObject);
            numbersInstantiated = true;
            numbersSentHome     = false;
        }
        if (goHome && numbersInstantiated && !numbersSentHome)
        {
            instantiatedCoinNumberOne.GetComponent <PowerCoinNumberMovementController> ().MoveNumberBack(true);
            instantiatedCoinNumberTwo.GetComponent <PowerCoinNumberMovementController> ().MoveNumberBack(true);
            instantiatedCoinNumberThree.GetComponent <PowerCoinNumberMovementController> ().MoveNumberBack(true);
            numbersSentHome = true;
        }

        if (goHome && PowerButtonHandler.GetCoinNumberCount() == 0)
        {
            circleObject.transform.rotation = Quaternion.Slerp(circleObject.transform.rotation, Quaternion.Euler(0, 0, 0), Time.deltaTime * 8f);
        }
        else if (!goHome)
        {
            circleObject.transform.rotation = Quaternion.Slerp(circleObject.transform.rotation, Quaternion.Euler(0, 0, -incrementalAngle * 5), Time.deltaTime * 8f);
        }

        if (goHome && Mathf.Abs((circleObject.transform.rotation.eulerAngles.z) - ((0))) < .1f)
        {
            Destroy(circleObject);
            Destroy(gameObject);
        }

        if (!currentStates.GetSingleStarPowerPressed() && touchOn)
        {
            if (Input.GetMouseButtonDown(0))
            {
                CheckTouch(Input.mousePosition);
            }

            if (Input.GetMouseButton(0))
            {
                CheckTouch2(Input.mousePosition);
            }

            if (Input.GetMouseButtonUp(0))
            {
//				if (instantiatedPressedSingleStarPowerButton != null)
//					Destroy (instantiatedPressedSingleStarPowerButton);
                CheckTouch3(Input.mousePosition);
            }
        }

        if (rotateNumbers)
        {
            coinNumberParent.transform.Rotate(new Vector3(0, 0, -180) * Time.deltaTime * 2);
            if (instantiatedCoinNumberOne == null && instantiatedCoinNumberTwo == null && instantiatedCoinNumberThree == null)
            {
                Destroy(coinNumberParent);
                rotateNumbers = false;
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (numbersInstantiated && instantiatedCoinNumberOne == null && instantiatedCoinNumberTwo == null && instantiatedCoinNumberThree == null)
        {
            numbersInstantiated = false;
        }
        if (!goHome && !numbersInstantiated && !currentStates.GetMultiStarPowerPressed() && Mathf.Abs(Mathf.Abs((circleObject.transform.rotation.eulerAngles.z) - (360 - (incrementalAngle * 5)))) < 4f)
        {
            instantiatedCoinNumberOne = (GameObject)Instantiate(coinNumberTwo, new Vector3(targetX, targetY, -6), Quaternion.identity);
            PowerButtonHandler.increaseCoinNumber();
            instantiatedCoinNumberTwo = (GameObject)Instantiate(coinNumberFive, new Vector3(targetX, targetY, -6), Quaternion.Euler(new Vector3(0, 0, -22.5f)));
            PowerButtonHandler.increaseCoinNumber();
            instantiatedCoinNumberThree = (GameObject)Instantiate(coinNumberZero, new Vector3(targetX, targetY, -6), Quaternion.Euler(new Vector3(0, 0, -45)));
            PowerButtonHandler.increaseCoinNumber();
            if (GameObject.Find("Multi Star Coin Holder") != null)
            {
                coinNumberParent = GameObject.Find("Multi Star Coin Holder");
            }
            else
            {
                coinNumberParent = new GameObject();
                coinNumberParent.transform.position = new Vector3(targetX, transform.position.y, transform.position.z);
                coinNumberParent.name = "Multi Star Coin Holder";
            }

            instantiatedCoinNumberOne.transform.parent   = coinNumberParent.transform;
            instantiatedCoinNumberTwo.transform.parent   = coinNumberParent.transform;
            instantiatedCoinNumberThree.transform.parent = coinNumberParent.transform;

            instantiatedCoinNumberOne.name   = "Power Coin One";
            instantiatedCoinNumberTwo.name   = "Power Coin Two";
            instantiatedCoinNumberThree.name = "Power Coin Three";
            instantiatedCoinNumberOne.GetComponent <PowerCoinNumberMovementController> ().SetAttachedButton(gameObject);
            instantiatedCoinNumberTwo.GetComponent <PowerCoinNumberMovementController> ().SetAttachedButton(gameObject);
            instantiatedCoinNumberThree.GetComponent <PowerCoinNumberMovementController> ().SetAttachedButton(gameObject);
            numbersInstantiated = true;
            numbersSentHome     = false;
        }
        if (goHome && numbersInstantiated && !numbersSentHome)
        {
            instantiatedCoinNumberOne.GetComponent <PowerCoinNumberMovementController> ().MoveNumberBack(true);
            instantiatedCoinNumberTwo.GetComponent <PowerCoinNumberMovementController> ().MoveNumberBack(true);
            instantiatedCoinNumberThree.GetComponent <PowerCoinNumberMovementController> ().MoveNumberBack(true);
            numbersSentHome = true;
        }

        if (goHome && PowerButtonHandler.GetCoinNumberCount() == 0)
        {
            circleObject.transform.rotation = Quaternion.Slerp(circleObject.transform.rotation, Quaternion.Euler(0, 0, 0), Time.deltaTime * 8f);
        }
        else if (!goHome)
        {
            circleObject.transform.rotation = Quaternion.Slerp(circleObject.transform.rotation, Quaternion.Euler(0, 0, -incrementalAngle * 5), Time.deltaTime * 8f);
        }
        if (goHome && Mathf.Abs((circleObject.transform.rotation.eulerAngles.z) - ((0))) < .1f)
        {
            Destroy(circleObject);
            Destroy(gameObject);
        }

        if (!currentStates.GetMultiStarPowerPressed() && touchOn && touchHandler.GetGameStarted())
        {
            if (Input.GetMouseButtonDown(0))
            {
                CheckTouch(Input.mousePosition);
            }

            if (Input.GetMouseButton(0))
            {
                CheckTouch2(Input.mousePosition);
            }

            if (Input.GetMouseButtonUp(0))
            {
//				if (instantiatedPressedMultiStarPowerButton != null)
//					Destroy (instantiatedPressedMultiStarPowerButton);
                CheckTouch3(Input.mousePosition);
            }
        }

//		if (launchStars && Time.time >= timeStamp + cooldown) {
//			soundHandler.PlayPowerUpSound ();
//			GameObject tempStar = (GameObject)Instantiate (GetRandomHomingStar (), new Vector3 (transform.position.x, transform.position.y, transform.position.z + 1), Quaternion.identity);
//			PaidPowerTracker.AddPowerToList (tempStar);
//			launchStarCount--;
//			if (launchStarCount <= 0) {
//				launchStars = false;
//				launchStarCount = 0;
//			}
//			timeStamp = Time.time;
//		}

        if (rotateNumbers)
        {
            coinNumberParent.transform.Rotate(new Vector3(0, 0, -180) * Time.deltaTime * 2);
            if (instantiatedCoinNumberOne == null && instantiatedCoinNumberTwo == null && instantiatedCoinNumberThree == null)
            {
                Destroy(coinNumberParent);
                rotateNumbers = false;
            }
        }
    }