Commit e82b88f0 authored by Samantha Straka's avatar Samantha Straka
Browse files

tutorial should work

parent 3e57a960
This diff is collapsed.
fileFormatVersion: 2
guid: 8f4ad2a8b2d3b6740aa9661fdcfd452f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 1009c5f08fdc23a45afbcae1d109abb9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5181478534556260186
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5181478534556260189}
- component: {fileID: 5181478534556260190}
- component: {fileID: 5181478534556260191}
- component: {fileID: 5181478534556260188}
m_Layer: 0
m_Name: DesktopPoster
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &5181478534556260189
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5181478534556260186}
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: -4.87, y: 2.41, z: -11.87}
m_LocalScale: {x: 0.35531, y: 0.35531, z: 0.35531}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!33 &5181478534556260190
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5181478534556260186}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &5181478534556260191
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5181478534556260186}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: ecd3debf49f9eca43bae5698bd0f2eec, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &5181478534556260188
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5181478534556260186}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
fileFormatVersion: 2
guid: 2c9fb1628519ebc4dae851e78d7c4930
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
using System.IO;
public class TutorialManager : MonoBehaviour
{
public GameObject vrCamera;
public Camera desktopCamera;
public GameObject poster;
public List<Material> posterAd;
public List<Material> posterNoAd;
public GameObject desktopWall, desktopPoster;
public GameObject puzzleContainer;
public List<GameObject> puzzleLocations;
public List<GameObject> cubes;
public List<string> adconditions;
public List<string> distractorconditions;
public List<string> audioConditions;
public List<string> logfile;
public List<int> conditionOrder;
private int nextCondition;
private string postermaterialName;
private string puzzlematerialName;
private Material posterMaterial;
bool lastCondition;
private int cubesInPuzzle = 0;
private bool allCubesSortedRight = false;
private int rightCubes = 0;
public GameObject smallAngleModerator;
int condition; //0 is no brand, 1 is poster brand, 2 is puzzle brand, 3 is audio brand
// Start is called before the first frame update
//int numberOfcondition = 8; //the number of the condition. Goes up when a puzzle is solved
//for visual angle
float desiredWidth, desiredHeight, screenWidth, screenHeigth;
private void Awake()
{
switch (StartScript.vr)
{
case 0:
print("VR");
desktopCamera.enabled = false;
desktopWall.SetActive(false);
desktopPoster.SetActive(false);
smallAngleModerator.SetActive(false);
break;
case 1:
print("Desktop");
vrCamera.SetActive(false);
desktopWall.SetActive(true);
desktopPoster.SetActive(true);
smallAngleModerator.SetActive(false);
break;
case 2:
print("VR Desktop");
desktopCamera.enabled = false;
desktopWall.SetActive(false);
desktopPoster.SetActive(false);
break;
case 3:
print("kleiner Winkel VR");
desktopCamera.enabled = false;
desktopWall.SetActive(false);
desktopPoster.SetActive(false);
smallAngleModerator.SetActive(true);
break;
default:
break;
}
}
void Start()
{
Shuffle(adconditions);
Shuffle(distractorconditions);
//first Condition is a random condition out of the condition List
// print(conditionOrder.Count);
lastCondition = false;
setPuzzleCubesToStartLocation();
logfile.Add(StartScript.VPNummer);
logfile.Add(StartScript.vr.ToString());
setNextCondition();
}
// Update is called once per frame
void Update()
{
}
public static void Shuffle(List <string> ts)
{
var count = ts.Count;
var last = count - 1;
for (var i = 0; i < last; ++i)
{
var r = UnityEngine.Random.Range(i, count);
var tmp = ts[i];
ts[i] = ts[r];
ts[r] = tmp;
}
}
public bool puzzleSolved()
{
foreach (GameObject c in cubes)
{
string mis = "";
mis += c.GetComponent<Cube>().Index.ToString() + "," + c.GetComponent<Cube>().getLocation().GetComponent<PuzzleCubeLocation>().getLocationIndex().ToString();
// print(mis);
logfile.Add(mis);
mis = "";
if (c.GetComponent<Cube>().atRightLocation())
{
rightCubes++;
}
}
if (rightCubes >= 8)
{
allCubesSortedRight = true;
rightCubes = 0;
StartCoroutine(ConditionDelay());
ConditionDelay();
}
else if (rightCubes < 8)
{
allCubesSortedRight = false;
print("correct" + allCubesSortedRight);
rightCubes = 0;
}
return allCubesSortedRight;
}
public void checkHowManyCubesInPuzzle(int counter)
{
cubesInPuzzle = cubesInPuzzle + counter;
//diese Funktion wird immer dann aufgerufen, wenn ein neuer Cube in das Puzzle gesetzt wird
//print(cubesInPuzzle);
if (cubesInPuzzle == 9)
{
//alle puzzle cubes sind drin und ich sollte checken ob das puzzzle richtig gelöst wurde
if (puzzleSolved())
{
puzzleContainer.GetComponent<Puzzle>().setContainerMaterial(1);
}
else if (!puzzleSolved())
{
puzzleContainer.GetComponent<Puzzle>().setContainerMaterial(2);
}
}
else if (cubesInPuzzle != 9)
{
puzzleContainer.GetComponent<Puzzle>().setContainerMaterial(0);
}
}
//sets PosterMaterial to the desired Material m
void setPosterMaterial(string path)
{
posterMaterial = Resources.Load("Images/" + path + "/" + path) as Material;
desktopPoster.GetComponent<MeshRenderer>().material = posterMaterial;
poster.GetComponent<MeshRenderer>().material = posterMaterial;
}
private Material getBrandMaterial()
{
//Gets Random Index between 0 and the size of the brand array
Material m = posterAd[Random.RandomRange(0, posterAd.Count)];
return m;
}
private Material getNoBrandMaterial()
{
//Gets Random Index between 0 and the size of the brand array
Material m = posterNoAd[Random.RandomRange(0, posterNoAd.Count)];
return m;
}
//sets all cubes to a start position so that they lie on the table
private void setPuzzleCubesToStartLocation()
{
foreach (GameObject puzzleCube in cubes)
{
puzzleCube.GetComponent<Cube>().setToOriginalPosition();
}
}
private void setPuzzleMaterial(string path)
{
foreach (GameObject puzzleCube in cubes)
{
puzzleCube.GetComponent<Cube>().setMaterial(path);
}
}
IEnumerator ConditionDelay()
{
//waits 5 Seconds before we start the next condition
//yield on a new YieldInstruction that waits for 5 seconds.
yield return new WaitForSeconds(3);
//After we have waited 5 seconds print the time again.
setPuzzleCubesToStartLocation();
puzzleContainer.GetComponent<Puzzle>().setContainerMaterial(0);
setNextCondition();
}
public void setNextCondition()
{
if (conditionOrder.Count == 1)
{
lastCondition = true;
}
//gets the modality of next condition
/*
* 0: poster is ad
* 1: puzzle is ad
* 2_ nothing is an ad
* 3: ad is audio
*
*
* Also sets the material of the next condition
*
* */
if (conditionOrder.Count > 0)
{
nextCondition = conditionOrder[Random.RandomRange(0, conditionOrder.Count)];
nextConditionMaterialName(nextCondition);
conditionOrder.Remove(nextCondition);
print(conditionOrder.Count);
}
else if (lastCondition)
{
print("Study over");
logfile.Add("Endtime" + System.DateTime.Now.ToString("HH:mm:ss:fff"));
WriteLog();
}
cubesInPuzzle = 0;
}
private void nextConditionMaterialName(int condition)
{
switch (condition)
{
case 0: //poster is ad
postermaterialName = adconditions[Random.RandomRange(0, adconditions.Count - 1)];
puzzlematerialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count - 1)];
setPosterMaterial(postermaterialName);
setPuzzleMaterial(puzzlematerialName);
distractorconditions.Remove(puzzlematerialName);
adconditions.Remove(postermaterialName);
logfile.Add(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
// print(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
break;
case 1: //puzzle is ad
puzzlematerialName = adconditions[Random.RandomRange(0, adconditions.Count - 1)];
postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count - 1)];
setPosterMaterial(postermaterialName);
setPuzzleMaterial(puzzlematerialName);
distractorconditions.Remove(postermaterialName);
adconditions.Remove(puzzlematerialName);
logfile.Add(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
//print(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
break;
case 2: //neither is an ad
puzzlematerialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count - 1)];
postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count - 1)];
if (puzzlematerialName == postermaterialName)
{
postermaterialName = postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count - 1)];
}
setPosterMaterial(postermaterialName);
setPuzzleMaterial(puzzlematerialName);
distractorconditions.Remove(postermaterialName);
distractorconditions.Remove(puzzlematerialName);
logfile.Add(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
print(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
break;
case 3: //ad is audio
puzzlematerialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
setPosterMaterial(postermaterialName);
setPuzzleMaterial(puzzlematerialName);
distractorconditions.Remove(postermaterialName);
distractorconditions.Remove(puzzlematerialName);
logfile.Add(condition.ToString() + "," + postermaterialName + "," + puzzlematerialName + "," + System.DateTime.Now.ToString("HH:mm:ss:fff"));
break;
default://should never happen
break;
}
}
public void WriteLog()
{
print("Writing Done");
Application.Quit();
}
}
fileFormatVersion: 2
guid: 93d539137aeeb2146a98be0ff8e69e40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment