コード例 #1
0
    IEnumerator resetGame(float numEndJuiceBubbles)
    {
        ShuffleBag <int> juiceAreas = new ShuffleBag <int>();

        juiceAreas.Add(0, 1);
        juiceAreas.Add(1, 1);
        juiceAreas.Add(2, 1);
        juiceAreas.Add(3, 1);
        yield return(new WaitForSeconds(2f));

        for (int i = 0; i < numEndJuiceBubbles; i++)
        {
            addRainbow(juiceAreas.Next());
            Services.Audio.PlaySoundEffect(Services.Clips.EndGamePop[Random.Range(0, Services.Clips.EndGamePop.Length)], 0.7f);
            yield return(new WaitForSeconds(.33f));
        }
        yield return(new WaitForSeconds(1f));

        addRainbow(4);
        Services.Audio.PlaySoundEffect(Services.Clips.EndGamePop[Random.Range(0, Services.Clips.EndGamePop.Length)], 0.7f);
        yield return(new WaitForSeconds(3f));

        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        yield return(null);
    }
コード例 #2
0
        // Setup the wall of cubes: 10x10 cubes on top of the T bar in the middle of the game area
        public void SetupWall()
        {
            // Create wall of cubes using the Shufflebag to get 50x green and 50x red cubes
            // Each integer in the Shufflebag represents a green (0) or red (1) cube
            // Usign the Shufflebag we know for sure that the number of green and red cubes is the same while the distribution is random.
            allCubes = new ShuffleBag(100);
            allCubes.Add(0, 50);    // Add 50x Green
            allCubes.Add(1, 50);    // Add 50x Red

            for (int y = 0; y < 10; y++)
            {
                for (int z = 0; z < 10; z++)
                {
                    // The position on top of the T bar where the cube will be instantiated
                    Vector3 pos = new Vector3(startX, startY + y, startZ + z);

                    CubeBehavior cb;

                    if (allCubes.Next() == 0)
                    {
                        cb = NetworkManager.Instance.InstantiateCube(0, pos, Quaternion.identity);
                        cb.networkObject.colorId = 1; // Green
                    }
                    else
                    {
                        cb = NetworkManager.Instance.InstantiateCube(1, pos, Quaternion.identity);
                        cb.networkObject.colorId = 2; // Red
                    }

                    // Assign the host's Id to the ownerNetId
                    cb.networkObject.ownerNetId = networkObject.MyPlayerId;
                }
            }
        }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        ShuffleBag <int> bag = new ShuffleBag <int>();
        int wallcount        = 15;

        for (int i = 0; i < walls.Length; i++)
        {
            walls[i].transform.localScale = new Vector3(Screen.width, 1.0f, 0.01f);
        }

        bag.Add(0);
        bag.Add(1);
        bag.Add(2);
        bag.Add(3);

        Instantiate(walls [0], new Vector3(0, wallcount, 0), new Quaternion(0, 0, 0, 0));
        wallcount += 15;

        Instantiate(walls [1], new Vector3(0, wallcount, 0), new Quaternion(0, 0, 0, 0));
        wallcount += 15;

        Instantiate(walls [2], new Vector3(0, wallcount, 0), new Quaternion(0, 0, 0, 0));
        wallcount += 15;

        Instantiate(walls [3], new Vector3(0, wallcount, 0), new Quaternion(0, 0, 0, 0));
        wallcount += 15;

        for (int i = 0; i < 2000; i++)
        {
            Instantiate(walls [bag.Next()], new Vector3(0, wallcount, 0), new Quaternion(0, 0, 0, 0));
            wallcount += 15;
        }
    }
コード例 #4
0
    void Is_Never_Empty()
    {
        bag.Add(1);

        int       numDefaults = 0;
        const int numSamples  = 1000;

        for (int i = 0; i < numSamples; i++)
        {
            int sample = bag.GetNext();
            numDefaults += sample == default(int) ? 1 : 0;
        }
        Assert.IsEqual(numDefaults, 0);
    }
コード例 #5
0
ファイル: AudioManager.cs プロジェクト: denniscarr/Whisper
 void AddScriptsToCue()
 {
     foreach (AudioClip asmr in scriptClips)
     {
         ASMRcue.Add(asmr);
     }
 }
コード例 #6
0
 void AddTonesToCue()
 {
     foreach (AudioClip toneClip in Tones)
     {
         toneCue.Add(toneClip);
     }
 }
コード例 #7
0
    void Start()
    {
        bubblePrefab      = Resources.Load("Prefabs/Bubble") as GameObject;
        smallBubblePrefab = Resources.Load("Prefabs/SmallBubble") as GameObject;
        dropPrefab        = Resources.Load("Prefabs/Waterdrop") as GameObject;
        spawnRegionsBag   = new ShuffleBag <int>();
        spawnRegionsBag.Add(0, 1);
        spawnRegionsBag.Add(1, 1);
        spawnRegionsBag.Add(2, 1);
        spawnRegionsBag.Add(3, 1);
        spawnRegionsBag.Add(4, 1);

        bubbleTypesBag = new ShuffleBag <int>();
        bubbleTypesBag.Add(0, 2);
        bubbleTypesBag.Add(1, 4);
    }
