Exemple #1
0
        public bool Collect(Collectable collectable)
        {
            switch (collectable)
            {
            case WeaponCollectable weaponCollectable:
                AddWeapon(weaponCollectable.CreateWeapon());
                return(true);

            case ArmorCollectable armorCollectable:
                if (Character.ArmorFull)
                {
                    return(false);
                }

                Character.AddArmor(5);
                return(true);

            case MedpackCollectable medpackCollectable:
                if (Character.HitpointsFull)
                {
                    return(false);
                }

                Character.AddHitpoints(5);
                return(true);

            default:
                throw new Exception($"Unknown collectable {collectable.GetType().Name}");
            }
        }