コード例 #1
0
    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;
        }
    }
コード例 #2
0
    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();
    }
コード例 #3
0
    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;
                }
            }
        }
    }
コード例 #4
0
 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);
             }
         }
     }
 }
コード例 #5
0
    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);
    }
コード例 #6
0
 // Start is called before the first frame update
 protected void Start()
 {
     myCircScript = GetComponent <CircleScript>();
     GetTarget();
 }
コード例 #7
0
    // 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);
    }
コード例 #8
0
 private void Start()
 {
     myAI         = GetComponentInParent <AIScript>();
     myCircScript = GetComponentInParent <CircleScript>();
     dangers      = new List <GameObject>();
 }
コード例 #9
0
ファイル: SaveData.cs プロジェクト: SamiBenAmara/SideBall
 public SaveData(CircleScript player)
 {
     money     = player.money;
     score     = player.score;
     highscore = player.highscore;
 }
コード例 #10
0
 // Use this for initialization
 void Start()
 {
     Circle    = this;
     isSuceess = false;
     isMoving  = false;
 }
コード例 #11
0
 // Use this for initialization
 void Start()
 {
     Circle = this;
     isSuceess = false;
     isMoving = false;
 }