Videojuego completo muy sencillo, solo has de poner la bola blanca en la caja blanca, si te pillan pierdes vidas y se reinicia el videojuego , si lo pones la bola blanca en la caja blanca ganas juego , juego completado. Manejo teclas w-a-s-d-.
Version especial para telefonos solamente arrastrar el dedo en pantalla.
https://videojuegosenlineaasaco4.blogspot.com/
¿Como hacer unos reinicios de juego cuando te matan enemigos?
En este videojuego nuevo de hoy , muy simple el tema , soy un cubo verde que tengo que empujar una bola blanca asta que esta toque un cubo blanco mientras lo ago me persiguen un cubos rojos que me quitan vidas.
Tengo 10 vidas y para este efecto pongo el siguiente script
using UnityEngine;
// Include the namespace required to use Unity UI
using UnityEngine.UI;
using System.Collections;
public class BAJAPUNTOS : MonoBehaviour {
// Create public variables for player speed, and for the Text UI game objects
public float speed;
public Text countText;
public Text winText;
//public AudioSource tickSource;
//public AudioSource tickSource;
// 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>
/// //////////////////////////////////////////
/// </summary>
//private int PUNTOS;/// <summary>
/// /////////////////////////////////////////////////
/// </summary>
// At the start of the game..
void Start ()
{
//tickSource = GetComponent<AudioSource> ();
//tickSource = Getcomponent<AudioSource> ();
// 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 = "";
}
// Each physics step..
//void FixedUpdate ()
//{
// Set some local float variables equal to the value of our Horizontal and Vertical Inputs
//float moveHorizontal = Input.GetAxis ("Horizontal");
//float moveVertical = Input.GetAxis ("Vertical");
// Create a Vector3 variable, and assign X and Z to feature our horizontal and vertical float variables above
//Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
// Add a physical force to our Player rigidbody using our 'movement' Vector3 above,
// multiplying it by 'speed' - our public player speed that appears in the inspector
// rb.AddForce (movement * speed);
//}
// When this game object intersects a collider with 'is trigger' checked,
// store a reference to that collider in a variable named 'other'..
void OnTriggerEnter(Collider other)
{
// ..and if the game object we intersect has the tag 'Pick Up' assigned to it..
//if (other.gameObject.CompareTag ("pruebassonido"))
//if (other.gameObject.CompareTag ("bolaesplota"))
if (other.gameObject.CompareTag ("MATA"))
//if (other.gameObject.CompareTag ("Terrain"))
//if (other.gameObject.CompareTag ("Pick Up 1"))
//if (other.gameObject.CompareTag ("Sphere"))
{
// Make the other game object (the pick up) inactive, to make it disappear
//other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
other.gameObject.SetActive (true);
// Add one to the score variable 'count'
count = count - 1;
//tickSource.Play ();
// Run the 'SetCountText()' function (see below)
SetCountText ();
}
}
// Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
void SetCountText()
{
// Update the text field of our 'countText' variable
//countText.text = "Count: " + count.ToString ();
countText.text = "VIDAS: " + count.ToString ();
// Check if our 'count' is equal to or exceeded 12
//if (count >= 20)
if (count <= -1)
{
// Set the text value of our 'winText'
winText.text = "JUEGO COMPLETADO";
//TextMeshPro = "CAMPEON GANASTES";
Application.LoadLevel (2);
//Destroy (gameObject, 1.2f);
//transform.position += transform.forward * 210.222f * Time.deltaTime; ///////etste solo
//transform.position += transform.forward *110.02f * Time.deltaTime;
//transform.position -= transform.forward *8.02f * Time.deltaTime;
//transform.Rotate (new Vector3 (12 * Time.deltaTime, 220, 290), Space.Self);
//Destroy (gameObject, 0.2f);
//transform.localScale += Vector3.right * 444 * Time.deltaTime;//OJOJOJOJOJOJOJOJOJO
//Destroy (gameObject, 0.2f);
//transform.Rotate(10, Time.deltaTime, 100, Space.World);
}
}
}
Este escript es el mismo de sumar puntos, e marcado de rojo donde vario el script para que reste en lugar de sumar, luego e puesto esta linea en el de arriba se ve para que al llegar a 0 el marcador se reinicie el juego
Application.LoadLevel (2);
A su vez este nivel tiene otro script con un temporizador que hace cambie al nivel de volver a jugar...hos pongo los tres scripts
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CAMBIANIVELPORTIEMPOTRANCURRIDO : MonoBehaviour {
[SerializeField] private float m_TimeOut = 2.0f;
[SerializeField] private bool m_DetachChildren = false;
private void Awake()
{
Invoke("DestroyNow", m_TimeOut);
}
private void DestroyNow()
{
if (m_DetachChildren)
{
transform.DetachChildren();
}
// DestroyObject(gameObject);
Application.LoadLevel (0);
}
}
No hay comentarios:
Publicar un comentario