add games

This commit is contained in:
2022-11-10 21:56:29 -03:00
commit 35300554e2
2182 changed files with 325017 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DebugRay : MonoBehaviour {
// Update is called once per frame
void Update () {
// simply draws a ray going from a point in a direction
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.red);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db712cf492faf4ac7b6ee36e535f169f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
public class Portal : MonoBehaviour {
// the other portal that this will teleport to/render
public GameObject linkedPortal;
// used to help prevent us from infinitely teleporting back and forth
private bool portalActive = true;
void OnTriggerEnter(Collider other) {
if (portalActive) {
// make other portal not teleport us and our current one enabled
linkedPortal.GetComponent<Portal>().Toggle();
// OnExit never gets called after teleportation from a portal, so we
// need to toggle manually
Toggle();
// cache player rotation to revert after teleport
float xRot = other.transform.rotation.x;
float zRot = other.transform.rotation.z;
// set the player's position and rotation to the other portal's
other.transform.SetPositionAndRotation(linkedPortal.transform.position,
Quaternion.identity);
other.transform.rotation = linkedPortal.transform.parent.transform.rotation;
// Y rotation from portal
float yRot = other.transform.eulerAngles.y;
// combine previously cached axes with new Y to get new rotation
other.transform.eulerAngles = new Vector3(xRot, yRot, zRot);
// override FPSController's mouse look caching
other.GetComponent<FirstPersonController>().MouseReset();
}
}
void OnTriggerExit(Collider other) {
// re-enable this portal for teleportation after we've exited
// (teleporting into it)
Toggle();
}
public void Toggle() {
// whether we can actually use this portal to teleport
portalActive = !portalActive;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cabe3e708e4954b59b61a124112b4cf9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PortalGun : MonoBehaviour {
private AudioSource portalSound;
private AudioSource errorSound;
public GameObject orangePortal;
public GameObject bluePortal;
public GameObject gunTip;
// Use this for initialization
void Start () {
portalSound = GetComponents<AudioSource>()[0];
errorSound = GetComponents<AudioSource>()[1];
}
// Update is called once per frame
void Update () {
// fire the right portal (left or right) based on input
if (Input.GetButtonDown("Fire1")) {
FirePortal("orange");
} else if (Input.GetButtonDown("Fire2")) {
FirePortal("blue");
}
}
void FirePortal(string type) {
// struct object that will hold our raycast information
RaycastHit hit;
// if we collide with an object with our raycast, spawn a portal there
if (Physics.Raycast(gunTip.transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity)) {
portalSound.Play();
// choose between the correct portals based on string input
GameObject portal = type == "orange" ? orangePortal : bluePortal;
// set the portal to the same position as the raycast point, and set
// its rotation to orient to the wall relative to what its "up" direction is,
// which is Vector.up in world space
portal.transform.SetPositionAndRotation(hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));
} else {
errorSound.Play();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1255eca7d9e3c42c08d90880ff2a6f41
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Win : MonoBehaviour
{
private GameObject gameObject;
private Text text;
private Color color;
// Start is called before the first frame update
void Start()
{
gameObject = GameObject.Find("WinText");
text = gameObject.GetComponent<Text>();
color = text.color;
// Make the text invisible
color.a = 0.0f;
text.color = color;
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other) {
// Show the text when player collides with finish line
color.a = 1.0f;
text.color = color;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c17dba26c96941a8984b18825fb674b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: