Example #1
0
 public void StartButton_OnClick()
 {
     Camera.main.orthographicSize = cameraSize;
     PlayerPrefs.SetInt(EPISODE_GAME_KEY, 0);
     PlatformController.BuildSecondPlatform();
     StickController.SetSpeedGrowStick(0);
     StickController.SetSpeedRotationStick(0);
     StickController.CreateObjectStick(CharController.GetVectorChar());
 }
 public void RestartButton_OnClick()
 {
     PlayerPrefs.SetInt(EPISODE_GAME_KEY, 0);
     CharController.SetStartCharPosition();
     StickController.DeleteObjectStick();
     PlatformController.DeletePlatform(0);
     PlatformController.DeletePlatform(1);
     PlatformController.BuildSecondPlatform();
     PlatformController.BuildFirstPlatform();
     StickController.SetSpeedGrowStick(0);
     StickController.SetSpeedRotationStick(0);
     StickController.CreateObjectStick(CharController.GetVectorChar());
 }
Example #3
0
    void Update()
    {
        //Debug.Log(PlayerPrefs.GetInt(EPISODE_GAME_KEY));
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (PlayerPrefs.GetInt(EPISODE_GAME_KEY).Equals(0))
            {
                PlayerPrefs.SetInt(EPISODE_GAME_KEY, 1);
                if (PlayerPrefs.GetInt(SOUND_KEY).Equals(0))
                {
                    audioSource.Play();
                }
                return;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            if (PlayerPrefs.GetInt(EPISODE_GAME_KEY).Equals(1))
            {
                audioSource.Stop();
                PlayerPrefs.SetInt(EPISODE_GAME_KEY, 2);
                return;
            }
        }
        switch (PlayerPrefs.GetInt(EPISODE_GAME_KEY))
        {
        case 3:
            stickTransform = StickController.GetTransformStick();

            firstPlatformTransform =
                PlatformController.GetTransformOfPlatform(0);

            secondPlatformTransform =
                PlatformController.GetTransformOfPlatform(1);

            StickLength = stickTransform.localScale.y;
            DistanceBetweenPlatforms = Mathf.Abs(
                secondPlatformTransform.position.x
                - firstPlatformTransform.position.x);

            WidthOfSecondPlatform = (secondPlatformTransform.localScale.x);
            MaxStickLength        = DistanceBetweenPlatforms;

            MinStickLength =
                DistanceBetweenPlatforms - WidthOfSecondPlatform;

            if (MinStickLength <= StickLength &&
                StickLength <= MaxStickLength)
            {
                CharController.SetVectorMoveChar(MaxStickLength);
                if (MaxStickLength - 0.4f
                    * WidthOfSecondPlatform
                    > StickLength && MaxStickLength - 0.6f
                    * WidthOfSecondPlatform < StickLength)
                {
                    currentScore++;
                    if (PlayerPrefs.GetInt(SOUND_KEY).Equals(0))
                    {
                        audioSource.PlayOneShot(bonusSound);
                    }
                }
                else
                {
                    if (PlayerPrefs.GetInt(SOUND_KEY).Equals(0))
                    {
                        audioSource.PlayOneShot(successSound);
                    }
                }
                currentScore++;
                UpdateScores(currentScore);
                PlayerPrefs.SetInt(EPISODE_GAME_KEY, 4);
            }
            else
            {
                ShowGameOverPanel(currentScore);
                currentScore = 0;
                if (PlayerPrefs.GetInt(SOUND_KEY).Equals(0))
                {
                    audioSource.PlayOneShot(deathSound);
                }
                PlayerPrefs.SetInt(EPISODE_GAME_KEY, 6);
            }
            break;

        case 5:
            StickController.SetSpeedGrowStick(0);
            StickController.SetSpeedRotationStick(0);
            PlayerPrefs.SetInt(EPISODE_GAME_KEY, 0);
            break;
        }
    }