Beispiel #1
0
        protected override void OnAfterCollideRegistered(IColliding obj)
        {
            string CollisionResult = "";

            if (obj is EnergyPack)
            {
                Health         += obj.GetPower();
                CollisionResult = $"HP restored: {obj.GetPower()}";
            }
            else
            {
                Health         -= obj.GetPower();
                CollisionResult = $"Damage taken: {obj.GetPower()}";
            }

            if (Health <= 0)
            {
                DestroySpaceObject();
            }

            Logger.LogInformation(
                "After collision registered. " +
                $"Object1: {this.GetType()}.{this.GetHashCode()}, " +
                $"{CollisionResult}, " +
                $"Object1 Health: {Health}"
                );

            CollisionsList.Clear();
        }
Beispiel #2
0
        private void DestroySpaceObject()
        {
            Destroyed = true;

            LeftTopPosition.X = -1100;

            CollisionsList.Clear();
        }
Beispiel #3
0
        private void DestroySpaceObject()
        {
            Destroyed = true;

            LeftTopPosition.X = -1000;

            CollisionsList.Clear();

            Dispose();

            AsteroidDestructionEvent?.Invoke(this);

            Logger.LogInformation(
                "Asteroid is desroyed. " +
                $"Object1: {this.GetType()}.{this.GetHashCode()}"
                );
        }