コード例 #1
0
 private bool calculateDrop(Ship ship)
 {
     if (Random.value <= .5f)
     {
         ItemType dropType = ItemTypeDescriptor.dropables()[Random.Range(0, ItemTypeDescriptor.dropables().Length)];
         loot.Add(Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>().init(ItemFactory.createItemData(dropType)));
     }
     if (Random.value <= .75f)
     {
         loot.Add(Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>().init(ItemFactory.createGoodsData(Random.Range(5, 20))));
     }
     if (Random.value <= .25f)
     {
         loot.Add(Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>().init(ItemFactory.createGoodsData(Random.Range(5, 20))));
     }
     foreach (Item item in loot)
     {
         item.gameObject.SetActive(false);
     }
     return(loot.Count > 0);
 }
コード例 #2
0
 public bool UpdateStock(Dictionary <MyItemType, ItemTypeDescriptor> stock)
 {
     ClearStock(stock);
     if (Alive)
     {
         Amount = Tank.Capacity * Tank.FilledRatio;
         if (stock.ContainsKey(type))
         {
             stock[type].Amount += Amount;
         }
         else
         {
             stock[type] = new ItemTypeDescriptor(type, Amount);
         }
         return(true);
     }
     else
     {
         Tank   = null;
         Amount = 0;
         return(false);
     }
 }