warlike feats, "the documents"
Continuando con el videojuego, e añadido una nueva opción , al apretar la tecla “o” el player activa una bomba con temporizador que hace estallar algunas torres de vigilancia, ¿y como lo e resuelto? E añadido una par o tres mas de nuevos scripts en c#.
E jugado con el efecto de gravedad del rigidbody, se puede manipular para que un gameobject caiga mas rápido o mas lento y lo e aprovechado para que un cubo al tocar con otro active una explosión, a la vez e puesto un reloj que marca un tiempo al girar la aguja y un sonido del tic tac conforme se a encendido un dispositivo, e tenido el problema de que el player al estar muy cerca al activar la bomba me producía un error y se colgaba el videojuego.
Lo e resuelto con otro script que hace que el player a la vez que coloque la bomba se aleja de la torre.
El primer paso para hacer este tema del juego sobre bomba con temporizador a sido preparar una esfera la e puesto como granada que lanza en player pero con un tac personalizado para que solo funcione si toca el cubo de la base de la torre, que al borrarse provoca la caída de otro cubo y ala aparición del reloj y que provoca por acción de otro script el derrumbe de la torre y la aparición de esta derrumbada destruida….a continuación facilito todos los scripts que e utilizado para esta acción particular del juego.
using UnityEngine;
using System.Collections;
public class TransformFunctions : MonoBehaviour
{
public float moveSpeed = 10f;
public float turnSpeed = 50f;
void Update ()
{
if (Input.GetKey(KeyCode.W))////funciona contantemente al apretar W mayusculas a de ser
//if (Input.GetKeyDown(KeyCode.W))// funciona pasito a pasito
//if(Input.GetKey(KeyCode.UpArrow))
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.S))////funciona contantemente al apretar W mayusculas a de ser
//if(Input.GetKey(KeyCode.DownArrow))
transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.O)) ////ametralladoraESPECIALRETROCEDE AL COLOCAR BOMBA
// if (Input.GetButtonDown ("Fire1")) original tiro a tiro
//transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);originalllllllllllllllllllllllllllllllll
transform.position -= Vector3.forward * Time.deltaTime;///////FAAAAALLLLLSSSOOOOOOOOOOOOOOOOOOOOOOOOOOOO--si--
if (Input.GetKey(KeyCode.A))////funciona contantemente al apretar W mayusculas a de ser
//if(Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.D))////funciona contantemente al apretar W mayusculas a de ser
//if(Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CONTROLREPARTIDOR : MonoBehaviour {
public Animator Anim;
public float WalkSpeed;
void Update () {
if (Input.GetKey (KeyCode.E)) {
Anim.SetBool ("CORRER", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("CORRER", false);
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("ANDA", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("ANDA", false);
if (Input.GetKey (KeyCode.S)) {
Anim.SetBool ("ATRAS", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("ATRAS", false);
if (Input.GetKey (KeyCode.A)) {
Anim.SetBool ("CORRER", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("CORRER", false);
if (Input.GetKey (KeyCode.P)) {
Anim.SetBool ("BOMBA", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("BOMBA", false);
if (Input.GetKey (KeyCode.O)) {
Anim.SetBool ("BOMBA", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("BOMBA", false);
if (Input.GetKey (KeyCode.D)) {
Anim.SetBool ("CORRER", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("CORRER", false);
if (Input.GetButton ("Fire1")) {
Anim.SetBool ("DISPARANDO", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("DISPARANDO", false);
if (Input.GetKey (KeyCode.M)) {
Anim.SetBool ("LANZAR", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("LANZAR", false);
}
}
}
}
}
}
}
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DESTRUYEPORTAGPERSONAL : MonoBehaviour {
//public float distancePerSecond;//////IMBENTADO
//public float Destroy = 0.2f;
// Use this for initialization
void Start () {
}
//void OnCollisionEnter (){
void OnCollisionEnter (Collision collision)
{
//if (collision.gameObject.tag == "maloazul (4)") {
//Destroy (gameObject, 0.0f);
if (collision.gameObject.tag == "MOCHILA") {
// Destroy ("MOCHILA");
Destroy (gameObject, 0.0f);
//transform.position = new Vector3 (198.301f, 20.316f, 136.023f);/////////nuebo mio
//transform.Translate (new Vector3 (198 * Time.deltaTime, 20, 136.2f), Space.Self);/////////////IMBENTADO
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class girosobresi : MonoBehaviour {
// Use this for initialization
void Start () {
//transform.rotation = Quaternion.Euler (0,45, 0);
}
// Update is called once per frame
void Update () {
// Es la rotacion de Angulos de Euler en grados.
transform.Rotate (new Vector3 (0 * Time.deltaTime, 0, 0.4f), Space.Self);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class aspa : MonoBehaviour {
// Use this for initialization
void Start () {
//transform.rotation = Quaternion.Euler (0,45, 0);
}
// Update is called once per frame
void Update () {
// Es la rotacion de Angulos de Euler en grados.
transform.Rotate (new Vector3 (33 * Time.deltaTime, 0, 0), Space.Self);
}
}
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace UnityStandardAssets.Utility
{
public class ActivateTrigger : MonoBehaviour
{
// A multi-purpose script which causes an action to occur when
// a trigger collider is entered.
public enum Mode
{
Trigger = 0, // Just broadcast the action on to the target
Replace = 1, // replace target with source
Activate = 2, // Activate the target GameObject
Enable = 3, // Enable a component
Animate = 4, // Start animation on target
Deactivate = 5 // Decativate target GameObject
}
public Mode action = Mode.Activate; // The action to accomplish
public Object target; // The game object to affect. If none, the trigger work on this game object
public GameObject source;
public int triggerCount = 1;
public bool repeatTrigger = false;
private void DoActivateTrigger()
{
triggerCount--;
if (triggerCount == 0 || repeatTrigger)
{
Object currentTarget = target ?? gameObject;
Behaviour targetBehaviour = currentTarget as Behaviour;
GameObject targetGameObject = currentTarget as GameObject;
if (targetBehaviour != null)
{
targetGameObject = targetBehaviour.gameObject;
}
switch (action)
{
case Mode.Trigger:
if (targetGameObject != null)
{
targetGameObject.BroadcastMessage("DoActivateTrigger");
}
break;
case Mode.Replace:
if (source != null)
{
if (targetGameObject != null)
{
Instantiate(source, targetGameObject.transform.position,
targetGameObject.transform.rotation);
DestroyObject(targetGameObject);
}
}
break;
case Mode.Activate:
if (targetGameObject != null)
{
targetGameObject.SetActive(true);
}
break;
case Mode.Enable:
if (targetBehaviour != null)
{
targetBehaviour.enabled = true;
}
break;
case Mode.Animate:
if (targetGameObject != null)
{
targetGameObject.GetComponent<Animation>().Play();
}
break;
case Mode.Deactivate:
if (targetGameObject != null)
{
targetGameObject.SetActive(false);
}
break;
}
}
}
private void OnTriggerEnter(Collider other)
{
DoActivateTrigger();
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LAUNCHER3 : MonoBehaviour {
public Rigidbody projectile;
public Rigidbody explosiveProjectile;
public float launchspeed = 50;
public bool useExplodingProjectiles = false;
private float _LaunchDelayTime = 0.0f;
public int stackSize = 60;
public Transform launchHole1;
public Transform launchHole2;
private Stack _Projectiles;
private Stack _ExplosiveProjectiles;
private Transform _myTransform;
// Use this for initialization
void Start ()
{
_myTransform = transform;
_Projectiles = new Stack();
if(useExplodingProjectiles)
{
_ExplosiveProjectiles = new Stack();
}
for(int i = 0; i < stackSize; i++)
{
Rigidbody tr = Instantiate (projectile, _myTransform.position, _myTransform.rotation) as Rigidbody;
PushProjectile(tr);
if(useExplodingProjectiles)
{
Rigidbody rr = Instantiate (explosiveProjectile, _myTransform.position, _myTransform.rotation) as Rigidbody;
PushExplosiveProjectile(rr);
}
}
}
// Update is called once per frame
void Update ()
{
if(_Projectiles.Count > 0)
{
if(Time.time > _LaunchDelayTime)
{
//if (Input.GetKeyDown(KeyCode.Space))
if (Input.GetKey (KeyCode.O)) /////////////////imbentadooooooooooooooooooooooooooooooooooooo
//if (Input.GetButton ("Fire1")) ////ametralladora
// if (Input.GetButtonDown ("Fire1")) original tiro a tiro
{
Rigidbody tr = PopProjectile();
tr.gameObject.SetActive(true);
tr.transform.position = launchHole1.position;
tr.transform.rotation = launchHole1.rotation;
tr.velocity = transform.TransformDirection (Vector3.forward * launchspeed);
tr = PopProjectile();
tr.gameObject.SetActive(true);
tr.transform.position = launchHole2.position;
tr.transform.rotation = launchHole2.rotation;
tr.velocity = transform.TransformDirection (Vector3.forward * launchspeed);
_LaunchDelayTime = Time.time + 0.5f;
}
}
}
if(useExplodingProjectiles)
{
if(_ExplosiveProjectiles.Count > 0)
{
if(Time.time > _LaunchDelayTime)
{
if (Input.GetButtonDown ("Fire2"))
{
Rigidbody tr = PopExplosiveProjectile();
tr.gameObject.SetActive(true);
tr.transform.position = launchHole1.position;
tr.transform.rotation = launchHole1.rotation;
tr.velocity = transform.TransformDirection (Vector3.forward * launchspeed);
tr = PopExplosiveProjectile();
tr.gameObject.SetActive(true);
tr.transform.position = launchHole2.position;
tr.transform.rotation = launchHole2.rotation;
tr.velocity = transform.TransformDirection (Vector3.forward * launchspeed);
_LaunchDelayTime = Time.time + 0.5f;
}
}
}
}
}
public void PushProjectile(Rigidbody x)
{
x.gameObject.SetActive(false);
_Projectiles.Push(x);
}
public Rigidbody PopProjectile()
{
return (Rigidbody)_Projectiles.Pop();
}
public void PushExplosiveProjectile(Rigidbody x)
{
x.gameObject.SetActive(false);
_ExplosiveProjectiles.Push(x);
}
public Rigidbody PopExplosiveProjectile()
{
return (Rigidbody)_ExplosiveProjectiles.Pop();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DESTRUYEPORTAGPERSONAL : MonoBehaviour {
//public float distancePerSecond;//////IMBENTADO
//public float Destroy = 0.2f;
// Use this for initialization
void Start () {
}
//void OnCollisionEnter (){
void OnCollisionEnter (Collision collision)
{
//if (collision.gameObject.tag == "maloazul (4)") {
//Destroy (gameObject, 0.0f);
if (collision.gameObject.tag == "MOCHILA") {
// Destroy ("MOCHILA");
Destroy (gameObject, 0.0f);
//transform.position = new Vector3 (198.301f, 20.316f, 136.023f);/////////nuebo mio
//transform.Translate (new Vector3 (198 * Time.deltaTime, 20, 136.2f), Space.Self);/////////////IMBENTADO
}
}
}
using UnityEngine;
using System.Collections;
using UnityEngine;
public class BORRAMIBALA : MonoBehaviour {
public float Destroy = 2f;
// Use this for initialization
void Start () {
}
void OnCollisionEnter (){
Destroy (gameObject, 3.30f);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class suenateclao : MonoBehaviour {
public AudioSource tickSource;
void Start () {
tickSource = GetComponent<AudioSource> ();
}
void Update () {
if (Input.GetKey (KeyCode.O)) {
tickSource.Play ();
}}
}
No hay comentarios:
Publicar un comentario