public void PopulateRing(float ringDistance) { ringSize = ringDistance; sequenceController = GetComponentInParent <SequenceController>(); circleScripts = new CircleScript[beats.Count]; for (int i = 0; i < beats.Count; i++) { //Instantiate the circle GameObject newCircle = Instantiate(circlePrefab); CircleScript circleScript = newCircle.GetComponent <CircleScript>(); //Initialize the Circle circleScript.Initialize(ringKeycode, beats[i], ringAudio, audioMixerGroup); newCircle.transform.SetParent(this.transform); circleScript.ringParent = this; //locate the Circle based on it's beat //Debug.Log("Locating Circle " + i.ToString()); circleScript.LocateCircle(ringDistance); //Give it a measure circleScript.measure = GiveMeasure(beats[i]); if (isMelody) { circleScript.SetClip(melodyNotes[i]); } circleScripts[i] = circleScript; } }
public static void SavePlayer(CircleScript player) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/player.fun"; FileStream stream = new FileStream(path, FileMode.Create); SaveData data = new SaveData(player); formatter.Serialize(stream, data); stream.Close(); }
public void IncrementScore(string player) { if (player == "PaletteRight") { //increment score of right player scoreRight++; scoreRightText.text = scoreRight.ToString(); } else if (player == "PaletteLeft") { //increment score of left player scoreLeft++; scoreLeftText.text = scoreLeft.ToString(); } else { //print error Debug.Log("name not recognized"); } ballS = Instantiate(ball); ballS.GetComponent <SpriteRenderer>().color = new Color((colorRight.r + colorLeft.r) / 2f, (colorRight.g + colorLeft.g) / 2f, (colorRight.b + colorLeft.b) / 2f); ballS.GetComponent <TrailRenderer>().startColor = new Color((colorRight.r + colorLeft.r) / 2f, (colorRight.g + colorLeft.g) / 2f, (colorRight.b + colorLeft.b) / 2f); ballS.gm = this; ballIsInst = true; foreach (GameObject circle in circleArr) { if (circle != null) { cs = circle.GetComponent <CircleScript>(); if (Random.Range(0f, 2f) > 1) { cs.isRight = true; } else { cs.isRight = false; } } } }
private void ScaleManager(bool isRight) { foreach (GameObject circle in circleArr) { if (circle != null) { cs = circle.GetComponent <CircleScript>(); if (cs.isRight && isRight) { circle.transform.localScale = new Vector3(1f + amp * multiplier, 1f + amp * multiplier, 1f); } else if (!cs.isRight && !isRight) { circle.transform.localScale = new Vector3(1f + amp * multiplier, 1f + amp * multiplier, 1f); } } } }
private void ColorManager(bool isRight) { foreach (GameObject circle in circleArr) { if (circle != null) { sr = circle.GetComponent <SpriteRenderer>(); cs = circle.GetComponent <CircleScript>(); if (cs.isRight && isRight) { sr.color = colorRight; } else if (!cs.isRight && !isRight) { sr.color = colorLeft; } } } if (isRight) { sr = GameObject.Find("PaletteRight").GetComponent <SpriteRenderer>(); sr.color = new Color(colorRight.r, colorRight.g, colorRight.b); } else { sr = GameObject.Find("PaletteLeft").GetComponent <SpriteRenderer>(); sr.color = new Color(colorLeft.r, colorLeft.g, colorLeft.b); } ballS.GetComponent <SpriteRenderer>().color = new Color((colorRight.r + colorLeft.r) / 2f, (colorRight.g + colorLeft.g) / 2f, (colorRight.b + colorLeft.b) / 2f); ballS.GetComponent <TrailRenderer>().startColor = new Color((colorRight.r + colorLeft.r) / 2f, (colorRight.g + colorLeft.g) / 2f, (colorRight.b + colorLeft.b) / 2f); }
// Start is called before the first frame update protected void Start() { myCircScript = GetComponent <CircleScript>(); GetTarget(); }
// Start is called before the first frame update void Start() { //get coordinate to create level relative to screenwidth bottomLeft = Camera.main.ScreenToWorldPoint(new Vector2(0, 0)); topRight = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height)); float width = topRight.x - bottomLeft.x; float height = topRight.y - bottomLeft.y; //define partition size relative to screenwidth partitionsize = (float)topRight.x / partitionX; partitionY = (float)topRight.y / partitionsize; int x = (int)(partitionX * (partitionY + 1)); circleArr = new GameObject[x]; float offset = partitionsize; colorRight = new Color(1f, 1f, 1f, 0.5f); colorLeft = new Color(1f, 1f, 1f, 0.5f); oldColL = colorLeft; oldColR = colorRight; //place circles on scene int t = 0; for (int i = 0; i < (int)(partitionY + 1); i++) { for (int j = 0; j < (int)partitionX; j++) { //instantiate with position decided by j and i on a grid relative to screen circleArr[t] = Instantiate(circleBg, new Vector3(bottomLeft.x + j * (float)width / partitionX + offset, bottomLeft.y + i * (float)height / partitionY + offset, 0), Quaternion.identity); cs = circleArr[t].GetComponent <CircleScript>(); sr = circleArr[t].GetComponent <SpriteRenderer>(); if (Random.Range(0f, 2f) > 1) { cs.isRight = true; } else { cs.isRight = false; } sr.color = new Color(1f, 1f, 1f, 0.5f); t++; } } scoreRight = 0; scoreLeft = 0; scoreLeftText.text = scoreLeft.ToString(); scoreRightText.text = scoreRight.ToString(); //instantiate both palette and assign sides PaletteScript palette1 = Instantiate(palette) as PaletteScript; PaletteScript palette2 = Instantiate(palette) as PaletteScript; palette1.Init(true); palette2.Init(false); _receiver = GameObject.Find("OSCRx").GetComponent <OSCReceiver>(); _receiver.Bind(addrColorLeft, ColorChange); _receiver.Bind(addrColorRight, ColorChange); _receiver.Bind(addrScaleRight, ScaleChange); _receiver.Bind(addrScaleLeft, ScaleChange); }
private void Start() { myAI = GetComponentInParent <AIScript>(); myCircScript = GetComponentInParent <CircleScript>(); dangers = new List <GameObject>(); }
public SaveData(CircleScript player) { money = player.money; score = player.score; highscore = player.highscore; }
// Use this for initialization void Start() { Circle = this; isSuceess = false; isMoving = false; }