Exemplo n.º 1
0
        public void DropPowerups(Player player)
        {
            FieldCellSlot[] slots      = new FieldCellSlot[GetWidth() * GetHeight()];
            int             slotsCount = GetEmptySlots(slots);

            if (slotsCount == 0)
            {
                return;
            }

            ShuffleSlots(slots, slotsCount);

            PowerupList powerups  = player.powerups;
            int         slotIndex = 0;

            for (int powerupIndex = 0; powerupIndex < Powerups.Count && slotIndex < slots.Length; ++powerupIndex)
            {
                int count = powerups.GetCount(powerupIndex);
                for (int i = 0; i < count && slotIndex < slots.Length; ++i)
                {
                    FieldCellSlot slot = slots[slotIndex++];
                    PowerupCell   cell = new PowerupCell(powerupIndex, slot.cx, slot.cy);
                    AddCell(cell);
                }
            }
        }
Exemplo n.º 2
0
        public PowerupsView(PowerupList powerups)
        {
            m_powerups       = powerups;
            m_innactiveColor = new Color(0, 0, 0, 0.5f);

            TextureImage[] images = InitPowerupImages();

            m_powerupViews = new PowerupView[images.Length];
            for (int i = 0; i < images.Length; ++i)
            {
                PowerupView pw = new PowerupView(images[i], powerups.GetCount(i));
                AddView(pw, i * pw.width, 0.0f);
                m_powerupViews[i] = pw;
            }

            ResizeToFitViews();
        }
        private void InitPowerups()
        {
            CVar[] initials = CVars.powerupsInitials;
            CVar[] max = CVars.powerupsMax;

            int totalCount = initials.Length;
            m_powerups = new PowerupList(this, totalCount);
            for (int powerupIndex = 0; powerupIndex < totalCount; ++powerupIndex)
            {
                int initialCount = initials[powerupIndex].intValue;
                int maxCount = max[powerupIndex].intValue;
                m_powerups.Init(powerupIndex, initialCount, maxCount);
            }
        }