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

automaatically sets conditions

parent d2cf51b7
This diff is collapsed.
......@@ -13,6 +13,9 @@ public class ControllerScript : MonoBehaviour
public SteamVR_Input_Sources handType;
private bool triggerDown;
private GameObject overlappedCube;
public List<String> conditions;
private int numberOfRepetitions = 0;
public GameManager manager;
// Start is called before the first frame update
void Start()
{
......@@ -79,7 +82,12 @@ public class ControllerScript : MonoBehaviour
overlappedCube = collision.gameObject;
}
else if (collision.gameObject.tag == "Button")
{
}
if (overlappedCube &&triggerDown&&!grabbedCube)
{
......@@ -90,6 +98,7 @@ public class ControllerScript : MonoBehaviour
}
}
......
......@@ -16,6 +16,15 @@ public class GameManager : MonoBehaviour
public GameObject puzzleContainer;
public List<GameObject> puzzleLocations;
public List<GameObject> cubes;
public List< string> adconditions;
public List<string> distractorconditions;
public List<int> conditionOrder;
private int nextCondition;
private string postermaterialName;
private string puzzlematerialName;
private Material posterMaterial;
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=0; //the number of the condition. Goes up when a puzzle is solved
......@@ -23,10 +32,16 @@ public class GameManager : MonoBehaviour
void Start()
{
//first Condition is a random condition out of the condition List
print(conditionOrder.Count);
desktopWall.SetActive(false);
desktopPoster.SetActive(false);
setPuzzleCubesToStartLocation();
setNextCondition();
}
// Update is called once per frame
......@@ -51,9 +66,16 @@ public class GameManager : MonoBehaviour
}
//sets PosterMaterial to the desired Material m
void setPosterMaterial(Material m)
void setPosterMaterial(string path)
{
poster.GetComponent<MeshRenderer>().material = m;
posterMaterial = Resources.Load("Images/" + path + "/" + path) as Material;
desktopPoster.GetComponent<MeshRenderer>().material = posterMaterial;
poster.GetComponent<MeshRenderer>().material = posterMaterial;
}
private Material getBrandMaterial()
{
......@@ -78,5 +100,89 @@ public class GameManager : MonoBehaviour
{
puzzleCube.GetComponent<PuzzleCubeScript>().setToOriginalPosition();
}
}
private void setPuzzleMaterial(string path)
{
foreach (GameObject puzzleCube in cubes)
{
puzzleCube.GetComponent<PuzzleCubeScript>().setMaterial(path) ;
}
}
private void setNextCondition()
{
//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
*
* */
nextCondition = conditionOrder[Random.RandomRange(0, conditionOrder.Count)];
conditionOrder.Remove(nextCondition);
nextConditionMaterialName(nextCondition);
print(nextCondition);
}
private void nextConditionMaterialName(int condition)
{
numberOfcondition++;
switch (condition)
{
case 0: //poster is ad
postermaterialName = adconditions[Random.RandomRange(0, adconditions.Count)];
adconditions.Remove(postermaterialName);
puzzlematerialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
distractorconditions.Remove(puzzlematerialName);
break;
case 1: //puzzle is ad
puzzlematerialName = adconditions[Random.RandomRange(0, adconditions.Count)];
adconditions.Remove(puzzlematerialName);
postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
distractorconditions.Remove(postermaterialName);
break;
case 2: //neither is an ad
puzzlematerialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
distractorconditions.Remove(puzzlematerialName);
postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
distractorconditions.Remove(postermaterialName);
break;
case 3: //ad is audio
puzzlematerialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
distractorconditions.Remove(puzzlematerialName);
postermaterialName = distractorconditions[Random.RandomRange(0, distractorconditions.Count)];
distractorconditions.Remove(postermaterialName);
break;
default://should never happen
break;
}
setPosterMaterial(postermaterialName);
setPuzzleMaterial(puzzlematerialName);
}
}
......@@ -12,7 +12,7 @@ public class Puzzle : MonoBehaviour
public GameObject cube2;
private bool allCubesPlacedRight;
private int rightCounter = 0;
private bool allCubesSortedRight = false;
public Puzzle(Material pic)
{
......@@ -22,11 +22,32 @@ public class Puzzle : MonoBehaviour
void Update()
{
foreach(GameObject c in Cubes)
{
}
public bool puzzleSolved()
{
foreach (GameObject c in Cubes)
{
if (c.GetComponent<PuzzleCubeScript>().atRightLocation())
{
rightCounter++;
}
print(c.GetComponent<PuzzleCubeScript>().atRightLocation());
}
if (rightCounter == 9)
{
allCubesPlacedRight = true;
;
}
else if (rightCounter < 9)
{
allCubesPlacedRight = false;
}
rightCounter = 0;
return allCubesPlacedRight;
}
}
......
......@@ -15,7 +15,7 @@ public class PuzzleCubeScript : MonoBehaviour
private void Awake()
{
puzzleMaterial = front.GetComponent<MeshRenderer>().materials[0];
setMaterial("pineapple");
}
// Start is called before the first frame update
void Start()
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Button
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.138
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.9622642, g: 0.040850822, b: 0.040850822, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
fileFormatVersion: 2
guid: 433ac2b2f689d7f45a078a48a1a51bff
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -9,6 +9,7 @@ TagManager:
- PuzzleCubeLocation
- PuzzleCube
- Floor
- Button
layers:
- Default
- TransparentFX
......
......@@ -5,7 +5,7 @@
"app_key": "application.generated.unity.advrtise.exe",
"launch_type": "url",
"url": "steam://launch/",
"action_manifest_path": "D:\\repositories\\advrtise.git\\adVRtise\\Assets\\StreamingAssets\\SteamVR\\actions.json",
"action_manifest_path": "D:\\Uni\\Repositories\\advrtise.git\\adVRtise\\Assets\\StreamingAssets\\SteamVR\\actions.json",
"strings": {
"en_us": {
"name": "adVRtise [Testing]"
......
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