private IThing CreateRandomThing(LootName thingName)
        {
            IThing thing = new Thing()
            {
                Name = thingName
            };

            Array values         = Enum.GetValues(typeof(LootProperties));
            int   propertyCount  = _rand.Next(3);
            int   propertyNumber = 0;

            while (propertyNumber < propertyCount)
            {
                LootProperties propertyName = (LootProperties)values.GetValue(
                    _rand.Next(values.Length - 1));

                if (thing.Properties.ContainsKey(propertyName))
                {
                    continue;
                }

                propertyNumber++;
                thing.Properties.Add(propertyName, _rand.Next(15));
            }

            return(thing);
        }
        public IList <IThing> CreateThings(int thingsCount)
        {
            IList <IThing> things = new List <IThing>();
            Array          values = Enum.GetValues(typeof(LootName));

            int thingNumber = 0;

            while (thingNumber < thingsCount)
            {
                LootName thingName = (LootName)values.GetValue(
                    _rand.Next(values.Length - 1));

                if (LootName.none == thingName)
                {
                    continue;
                }

                IThing thing = CreateThing(thingName);

                things.Add(thing);

                ++thingNumber;
            }

            return(things);
        }
Ejemplo n.º 3
0
        private IThing CreatePrototype(LootName name)
        {
            IThing prototype = new Thing();

            prototype.Name = name;

            return(prototype);
        }
Ejemplo n.º 4
0
        public void Add(LootName name, IInteractionObject actionSystem)
        {
            if (!(actionSystem is IAction action))
            {
                throw new GameException(
                          "ActionControllersStorage.Add: not an IAttackSystem. ");
            }

            _controllers.Add(actionSystem);
            _attackSystems.Add(name, action);
        }
Ejemplo n.º 5
0
        public IThing CreateThing(LootName name)
        {
            if (!_prototypes.TryGetValue(name, out IThing prototype))
            {
                prototype = CreatePrototype(name);
                if (null == prototype)
                {
                    throw new GameException("CreateThing: Unknown loot name. ");
                }

                _prototypes.Add(name, prototype);
            }

            return((IThing)prototype.Clone());
        }
Ejemplo n.º 6
0
        public static IThing RemoveModification(
            this IThing target, LootName modificationName)
        {
            if (!target.Components.TryGetValue(
                    modificationName, out IThing modification))
            {
                return(null);
            }

            target.Components.Remove(modificationName);
            var modificationKeys = modification.Properties.Keys;

            target.Cost -= modification.Cost;

            foreach (LootProperties name in modificationKeys)
            {
                target.Properties[name] = target.Properties[name] -
                                          modification.Properties[name];
            }
            return(modification);
        }
        private IThing CreateThing(LootName thingName)
        {
            switch (thingName)
            {
            case LootName.cutlass:
                return(CreateCutlass());

            case LootName.grenade:
                return(CreateGrenade());

            case LootName.gun:
                return(CreateGun());

            case LootName.scope:
                return(CreateScope());

            default:
                throw new GameException(
                          "ThingsRandFabric: Unknown loot type. ");
            }
        }