Exemple #1
0
        private void TryConsume(EjectedMassBlob blob)
        {
            if (!CanConsume(blob))
            {
                return;
            }

            Mass += blob.Mass;
            _fed++;

            Game.RemoveBlob(blob);

            if (_fed < Game.Settings.VirusFeedAmount)
            {
                return;
            }

            var normalizedVelocity = blob.Velocity.Normalize();
            var virus = new VirusBlob(Game, _physics, StateTracker, Position + normalizedVelocity)
            {
                Velocity = normalizedVelocity * Game.Settings.EjectSpeed
            };

            _fed = 0;
            Mass = Game.Settings.VirusMinMass;

            if (Game.Blobs.Count(x => x.GetType() == typeof(VirusBlob)) >= Game.Settings.VirusAbsoluteMaxAmount)
            {
                Game.RemoveBlob(this);
            }

            Game.AddBlob(virus);
        }
Exemple #2
0
        internal void EjectMass()
        {
            if (Game.TickCount < EjectMassTicks)
            {
                return;
            }

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

            EjectMassTicks = Game.TickCount + Game.Settings.EjectMassWaitTicks;

            var ejectMass          = Game.Settings.EjectMass;
            var normalizedVelocity = Velocity.Normalize();
            var ejectVelocity      = normalizedVelocity * Game.Settings.EjectSpeed;

            Mass -= ejectMass;

            var ejectedMassBlobPosition = Position + (normalizedVelocity * (Radius + GetRadius(ejectMass)));

            var ejectedMassBlob = new EjectedMassBlob(Game, _physics, StateTracker, ejectedMassBlobPosition)
            {
                Mass     = ejectMass,
                Velocity = ejectVelocity
            };

            Game.AddBlob(ejectedMassBlob);
        }
Exemple #3
0
        private bool CanConsume(EjectedMassBlob blob)
        {
            var distance = blob.Position.Dist(Position) - blob.Radius;

            return(distance < GetEatingRange());
        }
Exemple #4
0
        internal void EjectMass()
        {
            if (Game.TickCount < EjectMassTicks)
            {
                return;
            }

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

            EjectMassTicks = Game.TickCount + Game.Settings.EjectMassWaitTicks;

            var ejectMass = Game.Settings.EjectMass;
            var normalizedVelocity = Velocity.Normalize();
            var ejectVelocity = normalizedVelocity * Game.Settings.EjectSpeed;

            Mass -= ejectMass;

            var ejectedMassBlobPosition = Position + (normalizedVelocity * (Radius + GetRadius(ejectMass)));

            var ejectedMassBlob = new EjectedMassBlob(Game, _physics, StateTracker, ejectedMassBlobPosition)
            {
                Mass = ejectMass,
                Velocity = ejectVelocity
            };

            Game.AddBlob(ejectedMassBlob);
        }