1
0
forked from cgvr/DeltaVR

deltavr multiplayer 2.0

This commit is contained in:
Toomas Tamm
2023-05-08 15:56:10 +03:00
parent 978809a002
commit 07b9b9e2f4
10937 changed files with 2968397 additions and 1521012 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0ea0fa8b0421d3b498cea1682e63e99c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using UnityEngine;
namespace Audio
{
[CreateAssetMenu(menuName = "AudioClipGroup")]
public class AudioClipGroup : ScriptableObject
{
[Range(0, 2)] public float volumeMin = 1;
[Range(0, 2)] public float volumeMax = 1;
[Range(0, 2)] public float pitchMin = 1;
[Range(0, 2)] public float pitchMax = 1;
public float delay = 0.1f;
public List<AudioClip> audioClips;
private float _timestamp;
public void OnEnable()
{
_timestamp = 0;
}
public void Play()
{
if (AudioSourcePool.Instance == null) return;
Play(AudioSourcePool.Instance.GetAudioSource());
}
public void Play(AudioSource source)
{
if (audioClips.Count <= 0) return;
if (_timestamp > Time.time) return;
_timestamp = Time.time + delay;
source.volume = Random.Range(volumeMin, volumeMax);
source.pitch = Random.Range(pitchMin, pitchMax);
source.clip = audioClips[Random.Range(0, audioClips.Count)];
source.Play();
}
}
}

View File

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

View File

@@ -0,0 +1,34 @@
using System.Collections.Generic;
using UnityEngine;
namespace Audio
{
public class AudioSourcePool : MonoBehaviour
{
public static AudioSourcePool Instance;
public AudioSource audioSourcePrefab;
private List<AudioSource> _audioSources;
public void Awake()
{
Instance = this;
_audioSources = new List<AudioSource>();
}
public AudioSource GetAudioSource()
{
foreach (AudioSource source in _audioSources)
{
if (!source.isPlaying)
{
return source;
}
}
AudioSource newSource = Instantiate(audioSourcePrefab, this.transform);
_audioSources.Add(newSource);
return newSource;
}
}
}