コード例 #8
0
    public float intervalMax = 1f;                                       //max time to span new target

    private void Start()
    {
        //set up the singleton
        if (instance == null)
        {
            instance = this;
            // DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        // add prefabs to the TargetsBag
        TargetsBag = new ShuffleBag <GameObject>();
        for (int i = 0; i < TargetsArray.Count; ++i)
        {
            for (int j = 0; j < TargetsCount[i]; ++j)
            {
                TargetsBag.Add(TargetsArray[i]);
            }
        }

        Invoke("SpawnTarget", intervalMin);
    }
コード例 #9
0
ファイル: PanelRenderer.cs プロジェクト: cmdr2/panorama
    void Start()
    {
        PANORAMA_SHADER = Shader.Find("InsideVisible");
        statusMessage   = GameObject.Find("StatusMessage").GetComponent <TextMesh>();
        monoEyePano     = GameObject.Find("monoEyePano");
        leftEyePano     = GameObject.Find("leftEyePano");
        rightEyePano    = GameObject.Find("rightEyePano");
        leftEyeImg      = GameObject.Find("leftEyeImg");
        rightEyeImg     = GameObject.Find("rightEyeImg");
        imgCaption      = GameObject.Find("imgCaption");
        reportImage     = GameObject.Find("reportImage");
        saveFavorite    = GameObject.Find("saveFavorite");

        titleMessage = GameObject.Find("TitleMessage");
        fetchAudio   = GetComponent <AudioSource> ();
        analytics    = GameObject.Find("Analytics").GetComponent <Analytics>();
        analytics.Init();

        monoPanoramaShuffle = new ShuffleBag <int> (15003);
        for (int i = 0; i < 15003; i++)
        {
            monoPanoramaShuffle.Add(i, 1);
        }

        stereoImagesShuffle = new ShuffleBag <int> (4496);
        for (int i = 0; i < 4497; i++)
        {
            stereoImagesShuffle.Add(i, 1);
        }

        StartCoroutine(Fetch());
    }
コード例 #10
0
    // ---- inherited handlers ----

    void Awake()
    {
        // get ammo mass
        mass = ammoPrefab.GetComponent <Rigidbody>().mass;

        // create cannonball pool
        ammoPool             = new GameObjectPool(ammoPrefab, 5, false);
        ammoPool.initAction  = initBallHandler;
        ammoPool.spawnAction = spawnBallHandler;

        // shufflebag of colors: chance of 1/2 red, 1/3 green, 1/6 blue
        bag = new ShuffleBag <Color>();
        bag.Add(Color.red, 3);
        bag.Add(Color.green, 2);
        bag.Add(Color.blue, 1);
    }
コード例 #11
0
 //ShuffleBag LoadShuffleBag(ShuffleBag shuffleBag, TextAsset sentences, int amount)
 ShuffleBag LoadShuffleBag(ShuffleBag shuffleBag, string sentStr, int amount)
 {
     foreach (string sent in sentStr.Split('/'))
     {
         shuffleBag.Add(sent, amount);
     }
     return(shuffleBag);
 }
コード例 #12
0
ファイル: DeckOfCards.cs プロジェクト: ghaoyuxin/CodeLab-2
 protected virtual void AddCardsToDeck()
 {
     foreach (Card.Suit suit in Card.Suit.GetValues(typeof(Card.Suit)))
     {
         foreach (Card.Type type in Card.Type.GetValues(typeof(Card.Type)))
         {
             deck.Add(new Card(type, suit));
         }
     }
 }
コード例 #13
0
        public PoolManager(Transform container, int size, bool autoReuse, bool autoResize, T[] prefabs, params int[] prefabsShuffleBag)
        {
            _autoReuse  = autoReuse;
            _autoResize = autoResize;
            _pool       = new List <T>();
            _active     = new List <T>();

            _container = container;
            T[] children = _container.GetComponentsInChildren <T>();
            foreach (T child in children)
            {
                child.Init();
                _pool.Add(child);
            }

            if (_pool.Count < size && prefabs != null && prefabs.Length > 0 && prefabs[0] != null)
            {
                ShuffleBag <int> bag = new ShuffleBag <int>();
                for (int i = 0; i < prefabs.Length; i++)
                {
                    bag.Add(i, prefabsShuffleBag.Length > i ? prefabsShuffleBag[i] : 1);
                }

                int attempts = size + 200;
                while (_pool.Count < size && attempts > 0)
                {
                    T prefab = prefabs[bag.Next()];
                    if (prefab != null)
                    {
                        T newPoolObject = GameObject.Instantiate(prefabs[bag.Next()]) as T;
                        if (newPoolObject != null)
                        {
                            newPoolObject.transform.SetParent(container);
                            newPoolObject.Init();
                            _pool.Add(newPoolObject);
                        }
                        else
                        {
                            attempts--;
                        }
                    }
                    else
                    {
                        attempts--;
                    }
                }

                bag.Clear();
                bag = null;
            }

            prefabs = null;
        }
コード例 #14
0
    float successChance;           //% chance of success

    // Start is called before the first frame update
    void Start()
    {
        //calc successChance
        successChance = (numHits / (float)(numHits + numMisses));

        //Update button text
        buttonText.text = "Attack! (" +
                          successChance * 100 +
                          "% chance of success)";

        bag = new ShuffleBag <string>();  //create the shuffle bag

        for (int i = 0; i < numHits; i++) //put the hits in the bag
        {
            bag.Add("Hit!");
        }

        for (int i = 0; i < numMisses; i++) //put the misses in the bag
        {
            bag.Add("Miss!");
        }

        print(bag.Count); //print how many things are the bag
    }
コード例 #15
0
    void Start()
    {
        boxTransform = GetComponent <Transform>();
        commandBag   = new ShuffleBag <Command>(commandList.Count);
        foreach (Command c in commandList)
        {
            commandBag.Add(c, 1);
        }
        //Command binding has to happen in the start function
        ShuffleInputs(commandBag);
        buttonR = new UndoCommand();

        //set the ui buttons for shuffle and undo

        UndoButton.onClick.AddListener(() => { buttonR.Execute(boxTransform, buttonR); });
        ShuffleButton.onClick.AddListener(() => { ShuffleInputs(commandBag); });
    }
コード例 #16
0
    public void InitBags()
    {
        //create x # of bags using all of the letters
        bag = new ShuffleBag <char>();
        int[] array = letterFrequency.LetterArray();
        Debug.Log(array.Length);
        int lettersInBag = letterFrequency.TotalCharacters();

        for (int i = 0; i < BagCount; i++)
        {
            for (int j = 0; j < array.Length; j++)
            {
                for (int k = 0; k < array[j]; k++)
                {
                    //turns integer into character
                    bag.Add(char.ConvertFromUtf32(j + 65)[0]);
                    Debug.Log(char.ConvertFromUtf32(j + 65)[0]);
                }
            }
        }
    }
コード例 #17
0
ファイル: PanelRenderer.cs プロジェクト: cmdr2/panorama
    void Start()
    {
        PANORAMA_SHADER = Shader.Find ("InsideVisible");
        statusMessage = GameObject.Find ("StatusMessage").GetComponent<TextMesh>();
        monoEyePano = GameObject.Find ("monoEyePano");
        leftEyePano = GameObject.Find ("leftEyePano");
        rightEyePano = GameObject.Find ("rightEyePano");
        leftEyeImg = GameObject.Find ("leftEyeImg");
        rightEyeImg = GameObject.Find ("rightEyeImg");
        imgCaption = GameObject.Find ("imgCaption");
        reportImage = GameObject.Find ("reportImage");
        saveFavorite = GameObject.Find ("saveFavorite");

        titleMessage = GameObject.Find ("TitleMessage");
        fetchAudio = GetComponent<AudioSource> ();
        analytics = GameObject.Find ("Analytics").GetComponent<Analytics>();
        analytics.Init ();

        monoPanoramaShuffle = new ShuffleBag<int> (15003);
        for (int i = 0; i < 15003; i++) {
            monoPanoramaShuffle.Add(i, 1);
        }

        stereoImagesShuffle = new ShuffleBag<int> (4496);
        for (int i = 0; i < 4497; i++) {
            stereoImagesShuffle.Add(i, 1);
        }

        StartCoroutine (Fetch ());
    }
コード例 #18
0
ファイル: CombatSystem.cs プロジェクト: InferiorOlive/AIQuest
        public void ChooseAction(ulong id, AIStat aiStat, CombatInstance instance)
        {
            ulong[] actions = aInventorySystem.GetHand(id);
            if (actions == null) return;

            int count = 4;
            List<ulong> canUse = new List<ulong>();
            for (int i = 0; i < count; i++)
            {
                if (actions[i] != 0)
                    if (CanPerform(id, actions[i])) canUse.Add(actions[i]);
            }

            count = canUse.Count;
            if (count == 0) return;
            ShuffleBag<ulong> actionBag = new ShuffleBag<ulong>();

            for (int i = 0; i < count; i++)
            {
                string s = actionSystem.GetActionKey(canUse[i]);
                switch (aiStat)
                {
                    case AIStat.AGGRESSION:
                        actionBag.Add(canUse[i], (int)actionSystem.GetAggression(s));
                        break;
                    case AIStat.BALANCE:
                        actionBag.Add(canUse[i], (int)actionSystem.GetBalance(s));
                        break;
                    case AIStat.DEFENSE:
                        actionBag.Add(canUse[i], (int)actionSystem.GetDefense(s));
                        break;
                }
            }

            PerformAction(id, actionBag.Next(), instance);
        }