Пример #1
0
    Transform GenerateNbackObject(float x, float y)
    {
        Vector3 spawnPos = new Vector3(x, y, 0);

        // Generate Random Nback Object 30% chance of correct nback

        int forceCorrect = Random.Range(0, 10);
        int correctNback = Util.findNbackMatch(sequence, nLevel);

        int randNback = Random.Range(0, nbackObjects.Count);

        if (forceCorrect >= 3)
        {
            while (randNback == previous || randNback == correctNback)
            {
                randNback = Random.Range(0, nbackObjects.Count);
            }
        }
        else
        {
            randNback = correctNback;
            //Debug.Log ("Forcing to correct nback "+correctNback.ToString ());
        }

        previous = randNback;
        Transform       t    = GameObject.Instantiate(nbackObjects [randNback], spawnPos, Quaternion.identity) as Transform;
        NbackObjControl ctrl = t.gameObject.GetComponent <NbackObjControl> ();


        // Register in sequence
        sequence.Add(ctrl.type);
        if (Util.checkNbackMatch(sequence, nLevel))
        {
            ctrl.MarkCorrect();
        }

        // Used to prevent mineral reveal after nlevel changes
        if (nLevel != prevnLevel)
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if (count > 3)
        {
            prevnLevel = nLevel;
            count      = 0;
        }
        return(t);
    }
Пример #2
0
    Transform GenerateNbackObject(float x, float y)
    {
        Vector3 spawnPos = new Vector3(x, y, 0);

        // Generate Random Nback Object
        int             rand = Random.Range(0, nbackObjects.Count);
        Transform       t    = GameObject.Instantiate(nbackObjects [rand], spawnPos, Quaternion.identity) as Transform;
        NbackObjControl ctrl = t.gameObject.GetComponent <NbackObjControl> ();

        // Register in sequence
        sequence.Add(ctrl.type);
        if (Util.checkNbackMatch(sequence, nLevel))
        {
            ctrl.MarkCorrect();
        }

        return(t);
    }