void Update()
    {
        moveHor = Input.GetAxis("Horizontal") * speed;
        animator.SetFloat("Speed", Mathf.Abs(moveHor));
        animatorChest.SetFloat("DifferenceX", GameObject.Find("Chest").transform.position.x - GameObject.Find("Player").transform.position.x);

        if (CoinManagerScript.GetMoney() >= 10)
        {
            animatorChest.SetBool("open", true);
        }

        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
            animator.SetBool("IsJumping", true);
            SoundManagerScript.PlaySound("jump");
        }

        if (Input.GetButtonDown("Crouch"))
        {
            animator.SetBool("IsCrouching", true);
            crouch = true;
        }

        else if (Input.GetButtonUp("Crouch"))
        {
            animator.SetBool("IsCrouching", false);
            crouch = false;
        }
    }
 // Update is called once per frame
 void Start()
 {
     coinManager   = GameObject.Find("CoinManager").GetComponent <CoinManagerScript>();
     gameManager   = GameObject.Find("GameManager").GetComponent <GameManagerScript>();
     animatorChest = GameObject.Find("Chest").GetComponent <Animator>();
     rb            = GetComponent <Rigidbody2D>();
 }
    public void LevelsManagement()
    {
        CoinManagerScript.ResetMoney();
        HeartMenago.ResetHealth();

        level2 = LevelsManager.getLevel2();
        level3 = LevelsManager.getLevel3();

        if (!level2)
        {
            Level2.GetComponent <Button>().interactable = false;
            Level3.GetComponent <Button>().interactable = false;
        }

        else if (!level3)
        {
            Level2.GetComponent <Button>().interactable = true;
            Level3.GetComponent <Button>().interactable = false;
        }

        else
        {
            Level2.GetComponent <Button>().interactable = true;
            Level3.GetComponent <Button>().interactable = true;
        }

        points      = LevelsManager.getPoints();
        Points      = GameObject.Find("PointsText").GetComponent <Text>();
        Points.text = points.ToString();
    }
    void Start()
    {
        currentSpawnTimer = timeBetweenSpawns;

        scoreScript = GameObject.FindGameObjectWithTag("UI").GetComponent<ScoreUIScript>();
        exitScript = GameObject.FindGameObjectWithTag("Exit").GetComponent<ExitScript>();

        gameTime = 0.0f;

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        coinManager = GameObject.Find("CoinManager").GetComponent<CoinManagerScript>();
    }
    public void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.tag == "Coin")
        {
            coinManager.CollectedCoin();
            Destroy(collision.gameObject);
            SoundManagerScript.PlaySound("pickup");
        }

        else if (collision.tag == "Chest")
        {
            if (CoinManagerScript.GetMoney() >= 10)
            {
                animatorChest.SetBool("open", true);

                if (SceneManager.GetActiveScene().name == "Level1")
                {
                    LevelsManager.setLevel2();
                }

                else if (SceneManager.GetActiveScene().name == "Level2")
                {
                    LevelsManager.setLevel3();
                }

                gameManager.LoadLevels();
                SoundManagerScript.PlaySound("complete");
            }
        }

        else if (collision.tag == "Spike")
        {
            SoundManagerScript.PlaySound("hit");
            HeartMenago.heartbroken();
            gameManager.ResetLevel(controller);
        }

        else if (collision.tag == "Dead")
        {
            HeartMenago.heartbroken();
            gameManager.ResetLevel(controller);
            SoundManagerScript.PlaySound("fall");
        }
    }
 public void GameOverManagement()
 {
     points      = CoinManagerScript.GetMoney();
     Points      = GameObject.Find("PointsText").GetComponent <Text>();
     Points.text = points.ToString();
 }
Beispiel #7
0
 // Use this for initialization
 void Awake()
 {
     GMS = GameObject.Find("CoinManager").GetComponent <CoinManagerScript> ();
     GMS.cur_coins++;
 }