Пример #1
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        numLinks = 0;

        //AudioSource newSource = gameObject.AddComponent<AudioSource>();
        //newSource.playOnAwake = false;
        //newSource.loop = false;
        asmrScriptSources = new List <AudioSource>();
        // asmrScriptSources.Add(newSource);

        if (!IsValidToneCue())
        {
            ASMRcue = new ShuffleBag <AudioClip>();

            AddScriptsToCue();
        }
    }
Пример #2
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);
    }
    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);
    }
Пример #4
0
    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());
    }
Пример #5
0
        protected override void OnEnable()
        {
            base.OnEnable();

            _shuffleBag = null;
            _clipIndex  = 0;
        }
Пример #6
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;
                }
            }
        }
Пример #7
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;
        }
    }
Пример #8
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);
 }
Пример #9
0
    void Awake()
    {
        if (!IsValidToneCue())
        {
            toneCue = new ShuffleBag <AudioClip>();

            AddTonesToCue();
        }
    }
Пример #10
0
 private static void AddToShuffleBag(Dictionary <int, ShuffleBag <ItemConfig> > dict, ItemConfig item, int chance, int bagIndex)
 {
     if (!dict.TryGetValue(bagIndex, out var bag))
     {
         bag = new ShuffleBag <ItemConfig>();
         dict.Add(bagIndex, bag);
     }
     bag.Add(item, chance);
 }
Пример #11
0
        /// <summary>
        ///   Instantiate the enumerator to loop through what is left in the bag.
        ///   If the bag was emptied, fills it again.
        /// </summary>
        public ShuffleBagEnumerator(ShuffleBag <T2> sourceBag)
        {
            this.sourceBag = sourceBag;

            // If the shuffle bag is empty, just fill and shuffle it, else just use whatever is left in it.
            if (sourceBag.currentContent.Count == 0 && sourceBag.automaticRefill)
            {
                sourceBag.FillAndShuffle();
            }
        }
Пример #12
0
    public void RestartGame()
    {
        numLinks = 0;
        normalGameSnapshot.TransitionTo(0.3f);
        if (!IsValidToneCue())
        {
            ASMRcue = new ShuffleBag <AudioClip>();

            AddScriptsToCue();
        }
    }
Пример #13
0
    public CellularAutomata(int ChanceToStartInanimate, ShuffleBag<Obstacle> ObstaclesShuffleBag)
    {
        this.ChanceToStartInanimate = ChanceToStartInanimate;
        this.ChancesShuffleBag = new ShuffleBag<int>();
        this.ObstaclesShuffleBag = ObstaclesShuffleBag;
        this.CellGetterCounter = 0;
        this.CellMap = new List<Obstacle>();

        InitializeChances();
        InitializeMap();
    }
Пример #14
0
 void ShuffleInputs(ShuffleBag <Command> bag)
 {
     //ideally this should work with the pointers?
     //as is it works with a predefined set
     //maybe this can be a use for enums
     buttonW = bag.Next();
     buttonA = bag.Next();
     buttonS = bag.Next();
     buttonD = bag.Next();
     UpdateUI();
 }
Пример #15
0
    // Use this for initialization
    void Awake()
    {
        if (!IsValidDeck())
        {
            deck = new ShuffleBag <Card>();

            AddCardsToDeck();
        }

        Debug.Log("Cards in Deck: " + deck.Count);
    }
Пример #16
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;
        }
Пример #17
0
    // Use this for initialization
    void Awake()
    {
        if (!IsValidDeck())
        {
            deck = new ShuffleBag <Card>();

            AddCardsToDeck();
        }

        //Debug.Log("Cards in Deck: " + (deck.cursor + 1));
        cardsInDeck.text = ((deck.cursor + 1) % deck.Count + 1).ToString();
    }
Пример #18
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);
    }
Пример #19
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);
    }
Пример #20
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); });
    }
Пример #21
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]);
                }
            }
        }
    }
Пример #22
0
    private TwitterItem GenerateTwitterItem(ShuffleBag <string> bag, bool withImage)
    {
        string famousPerson = StaticData.Name;

        // have a start tweet first
        if (!hasStartTweet)
        {
            bag           = startBag;
            hasStartTweet = true;
        }

        string shortName = famousPerson.Replace(" ", "_").Substring(0, Math.Min(famousPerson.Length, 8));

        return(new TwitterItem
        {
            Username = String.Format(nameBag.Next(), shortName),
            Name = nameGenerator.GenerateRandomFirstAndLastName(),
            Tweet = String.Format(bag.Next(), famousPerson),
            Timestamp = DateTime.Now,
            ImageSeed = withImage ? GetImageSeed : (int?)null
        });
    }
Пример #23
0
        private static void Init()
        {
            GameData.AddInit(Init);
            _prefixBag.Clear();
            _suffixBag.Clear();
            var modifierList = GameData.GetSheet(DatabaseSheets.ItemModifiers);

            foreach (var loadedDataEntry in modifierList)
            {
                if (!loadedDataEntry.Value.TryGetValue(DatabaseFields.ModifierGroup, out string modGroup))
                {
                    continue;
                }
                var isPrefix = loadedDataEntry.Value.GetValue <bool>(DatabaseFields.IsPrefix);
                var dict     = isPrefix ? _prefixBag : _suffixBag;
                if (!dict.TryGetValue(modGroup, out var bag))
                {
                    bag = new ShuffleBag <DataEntry>();
                    dict.Add(modGroup, bag);
                }
                bag.Add(loadedDataEntry.Value, (int)loadedDataEntry.Value.GetValue <float>(DatabaseFields.Chance) * 100);
            }
        }
Пример #24
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
    }
Пример #25
0
        protected virtual AudioClip ChooseClip(AudioClip[] clips)
        {
            switch (_clipSelection)
            {
            case ClipSelectionMode.Random:
                return(RandomUtils.Choose(clips));

            case ClipSelectionMode.Shuffle:
                if (_shuffleBag == null)
                {
                    _shuffleBag = new ShuffleBag <AudioClip>(clips);
                }

                return(_shuffleBag.GetNext());

            case ClipSelectionMode.ClampedSequence:
                return(clips[Mathf.Min(_clipIndex++, clips.Length - 1)]);

            case ClipSelectionMode.LoopingSequence:
                return(clips[MathUtils.WrapIndex(_clipIndex++, clips.Length)]);
            }

            return(null);
        }
Пример #26
0
    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 ());
    }
Пример #27
0
        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);
        }
Пример #28
0
 void OnValidate()
 {
     _shuffleBag = null;
     _clipIndex  = 0;
 }
Пример #29
0
 void TestSetup()
 {
     bag = new ShuffleBag <int>();
 }
Пример #30
0
 //public StringBuilder TextGenerator(ShuffleBag shuffleBag)
 void TextGenerator(ShuffleBag shuffleBag)
 {
     sbText.Append(shuffleBag.Next());
     mainText.text = sbText.ToString();
     //return sb;
 }
Пример #31
0
 void EndTitleGenerator(ShuffleBag shuffleBag)
 {
     sbEndTitle.Append(shuffleBag.Next());
     endTitle.text = sbEndTitle.ToString();
     //return sb;
 }
Пример #32
0
 void Awake()
 {
     _cfg       = FindObjectOfType <Config>();
     _main      = FindObjectOfType <MainBuilding>();
     _moduleBag = new ShuffleBag <Module>(modulePrefabs);
 }
Пример #33
0
 public void NumberTextUpdate(string tempString)
 {
     shuffleBags[4] = new ShuffleBag(1);
     shuffleBags[4] = LoadShuffleBag(shuffleBags[4], tempString, 1);
 }