Пример #1
0
        internal void Split()
        {
            if (Game.TickCount < SplitTicks)
            {
                return;
            }

            if (Owner.Blobs.Count >= Game.Settings.MaxPlayerBlobCount)
            {
                return;
            }

            if (Mass < Game.Settings.MinMassSplit)
            {
                return;
            }

            SplitTicks = Game.TickCount + Game.Settings.SplitWaitTicks;

            var newMass = Mass / 2.0f;

            Mass = newMass;

            var split = new PlayerBlob(Owner, Game, _physics, StateTracker, Position, false)
            {
                Mass     = newMass,
                Velocity = Velocity * Game.Settings.SplitSpeedFactor
            };

            split.UpdateRecombineInstant();
            UpdateRecombineInstant();

            Game.AddBlob(split);
        }
Пример #2
0
        private void TryConsume(PlayerBlob blob)
        {
            if (!CanConsume(blob))
            {
                return;
            }

            var maxSplits = (int)Math.Floor(blob.Mass / Game.Settings.MaxPlayerBlobCount);
            var numSplits = Game.Settings.MaxPlayerBlobCount - blob.Owner.Blobs.Count;

            numSplits = Math.Min(numSplits, maxSplits);

            var splitMass = Math.Min(blob.Mass / (numSplits + 1), Game.Settings.MinMassSplit);

            if (numSplits <= 0)
            {
                return;
            }

            blob.Mass += Mass;
            Game.RemoveBlob(this);

            var bigSplits = 0;
            var endMass   = blob.Mass - (numSplits * splitMass);

            if ((endMass > 300) && (numSplits > 0))
            {
                bigSplits++;
                numSplits--;
            }
            if ((endMass > 1200) && (numSplits > 0))
            {
                bigSplits++;
                numSplits--;
            }
            if ((endMass > 3000) && (numSplits > 0))
            {
                bigSplits++;
                numSplits--;
            }

            for (var i = 0; i < numSplits; i++)
            {
                var direction = GetVectorInDirection(2.0 * Math.PI * (i / (double)numSplits));
                SplitConsumer(blob, splitMass, direction);
                blob.Mass -= splitMass;
            }

            for (var i = 0; i < bigSplits; i++)
            {
                var direction = GetVectorInDirection(Game.Random.NextDouble() * 2 * Math.PI);
                splitMass = blob.Mass / 4;
                SplitConsumer(blob, splitMass, direction);
                blob.Mass -= splitMass;
            }

            blob.UpdateRecombineInstant();
        }
Пример #3
0
        private void SplitConsumer(PlayerBlob consumer, float splitMass, Vector direction)
        {
            var speed = consumer.Velocity.Length * Game.Settings.SplitSpeedFactor;
            var split = new PlayerBlob(consumer.Owner, Game, _physics, StateTracker, consumer.Position, false)
            {
                Velocity = direction * speed,
                Mass     = splitMass
            };

            split.UpdateRecombineInstant();

            Game.AddBlob(split);
        }
Пример #4
0
        internal void Split()
        {
            if (Game.TickCount < SplitTicks)
            {
                return;
            }

            if (Owner.Blobs.Count >= Game.Settings.MaxPlayerBlobCount)
            {
                return;
            }

            if (Mass < Game.Settings.MinMassSplit)
            {
                return;
            }

            SplitTicks = Game.TickCount + Game.Settings.SplitWaitTicks;

            var newMass = Mass / 2.0f;

            Mass = newMass;

            var split = new PlayerBlob(Owner, Game, _physics, StateTracker, Position, false)
            {
                Mass = newMass,
                Velocity = Velocity * Game.Settings.SplitSpeedFactor
            };

            split.UpdateRecombineInstant();
            UpdateRecombineInstant();

            Game.AddBlob(split);
        }