Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (obstaculos <= 0)
     {
         God.GameOver("Walker");
     }
 }
    // Update is called once per frame
    void Update()
    {
        this.transform.position = Vector3.Lerp(new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z), new Vector3(-13.2f, this.transform.position.y, this.transform.position.z), Time.deltaTime / 3);
        this.GetComponent <Rigidbody> ().velocity = new Vector3(0f, this.GetComponent <Rigidbody> ().velocity.y, 0f);

        if (active)
        {
            if (HP <= 0 || this.transform.position.x < -20f || this.transform.position.y < -5f)
            {
                try {
                    GameObject.Find("Main Camera W1").GetComponent <AudioSource> ().mute = true;
                    GameObject.Find("Main Camera M1").GetComponent <AudioSource> ().mute = true;
                } catch (System.NullReferenceException) {
                }
                God.GameOver("Meddler");
            }

            rigidBody.AddForce(Vector3.down * JumpSpeed);
            if ((Input.GetKeyDown(KeyCode.UpArrow)) || (SwipeDetector.swipeValue > 0))
            {
                jump();
            }

            //pressionar o botao ou deslizar o dedo para baixo
            if (Input.GetKeyDown(KeyCode.DownArrow) || (SwipeDetector.swipeValue < 0))
            {
                sweep();
            }
            if (sweepKick == true)
            {
                actionTime += Time.deltaTime;
            }
            if (actionTime >= sweepKickDuration)
            {
                SwipeDetector.swipeValue = 0;
                capsuleCollider.height   = 4.5f;
                capsuleCollider.center   = newCenterRun;
                sweepKick  = false;
                actionTime = 0;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (PlataformGenerator.Player.transform.position.x < -15f || PlataformGenerator.Player.transform.position.y < -5f)
        {
            try {
                GameObject.Find("Main Camera W1").GetComponent <AudioSource> ().mute = true;
                GameObject.Find("Main Camera M1").GetComponent <AudioSource> ().mute = true;
            } catch (System.NullReferenceException) {
            }
            God.GameOver("Meddler");
        }
        if (randomJump && Random.value < 0.01f)
        {
            if (Random.value < 0.3f)
            {
                PlataformGenerator.instance.buttonPew();
            }
            if (Random.value < 0.5f)
            {
                PlataformGenerator.Player.gameObject.GetComponent <PlayerController> ().jump();
            }
            else
            {
                PlataformGenerator.Player.gameObject.GetComponent <PlayerController> ().sweep();
            }
            if (PlataformGenerator.Player.transform.position.x < -20f || PlataformGenerator.Player.transform.position.y < -5f)
            {
                try {
                    GameObject.Find("Main Camera W1").GetComponent <AudioSource> ().mute = true;
                    GameObject.Find("Main Camera M1").GetComponent <AudioSource> ().mute = true;
                } catch (System.NullReferenceException) {
                }
                God.GameOver("Meddler");
            }
        }
        if (randomMonster && Random.value < 0.02f)
        {
            GameMaster.instance.obstaculos--;
            if (Random.value < 0.1)
            {
                GameMaster.dropPlataform();
            }
            else if (Random.value < 0.1)
            {
                GameMaster.barracaDoce();
            }
            else if (Random.value < 0.75)
            {
                GameMaster.spawnMonster(0);
            }
            else
            {
                switch (Random.Range(1, 4))
                {
                case 1:
                    GameMaster.spawnPowerUp("Jump");
                    break;

                case 2:
                    GameMaster.spawnPowerUp("Shield");
                    break;

                case 3:
                    GameMaster.spawnPowerUp("Speed");
                    break;
                }
            }
        }

        meddlerScore.text = (150 * Score.despawned + 200 * Score.powerUp).ToString();
        walkerScore.text  = (10 * Score.despawned + 200 * Score.died + 50 * Score.powerUp).ToString();
    }