domingo, 16 de enero de 2022

¿como funciona un sistema de quitar puntos o vidas en Unity y al hacerlo cambie la escena?;

¿Como funciona un sistema de quitar puntos o vidas en

Unity y al hacerlo cambie la escena?...adjunto el script

 

  using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DISMINUYEPUNTOSYCAMBIALAESCENA : MonoBehaviour {



        // Create public variables for player speed, and for the Text UI game objects
        public float speed;
        public Text countText;
        public Text winText;

        // Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
        private Rigidbody rb;
        private int count;/// <summary>



        // At the start of the game..
        void Start ()
        {


            // Assign the Rigidbody component to our private rb variable
            rb = GetComponent<Rigidbody>();

            // Set the count to zero 
            count = 10;

            // Run the SetCountText function to update the UI (see below)
            SetCountText ();

            // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
            winText.text = "";
        }


        void OnTriggerEnter(Collider other) 
        {


            if (other.gameObject.CompareTag ("pomada"))



            {
                // Make the other game object (the pick up) inactive, to make it disappear
                other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                // Add one to the score variable 'count'
                count = count - 1;


                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {


            countText.text = "VIDAS: " + count.ToString ();
            // Check if our 'count' is equal to or exceeded 12
            if (count <= 1) 
                //if (count >= 99) 
            {
                // Set the text value of our 'winText'
            //    winText.text = "JUEGO COMPLETADO";

                //    Destroy (gameObject, 1.2f); 

                Application.LoadLevel (1);

            }
        }
    }

 

 ----------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------- 

mismo script explicando las lineas..........

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DISMINUYEPUNTOSYCAMBIALAESCENA : MonoBehaviour {



        // Create public variables for player speed, and for the Text UI game objects
        public float speed;
        public Text countText;
        public Text winText;

        // Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
        private Rigidbody rb;
        private int count;/// <summary>



        // At the start of the game..
        void Start ()
        {


            // Assign the Rigidbody component to our private rb variable
            rb = GetComponent<Rigidbody>();

            // PARTIENDO DE 10 VIDAS QUE IRAN DISMINUYENDO
            count = 10;

            // Run the SetCountText function to update the UI (see below)
            SetCountText ();

            // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
            winText.text = "";
        }


        void OnTriggerEnter(Collider other) 
        {

//GAMEOBJECT CON NOMBRE TAG "POMADA" QUE PRODUCIDA LA RESTA DE PUNTOS DE 1 EN 1
              if (other.gameObject.CompareTag ("pomada"))



            {
                // Make the other game object (the pick up) inactive, to make it disappear
                other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                // RESTA 1 PUNTO
                count = count - 1;


                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {


            countText.text = "VIDAS: " + count.ToString ();
            // CUANDO ES MENOR DE 1 PUNTO CAMBIA LA ESCENA
            if (count <= 1) 

                //if (count >= 99) 
            {
                // Set the text value of our 'winText'
            //    winText.text = "JUEGO COMPLETADO";

                //    Destroy (gameObject, 1.2f); 

                Application.LoadLevel (1);

            }
        }
    }


play!!!;

 

the-wolf-man-of-the-underground-iii-demo-4 Y demo 4...perfeccionando las agresiones de los guardias, perdiendo vida si me agreden, y destrozando una zona del ascensor desde donde salen los guardias para que dejen de salir y atacar al hombre lobo, tienes que golpear el cuadro eléctrico del ascensor