Scripts

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Scripts

Colision.cs

Este script es la modificación de los scripts incluidos en “Simple Waypoint System”. Se utiliza
para detectar la colisión de un objeto con otro objeto con tag “Nave”. Al colisionar se activan y
desactivan otros objetos.

using UnityEngine;
using System.Collections;

using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using DG.Tweening;
using SWS;

public class Colision : MonoBehaviour


{

public ExampleClass4 example4;

void OnTriggerEnter(Collider col)


{
if (col.CompareTag("Nave"))
{

example4.objetoEncender.SetActive(true);
example4.objetooff3.SetActive(true);
example4.objetoEncender2.SetActive(true);
example4.objetooff.SetActive(false);
example4.objetooff2.SetActive(false);
example4.moveRef.Pause();

[System.Serializable]
public class ExampleClass4
{
public splineMove moveRef;
public GameObject objetoEncender;
public GameObject objetoEncender2;
public GameObject objetooff;
public GameObject objetooff2;
public GameObject objetooff3;
}

Irme.cs
Este script es la modificación de los scripts incluidos en “Simple Waypoint System”. Se utiliza
para encender y apagar objetos cuando el cursor del casco de realidad virtual colisiona sobre el
objeto que contenga este script. Esto hace que la nave empiece su camino desde el punto
original por la ruta trazada en moveRef.

using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using VRStandardAssets.Utils;
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using DG.Tweening;
using SWS;
namespace VRStandardAssets.Menu
{
public class Irme : MonoBehaviour
{

// Use this for initialization


[SerializeField] private SelectionRadial m_SelectionRadial; // This controls when the
selection is complete.
[SerializeField] private VRInteractiveItem m_InteractiveItem; // The interactive item
for where the user should click to load the level.

private bool m_GazeOver;


public ExampleClass2 example2;

void Start()
{

}
private void OnEnable()
{
m_InteractiveItem.OnOver += HandleOver;
m_InteractiveItem.OnOut += HandleOut;
m_SelectionRadial.OnSelectionComplete += HandleSelectionComplete;
//Debug.Log("Toy Dentro");
}

private void OnDisable()


{
m_InteractiveItem.OnOver -= HandleOver;
m_InteractiveItem.OnOut -= HandleOut;
m_SelectionRadial.OnSelectionComplete -= HandleSelectionComplete;
//Debug.Log("Toy Fuera");
}

// Update is called once per frame


void Update()
{
if (m_GazeOver)
{
if (Input.GetKeyDown("space"))
{
m_SelectionRadial.LlenarBarra();
}

if (Input.GetKeyUp("space"))
{
m_SelectionRadial.DetenerLlenado();
}
}
}

private void HandleOver()


{
m_SelectionRadial.Show();
m_GazeOver = true;
/* if (transform.tag=="Sol")
{
informacionsol.GetComponent<CanvasGroup>().alpha = 1;
informaciontierra.GetComponent<CanvasGroup>().alpha = 0;
}
if (transform.tag == "Tierra")
{
informacionsol.GetComponent<CanvasGroup>().alpha = 0;
informaciontierra.GetComponent<CanvasGroup>().alpha = 1;
}*/
}

private void HandleOut()


{
// Cuando el usuario mira hacia otro lado de la representación de la escena, esconda
el radial.
m_SelectionRadial.Hide();
//Vuelve invisible al texto cuando "alpha" sea igual a cero.

m_GazeOver = false;
}

private void HandleSelectionComplete()


{
// If the user is looking at the rendering of the scene when the radial's selection
finishes, activate the button.
if (m_GazeOver)

{
print("Me he ido");
example2.moveRef.Pause();
example2.apagarR1.SetActive(false);
example2.apagarR2.SetActive(false);
example2.objetoEncender.SetActive(false);
example2.objetoEncender2.SetActive(false);
example2.objetoEncender3.SetActive(false);
example2.objetoEncender4.SetActive(false);

example2.offTierraPanel.SetActive(false);
example2.offTierraPlaneta.SetActive(false);
example2.offTierraColision.SetActive(false);
example2.offMartePanel.SetActive(false);
example2.offMartePlaneta.SetActive(false);
example2.offMarteColision.SetActive(false);

example2.offJupiterPanel.SetActive(false);
example2.offJupiterPlaneta.SetActive(false);
example2.offJupiterColision.SetActive(false);

example2.offUranoPanel.SetActive(false);
example2.offUranoPlaneta.SetActive(false);
example2.offUranoColision.SetActive(false);

example2.offNeptunoPanel.SetActive(false);
example2.offNeptunoPlaneta.SetActive(false);
example2.offNeptunoColision.SetActive(false);

example2.offSaturnoPanel.SetActive(false);
example2.offSaturnoPlaneta.SetActive(false);
example2.offSaturnoColision.SetActive(false);

example2.SS.SetActive(true);
example2.panel.SetActive(true);
example2.planetas.SetActive(true);
//example4.moveRef.Pause();
example2.moveRef.Resume();

}
[System.Serializable]
public class ExampleClass2
{
public splineMove moveRef;
public GameObject SS;
public GameObject panel;
public GameObject planetas;
public GameObject objetoEncender;
public GameObject objetoEncender2;
public GameObject objetoEncender3;
public GameObject objetoEncender4;
public GameObject apagarR1;
public GameObject apagarR2;
public GameObject offTierraPanel;
public GameObject offTierraPlaneta;
public GameObject offTierraColision;
public GameObject offMartePanel;
public GameObject offMartePlaneta;
public GameObject offMarteColision;

public GameObject offJupiterPanel;


public GameObject offJupiterPlaneta;
public GameObject offJupiterColision;

public GameObject offUranoPanel;


public GameObject offUranoPlaneta;
public GameObject offUranoColision;

public GameObject offNeptunoPanel;


public GameObject offNeptunoPlaneta;
public GameObject offNeptunoColision;

public GameObject offSaturnoPanel;


public GameObject offSaturnoPlaneta;
public GameObject offSaturnoColision;

}
}

NoIrme.cs

Este script es similar a Irme.cs. Se utiliza para encender y apagar objetos cuando el cursor del
casco de realidad virtual colisiona sobre el objeto que contenga este script. Esto hace que la
nave regrese al punto original por la ruta trazada en moveRef

using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using VRStandardAssets.Utils;
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using DG.Tweening;
using SWS;
namespace VRStandardAssets.Menu
{
public class NoIrme : MonoBehaviour
{
// Use this for initialization
[SerializeField] private SelectionRadial m_SelectionRadial; // This controls when the
selection is complete.
[SerializeField] private VRInteractiveItem m_InteractiveItem; // The interactive item
for where the user should click to load the level.
public static int vidas=0;
private bool m_GazeOver;
public splineMove moveRef;
public GameObject OffSistemaSolar;
public GameObject OnColision;
public GameObject OffColision2;
public GameObject OffColision3;
public GameObject OffColision4;
public GameObject OffColision5;
public GameObject OffColision6;
public GameObject OffColision7;
public GameObject OffColision8;
void Awake()
{

void Start()
{
vidas = 0;

}
private void OnEnable()
{
m_InteractiveItem.OnOver += HandleOver;
m_InteractiveItem.OnOut += HandleOut;
m_SelectionRadial.OnSelectionComplete += HandleSelectionComplete;
//Debug.Log("Toy Dentrooooooooooooooooooooo");
}

private void OnDisable()


{
m_InteractiveItem.OnOver -= HandleOver;
m_InteractiveItem.OnOut -= HandleOut;
m_SelectionRadial.OnSelectionComplete -= HandleSelectionComplete;
//Debug.Log("Toy Fuera");
}

// Update is called once per frame


void Update()
{
if (m_GazeOver)
{
if (Input.GetKeyDown("space"))
{
m_SelectionRadial.LlenarBarra();
}

if (Input.GetKeyUp("space"))
{
m_SelectionRadial.DetenerLlenado();
}
}
}

private void HandleOver()


{
m_SelectionRadial.Show();
m_GazeOver = true;
/* if (transform.tag=="Sol")
{
informacionsol.GetComponent<CanvasGroup>().alpha = 1;
informaciontierra.GetComponent<CanvasGroup>().alpha = 0;
}
if (transform.tag == "Tierra")
{
informacionsol.GetComponent<CanvasGroup>().alpha = 0;
informaciontierra.GetComponent<CanvasGroup>().alpha = 1;
}*/
if (this.gameObject.tag == "Venus") { print("Estoy en Venus"); }
if (this.gameObject.tag == "Mercurio") { print("Estoy en Mercurio"); }
if (this.gameObject.tag == "Tierra") { print("Estoy en Tierra"); }
if (this.gameObject.tag == "Marte") { print("Estoy en Marte"); }
if (this.gameObject.tag == "Jupiter") { print("Estoy en Jupiter"); }
if (this.gameObject.tag == "Urano") { print("Estoy en Urano"); }
if (this.gameObject.tag == "Neptuno") { print("Estoy en Neptuno"); }
}

private void HandleOut()


{
// Cuando el usuario mira hacia otro lado de la representación de la escena, esconda
el radial.
m_SelectionRadial.Hide();
//Vuelve invisible al texto cuando "alpha" sea igual a cero.

m_GazeOver = false;
}

private void HandleSelectionComplete()


{
// If the user is looking at the rendering of the scene when the radial's selection
finishes, activate the button.
if (m_GazeOver)

{
print("He ido al planeta");

OnColision.gameObject.SetActive(true);
OffColision2.gameObject.SetActive(false);
OffColision3.gameObject.SetActive(false);
OffColision4.gameObject.SetActive(false);
OffColision5.gameObject.SetActive(false);
OffColision6.gameObject.SetActive(false);
OffColision7.gameObject.SetActive(false);
OffColision8.gameObject.SetActive(false);

OffSistemaSolar.gameObject.SetActive(false);
moveRef.StartMove();

}
}
}
}

You might also like