Exemple #1
0
    public void TakeDamage(float damage)
    {
        PopUpController.CreateFloatingText(damage.ToString(), UIsocket, player.transform.position, transform.position);

        health -= damage;
        UpdateHealth();

        StartCoroutine(ChangeTexture());

        if (health <= 0)
        {
            isDead = true;
            StartCoroutine(DieAnimation());
            Die();
        }
    }
Exemple #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Target")
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY;

            if (other.gameObject.transform.parent.name == gameObject.name)
            {
                PopUpController.CreateFloatingText("¡Bien!", transform);
                Game2Manager.correctHits++;
            }
            else
            {
                Game2Manager.failedTarget = true;
            }
        }
    }
Exemple #3
0
    private void Update()
    {
        float translation = Input.GetAxis("Horizontal") * speed * Time.deltaTime;

        if (touchingFloor) //mientras que toque la plataforma se termina el tiempo para pensar a donde saltar
        {
            actualTime += Time.deltaTime;
        }

        if (!touchingFloor)
        {
            timeInAir += Time.deltaTime;
            if (timeInAir > 5)
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
                PlatformSpawner.PlatformsSpawned = false;
            }
        }

        if (actualTime >= totalTime)
        {
            GameObject plat = GameObject.Find(SignManager.correctDirection);
            wrongPlat = plat.gameObject.GetComponent <Platform>();

            if (wrongPlat.color != "Red")
            {
                CameraShake.shouldShake = true;
                Game3Manager.failed     = true;
                actualTime = 0;
            }
            else
            {
                PopUpController.CreateFloatingText("¡Bien!", transform);
                Game3Manager.correct = true;
            }
            actualTime = 0;
        }


        if (!jumping)
        {
            transform.Translate(translation, 0, 0);
        }
    }
Exemple #4
0
    void Shoot()
    {
        RaycastHit hitInfo;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hitInfo, 200))
        {
            if (SignManagerGame5.typeDecider == 0) // si el cartel dice que me fije por el numero
            {
                Debug.Log(hitInfo.transform.name);
                if (hitInfo.transform.name.Substring(0, 1) == SignManagerGame5.number) //si el nombre del portal es igual al numero, esta bien
                {
                    PopUpController.CreateFloatingText("¡Bien!", hitInfo.transform);
                    Game5Control.correct = true;
                }
                else
                {
                    CameraShake.shouldShake = true;
                    Game5Control.failed     = true;
                }
            }
            if (SignManagerGame5.typeDecider == 1)                                                  // si el cartel dice que me fije por el nombre
            {
                bool correct = hitInfo.collider.gameObject.GetComponent <Portal>().CompareColors(); // llama a la funcion CompareColors del script del baculo
                if (correct)
                {
                    PopUpController.CreateFloatingText("¡Bien!", hitInfo.transform);
                    Game5Control.correct = true;
                }
                else
                {
                    CameraShake.shouldShake = true;
                    Game5Control.failed     = true;
                }
            }

            PortalManager.newRound  = true;
            SignManagerGame5.reDraw = true;
        }
    }
Exemple #5
0
    private void OnCollisionEnter(Collision collision)
    {
        timeInAir  = 0;
        actualTime = 0;
        justLanded = true;

        if (collision.gameObject.tag == "Platform")
        {
            PlatformSpawner.currentPlatform = collision.transform;           //la poscision de la plataforma en la que estoy se la paso al script Spawner para que sepa donde spawnear las siguientes plataformas

            platformScript = collision.gameObject.GetComponent <Platform>(); //agarro el script de la plataforma en la que estoy
            PlatformSpawner.currentPlatformColor = platformScript.color;     //le paso el color de la plataforma del script de la plataforma al script Spawner

            if (platformScript.color == "Red" || PlatformSpawner.currentPlatform == PlatformSpawner.lastPlatform)
            {
                CameraShake.shouldShake = true;
                Game3Manager.failed     = true;
            }
            else if (SignManager.correctDirection == collision.gameObject.name) //si cayó en la plataforma correcta(si la direccion era izq y el nombre de la paltaforma es izq), se le da como bien
            {
                PopUpController.CreateFloatingText("¡Bien!", transform);
                Game3Manager.correct = true;
            }
            else
            {
                if (collision.gameObject.name != "RightPlatform")
                {
                    CameraShake.shouldShake = true;
                    Game3Manager.failed     = true;
                }
            }
        }
        if (collision.gameObject.name == "")
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            PlatformSpawner.PlatformsSpawned = false;
        }
    }
Exemple #6
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "rock")
     {
         //logica
     }
     else
     {
         if (other.gameObject.tag == ballManagerScript.correctBall.ToString())
         {
             PopUpController.CreateFloatingText("¡Bien!", other.gameObject.transform);
             ballManagerScript.correctBallCount++;
             ballManagerScript.totalCorrectBalls++;
         }
         else
         {
             CameraShake.shouldShake            = true;
             ballManagerScript.correctBallCount = 0;
             ballManagerScript.LostStreak();
         }
     }
     // Debug.Log(ballManagerScript.correctBallCount);
     ballManagerScript.currentBallCount--;
 }