コード例 #1
0
ファイル: InventoryScript.cs プロジェクト: wndtanaka/DIP_SQL
 private void LateUpdate()
 {
     if (Input.GetKeyDown(KeyCode.I))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(16);
         bag.Use();
     }
     if (Input.GetKeyDown(KeyCode.J))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(8);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.K))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(16);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.L))
     {
         HealthPotion potion = (HealthPotion)Instantiate(items[1]);
         AddItem(potion);
     }
     if (Input.GetKeyDown(KeyCode.V))
     {
         Apple apple = (Apple)Instantiate(items[2]);
         AddItem(apple);
     }
 }
コード例 #2
0
        private static void SeedInitialPlayerInventory(IPlayer player)
        {
            Position defaultPosition = new Position(0, 0);

            ICollectible healthPotion = new HealthPotion(defaultPosition);

            healthPotion.State = ItemState.Collected;

            ICollectible shield = new RegularShield(defaultPosition);

            shield.State = ItemState.Collected;

            ICollectible sword = new RegularSword(defaultPosition);

            sword.State = ItemState.Collected;

            player.AddItemToInventory(healthPotion);
            player.AddItemToInventory(healthPotion);
            player.AddItemToInventory(shield);
            player.AddItemToInventory(sword);
        }