Beispiel #1
0
    void SpawnBall()
    {
        objectsArray.AddLast(new RouteSegment(Instantiate(ballPrefabe, startNode.transform.position, new Quaternion(0, 0, 0, 1)), 1, forwardSpeed));
        S_Ball objComponent = objectsArray.Last.Value.obj.GetComponent <S_Ball>();

        objComponent.isInArray = true;
        objComponent.SetColor(rngObj.Next());
    }
    private void Start()
    {
        // Set references to relevant game object scripts
        m_ScriptBall   = m_ObjectBall.GetComponent <S_Ball>();
        m_ScriptCamera = m_ObjectCamera.GetComponent <S_GameCamera>();
        m_ImageInGameProjectedDirection = m_CanvasInGameProjectedPath.GetComponentInChildren <Image>();
        m_ImageInGamePowerButtonFill    = m_ButtonInGamePower.GetComponent <Image>();

        m_ImageInGamePowerButtonFill.type       = Image.Type.Filled;
        m_ImageInGamePowerButtonFill.fillAmount = 0.0f;

        // Set listeners for UI buttons
        m_ButtonStartingStartLevel.onClick.AddListener(() => { StartRound(); });
        m_ButtonStartingQuitToMenu.onClick.AddListener(() => { QuitToMainMenu(); });

#if UNITY_ANDROID
        m_ButtonEndingLeaderboard.onClick.AddListener(() => { ShowLeaderboard(); });
#endif

        m_ButtonEndingReplayLevel.onClick.AddListener(() => { RestartRound(); });
        m_ButtonEndingQuitToMenu.onClick.AddListener(() => { QuitToMainMenu(); });
        m_ButtonInGameRestart.onClick.AddListener(() => { ProcessPlayerPressingRestartButton(); });
        m_ButtonInGameEndGame.onClick.AddListener(() => { QuitToMainMenuInGame(); });

        m_iCurrentLevelNumber = PlayerPrefs.GetInt("CurrentLevel");

        if (m_iCurrentLevelNumber < m_iParScores.Length)
        {
            m_ButtonEndingNextLevel.onClick.AddListener(() => { GoToLevel(m_iCurrentLevelNumber + 1); });
            print("Set next level to " + m_iCurrentLevelNumber + 1);
        }
        else
        {
            m_ButtonEndingNextLevel.gameObject.SetActive(false);
        }

        SetHoleAndParText();

        m_AudioPlayerMusic.loop = true;
        m_AudioPlayerMusic.clip = m_AudioClipMusicEndGame;
        m_AudioPlayerMusic.Play();

        m_AudioPlayerSFX.loop = false;

        // Display the starting UI
        DisplayStartLevelUI();
    }
Beispiel #3
0
    void SpawnBall()
    {
        ball = Instantiate(ballPrefabe, transform.position, new Quaternion(0, 0, 0, 1));
        ball.SetColor((int)currentColor);

        Renderer materialRenderer = transform.GetChild(0).GetComponent <Renderer>();

        materialRenderer.material = materials[(int)currentColor];

        nextColor = (BallColor)rngObject.Next();

        materialRenderer          = transform.GetChild(1).GetComponent <Renderer>();
        materialRenderer.material = materials[(int)nextColor];

        rb           = ball.GetComponent <Rigidbody>();
        currentColor = nextColor;
    }