Пример #1
0
    private MushroomDescriptor GetDescriptorFor(int x, int y, MushroomBehaviour mushroomBehaviour, MushroomColor mushroomColor)
    {
        MushroomDescriptor mushroomDescriptor = new MushroomDescriptor();

        mushroomDescriptor.mPos       = new Vector2Int(x, y);
        mushroomDescriptor.mBehaviour = mushroomBehaviour;
        mushroomDescriptor.mColor     = mushroomColor;

        return(mushroomDescriptor);
    }
Пример #2
0
    private void GenereateRoundForGame()
    {
        List <MushroomDescriptor> mushroomBases = new List <MushroomDescriptor>();

        System.Random random = new System.Random();

        { // Generate Color and behaviour links
            for (int i = 0; i < numColors; ++i)
            {
                mushroomBases.Add(new MushroomDescriptor());
            }

            List <int> picked = new List <int>();

            for (int i = 1; i < mMushroomColors.Count; ++i)
            {
                picked.Add(i);
            }

            for (int i = 0; i < numColors; ++i)
            {
                int index = random.Next(picked.Count);
                mushroomBases[i].mColor = mMushroomColors[picked[index]];

                picked.Remove(index);
            }

            picked = new List <int>();

            for (int i = 1; i < mMushroomBehaviours.Count; ++i)
            {
                picked.Add(i);
            }

            for (int i = 0; i < numColors; ++i)
            {
                int index = random.Next(picked.Count);
                mushroomBases[i].mBehaviour = mMushroomBehaviours[picked[index]];

                picked.Remove(index);
            }
        }

        mRounds = new List <Round>();

        { // Round Nothing
            Round round = new Round();
            round.mMushroomsToSpawn = new List <MushroomDescriptor>();

            MushroomDescriptor nothingMush = GetDescriptorFor(0, 0, mMushroomBehaviours[0], mMushroomColors[0]);
            round.mMushroomsToSpawn.Add(nothingMush);

            mRounds.Add(round);
        }

        { // Round 1
            Round round = new Round();
            round.mMushroomsToSpawn = new List <MushroomDescriptor>();

            int numMush = 2;
            for (int i = 0; i < numMush; ++i)
            {
                var mushBase = mushroomBases[random.Next(numColors)];

                MushroomDescriptor descriptor = GetDescriptorFor(0, 0, mushBase.mBehaviour, mushBase.mColor);
                round.mMushroomsToSpawn.Add(descriptor);
            }

            mRounds.Add(round);
        }

        { // Round 2
            Round round = new Round();
            round.mMushroomsToSpawn = new List <MushroomDescriptor>();

            int numMush = 4;
            for (int i = 0; i < numMush; ++i)
            {
                var mushBase = mushroomBases[random.Next(numColors)];

                MushroomDescriptor descriptor = GetDescriptorFor(0, 0, mushBase.mBehaviour, mushBase.mColor);
                round.mMushroomsToSpawn.Add(descriptor);
            }

            mRounds.Add(round);
        }

        { // Round 3
            Round round = new Round();
            round.mMushroomsToSpawn = new List <MushroomDescriptor>();

            int numMush = 8;
            for (int i = 0; i < numMush; ++i)
            {
                var mushBase = mushroomBases[random.Next(numColors)];

                MushroomDescriptor descriptor = GetDescriptorFor(0, 0, mushBase.mBehaviour, mushBase.mColor);
                round.mMushroomsToSpawn.Add(descriptor);
            }

            mRounds.Add(round);
        }
    }