Scripts are WiP
This commit is contained in:
parent
2f3119a996
commit
a3a852abf8
Assets
Oculus
OurPrefabs.metaOurPrefabs
OurScripts
SharedSpatialAnchors/Scenes
ThirdParty/Photon/PhotonUnityNetworking/Resources
WorldPoliticalMapGlobeEdition/Scripts/Core/Internal
ProjectSettings
@ -39,5 +39,5 @@ MonoBehaviour:
|
||||
systemSplashScreen: {fileID: 0}
|
||||
systemSplashScreenType: 0
|
||||
_systemLoadingScreenBackground: 0
|
||||
ovrPluginMd5Win64: e2f96821b9509a5aaf6b44cbb176818322193b3113af1adc9e0af028693c38c9
|
||||
ovrPluginMd5Android: b11c9996e5f49cf2c13b34f2f4bb8d16ad9dd1b4f768087f23be43976458361d
|
||||
ovrPluginMd5Win64: e2f96821b9509a5aaf6b44cbb17681838f16294dc8b353245927ecd374ef4ef2
|
||||
ovrPluginMd5Android: b11c9996e5f49cf2c13b34f2f4bb8d16709b89a4a858464e0e3b2e4a1cd2cc19
|
||||
|
8
Assets/OurPrefabs.meta
Normal file
8
Assets/OurPrefabs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9936e11436a8ae74c8ed9a12dadbe02f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3635
Assets/OurPrefabs/WorldMapGlobe.prefab
Normal file
3635
Assets/OurPrefabs/WorldMapGlobe.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/OurPrefabs/WorldMapGlobe.prefab.meta
Normal file
7
Assets/OurPrefabs/WorldMapGlobe.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bae2d9615fea3d44e91f0d1eb7e1d0b1
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -2,18 +2,28 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using WPM;
|
||||
using static OVRPlugin;
|
||||
|
||||
public class ColorizeCountriesScript : MonoBehaviour
|
||||
{
|
||||
public DataManager dataManager;
|
||||
public WorldMapGlobe map;
|
||||
|
||||
//public GlobeControllerScript globeController;
|
||||
//int selectedYear;
|
||||
|
||||
void Start()
|
||||
{
|
||||
map = WorldMapGlobe.instance;
|
||||
|
||||
//map.ToggleCountrySurface("Brazil", true, Color.green);
|
||||
}
|
||||
|
||||
/* void Update()
|
||||
{
|
||||
selectedYear = globeController.selectedYear;
|
||||
}*/
|
||||
|
||||
public void ColorizeCountries(int year)
|
||||
{
|
||||
List<DataFormatWorld> data = dataManager.GetDataForYear(year);
|
||||
@ -37,12 +47,13 @@ public class ColorizeCountriesScript : MonoBehaviour
|
||||
Color color = CalculateColor(entry.co2emissions, minCO2, maxCO2);
|
||||
//Applying the appropriate color to the contry
|
||||
map.ToggleCountrySurface(entry.countryName, true, color);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Color CalculateColor(float value, float min, float max)
|
||||
{
|
||||
float normalized = (value - min) / (max - min);
|
||||
return Color.Lerp(Color.green, Color.red, normalized);
|
||||
return Color.Lerp(Color.white, Color.red, normalized);
|
||||
}
|
||||
}
|
@ -1,118 +1,130 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using WPM;
|
||||
using Photon.Pun;
|
||||
using Photon.Realtime;
|
||||
using WPM;
|
||||
|
||||
public class GlobeControllerScript : MonoBehaviourPun // Inherit from MonoBehaviourPun
|
||||
public class GlobeInteraction : MonoBehaviourPunCallbacks
|
||||
{
|
||||
public DataManager dataManager;
|
||||
public float rotateSpeed; // degrees per second
|
||||
float step;
|
||||
private bool isInteracting = false;
|
||||
public float rotateSpeed = 100f;
|
||||
private float step;
|
||||
private int selectedYear;
|
||||
public ColorizeCountriesScript colorizeScript;
|
||||
public int selectedYear;
|
||||
public DataManager dataManager;
|
||||
//public WorldMapGlobe map;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
colorizeScript.map.ToggleCountrySurface("Brazil", true, Color.blue);
|
||||
selectedYear = 2018;
|
||||
//map = WorldMapGlobe.instance;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!photonView.IsMine) return; // If it's not the local player's object, don't execute the input code
|
||||
|
||||
HandleInput();
|
||||
HandleRotation();
|
||||
}
|
||||
|
||||
void HandleInput()
|
||||
{
|
||||
// Handle color change input
|
||||
if (OVRInput.GetUp(OVRInput.RawButton.Y) || OVRInput.Get(OVRInput.RawButton.RIndexTrigger))
|
||||
{/*
|
||||
if (photonView.IsMine && isInteracting)
|
||||
{
|
||||
photonView.RPC("ColorizeCountriesRPC", RpcTarget.All, selectedYear); // Call RPC to colorize countries for all players
|
||||
Debug.Log("Hello from inside the if condition");
|
||||
HandleRotation();
|
||||
ChangeYear();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckForInteraction();
|
||||
}*/
|
||||
//}
|
||||
|
||||
//**Rotation code**
|
||||
//private void HandleRotation()
|
||||
//{
|
||||
if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickLeft) || Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
//photonView.RPC("RotateLeftRPC", RpcTarget.All);
|
||||
RotateLeftRPC();
|
||||
//Debug.
|
||||
|
||||
}
|
||||
|
||||
// Handle year selection logic
|
||||
if (OVRInput.GetUp(OVRInput.RawButton.A))
|
||||
if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight) || Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
SelectPreviousYear();
|
||||
//photonView.RPC("RotateRightRPC", RpcTarget.All);
|
||||
RotateRightRPC();
|
||||
|
||||
|
||||
}
|
||||
else if (OVRInput.GetUp(OVRInput.RawButton.B))
|
||||
|
||||
if (OVRInput.Get(OVRInput.Button.One) || Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
SelectNextYear();
|
||||
}
|
||||
if (OVRInput.Get(OVRInput.Button.Two) || Input.GetKeyDown(KeyCode.J))
|
||||
{
|
||||
SelectPreviousYear();
|
||||
}
|
||||
|
||||
/*if (!OVRInput.Get(OVRInput.Button.PrimaryThumbstickLeft) && !OVRInput.Get(OVRInput.Button.PrimaryThumbstickRight))
|
||||
{
|
||||
isInteracting = false;
|
||||
photonView.RPC("ReleaseOwnership", RpcTarget.All);
|
||||
}*/
|
||||
}
|
||||
|
||||
void HandleRotation()
|
||||
//[PunRPC]
|
||||
void RotateLeftRPC()
|
||||
{
|
||||
step = rotateSpeed * Time.deltaTime;
|
||||
transform.Rotate(0, step, 0);
|
||||
}
|
||||
|
||||
if (OVRInput.Get(OVRInput.RawButton.RThumbstickLeft))
|
||||
{
|
||||
RotateLeft();
|
||||
}
|
||||
//[PunRPC]
|
||||
void RotateRightRPC()
|
||||
{
|
||||
step = rotateSpeed * Time.deltaTime;
|
||||
transform.Rotate(0, -step, 0);
|
||||
}
|
||||
//**Rotation Code End**
|
||||
|
||||
if (OVRInput.Get(OVRInput.RawButton.RThumbstickRight))
|
||||
//**Change Year Code**
|
||||
// private void ChangeYear()
|
||||
//{
|
||||
/* if (OVRInput.Get(OVRInput.Touch.One))
|
||||
{
|
||||
RotateRight();
|
||||
SelectNextYear();
|
||||
}
|
||||
if (OVRInput.Get(OVRInput.Touch.Two))
|
||||
{
|
||||
SelectPreviousYear();
|
||||
}*/
|
||||
|
||||
/*if (!OVRInput.Get(OVRInput.Touch.One) && !OVRInput.Get(OVRInput.Touch.Two))
|
||||
{
|
||||
isInteracting = false;
|
||||
photonView.RPC("ReleaseOwnership", RpcTarget.All);
|
||||
}*/
|
||||
//}
|
||||
|
||||
void SelectNextYear()
|
||||
{
|
||||
selectedYear = Mathf.Min(selectedYear + 1, 2018);
|
||||
//photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear);
|
||||
UpdateSelectedYearRPC(selectedYear);
|
||||
}
|
||||
|
||||
void SelectPreviousYear()
|
||||
{
|
||||
selectedYear = Mathf.Max(selectedYear - 1, 1991); // Adjust year bounds as needed
|
||||
photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear); // Call RPC to update selected year for all players
|
||||
selectedYear = Mathf.Max(selectedYear - 1, 1991);
|
||||
//photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear);
|
||||
UpdateSelectedYearRPC(selectedYear);
|
||||
}
|
||||
|
||||
void SelectNextYear()
|
||||
{
|
||||
selectedYear = Mathf.Min(selectedYear + 1, 2018); // Adjust year bounds as needed
|
||||
photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear); // Call RPC to update selected year for all players
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
|
||||
void UpdateSelectedYearRPC(int year)
|
||||
{
|
||||
selectedYear = year;
|
||||
Debug.Log("Selected Year: " + selectedYear);
|
||||
colorizeScript.ColorizeCountries(selectedYear);
|
||||
}
|
||||
//**Change Year Code End**
|
||||
|
||||
[PunRPC]
|
||||
void ColorizeCountriesRPC(int year)
|
||||
{
|
||||
Debug.Log("Colorizing countries for year: " + year);
|
||||
colorizeScript.ColorizeCountries(year);
|
||||
}
|
||||
|
||||
void RotateLeft()
|
||||
{
|
||||
transform.Rotate(0, step, 0);
|
||||
photonView.RPC("RotateLeftRPC", RpcTarget.Others); // Send RPC to other clients
|
||||
Debug.Log("Right Thumbstick detected - Left");
|
||||
}
|
||||
|
||||
void RotateRight()
|
||||
{
|
||||
transform.Rotate(0, -step, 0);
|
||||
photonView.RPC("RotateRightRPC", RpcTarget.Others); // Send RPC to other clients
|
||||
Debug.Log("Right Thumbstick detected - Right");
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void RotateLeftRPC()
|
||||
{
|
||||
transform.Rotate(0, step, 0);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void RotateRightRPC()
|
||||
{
|
||||
transform.Rotate(0, -step, 0);
|
||||
}
|
||||
//**Interaction and Ownership handling**
|
||||
|
||||
//**Interaction and Ownership handling End**
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -55,6 +55,7 @@ MonoBehaviour:
|
||||
- RotateRight
|
||||
- RotateRightRPC
|
||||
- UpdateSelectedYearRPC
|
||||
- ReleaseOwnership
|
||||
DisableAutoOpenWizard: 1
|
||||
ShowSettings: 1
|
||||
DevRegionSetOnce: 1
|
||||
|
@ -1784,7 +1784,7 @@ namespace WPM {
|
||||
ray = new Ray(cam.transform.position, cam.transform.forward);
|
||||
}
|
||||
#else
|
||||
if (_VREnabled) {
|
||||
if (!_VREnabled) {
|
||||
ray = new Ray(cam.transform.position, cam.transform.forward);
|
||||
} else {
|
||||
Vector3 mousePos;
|
||||
|
@ -534,7 +534,7 @@ PlayerSettings:
|
||||
iPhone: 0
|
||||
tvOS: 0
|
||||
overrideDefaultApplicationIdentifier: 1
|
||||
AndroidBundleVersionCode: 38
|
||||
AndroidBundleVersionCode: 39
|
||||
AndroidMinSdkVersion: 32
|
||||
AndroidTargetSdkVersion: 0
|
||||
AndroidPreferredInstallLocation: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user