void Awake() { if (!target) { target = GetComponent <Shapes2D.Shape>(); } }
// Use this for initialization void Start() { Shapes2D.Shape w_1 = wedge.GetComponent <Shapes2D.Shape>(); w_1.settings.startAngle = 0; w_1.settings.endAngle = 90; }
// Start is called before the first frame update void Start() { gateShape = GetComponent <Shapes2D.Shape>(); initColor = gateShape.settings.fillColor; entered = false; effect = GetComponent <AudioSource>(); }
public void Init(RockData aRockData, bool ignoreNewlySeen) { rockData = aRockData; mIgnoreNewlySeen = ignoreNewlySeen; if (!mRockShape) { if (mRockShapes == null) { mRockShapes = rockShapesRoot.GetComponentsInChildren <Shapes2D.Shape>(); } if (mRockShapes.Length > 0) { int rockShapeInd = Random.Range(0, mRockShapes.Length); for (int i = 0; i < mRockShapes.Length; i++) { mRockShapes[i].gameObject.SetActive(rockShapeInd == i); } mRockShape = mRockShapes[rockShapeInd]; mRockShapeImage = mRockShape.GetComponent <Image>(); } } }
// Update is called once per frame void Update() { //GetRelativeColourPercentage(); if (!isBallRolling) { launcher.SetActive(true); flasher.StartFlashes(arcList); isBallRolling = !isBallRolling; isFlashing = true; } if (isFlashing) { if (Input.GetMouseButtonDown(0)) { RaycastHit hitInfo; bool hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo); if (hit) { Shapes2D.Shape shape = hitInfo.transform.gameObject.GetComponent <Shapes2D.Shape>(); int shapeIndex = arcList.IndexOf(shape); if (shapeIndex >= 0) { launchVector = CalculateLaunchVector(shapeIndex); isFlashing = !isFlashing; //Call function to launch ball here ballprefab.InitialVelocity = launchVector; ballprefab.transform.gameObject.SetActive(true); ballprefab.LaunchBall(); } } } if (!flasher.startFlashes && inlet.cubeIndex >= 0) { launchVector = CalculateLaunchVector(inlet.cubeIndex); isFlashing = !isFlashing; GameObject.Find("Index").GetComponent <Text>().text = "Index: " + inlet.cubeIndex; //Call function to launch ball here ballprefab.InitialVelocity = launchVector; ballprefab.LaunchBall(); } } // After running out of balls if (BallCount <= 0) { StartCoroutine(CheckWin()); } // Flashes //GetRelativeColourPercentage(); }
/* Single Flash Operation */ IEnumerator SingleFlash() { while (startFlashes) { //Generate a random number from the list of indices that have non-zero counters System.Random random = new System.Random(); int randomIndex = random.Next(s_indexes.Count); int randomShapeIndex = s_indexes[randomIndex]; //Turn off the cubes to give the flashing image TurnOff(); //If the counter is non-zero, then flash that cube and decrement the flash counter if (flash_counter[randomShapeIndex] > 0) { yield return(new WaitForSecondsRealtime((1f / freqHz))); Shapes2D.Shape randomShape = arcShapes[randomIndex]; randomShape.settings.fillColor = onColor; flash_counter[randomShapeIndex]--; counter++; //print("CUBE: " + randomShape.ToString()); //print(counter); //Write to the LSL Outlet stream marker.Write("s," + randomShape.ToString()); } else if (numTrials == counter) { print("Done P300 Single Flash Trials"); break; } else { //If the counter for a specific cube has reached zero, then remove it from the indexes so that the random //number generator does not pick it again (to reduce lag) if (flash_counter[randomShapeIndex] == 0) { s_indexes.RemoveAt(randomIndex); } //Go to the next iteration of the single flash continue; } yield return(new WaitForSecondsRealtime(flashLength)); } ResetCounters(); //Write to LSL stream to indicate end of P300 SingleFlash //marker.Write("P300 SingleFlash Ends"); startFlashes = !startFlashes; //keyLocks[KeyCode.S] = !keyLocks[KeyCode.S]; }
public void TurnOff() { for (int i = 0; i < arcShapes.Count; i++) { Shapes2D.Shape shape = arcShapes[i]; string shapeName = shape.ToString(); if (shapeName.Contains("Large")) { shape.settings.fillColor = largeColor; } else if (shapeName.Contains("Medium")) { shape.settings.fillColor = mediumColor; } else { shape.settings.fillColor = smallColor; } } }
private void Start() { startPosition = this.transform.position; objects = new GameObject[11]; lines = new Shapes2D.Shape[5]; donuts = new Shapes2D.Shape[5]; positions = new float[5]; for (int i = 0; i < 11; i++) { objects[i] = gameObject.transform.GetChild(i).gameObject; } for (int i = 0; i < 5; i++) { positions[i] = 50f; lines[i] = objects[i].GetComponent <Shapes2D.Shape>(); lines[i].enabled = false; lines[i].settings.fillColor = Color.gray; lines[i].transform.position = startPosition; lines[i].transform.localScale = new Vector3(thickness, radius, 0); donuts[i] = objects[i + 5].GetComponent <Shapes2D.Shape>(); donuts[i].enabled = false; donuts[i].settings.fillColor = Color.blue; } curve = (gameObject.transform.GetChild(10).gameObject).GetComponent <Shapes2D.Shape>(); curve.enabled = false; curve2 = (gameObject.transform.GetChild(11).gameObject).GetComponent <Shapes2D.Shape>(); curve2.enabled = false; drawStar(); //drawDonuts(); drawCurve(); }
public List <Shapes2D.Shape> CreateArcList() { arcs = new List <Shapes2D.Shape>(); arcs.Add(largeArc); arcs.Add(mediumArc); arcs.Add(smallArc); int zRotation = 18; for (int i = 1; i < segments; i++) { Shapes2D.Shape newLarge = Instantiate(largeArc); newLarge.transform.rotation = largeArc.transform.rotation; newLarge.transform.Rotate(0, 0, zRotation); newLarge.transform.position = largeArc.transform.position; newLarge.transform.parent = largeArc.transform.parent; arcs.Add(newLarge); Shapes2D.Shape newMed = Instantiate(mediumArc); newMed.transform.rotation = largeArc.transform.rotation; newMed.transform.Rotate(0, 0, zRotation); newMed.transform.position = largeArc.transform.position; newMed.transform.parent = largeArc.transform.parent; arcs.Add(newMed); Shapes2D.Shape newSmall = Instantiate(smallArc); newSmall.transform.rotation = largeArc.transform.rotation; newSmall.transform.Rotate(0, 0, zRotation); newSmall.transform.position = largeArc.transform.position; newSmall.transform.parent = largeArc.transform.parent; arcs.Add(newSmall); zRotation += 18; } return(arcs); }
// Start is called before the first frame update void Start() { bgShape = GetComponent <Shapes2D.Shape>(); initColor = bgShape.settings.fillColor2; initFillRotation = bgShape.settings.fillRotation; }
// Start is called before the first frame update void Start() { gateShape = GetComponent <Shapes2D.Shape>(); effect = GetComponent <AudioSource>(); entered = false; }