Ejemplo n.º 1
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (IsAStick(other.gameObject))
     {
         _overedStick = other.GetComponent <StickController>();
     }
 }
Ejemplo n.º 2
0
 void GameManager_OnStickStartGrow()
 {
     if (IsActive)
     {
         StickController.StartGrow();
         Debug.Log("StartGrow");
     }
 }
Ejemplo n.º 3
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());
 }
Ejemplo n.º 4
0
 void GameManager_OnStickStopGrow()
 {
     if (IsActive)
     {
         StickController.StopGrow();
         StickController.FallStick();
         Debug.Log("StopGrow");
     }
 }
Ejemplo n.º 5
0
    void OnTriggerExit2D(Collider2D other)
    {
        if (IsAStick(other.gameObject))
        {
            // Restore opacity on the disks of the hovered stick (and it is not the stick the disk is on)
            if (_isMouseDragging && !IsCurrentStick(other.GetComponent <StickController>()))
            {
                other.GetComponent <StickController>().SetDisksTransparent(false, this);
            }

            _overedStick = null;
        }
    }
Ejemplo n.º 6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (IsAStick(other.gameObject))
        {
            _overedStick = other.GetComponent <StickController>();

            // Trigger a laywer of transparency on the disks of the hovered stick (and it is not the stick the disk is on)
            if (_isMouseDragging && !IsCurrentStick(_overedStick))
            {
                other.GetComponent <StickController>().SetDisksTransparent(true, this);
            }
        }
    }
Ejemplo n.º 7
0
 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());
 }
Ejemplo n.º 8
0
    public void MainMenu_OnEnter()
    {
        cameraSize = 3.5f;
        charObj    = GameObject.Find("Player");
        CharController.SetStartCharPosition();
        Camera.main.orthographicSize = 1f;

        transform.position = new Vector3(
            charObj.transform.position.x + 0.5f,
            charObj.transform.position.y,
            gameObject.transform.position.z);

        PlayerPrefs.SetInt(EPISODE_GAME_KEY, 7);
        StickController.DeleteObjectStick();
        PlatformController.DeletePlatform(0);
        PlatformController.DeletePlatform(1);
        PlatformController.BuildFirstPlatform();
    }
Ejemplo n.º 9
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != null)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        boardScript = GetComponent <BoardManager>();
        stickScript = GetComponent <StickController>();

        CameraSetting();

        InitialGameState();
    }
Ejemplo n.º 10
0
 void Update()
 {
     if (PlayerPrefs.GetInt(EPISODE_GAME_KEY).Equals(0) ||
         PlayerPrefs.GetInt(EPISODE_GAME_KEY).Equals(7))
     {
         transform.position = VectorMoveHero;
     }
     if (!transform.position.Equals(VectorMoveHero))
     {
         transform.position = Vector3.MoveTowards(
             transform.position,
             VectorMoveHero,
             Time.deltaTime * speedRotationStick);
     }
     else if (PlayerPrefs.GetInt(EPISODE_GAME_KEY).Equals(4))
     {
         StickController.DeleteObjectStick();
         StickController.CreateObjectStick(VectorMoveHero);
         PlatformController.ChangeColumns();
     }
 }
Ejemplo n.º 11
0
 private bool IsCurrentStick(StickController other)
 {
     // Check if a stick is the same has the one on which this disk is piled
     return(currentStick.name == other.name);
 }
Ejemplo n.º 12
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;
        }
    }
Ejemplo n.º 13
0
 void Start()
 {
     Stick = GetComponent <StickController>();
     Hand.GetComponent <ObjectDetect>().Grabber = this;
 }
 void Start()
 {
     stickCont = stickController.GetComponent <StickController>();
 }