void generateTableObject(int level, string dist, string objectPosition, int group, bool active) { string name = "Lvl" + level + "_" + objectPosition + "_Group" + group + "_" + dist; Transform parent = points.transform.Find(name); int childIndex = Random.Range(0, parent.childCount); GameObject newTableObject = Instantiate(tablePrefabs[0], parent.GetChild(childIndex).position, Quaternion.identity) as GameObject; newTableObject.transform.SetParent(tableWrapper.transform); if (!active) { newTableObject.transform.Find("Canvas").gameObject.SetActive(false); newTableObject.GetComponent <BoxCollider>().enabled = false; } else { Debug.Log("numberOfLabel - 1 = " + (numberOfLabel - 1).ToString()); instantiatedTableActiveGameObjects[numberOfLabel - 1] = newTableObject; newTableObject.GetComponent <BoxCollider>().enabled = false; newTableObject.AddComponent <TableObject>(); newTableObject.GetComponent <TableObject>().setValues((shuffledIds[numberOfLabel++]).ToString(), level.ToString(), objectPosition); TableObject activeTableGameObject = newTableObject.GetComponent <TableObject>(); Collected_Objects tempCollectedObject = new Collected_Objects(); tempCollectedObject.SetValues(ExperimentParameters.gameplay_id, int.Parse(activeTableGameObject.id), activeTableGameObject.objectPosition, BringLevelToString(int.Parse(activeTableGameObject.level)), false, false, "", activeTableGameObject.attempts); activeTableGameObject.SetCollectedObject(tempCollectedObject); debugCollectedObjects(activeTableGameObject.collected_Objects); } }
public void tableObjectSelectedByCalculator(string id, string side) { Debug.Log("id = " + id); for (int i = 0; i < instantiatedTableActiveGameObjects.Length; i++) { TableObject activeTableGameObject = instantiatedTableActiveGameObjects[i].GetComponent <TableObject>(); Debug.Log(i + " " + instantiatedTableActiveGameObjects[i].GetComponent <TableObject>().id); if (id.Equals(activeTableGameObject.id)) { Debug.Log(instantiatedTableActiveGameObjects[i].gameObject.name); Collected_Objects tempCollectedObject = new Collected_Objects(); // if (side.Equals(activeTableGameObject.side)) if (side.Equals(activeTableGameObject.objectPosition)) { Debug.Log("ATTEMPTS " + activeTableGameObject.attempts); activeTableGameObject.obj_recorded_on_pad = true; activeTableGameObject.finishedRecordOnAttempt = true; //dbgrabconnection.UpdateCollectedObjectOnPad(int.Parse(activeTableGameObject.id),activeTableGameObject.obj_recorded_on_pad); activeTableGameObject.SetAttempts(activeTableGameObject.attempts++); tempCollectedObject.SetValues(ExperimentParameters.gameplay_id, int.Parse(activeTableGameObject.id), activeTableGameObject.objectPosition, BringLevelToString(int.Parse(activeTableGameObject.level)), activeTableGameObject.obj_recorded_on_pad, false, "", activeTableGameObject.attempts); Debug.Log("tempCollectedObject " + tempCollectedObject.obj_recorded_after_attempt); activeTableGameObject.SetCollectedObject(tempCollectedObject); // activeTableGameObject.SetAttempts(1); //first try and succeeded // dbgrabconnection.CreateCollectedObjectsRow(tempCollectedObject); activeTableGameObject.canvas.GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite>("Textures/UiSprites/golden_star"); activeTableGameObject.canvas.GetChild(0).GetChild(0).GetComponent <Text>().enabled = false; } if (!activeTableGameObject.finishedRecordOnAttempt) { activeTableGameObject.SetAttempts(activeTableGameObject.attempts++); } } } }