View File

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

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DontDestroy : MonoBehaviour
{
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using System;
public static class Events
{
public static event Action OnBreakoutEndGame;
public static void BreakoutEndGame() => OnBreakoutEndGame?.Invoke();
public static event Action OnBreakoutStartGame;
public static void BreakoutStartGame() => OnBreakoutStartGame?.Invoke();
public static event Action<float> OnBreakoutSetSpeed;
public static void BreakoutSetSpeed(float speed) => OnBreakoutSetSpeed?.Invoke(speed);
public static event Action OnBreakoutReduceBalls;
public static void ReduceBalls() => OnBreakoutReduceBalls?.Invoke();
public static event Action OnBreakoutAddBalls;
public static void AddBalls() => OnBreakoutAddBalls?.Invoke();
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1aa28fa642a9ed849a682e45b96de2b4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectionTray : MonoBehaviour
{
public List<GameObject> row1;
public List<GameObject> row2;
public List<GameObject> row3;
public List<GameObject> row4;
public void RowShow(int i)
{
switch (i)
{
case 1:
foreach(GameObject go in row1)
{
go.SetActive(true);
}
break;
case 2:
foreach (GameObject go in row2)
{
go.SetActive(true);
}
break;
case 3:
foreach (GameObject go in row3)
{
go.SetActive(true);
}
break;
case 4:
foreach (GameObject go in row4)
{
go.SetActive(true);
}
break;
}
}
}

View File

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

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class TreasureHunt : MonoBehaviour
{
public TMP_Text collectedText;
private int totalCollected;
private void Awake()
{
totalCollected = 0;
}
void Start()
{
collectedText.text = totalCollected.ToString() + "/8 objects collected";
}
public void addTotal()
{
totalCollected++;
collectedText.text = totalCollected.ToString() + "/8 objects collected";
}
}

View File

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

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TreasureObject : MonoBehaviour
{
public TreasureHunt controller;
public CollectionTray tray;
public int row;
private void Collected()
{
//controller.addTotal();
tray.RowShow(row);
GetComponent<Renderer>().enabled = false;
GetComponent<BoxCollider>().enabled = false;
//Destroy(gameObject);
}
public void CollectedPun()
{
//photonView.RPC("Collected", RpcTarget.AllBuffered);
}
private void OnTriggerEnter(Collider other)
{
if (other.transform.CompareTag("MenuHand"))
{
CollectedPun();
}
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class PhysButton : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if(other.tag == "MenuHand")
{
GetComponent<Button>().onClick.Invoke();
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class PlayerText : MonoBehaviour
{
public Transform lookCamera;
private void Start()
{
//photonView.RPC("ChangeText", RpcTarget.AllBuffered);
GameObject[] players = GameObject.FindGameObjectsWithTag("MainCamera");
foreach(GameObject player in players)
{
// if (player.transform.parent.parent.gameObject.GetPhotonView().IsMine)
// {
// lookCamera = player.transform;
// }
}
}
private void Update()
{
transform.LookAt(lookCamera);
}
}

View File

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

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Poster : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Vector2[] uvSingleFace = {
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(0, 1),
new Vector2(1, 1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1),
new Vector2(-1, -1)
};
GetComponent<MeshFilter>().mesh.uv = uvSingleFace;
}
}

View File

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

View File

@@ -0,0 +1 @@
C# scripts, shaders etc go here.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b2eba341b0ca0ae49889cc9ba59875eb
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RigGrounded : MonoBehaviour
{
public LayerMask layermask;
public Transform head;
void Update()
{
RaycastHit hit;
if(Physics.Raycast(head.position, Vector3.down, out hit, Mathf.Infinity, layermask))
{
Debug.Log(hit.transform.name);
transform.position = new Vector3(transform.position.x, hit.point.y, transform.position.z);
}
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd9f7a9938a4bf24a84872811c68d93f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NavPoint : MonoBehaviour
{
public NavPoint previous;
public NavPoint next;
public NavPoint GetNext()
{
return next;
}
void OnDrawGizmos()
{
if (next == null) return;
Gizmos.color = Color.yellow;
Gizmos.DrawLine(transform.position, next.transform.position);
}
}

View File

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

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
public class NavPointFollower : MonoBehaviour
{
public NavPoint startNavPoint;
public float rotationSpeed = 1f;
public float speed = 1f;
private Rigidbody _rigidbody;
private void Start()
{
_rigidbody = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
var transform1 = transform;
var position = transform1.position;
_rigidbody.MovePosition(position + transform1.forward * (speed * Time.deltaTime));
var direction = (startNavPoint.transform.position - position).normalized;
direction.y = 0;
var lookRotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * rotationSpeed);
if (Vector3.Distance(transform.position, startNavPoint.transform.position) < 0.3f)
{
startNavPoint = startNavPoint.GetNext();
}
}
}

View File

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

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RGB : MonoBehaviour
{
public float colorChangeInterval = 2f;
public float minColor = 0;
public float maxColor = 100;
private Light _light;
private float _nextColorChange;
// Start is called before the first frame update
void Start()
{
_light = GetComponent<Light>();
_nextColorChange = Time.time;
}
// Update is called once per frame
void Update()
{
if (!(_nextColorChange <= Time.time)) return;
var r = Random.Range(minColor, maxColor);
var g = Random.Range(minColor, maxColor);
var b = Random.Range(minColor, maxColor);
_light.color = new Color(r, g, b);
_nextColorChange = Time.time + colorChangeInterval;
}
}

View File

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

View File

@@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class TeleportOverride : MonoBehaviour
{
private PlayerActions input;
private Vector2 axis;
private bool rayEnabled;
public MonoBehaviour ray;
private void Awake()
{
input = new PlayerActions();
input.XRIRightHandLocomotion.TeleportModeActivate.performed += ctx => CallRay();
}
// Update is called once per frame
void Update()
{
}
void CallRay()
{
if (rayEnabled)
{
ray.enabled = false;
rayEnabled = false;
}
else
{
ray.enabled = true;
rayEnabled = true;
}
}
private void OnEnable()
{
input.Enable();
}
private void OnDisable()
{
input.Disable();
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 61a331e7954a1664098fa22a504a0384
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
namespace UnityXR
{
public class HandPresence : MonoBehaviour
{
public bool showController;
public InputDeviceCharacteristics controllerCharacteristics;
public List<GameObject> controllerPrefabs;
public GameObject handModelPrefab;
private InputDevice _targetDevice;
private GameObject _spawnedController;
private GameObject _spawnedHandModel;
private Animator _handAnimator;
private static readonly int Trigger = Animator.StringToHash("Trigger");
private static readonly int Grip = Animator.StringToHash("Grip");
private void TryInitialize()
{
var devices = new List<InputDevice>();
InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);
if (devices.Count <= 0) return;
_targetDevice = devices[0];
GameObject prefab = controllerPrefabs.Find(controller => controller.name == _targetDevice.name);
_spawnedController = Instantiate(prefab ? prefab : controllerPrefabs[0], transform);
_spawnedHandModel = Instantiate(handModelPrefab, transform);
_handAnimator = _spawnedHandModel.GetComponent<Animator>();
}
private void UpdateHandAnimation()
{
if (_targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
{
_handAnimator.SetFloat(Trigger, triggerValue);
}
else
{
_handAnimator.SetFloat(Trigger, 0);
}
if (_targetDevice.TryGetFeatureValue(CommonUsages.grip, out float gripValue))
{
_handAnimator.SetFloat(Grip, gripValue);
}
else
{
_handAnimator.SetFloat(Grip, 0);
}
}
// Update is called once per frame
void Update()
{
if (!_targetDevice.isValid)
{
TryInitialize();
}
else
{
if (showController)
{
_spawnedHandModel.SetActive(false);
_spawnedController.SetActive(true);
}
else
{
_spawnedHandModel.SetActive(true);
_spawnedController.SetActive(false);
UpdateHandAnimation();
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
namespace UnityXR
{
public class WorldSpaceUpTeleportWorldArea : TeleportationArea
{
// Override the teleport request to use the world rotation and not our gameObject's transform
protected override bool GenerateTeleportRequest(IXRInteractor interactor, RaycastHit raycastHit, ref TeleportRequest teleportRequest)
{
teleportRequest.destinationPosition = raycastHit.point;
teleportRequest.matchOrientation = MatchOrientation.WorldSpaceUp; // use the area transform for data.
teleportRequest.destinationRotation = Quaternion.identity;
return true;
}
}
}

View File

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

View File

@@ -0,0 +1,26 @@
using UnityEngine.XR.Interaction.Toolkit;
public class XRGrabVelocityTracked : XRGrabInteractable
{
protected override void OnSelectEntered(SelectEnterEventArgs args)
{
SetParentToXRRig();
base.OnSelectEntered(args);
}
protected override void OnSelectExited(SelectExitEventArgs args)
{
SetParentToWorld();
base.OnSelectExited(args);
}
public void SetParentToXRRig()
{
transform.SetParent(interactorsSelecting[0].transform);
}
public void SetParentToWorld()
{
transform.SetParent(null);
}
}

View File

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