Пример #1
0
        public void SelectBoxRandomly(Player player)
        {
            var result = _random.Next(0, Boxes.Count);

            player.ChosenBox = Boxes[result];
            Boxes.RemoveAt(result);
        }
Пример #2
0
        public void HandleBoxes()
        {
            if (Voxels == null)
            {
                Voxels = new List <Voxel>();
            }

            if (Boxes == null)
            {
                Boxes = new List <Body>();
            }

            if (Voxels.Count == 0)
            {
                foreach (Body component in Boxes)
                {
                    KillBox(component);
                }
                Boxes.Clear();
            }

            int numBoxes = Math.Min(Math.Max(Resources.CurrentResourceCount / ResourcesPerVoxel, 1), Voxels.Count);

            if (Boxes.Count > numBoxes)
            {
                for (int i = Boxes.Count - 1; i >= numBoxes; i--)
                {
                    KillBox(Boxes[i]);
                    Boxes.RemoveAt(i);
                }
            }
            else if (Boxes.Count < numBoxes)
            {
                for (int i = Boxes.Count; i < numBoxes; i++)
                {
                    CreateBox(Voxels[i].Position + VertexNoise.GetNoiseVectorFromRepeatingTexture(Voxels[i].Position));
                }
            }
        }