コード例 #1
0
ファイル: DmItemFactory.cs プロジェクト: Craydel/DM_UBER_TOOL
        /// <summary>
        /// create a pack, and some number of things it contains
        /// </summary>
        /// <returns></returns>
        private static DmItemContainer CreateContainer()
        {
            DmItemContainer item = null;

              // pick type of container
              int choices = Enum.GetValues( typeof( DmItemTypeContainer ) ).Length;
              DmItemTypeContainer choice  = (DmItemTypeContainer)rand.Next( choices );

              // create the item of that type
              item = new DmItemContainer( choice );

              // based on the type of container, pick a number of items it contains
              int numItems = 0;
              switch( choice )
              {
            case DmItemTypeContainer.ScrollCase:
              numItems = rand.Next(3)+1;
              for( int i=0; i<numItems; i++ )
              {
            DmItemEquipment tmpItem = new DmItemEquipment( DmItemTypeEquipment.Parchment );
            if( rand.Next( 100 ) > 50 )
            {
              tmpItem.Quality = DmItemQuality.Masterwork;
              tmpItem.Enchantment = PickEnchantmentConsumable();
            }
            item.Contents.Add( tmpItem );
              }
              break;

            case DmItemTypeContainer.SmallSack:
              numItems = rand.Next( 2, 4 );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Food ) );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Equipment ) );
              break;

            case DmItemTypeContainer.LargeSack:
              numItems = rand.Next( 3, 7 );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Food ) );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Equipment ) );
              break;

            case DmItemTypeContainer.Backpack:
              numItems = rand.Next( 6, 8 );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Food ) );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Equipment ) );
              break;

            case DmItemTypeContainer.BasketWicker:
              numItems = rand.Next( 2, 4 );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Food ) );
              break;

            case DmItemTypeContainer.BucketWooden:
              numItems = rand.Next( 2, 4 );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Food ) );
              break;

            case DmItemTypeContainer.Chest:
              numItems = rand.Next( 10, 20 );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Food ) );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Equipment ) );
              break;

            case DmItemTypeContainer.Barrel:
              numItems = rand.Next( 3, 8 );
              for( int i=0; i<numItems; i++ )
            item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Equipment ) );
              break;

            default: // BeltPouch contents by default
              // only money
              item.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
              break;
              }

              return item;
        }
コード例 #2
0
ファイル: DmNpcFactory.cs プロジェクト: Craydel/DM_UBER_TOOL
        /// <summary>
        /// Generate some general goods the NPC has with them
        /// </summary>
        /// <param name="npc"></param>
        /// <returns></returns>
        private static List<DmItemAbstract> GenerateInventory( DmNPC npc )
        {
            List<DmItemAbstract> list = new List<DmItemAbstract>();

              // Money :
              //  Adventurers should have a money pouch. Maybe more.

              //  Commoners may or may not have one on their person.

              // Packs :
              //  Adventurers should be created with at least one, and it should have a fairly basic set
              //    (bedrool, food, light source) as well as other goods.)
              //    Additional packs  may be generated, but increasingly less likely.

              //  Commoners may or may not have a pack with them.  If they do, it shall be created completely at random
              //    (who knows when a farmer might wander into a bar with a single sheet of parchment, an empty scroll case, and a ladder?

              switch( npc.characterType )
              {
            case NPCType.Adventurer:
              {
            // create the money pouch
            DmItemContainer beltpouch = new DmItemContainer( DmItemTypeContainer.BeltPouch );

            // add some random type/amount of money
            beltpouch.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
            beltpouch.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );
            beltpouch.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );

            // add the filled pouch to the list
            list.Add( beltpouch );

            // Good chance for 1 bag...
            if( rand.Next( 100 ) < 90 )
            {
              list.Add( DmItemFactory.CreateItem( DmItemType.Container ) );

              // if they have one, small chance for a 2nd...
              if( rand.Next( 100 ) < 30 )
              {
                list.Add( DmItemFactory.CreateItem( DmItemType.Container ) );

                // if they have 2, _really_ slim chance for a 3rd.
                if( rand.Next( 100 ) <  5 )
                  list.Add( DmItemFactory.CreateItem( DmItemType.Container ) );
              }
            }
              }
              break;

            default:
              {
            if( npc.characterProfession == NPCTypeProfession.None )
            {
              // beggar?  slim chance for money, nothing else.
              if( rand.Next( 100 ) < 10 )
              {
                // create the money pouch
                DmItemContainer beltpouch = new DmItemContainer( DmItemTypeContainer.BeltPouch );

                // add some random type/amount of money
                // TODO : maybe (just maybe) limit this to make sure we didn;t just give some grubby beggar a fist-ful of platinum.
                //        unless we meant to, so we could return it to it's rightful owner coughtcoughtstealitcoughcough.
                beltpouch.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );

                // add the filled pouch to the list
                list.Add( beltpouch );
              }
            }
            else
            {
              // not a beggar : good chance for money, slim chance for 1 bag of stuff.
              if( rand.Next( 100 ) < 80 )
              {
                // create the money pouch
                DmItemContainer beltpouch = new DmItemContainer( DmItemTypeContainer.BeltPouch );

                // add some random type/amount of money
                beltpouch.Contents.Add( DmItemFactory.CreateItem( DmItemType.Money ) );

                // add the filled pouch to the list
                list.Add( beltpouch );
              }

              // TODO : limit this some?  Or should NPCs be allowed to drag around a bucket and a locked chest?
              if( rand.Next( 100 ) < 20 )
                list.Add( DmItemFactory.CreateItem( DmItemType.Container ) );
            }
              }
              break;
              }

              return list;
        }