diff --git a/Assets/Scenes/Worlds/MountainWorld.unity b/Assets/Scenes/Worlds/MountainWorld.unity index 1eded51e0d3ae0d6c59a4c0bb7d23c181febc6b1..2652ab89b47079cb6c7f0767963b33ae2bfc8607 100644 --- a/Assets/Scenes/Worlds/MountainWorld.unity +++ b/Assets/Scenes/Worlds/MountainWorld.unity @@ -11580,7 +11580,7 @@ PrefabInstance: - target: {fileID: 8182354677883374721, guid: b07552db700124a4680401e6fb94c186, type: 3} propertyPath: m_AnchoredPosition.x - value: 940 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8182354677883374721, guid: b07552db700124a4680401e6fb94c186, type: 3} @@ -30149,7 +30149,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: -18.499939} - m_SizeDelta: {x: 480, y: 320} + m_SizeDelta: {x: 680, y: 520} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &936581421 MonoBehaviour: @@ -30192,7 +30192,7 @@ CanvasRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 936581419} - m_CullTransparentMesh: 1 + m_CullTransparentMesh: 0 --- !u!1001 &937462613 PrefabInstance: m_ObjectHideFlags: 0 @@ -69011,6 +69011,11 @@ MonoBehaviour: ingredient3: {fileID: 648095404} ingredient4: {fileID: 281747982} finishedMaterial: {fileID: 2100000, guid: 2f12fcec4b3dcc0489472b3a9cfa44c1, type: 2} + maxNumberPropsDisplayed: 11 + circleRadius: 1 + heightAbove: 2 + rotationSpeed: 50 + propScale: 0.5 --- !u!1001 &2132461601 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Utility/Prop Interaction/BookGlowAndInteract.cs b/Assets/Scripts/Utility/Prop Interaction/BookGlowAndInteract.cs index 59e2c5b2fc7cebab4a84bbce39054b80bca52c30..35db4369d591c25a0883af1ab23c313e39ee0b9a 100644 --- a/Assets/Scripts/Utility/Prop Interaction/BookGlowAndInteract.cs +++ b/Assets/Scripts/Utility/Prop Interaction/BookGlowAndInteract.cs @@ -16,7 +16,9 @@ public class BookGlowAndInteract : MonoBehaviour private bool active; private SimpleMessageDisplay messageDisplay; private BrewingPotInteract brewingPot; - + private string lgs = "Solve this riddle to brew the Potion\n6a +3b +4d = 39\n3b +4d -2c = 25\n2a -2c +3b = 17\n5a +3 = 13\n\na is the big red mushroom, b the red flower\nc the brown mushroom and d the small red mushroom\nClose with ESC"; + private int[] sol ={2,5,1,3}; + void Start() { objectRenderer = GetComponent<Renderer>(); @@ -65,8 +67,7 @@ void Update() { clicked = true; objectRenderer.material = originalMaterial; - messageDisplay.ShowMessage("Hallllooooo\n \n \n Close with ESC"); - Debug.LogError("Hit registered Where text???!"); + messageDisplay.ShowMessage(lgs); } } } diff --git a/Assets/Scripts/Utility/Prop Interaction/BrewingPotInteract.cs b/Assets/Scripts/Utility/Prop Interaction/BrewingPotInteract.cs index 82bd54d34525050a06def484ed7095b473594c5a..e3dadc942316b1a9a940e63909bf47523e02fd19 100644 --- a/Assets/Scripts/Utility/Prop Interaction/BrewingPotInteract.cs +++ b/Assets/Scripts/Utility/Prop Interaction/BrewingPotInteract.cs @@ -10,26 +10,94 @@ public class BrewingPotInteract : MonoBehaviour public GameObject ingredient4; public Material finishedMaterial; - - private List<string> recipe = new List<string>(); + + private List<GameObject> recipe = new List<GameObject>(); private int counter = 0; private Renderer objectRenderer; private bool finished = false; private string lgs; + + public int maxNumberPropsDisplayed = 11; + public float circleRadius = 1.0f; + public float heightAbove = 2.0f; + public float rotationSpeed = 50.0f; + public float propScale = 0.5f; + + private GameObject[] props; + private int propCount = 0; + private float[] angles; + //solution values for the LGS + private int[] sol ={2,5,1,3}; + private int numberOfPropsInRecipe; // Start is called before the first frame update void Start() { - //For now build the recipe here - recipe.Add(ingredient1.name); - recipe.Add(ingredient2.name); - recipe.Add(ingredient3.name); - recipe.Add(ingredient4.name); + GameObject[] obj = {ingredient1,ingredient2,ingredient3,ingredient4}; + for(int i = 0; i < sol.Length; i++) + { + for(int x = 0; x < sol[i] ; x++) + { + recipe.Add(obj[i]); + numberOfPropsInRecipe++; + } + } objectRenderer = GetComponent<Renderer>(); + props = new GameObject[maxNumberPropsDisplayed]; + angles = new float[maxNumberPropsDisplayed]; + } + + void Update() + { + for (int i = 0; i < propCount; i++) + { + if (props[i] != null) + { + angles[i] += rotationSpeed * Time.deltaTime; + if (angles[i] >= 360.0f) + { + angles[i] -= 360.0f; + } + + UpdatePropPosition(i); + } + } + } + + void UpdatePropPosition(int index) + { + float radians = angles[index] * Mathf.Deg2Rad; + Vector3 offset = new Vector3(Mathf.Cos(radians), 0, Mathf.Sin(radians)) * circleRadius; + props[index].transform.position = transform.position + offset + Vector3.up * heightAbove; } + void AddProp(GameObject prop){ + if(propCount < maxNumberPropsDisplayed){ + props[propCount] = Instantiate(prop); + + props[propCount].transform.localScale = Vector3.one * propScale; + + angles[propCount] = propCount * (360.0f / maxNumberPropsDisplayed); + + UpdatePropPosition(propCount); + propCount++; + } + } + + void RemoveAllProps(){ + + for(int i = 0; i < propCount; i++) + { + Destroy(props[i]); + } + + propCount = 0; + props = new GameObject[maxNumberPropsDisplayed]; + angles = new float[maxNumberPropsDisplayed]; + } + void OnMouseDown() { if(finished){ @@ -39,21 +107,19 @@ void OnMouseDown() if (ClickTracker.Instance != null) { string item = ClickTracker.Instance.RemoveOneItem(); - if(string.Compare(item,recipe[counter]) == 0){ - if(counter == 3){ + if(string.Compare(item,recipe[counter].name) == 0){ + AddProp(recipe[counter]); + if(counter == numberOfPropsInRecipe - 1){ objectRenderer.material = finishedMaterial; finished = true; } counter ++; } else { + RemoveAllProps(); counter = 0; } } else { Debug.LogError("ClickTracker: Instance is null"); } } - - public string getLGS(){ - return lgs; - } }